[storage] New attempt to save cursor position

This commit is contained in:
Laury
2022-06-10 16:15:31 +02:00
parent 1db74c78ab
commit c826e556a1
9 changed files with 91 additions and 2 deletions

View File

@@ -65,13 +65,19 @@ void EditorController::viewWillAppear() {
ViewController::viewWillAppear();
m_editorView.loadSyntaxHighlighter();
if(GlobalPreferences::sharedGlobalPreferences()->cursorSaving()) {
m_editorView.setCursorLocation(m_editorView.text() + strlen(m_editorView.text()));
int offset = m_script.cursorOffset();
if (offset != -1) {
m_editorView.setCursorLocation(m_editorView.text() + offset);
} else {
m_editorView.setCursorLocation(m_editorView.text() + strlen(m_editorView.text()));
}
} else {
m_editorView.setCursorLocation(m_editorView.text() + strlen(m_editorView.text()));
}
}
void EditorController::viewDidDisappear() {
m_script.setCursorOffset(m_editorView.cursorLocation() - m_script.content());
m_editorView.resetSelection();
m_menuController->scriptContentEditionDidFinish();
}