Commit 868821ca authored by Leander Schulten's avatar Leander Schulten
Browse files

ModuleView: Fix glitch where the text was wrong rendered when code completion...

ModuleView: Fix glitch where the text was wrong rendered when code completion inserts multiple lines
parent 24e295f6
Pipeline #177967 passed with stage
in 1 minute and 50 seconds
......@@ -4,6 +4,7 @@ import QtQuick.Layouts 1.0
import custom.licht 1.0
import QtQuick.Controls.Material 2.2
import QtQuick.Dialogs 1.2
import QtQml 2.12
import "components"
Item{
......@@ -527,18 +528,33 @@ Item{
module: listView.currentModelData
document: codeEditor.textDocument
onInsertText: {
console.log(newText);
codeEditor.insert(codeEditor.cursorPosition,newText);
// Hack to display all new text, sometimes new text disappear
//codeEditor.selectAll();
//codeEditor.deselect();
codeEditor.cursorPosition = pos;
// deplay code and run at next iteration
timer.setTimeout(function(){
codeEditor.insert(codeEditor.cursorPosition,newText);
codeEditor.cursorPosition = pos;
}, 0);
}
onInformation:{
informationDialog.text = text
informationDialog.visible = true;
}
}
Timer {
// from https://stackoverflow.com/a/50224584/10162645
id: timer
function setTimeout(cb, delayTime) {
timer.interval = delayTime;
timer.repeat = false;
timer.triggered.connect(cb);
timer.triggered.connect(function release () {
timer.triggered.disconnect(cb); // This is important
timer.triggered.disconnect(release); // This is important as well
});
timer.start();
}
}
}
}
Button{
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment