on master help sign in
Fix selecting a changed file in global search (#5639)
361a834Pascal Kuthe
helix-term/src/commands.rs+4
@@ -2003,6 +2003,10 @@ fn global_search(cx: &mut Context) {
2003 let line_num = *line_num;
2003 let line_num = *line_num;
2004 let (view, doc) = current!(cx.editor);
2004 let (view, doc) = current!(cx.editor);
2005 let text = doc.text();
2005 let text = doc.text();
2006+ if line_num >= text.len_lines() {
2007+ cx.editor.set_error("The line you jumped to does not exist anymore because the file has changed.");
2008+ return;
2009+ }
2006 let start = text.line_to_char(line_num);
2010 let start = text.line_to_char(line_num);
2007 let end = text.line_to_char((line_num + 1).min(text.len_lines()));
2011 let end = text.line_to_char((line_num + 1).min(text.len_lines()));
2008
2012