diff options
| author | Jason Felice <jason.m.felice@gmail.com> | 2019-11-11 21:06:37 -0500 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2019-11-12 20:54:32 +1100 |
| commit | 5fae16faefe65464a37322390be3bb291cc3bafd (patch) | |
| tree | 996f8dcdd271cea453aeceb2dea9e4985e323195 /src/selection.cc | |
| parent | 6eb820dc54c96100909a179f2a58bbb9b00b51cd (diff) | |
Implement %val{selections_char_desc}
Fixes #3194
Diffstat (limited to 'src/selection.cc')
| -rw-r--r-- | src/selection.cc | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/selection.cc b/src/selection.cc index a5b2c7b1..412d4f2d 100644 --- a/src/selection.cc +++ b/src/selection.cc @@ -480,13 +480,13 @@ String selection_to_string(const Selection& selection) cursor.line + 1, cursor.column + 1); } -String selection_list_to_string(const SelectionList& selections) +String selection_to_string_char(const Buffer& buffer, const Selection& selection) { - auto beg = &*selections.begin(), end = &*selections.end(); - auto main = beg + selections.main_index(); - using View = ConstArrayView<Selection>; - return join(concatenated(View{main, end}, View{beg, main}) | - transform(selection_to_string), ' ', false); + const auto& cursor = selection.cursor(); + const auto& anchor = selection.anchor(); + return format("{}.{},{}.{}", + anchor.line + 1, buffer[anchor.line].char_count_to(anchor.column) + 1, + cursor.line + 1, buffer[cursor.line].char_count_to(cursor.column) + 1); } Selection selection_from_string(StringView desc) |
