Do not panic if entered unknown code via stack trace

e.g. Rust std library
imgbot
Dmitry Sharshakov 3 years ago
parent 3a5e044c89
commit ec599a1eac
No known key found for this signature in database
GPG Key ID: 471FD32E15FD8473

@ -324,17 +324,21 @@ impl Application {
.unwrap(); .unwrap();
let (view, doc) = current!(self.editor); let (view, doc) = current!(self.editor);
log::info!("{:?}", doc);
let start = doc.text().line_to_char(line - 1) + column; let text_end = doc.text().len_chars() - 1;
let start = doc.text().try_line_to_char(line - 1).unwrap_or(0) + column;
if let Some(end_line) = end_line { if let Some(end_line) = end_line {
let end = let end = doc.text().try_line_to_char(end_line - 1).unwrap_or(0)
doc.text().line_to_char(end_line - 1) + end_column.unwrap_or(0); + end_column.unwrap_or(0);
doc.set_selection( doc.set_selection(
view.id, view.id,
Selection::new(smallvec![Range::new(start, end)], 0), Selection::new(
smallvec![Range::new(start.min(text_end), end.min(text_end))],
0,
),
); );
} else { } else {
doc.set_selection(view.id, Selection::point(start)); doc.set_selection(view.id, Selection::point(start.min(text_end)));
} }
align_view(doc, view, Align::Center); align_view(doc, view, Align::Center);
} }

Loading…
Cancel
Save