summaryrefslogtreecommitdiff
path: root/src/normal.cc
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2013-12-15 20:52:57 +0000
committerMaxime Coste <frrrwww@gmail.com>2013-12-15 20:52:57 +0000
commitf83d5672f830d49e9ff9fa2f5df8144d0e362e56 (patch)
tree65d38c6e50a821ce6fb365a65a817ade60646556 /src/normal.cc
parentea95632709a6ae3df76772e83e1497a9fcfee52d (diff)
Fix replace_with_char behaviour, keep the same selections
Diffstat (limited to 'src/normal.cc')
-rw-r--r--src/normal.cc11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/normal.cc b/src/normal.cc
index 6bdab3c1..052d1fd5 100644
--- a/src/normal.cc
+++ b/src/normal.cc
@@ -374,9 +374,14 @@ void replace_with_char(Context& context, int)
return;
ScopedEdition edition(context);
Buffer& buffer = context.buffer();
- SelectionList selections = context.selections();
- select_all_matches(buffer, selections, Regex{"."});
- insert<InsertMode::Replace>(buffer, selections, codepoint_to_str(key.key));
+ SelectionList& selections = context.selections();
+ std::vector<String> strings;
+ for (auto& sel : selections)
+ {
+ CharCount count = char_length(buffer, sel);
+ strings.emplace_back(key.key, count);
+ }
+ insert<InsertMode::Replace>(buffer, selections, strings);
}, "replace with char", "enter char to replace with\n");
}