Skip to content

Commit

Permalink
adjust the range after replacing
Browse files Browse the repository at this point in the history
closes #405
  • Loading branch information
stefankueng committed Jan 11, 2025
1 parent 2ac9b97 commit 9303530
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/Commands/CmdFindReplace.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// This file is part of BowPad.
//
// Copyright (C) 2013-2024 - Stefan Kueng
// Copyright (C) 2013-2025 - Stefan Kueng
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -1647,7 +1647,12 @@ void CFindReplaceDlg::DoReplace(int id)
else
Scintilla().SetTargetStart(targetEnd + 1);
if (bReplaceOnlyInSelection)
Scintilla().SetTargetEnd(selEnd);
{
auto newSelEnd = selEnd + static_cast<Scintilla::Position>(sReplaceString.length()) - static_cast<Scintilla::Position>(g_findString.length());
if (newSelEnd > Scintilla().Length())
newSelEnd = Scintilla().Length();
Scintilla().SetTargetEnd(newSelEnd);
}
else
{
auto docLen = Scintilla().Length();
Expand Down

0 comments on commit 9303530

Please sign in to comment.