diff options
| author | Maxime Coste <mawww@kakoune.org> | 2017-05-21 08:24:44 +0100 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2017-05-21 08:24:44 +0100 |
| commit | ad9ad7e603fe115c2ef6ee9a4731af9c2014ac11 (patch) | |
| tree | f3d2295e99e5388a10fbb2de8c8723fef18efd54 /src/buffer.cc | |
| parent | c6508ee101bed954183d307bde4f991d67dcf286 (diff) | |
Fix vertical movement with tabstops
Fixes #1388
Diffstat (limited to 'src/buffer.cc')
| -rw-r--r-- | src/buffer.cc | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/buffer.cc b/src/buffer.cc index 6d9321d6..e5527693 100644 --- a/src/buffer.cc +++ b/src/buffer.cc @@ -186,11 +186,10 @@ BufferCoord Buffer::offset_coord(BufferCoord coord, CharCount offset, ColumnCoun BufferCoordAndTarget Buffer::offset_coord(BufferCoordAndTarget coord, LineCount offset, ColumnCount tabstop) { - auto column = coord.target == -1 ? get_column(*this, tabstop, coord) : coord.target; - auto line = Kakoune::clamp(coord.line + offset, 0_line, line_count()-1); - StringView content = m_lines[line]; - - auto final_column = std::max(0_col, std::min(column, content.column_length() - 2)); + const auto column = coord.target == -1 ? get_column(*this, tabstop, coord) : coord.target; + const auto line = Kakoune::clamp(coord.line + offset, 0_line, line_count()-1); + const auto max_column = get_column(*this, tabstop, {line, m_lines[line].length()-1}); + const auto final_column = std::max(0_col, std::min(column, max_column - 1)); return {line, get_byte_to_column(*this, tabstop, {line, final_column}), column}; } |
