Do not panic if entered unknown code via stack trace
e.g. Rust std library
This commit is contained in:
parent
3a5e044c89
commit
ec599a1eac
1 changed files with 10 additions and 6 deletions
|
@ -324,17 +324,21 @@ impl Application {
|
|||
.unwrap();
|
||||
|
||||
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 {
|
||||
let end =
|
||||
doc.text().line_to_char(end_line - 1) + end_column.unwrap_or(0);
|
||||
let end = doc.text().try_line_to_char(end_line - 1).unwrap_or(0)
|
||||
+ end_column.unwrap_or(0);
|
||||
doc.set_selection(
|
||||
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 {
|
||||
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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue