From cb8cd73d839a96f98bb1ce887c694271f9c24788 Mon Sep 17 00:00:00 2001 From: Neil Date: Tue, 22 Nov 2022 09:24:07 +1100 Subject: Add SCI_REPLACETARGETMINIMAL to change text without causing unchanged prefix and suffix to be marked as modified in change history. --- src/Document.cxx | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/Document.cxx') diff --git a/src/Document.cxx b/src/Document.cxx index 0237cef78..6a638471d 100644 --- a/src/Document.cxx +++ b/src/Document.cxx @@ -1242,6 +1242,17 @@ void Document::CheckReadOnly() { } } +void Document::TrimReplacement(std::string_view &text, Range &range) const noexcept { + while (!text.empty() && !range.Empty() && (text.front() == CharAt(range.start))) { + text.remove_prefix(1); + range.start++; + } + while (!text.empty() && !range.Empty() && (text.back() == CharAt(range.end-1))) { + text.remove_suffix(1); + range.end--; + } +} + // Document only modified by gateways DeleteChars, InsertString, Undo, Redo, and SetStyleAt. // SetStyleAt does not change the persistent state of a document -- cgit v1.2.3