summaryrefslogtreecommitdiff
path: root/src/buffer.cc
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2022-06-08 19:43:03 +1000
committerMaxime Coste <mawww@kakoune.org>2022-07-05 08:43:40 +1000
commitdf79d0c2453991c4762c6c6ffbccd714312c87f9 (patch)
tree6b92b4789d05cd5a78d2b7d22adb72f3c4d26402 /src/buffer.cc
parentb5e565bd6a957373096ad7fd636d4e931940cf9b (diff)
Distinguish between non-eol max column target and plain max column
Diffstat (limited to 'src/buffer.cc')
-rw-r--r--src/buffer.cc5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/buffer.cc b/src/buffer.cc
index b2552085..4d7d432d 100644
--- a/src/buffer.cc
+++ b/src/buffer.cc
@@ -155,14 +155,15 @@ BufferCoord Buffer::clamp(BufferCoord coord) const
return coord;
}
-BufferCoord Buffer::offset_coord(BufferCoord coord, CharCount offset, ColumnCount, bool) const
+BufferCoord Buffer::offset_coord(BufferCoord coord, CharCount offset, ColumnCount) const
{
return utf8::advance(iterator_at(coord), offset < 0 ? begin() : end()-1, offset).coord();
}
-BufferCoordAndTarget Buffer::offset_coord(BufferCoordAndTarget coord, LineCount offset, ColumnCount tabstop, bool avoid_eol) const
+BufferCoordAndTarget Buffer::offset_coord(BufferCoordAndTarget coord, LineCount offset, ColumnCount tabstop) const
{
const auto column = coord.target == -1 ? get_column(*this, tabstop, coord) : coord.target;
+ const bool avoid_eol = coord.target < max_column;
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 - (avoid_eol ? 1 : 0)));