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 ...@@ -4,6 +4,7 @@ import QtQuick.Layouts 1.0
import custom.licht 1.0 import custom.licht 1.0
import QtQuick.Controls.Material 2.2 import QtQuick.Controls.Material 2.2
import QtQuick.Dialogs 1.2 import QtQuick.Dialogs 1.2
import QtQml 2.12
import "components" import "components"
Item{ Item{
...@@ -527,18 +528,33 @@ Item{ ...@@ -527,18 +528,33 @@ Item{
module: listView.currentModelData module: listView.currentModelData
document: codeEditor.textDocument document: codeEditor.textDocument
onInsertText: { onInsertText: {
console.log(newText); // deplay code and run at next iteration
codeEditor.insert(codeEditor.cursorPosition,newText); timer.setTimeout(function(){
// Hack to display all new text, sometimes new text disappear codeEditor.insert(codeEditor.cursorPosition,newText);
//codeEditor.selectAll(); codeEditor.cursorPosition = pos;
//codeEditor.deselect(); }, 0);
codeEditor.cursorPosition = pos;
} }
onInformation:{ onInformation:{
informationDialog.text = text informationDialog.text = text
informationDialog.visible = true; 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{ 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