Fix replace_with_char behaviour, keep the same selections
This commit is contained in:
parent
ea95632709
commit
f83d5672f8
|
@ -374,9 +374,14 @@ void replace_with_char(Context& context, int)
|
||||||
return;
|
return;
|
||||||
ScopedEdition edition(context);
|
ScopedEdition edition(context);
|
||||||
Buffer& buffer = context.buffer();
|
Buffer& buffer = context.buffer();
|
||||||
SelectionList selections = context.selections();
|
SelectionList& selections = context.selections();
|
||||||
select_all_matches(buffer, selections, Regex{"."});
|
std::vector<String> strings;
|
||||||
insert<InsertMode::Replace>(buffer, selections, codepoint_to_str(key.key));
|
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");
|
}, "replace with char", "enter char to replace with\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,6 +51,13 @@ inline BufferIterator erase(Buffer& buffer, const Range& range)
|
||||||
utf8::next(buffer.iterator_at(range.max())));
|
utf8::next(buffer.iterator_at(range.max())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline CharCount char_length(const Buffer& buffer, const Range& range)
|
||||||
|
{
|
||||||
|
return utf8::distance(buffer.iterator_at(range.min()),
|
||||||
|
utf8::next(buffer.iterator_at(range.max())));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
inline void avoid_eol(const Buffer& buffer, BufferCoord& coord)
|
inline void avoid_eol(const Buffer& buffer, BufferCoord& coord)
|
||||||
{
|
{
|
||||||
const auto column = coord.column;
|
const auto column = coord.column;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user