diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Editor.cxx | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/src/Editor.cxx b/src/Editor.cxx index b5143090b..c243e00a6 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -181,14 +181,11 @@ void LineLayoutCache::AllocateForLevel(int linesOnScreen, int linesInDoc) { } if (lengthForLevel > size) { Deallocate(); - } else { - if (lengthForLevel < length) { - for (int i=lengthForLevel; i<length; i++) { - delete cache[i]; - cache[i] = 0; - } + } else if (lengthForLevel < length) { + for (int i=lengthForLevel; i<length; i++) { + delete cache[i]; + cache[i] = 0; } - Invalidate(LineLayout::llInvalid); } if (!cache) { Allocate(lengthForLevel); @@ -1219,10 +1216,12 @@ void Editor::InvalidateCaret() { } void Editor::NeedWrapping(int docLineStartWrapping) { - docLineLastWrapped = docLineStartWrapping - 1; - if (docLineLastWrapped < -1) - docLineLastWrapped = -1; - llc.Invalidate(LineLayout::llPositions); + if (docLineLastWrapped > (docLineStartWrapping - 1)) { + docLineLastWrapped = docLineStartWrapping - 1; + if (docLineLastWrapped < -1) + docLineLastWrapped = -1; + llc.Invalidate(LineLayout::llPositions); + } } // Check if wrapping needed and perform any needed wrapping. @@ -1623,6 +1622,9 @@ void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayou ll->widthLine = width; if (width == LineLayout::wrapWidthInfinite) { ll->lines = 1; + } else if (width > ll->positions[ll->numCharsInLine]) { + // Simple common case where line does not need wrapping. + ll->lines = 1; } else { ll->lines = 0; // Calculate line start positions based upon width. |