Skip to content

Commit 3308f19

Browse files
GraiccShekhinah Memmel
authored and
Shekhinah Memmel
committed
Fix append cursor location when selection anchor is at end of document (helix-editor#4147)
1 parent 2f2f028 commit 3308f19

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

helix-term/src/commands.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2225,7 +2225,7 @@ fn append_mode(cx: &mut Context) {
22252225
.iter()
22262226
.last()
22272227
.expect("selection should always have at least one range");
2228-
if !last_range.is_empty() && last_range.head == end {
2228+
if !last_range.is_empty() && last_range.to() == end {
22292229
let transaction = Transaction::change(
22302230
doc.text(),
22312231
[(end, end, Some(doc.line_ending.as_str().into()))].into_iter(),

helix-term/tests/test/movement.rs

+21
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,27 @@ async fn cursor_position_newly_opened_file() -> anyhow::Result<()> {
8686
Ok(())
8787
}
8888

89+
#[tokio::test]
90+
async fn cursor_position_append_eof() -> anyhow::Result<()> {
91+
// Selection is fowards
92+
test((
93+
"#[foo|]#",
94+
"abar<esc>",
95+
helpers::platform_line("#[foobar|]#\n").as_ref(),
96+
))
97+
.await?;
98+
99+
// Selection is backwards
100+
test((
101+
"#[|foo]#",
102+
"abar<esc>",
103+
helpers::platform_line("#[foobar|]#\n").as_ref(),
104+
))
105+
.await?;
106+
107+
Ok(())
108+
}
109+
89110
#[tokio::test]
90111
async fn select_mode_tree_sitter_next_function_is_union_of_objects() -> anyhow::Result<()> {
91112
test_with_config(

0 commit comments

Comments
 (0)