Skip to content

Commit

Permalink
Inline CheckModificationForWrap().
Browse files Browse the repository at this point in the history
  • Loading branch information
zufuliu committed Nov 16, 2023
1 parent 9de4a99 commit 4e872ae
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 30 deletions.
59 changes: 30 additions & 29 deletions scintilla/src/Editor.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -2653,18 +2653,25 @@ void Editor::NotifySavePoint(Document *, void *, bool atSavePoint) noexcept {
NotifySavePoint(atSavePoint);
}

void Editor::CheckModificationForWrap(DocModification mh) {
if (FlagSet(mh.modificationType, ModificationFlags::InsertText | ModificationFlags::DeleteText)) {
view.llc.Invalidate(LineLayout::ValidLevel::checkTextAndStyle);
const Sci::Line lineDoc = pdoc->SciLineFromPosition(mh.position);
const Sci::Line lines = std::max<Sci::Line>(0, mh.linesAdded);
if (Wrapping()) {
NeedWrapping(lineDoc, lineDoc + lines + 1);
void Editor::CheckModificationForShow(const DocModification &mh) {
const Sci::Line lineOfPos = pdoc->SciLineFromPosition(mh.position);
Sci::Position endNeedShown = mh.position;
if (FlagSet(mh.modificationType, ModificationFlags::BeforeInsert)) {
if (pdoc->ContainsLineEnd(mh.text, mh.length) && (mh.position != pdoc->LineStart(lineOfPos)))
endNeedShown = pdoc->LineStart(lineOfPos + 1);
} else {
// If the deletion includes any EOL then we extend the need shown area.
endNeedShown = mh.position + mh.length;
Sci::Line lineLast = pdoc->SciLineFromPosition(mh.position + mh.length);
for (Sci::Line line = lineOfPos + 1; line <= lineLast; line++) {
const Sci::Line lineMaxSubord = pdoc->GetLastChild(line);
if (lineLast < lineMaxSubord) {
lineLast = lineMaxSubord;
endNeedShown = pdoc->LineEnd(lineLast);
}
}
RefreshStyleData();
// Fix up annotation heights
SetAnnotationHeights(lineDoc, lineDoc + lines + 2);
}
NeedShown(mh.position, endNeedShown - mh.position);
}

namespace {
Expand Down Expand Up @@ -2750,24 +2757,7 @@ void Editor::NotifyModified(Document *, DocModification mh, void *) {
}
if (FlagSet(mh.modificationType, (ModificationFlags::BeforeInsert | ModificationFlags::BeforeDelete)) && pcs->HiddenLines()) {
// Some lines are hidden so may need shown.
const Sci::Line lineOfPos = pdoc->SciLineFromPosition(mh.position);
Sci::Position endNeedShown = mh.position;
if (FlagSet(mh.modificationType, ModificationFlags::BeforeInsert)) {
if (pdoc->ContainsLineEnd(mh.text, mh.length) && (mh.position != pdoc->LineStart(lineOfPos)))
endNeedShown = pdoc->LineStart(lineOfPos + 1);
} else {
// If the deletion includes any EOL then we extend the need shown area.
endNeedShown = mh.position + mh.length;
Sci::Line lineLast = pdoc->SciLineFromPosition(mh.position + mh.length);
for (Sci::Line line = lineOfPos + 1; line <= lineLast; line++) {
const Sci::Line lineMaxSubord = pdoc->GetLastChild(line);
if (lineLast < lineMaxSubord) {
lineLast = lineMaxSubord;
endNeedShown = pdoc->LineEnd(lineLast);
}
}
}
NeedShown(mh.position, endNeedShown - mh.position);
CheckModificationForShow(mh);
}
if (mh.linesAdded != 0) {
// Update contraction state for inserted and removed lines
Expand Down Expand Up @@ -2796,7 +2786,18 @@ void Editor::NotifyModified(Document *, DocModification mh, void *) {
Redraw();
}
}
CheckModificationForWrap(mh);
//CheckModificationForWrap(mh);
if (FlagSet(mh.modificationType, ModificationFlags::InsertText | ModificationFlags::DeleteText)) {
view.llc.Invalidate(LineLayout::ValidLevel::checkTextAndStyle);
const Sci::Line lineDoc = pdoc->SciLineFromPosition(mh.position);
const Sci::Line lines = std::max<Sci::Line>(0, mh.linesAdded);
if (Wrapping()) {
NeedWrapping(lineDoc, lineDoc + lines + 1);
}
RefreshStyleData();
// Fix up annotation heights
SetAnnotationHeights(lineDoc, lineDoc + lines + 2);
}
if (mh.linesAdded != 0) {
// Avoid scrolling of display if change before current display
if (mh.position < posTopLine && !CanDeferToLastStep(mh)) {
Expand Down
2 changes: 1 addition & 1 deletion scintilla/src/Editor.h
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ class Editor : public EditModel, public DocWatcher {

void NotifyModifyAttempt(Document *document, void *userData) noexcept override;
void NotifySavePoint(Document *document, void *userData, bool atSavePoint) noexcept override;
void CheckModificationForWrap(DocModification mh);
void CheckModificationForShow(const DocModification &mh);
void NotifyModified(Document *document, DocModification mh, void *userData) override;
void NotifyDeleted(Document *document, void *userData) noexcept override;
void NotifyStyleNeeded(Document *doc, void *userData, Sci::Position endStyleNeeded) override;
Expand Down

0 comments on commit 4e872ae

Please sign in to comment.