diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2012-10-11 14:23:20 +0200 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2012-10-11 14:23:20 +0200 |
| commit | 4f1ab5b74935d3250c41bbee5f347ec4f815063c (patch) | |
| tree | 1dd0aed8824232543e9195e0fa5d81e55db32c26 /src | |
| parent | 4210a177531d9b88330aa43ec44c5e8c2ac8d73b (diff) | |
fix Window::scroll_to_keep_cursor_visible_ifn
Diffstat (limited to 'src')
| -rw-r--r-- | src/window.cc | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/window.cc b/src/window.cc index e74098c0..45485dd8 100644 --- a/src/window.cc +++ b/src/window.cc @@ -72,7 +72,7 @@ void Window::set_dimensions(const DisplayCoord& dimensions) void Window::scroll_to_keep_cursor_visible_ifn() { - BufferIterator cursor = selections().back().last(); + const BufferIterator cursor = selections().back().last(); // scroll lines if needed if (cursor.line() < m_position.line) @@ -107,10 +107,11 @@ void Window::scroll_to_keep_cursor_visible_ifn() else column += atom.content.content().char_length(); + CharCount cursor_col = utf8::distance(line_begin, cursor); // we could early out on this, but having scrolling left // faster than not scrolling at all is not really useful. - if (column < m_position.column) - m_position.column = column; + if (cursor_col < m_position.column) + m_position.column = cursor_col; else if (column >= m_position.column + m_dimensions.column) m_position.column = column - (m_dimensions.column - 1); |
