From 50d26808c5fd0421ad0aa7803d39ce3efa2d324c Mon Sep 17 00:00:00 2001 From: Neil Date: Thu, 31 Dec 2015 14:38:45 +1100 Subject: Bug [#1796]. Expand folded areas before deleting fold header line. --- doc/ScintillaHistory.html | 7 +++++++ src/Editor.cxx | 23 +++++++++++++++-------- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html index 505f659d6..c7f71d5d9 100644 --- a/doc/ScintillaHistory.html +++ b/doc/ScintillaHistory.html @@ -542,6 +542,13 @@ selection.
  • + Expand folded areas before deleting fold header line. + Bug #1796. +
  • +
  • + Treat Unicode line ends like common line ends when maintaining fold state. +
  • +
  • Highlight whole run for hover indicator when wrapped. Bug #1784.
  • diff --git a/src/Editor.cxx b/src/Editor.cxx index 58abc37fd..29799534e 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -2579,17 +2579,24 @@ void Editor::NotifyModified(Document *, DocModification mh, void *) { } if ((mh.modificationType & (SC_MOD_BEFOREINSERT | SC_MOD_BEFOREDELETE)) && cs.HiddenLines()) { // Some lines are hidden so may need shown. - // TODO: check if the modified area is hidden. + const int lineOfPos = pdoc->LineFromPosition(mh.position); + int endNeedShown = mh.position; if (mh.modificationType & SC_MOD_BEFOREINSERT) { - int lineOfPos = pdoc->LineFromPosition(mh.position); - const bool insertingNewLine = pdoc->ContainsLineEnd(mh.text, mh.length); - if (insertingNewLine && (mh.position != pdoc->LineStart(lineOfPos))) - NeedShown(mh.position, pdoc->LineStart(lineOfPos+1) - mh.position); - else - NeedShown(mh.position, 0); + if (pdoc->ContainsLineEnd(mh.text, mh.length) && (mh.position != pdoc->LineStart(lineOfPos))) + endNeedShown = pdoc->LineStart(lineOfPos+1); } else if (mh.modificationType & SC_MOD_BEFOREDELETE) { - NeedShown(mh.position, mh.length); + // Extend the need shown area over any folded lines + endNeedShown = mh.position + mh.length; + int lineLast = pdoc->LineFromPosition(mh.position+mh.length); + for (int line = lineOfPos; line <= lineLast; line++) { + const int lineMaxSubord = pdoc->GetLastChild(line, -1, -1); + if (lineLast < lineMaxSubord) { + lineLast = lineMaxSubord; + endNeedShown = pdoc->LineEnd(lineLast); + } + } } + NeedShown(mh.position, endNeedShown - mh.position); } if (mh.linesAdded != 0) { // Update contraction state for inserted and removed lines -- cgit v1.2.3