From 9d73a0d1128f8237eef2d4bf475496d4db081df2 Mon Sep 17 00:00:00 2001 From: Mike Trinkala Date: Thu, 9 Feb 2023 06:28:33 -0800 Subject: Fix the infinite loop when copying the cursor to the top of the file (#5888) Example: ``` test testitem ``` Select line 2 with x, then type Alt-C; Helix will go into an infinite loop. The saturating_sub keeps the head_row and anchor_row pinned at 0, and a selection is never made since the first line is too short.--- helix-term/src/commands.rs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'helix-term/src/commands.rs') diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index e6cbed2c..d7d87b5a 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -1617,6 +1617,10 @@ fn copy_selection_on_line(cx: &mut Context, direction: Direction) { sels += 1; } + if anchor_row == 0 && head_row == 0 { + break; + } + i += 1; } } -- cgit v1.2.3-70-g09d2