Macro IDE: replace only in selected text if multi-line selection is present

This commit is contained in:
Matthias Koefferlein 2021-06-09 21:43:51 +02:00
parent f956dd478b
commit 4cb477a91d
1 changed files with 12 additions and 1 deletions

View File

@ -1150,10 +1150,21 @@ MacroEditorPage::replace_all (const QString &replace)
const QTextDocument *doc = mp_text->document ();
QTextBlock bs = doc->begin (), be = doc->end ();
QTextCursor c = mp_text->textCursor ();
if (c.hasSelection ()) {
QTextBlock s = mp_text->document ()->findBlock (mp_text->textCursor ().selectionStart ());
QTextBlock e = mp_text->document ()->findBlock (mp_text->textCursor ().selectionEnd ());
if (e != s) {
bs = s;
be = e;
}
}
c.beginEditBlock ();
for (QTextBlock b = doc->begin(); b != doc->end(); b = b.next()) {
for (QTextBlock b = bs; b != be; b = b.next()) {
int o = 0;