mirror of
https://github.com/ilyakooo0/helix.git
synced 2024-12-01 11:23:10 +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);
|
let (view, doc) = current!(cx.editor);
|
||||||
enter_insert_mode(doc);
|
enter_insert_mode(doc);
|
||||||
doc.restore_cursor = true;
|
doc.restore_cursor = true;
|
||||||
|
let text = doc.text().slice(..);
|
||||||
|
|
||||||
let selection = doc.selection(view.id).clone().transform(|range| {
|
// TODO: preserve selections, like in `Insert` mode. Probably we'll want
|
||||||
let to = if range.to() == range.from() {
|
// an explicit separate `Append` mode or something similar, so that we
|
||||||
// For 1-width cursor semantics.
|
// don't change the selection at all, and instead just display and edit
|
||||||
graphemes::next_grapheme_boundary(doc.text().slice(..), range.to())
|
// things differently.
|
||||||
} else {
|
let selection = doc
|
||||||
range.to()
|
.selection(view.id)
|
||||||
};
|
.clone()
|
||||||
Range::new(range.from(), to)
|
.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) {
|
if selection.iter().any(|range| range.head == end) {
|
||||||
let transaction = Transaction::change(
|
let transaction = Transaction::change(
|
||||||
|
Loading…
Reference in New Issue
Block a user