diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2014-09-09 19:35:54 +0100 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2014-09-09 19:42:57 +0100 |
| commit | 50924944274d43149267cd9238625e40b46bbfeb (patch) | |
| tree | 395366fa1159a5cffa760a4ae0ce98fd9604ee84 /src/buffer.cc | |
| parent | 7fc1564c0c15508a44abe1627002532d6ae52ae2 (diff) | |
Add support for target column preservation
Fixes #64
Diffstat (limited to 'src/buffer.cc')
| -rw-r--r-- | src/buffer.cc | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/buffer.cc b/src/buffer.cc index c41d7e8a..e22a29cb 100644 --- a/src/buffer.cc +++ b/src/buffer.cc @@ -137,14 +137,14 @@ ByteCoord Buffer::offset_coord(ByteCoord coord, CharCount offset) return {coord.line, line.byte_count_to(character)}; } -ByteCoord Buffer::offset_coord(ByteCoord coord, LineCount offset) +ByteCoordAndTarget Buffer::offset_coord(ByteCoordAndTarget coord, LineCount offset) { - auto character = m_lines[coord.line].char_count_to(coord.column); + auto character = coord.target == -1 ? m_lines[coord.line].char_count_to(coord.column) : coord.target; auto line = Kakoune::clamp(coord.line + offset, 0_line, line_count()-1); auto& content = m_lines[line]; character = std::max(0_char, std::min(character, content.char_length() - 2)); - return {line, content.byte_count_to(character)}; + return {line, content.byte_count_to(character), character}; } String Buffer::string(ByteCoord begin, ByteCoord end) const |
