diff --git a/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp b/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp index c58647614..460f259da 100644 --- a/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp +++ b/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp @@ -2112,6 +2112,47 @@ void ScintillaEditView::setLineIndent(int line, int indent) const { execute(SCI_SETSEL, crange.cpMin, crange.cpMax); } +void ScintillaEditView::updateLineNumberWidth() +{ + if (_lineNumbersShown) + { + int linesVisible = (int) execute(SCI_LINESONSCREEN); + if (linesVisible) + { + int firstVisibleLineVis = (int) execute(SCI_GETFIRSTVISIBLELINE); + int lastVisibleLineVis = linesVisible + firstVisibleLineVis + 1; + + if (execute(SCI_GETWRAPMODE) != SC_WRAP_NONE) + { + int numLinesDoc = (int) execute(SCI_GETLINECOUNT); + int prevLineDoc = (int) execute(SCI_DOCLINEFROMVISIBLE, firstVisibleLineVis); + for (int i = firstVisibleLineVis + 1; i <= lastVisibleLineVis; ++i) + { + int lineDoc = (int) execute(SCI_DOCLINEFROMVISIBLE, i); + if (lineDoc == numLinesDoc) + break; + if (lineDoc == prevLineDoc) + lastVisibleLineVis++; + prevLineDoc = lineDoc; + } + } + + int lastVisibleLineDoc = (int) execute(SCI_DOCLINEFROMVISIBLE, lastVisibleLineVis); + int i = 0; + + while (lastVisibleLineDoc) + { + lastVisibleLineDoc /= 10; + ++i; + } + + i = max(i, 3); + int pixelWidth = int(8 + i * execute(SCI_TEXTWIDTH, STYLE_LINENUMBER, (LPARAM)"8")); + execute(SCI_SETMARGINWIDTHN, _SC_MARGE_LINENUMBER, pixelWidth); + } + } +} + const char * ScintillaEditView::getCompleteKeywordList(std::basic_string & kwl, LangType langType, int keywordIndex) { kwl += " "; diff --git a/PowerEditor/src/ScitillaComponent/ScintillaEditView.h b/PowerEditor/src/ScitillaComponent/ScintillaEditView.h index 4a4f6ea57..49e760065 100644 --- a/PowerEditor/src/ScitillaComponent/ScintillaEditView.h +++ b/PowerEditor/src/ScitillaComponent/ScintillaEditView.h @@ -516,29 +516,7 @@ public: } } - void updateLineNumberWidth() { - if (_lineNumbersShown) - { - int linesVisible = (int) execute(SCI_LINESONSCREEN); - if (linesVisible) - { - int firstVisibleLineVis = (int) execute(SCI_GETFIRSTVISIBLELINE); - int lastVisibleLineVis = linesVisible + firstVisibleLineVis + 1; - int lastVisibleLineDoc = (int) execute(SCI_DOCLINEFROMVISIBLE, lastVisibleLineVis); - int i = 0; - while (lastVisibleLineDoc) - { - lastVisibleLineDoc /= 10; - ++i; - } - i = max(i, 3); - { - int pixelWidth = int(8 + i * execute(SCI_TEXTWIDTH, STYLE_LINENUMBER, (LPARAM)"8")); - execute(SCI_SETMARGINWIDTHN, _SC_MARGE_LINENUMBER, pixelWidth); - } - } - } - }; + void updateLineNumberWidth(); void setCurrentLineHiLiting(bool isHiliting, COLORREF bgColor) const { execute(SCI_SETCARETLINEVISIBLE, isHiliting);