Fix selecting a changed file in global search (#5639)

pull/5655/head
Pascal Kuthe 2 years ago committed by GitHub
parent 17acadb305
commit 361a834486
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -2003,6 +2003,10 @@ fn global_search(cx: &mut Context) {
let line_num = *line_num; let line_num = *line_num;
let (view, doc) = current!(cx.editor); let (view, doc) = current!(cx.editor);
let text = doc.text(); let text = doc.text();
if line_num >= text.len_lines() {
cx.editor.set_error("The line you jumped to does not exist anymore because the file has changed.");
return;
}
let start = text.line_to_char(line_num); let start = text.line_to_char(line_num);
let end = text.line_to_char((line_num + 1).min(text.len_lines())); let end = text.line_to_char((line_num + 1).min(text.len_lines()));

Loading…
Cancel
Save