mirror of
https://github.com/helix-editor/helix.git
synced 2024-11-10 10:35:16 +03:00
Fix append mode not editing correctly.
This is currently a bit of a hack, and still doesn't behave quite how we probably want. Left a TODO.
This commit is contained in:
parent
063aa9452d
commit
7d07704e6f
@ -1281,18 +1281,19 @@ fn append_mode(cx: &mut Context) {
|
||||
let (view, doc) = current!(cx.editor);
|
||||
enter_insert_mode(doc);
|
||||
doc.restore_cursor = true;
|
||||
let text = doc.text().slice(..);
|
||||
|
||||
let selection = doc.selection(view.id).clone().transform(|range| {
|
||||
let to = if range.to() == range.from() {
|
||||
// For 1-width cursor semantics.
|
||||
graphemes::next_grapheme_boundary(doc.text().slice(..), range.to())
|
||||
} else {
|
||||
range.to()
|
||||
};
|
||||
Range::new(range.from(), to)
|
||||
});
|
||||
// TODO: preserve selections, like in `Insert` mode. Probably we'll want
|
||||
// an explicit separate `Append` mode or something similar, so that we
|
||||
// don't change the selection at all, and instead just display and edit
|
||||
// things differently.
|
||||
let selection = doc
|
||||
.selection(view.id)
|
||||
.clone()
|
||||
.min_width_1(text)
|
||||
.transform(|range| Range::new(range.to(), range.to()));
|
||||
|
||||
let end = doc.text().len_chars();
|
||||
let end = text.len_chars();
|
||||
|
||||
if selection.iter().any(|range| range.head == end) {
|
||||
let transaction = Transaction::change(
|
||||
|
Loading…
Reference in New Issue
Block a user