From 901b2782f3095ccf3f695cda40b17697d9c890f6 Mon Sep 17 00:00:00 2001 From: skyjake Date: Tue, 21 May 2013 08:17:46 +0300 Subject: [PATCH] libshell|AbstractLineEditor: Move between lines based on advance width --- doomsday/libshell/src/abstractlineeditor.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doomsday/libshell/src/abstractlineeditor.cpp b/doomsday/libshell/src/abstractlineeditor.cpp index 523d9464a6..ca931a069c 100644 --- a/doomsday/libshell/src/abstractlineeditor.cpp +++ b/doomsday/libshell/src/abstractlineeditor.cpp @@ -126,6 +126,7 @@ DENG2_PIMPL(AbstractLineEditor) DENG2_ASSERT(lineOff == 1 || lineOff == -1); de::Vector2i const linePos = lineCursorPos(); + int const destWidth = wraps->rangeWidth(Range(lineSpan(linePos.y).range.start, cursor)); // Check for no room. if(!linePos.y && lineOff < 0) return false; @@ -133,7 +134,7 @@ DENG2_PIMPL(AbstractLineEditor) // Move cursor onto the adjacent line. WrappedLine span = lineSpan(linePos.y + lineOff); - cursor = span.range.start + linePos.x; + cursor = wraps->indexAtWidth(span.range, destWidth); if(!span.isFinal) span.range.end--; if(cursor > span.range.end) cursor = span.range.end;