aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Document.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'src/Document.cxx')
-rw-r--r--src/Document.cxx25
1 files changed, 7 insertions, 18 deletions
diff --git a/src/Document.cxx b/src/Document.cxx
index ab4da0179..d4754233e 100644
--- a/src/Document.cxx
+++ b/src/Document.cxx
@@ -2571,10 +2571,10 @@ bool SCI_METHOD Document::SetStyleFor(Sci_Position length, char style) {
return false;
}
enteredStyling++;
- const Sci::Position prevEndStyled = endStyled;
- if (cb.SetStyleFor(endStyled, length, style)) {
+ const ChangedRange cr = cb.SetStyleFor(endStyled, length, style);
+ if (!cr.Empty()) {
const DocModification mh(ModificationFlags::ChangeStyle | ModificationFlags::User,
- prevEndStyled, length);
+ cr.start, cr.end - cr.start + 1);
NotifyModified(mh);
}
endStyled += length;
@@ -2587,22 +2587,11 @@ bool SCI_METHOD Document::SetStyles(Sci_Position length, const char *styles) {
return false;
}
enteredStyling++;
- bool didChange = false;
- Sci::Position startMod = 0;
- Sci::Position endMod = 0;
- for (int iPos = 0; iPos < length; iPos++, endStyled++) {
- PLATFORM_ASSERT(endStyled < Length());
- if (cb.SetStyleAt(endStyled, styles[iPos])) {
- if (!didChange) {
- startMod = endStyled;
- }
- didChange = true;
- endMod = endStyled;
- }
- }
- if (didChange) {
+ const ChangedRange cr = cb.SetStyles(endStyled, styles, length);
+ endStyled += length;
+ if (!cr.Empty()) {
const DocModification mh(ModificationFlags::ChangeStyle | ModificationFlags::User,
- startMod, endMod - startMod + 1);
+ cr.start, cr.end - cr.start + 1);
NotifyModified(mh);
}
enteredStyling--;