Skip to content

Commit a11848e

Browse files
committed
Improve Addons::Context
1 parent e7116e6 commit a11848e

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

addons/src/addons-context.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2023 Nick Egorrov, nicegorov@yandex.ru
2+
* Copyright (C) 2023-2025 Nick Egorrov, nicegorov@yandex.ru
33
*
44
* This file is part of GCodeWorkShop.
55
*
@@ -98,6 +98,16 @@ void Addons::Context::push(const QString& text)
9898
cursor.setPosition(m_fragmentEnd, QTextCursor::MoveAnchor);
9999
cursor.setPosition(m_fragmentStart, QTextCursor::KeepAnchor);
100100
cursor.insertText(text);
101+
int diff = text.size() - m_fragmentEnd + m_fragmentStart;
102+
103+
if (m_selectionStart == m_fragmentEnd) {
104+
m_selectionStart += diff;
105+
}
106+
107+
if (m_selectionEnd == m_fragmentEnd) {
108+
m_selectionEnd += diff;
109+
}
110+
101111
cursor.setPosition(m_selectionEnd, QTextCursor::MoveAnchor);
102112
cursor.setPosition(m_selectionStart, QTextCursor::KeepAnchor);
103113
m_edit->setTextCursor(cursor);

0 commit comments

Comments
 (0)