Refactor retrieving oldest and newest selection

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
Antonio Scandurra 2021-11-18 15:04:12 +01:00
parent 0a6293bcda
commit 401b59be5c
4 changed files with 149 additions and 30 deletions

View file

@ -258,11 +258,7 @@ impl DiagnosticMessage {
fn update(&mut self, editor: ViewHandle<Editor>, cx: &mut ViewContext<Self>) {
let editor = editor.read(cx);
let cursor_position = editor
.selections::<usize>(cx)
.max_by_key(|selection| selection.id)
.unwrap()
.head();
let cursor_position = editor.newest_selection(cx).head();
let new_diagnostic = editor
.buffer()
.read(cx)