diff --git a/plugins/builtin/include/content/views/view_pattern_editor.hpp b/plugins/builtin/include/content/views/view_pattern_editor.hpp index db25fe728..da7afbaac 100644 --- a/plugins/builtin/include/content/views/view_pattern_editor.hpp +++ b/plugins/builtin/include/content/views/view_pattern_editor.hpp @@ -248,6 +248,7 @@ namespace hex::plugin::builtin { std::mutex m_logMutex; + PerProvider m_cursorPosition; PerProvider> m_lastEvaluationError; PerProvider> m_lastCompileError; PerProvider> m_callStack; diff --git a/plugins/builtin/source/content/views/view_pattern_editor.cpp b/plugins/builtin/source/content/views/view_pattern_editor.cpp index 4435b9d44..1bac9ff0e 100644 --- a/plugins/builtin/source/content/views/view_pattern_editor.cpp +++ b/plugins/builtin/source/content/views/view_pattern_editor.cpp @@ -566,7 +566,7 @@ namespace hex::plugin::builtin { } if (m_hasUnevaluatedChanges && m_runningEvaluators == 0 && m_runningParsers == 0) { - if ((std::chrono::steady_clock::now() - m_lastEditorChangeTime) > std::chrono::seconds(1)) { + if ((std::chrono::steady_clock::now() - m_lastEditorChangeTime) > std::chrono::seconds(1LL)) { m_hasUnevaluatedChanges = false; auto code = m_textEditor.GetText(); @@ -1735,7 +1735,7 @@ namespace hex::plugin::builtin { *m_breakpointHit = true; m_resetDebuggerVariables = true; while (*m_breakpointHit) { - std::this_thread::sleep_for(std::chrono::milliseconds(100)); + std::this_thread::sleep_for(std::chrono::milliseconds(100LL)); } }); @@ -1758,7 +1758,7 @@ namespace hex::plugin::builtin { m_dangerousFunctionCalled = true; while (m_dangerousFunctionsAllowed == DangerousFunctionPerms::Ask) { - std::this_thread::sleep_for(std::chrono::milliseconds(100)); + std::this_thread::sleep_for(std::chrono::milliseconds(100LL)); } return m_dangerousFunctionsAllowed == DangerousFunctionPerms::Allow; @@ -1852,15 +1852,19 @@ namespace hex::plugin::builtin { m_envVarEntries->emplace_back(0, "", i128(0), EnvVarType::Integer); m_debuggerDrawer.get(provider) = std::make_unique(); + m_cursorPosition.get(provider) = TextEditor::Coordinates(0, 0); }); EventProviderChanged::subscribe(this, [this](prv::Provider *oldProvider, prv::Provider *newProvider) { - if (oldProvider != nullptr) + if (oldProvider != nullptr) { m_sourceCode.set(oldProvider, m_textEditor.GetText()); + m_cursorPosition.set(m_textEditor.GetCursorPosition(),oldProvider); + } - if (newProvider != nullptr) + if (newProvider != nullptr) { m_textEditor.SetText(m_sourceCode.get(newProvider)); - else + m_textEditor.SetCursorPosition(m_cursorPosition.get(newProvider)); + } else m_textEditor.SetText(""); });