goto_diag: avoid wraparound by default (#12704)

pull/12707/head
Zi How Poh 2025-01-28 04:41:34 +08:00 committed by GitHub
parent fec5101a41
commit 0c8f0c0334
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 4 deletions

View File

@ -3824,8 +3824,7 @@ fn goto_next_diag(cx: &mut Context) {
let diag = doc
.diagnostics()
.iter()
.find(|diag| diag.range.start > cursor_pos)
.or_else(|| doc.diagnostics().first());
.find(|diag| diag.range.start > cursor_pos);
let selection = match diag {
Some(diag) => Selection::single(diag.range.start, diag.range.end),
@ -3852,8 +3851,7 @@ fn goto_prev_diag(cx: &mut Context) {
.diagnostics()
.iter()
.rev()
.find(|diag| diag.range.start < cursor_pos)
.or_else(|| doc.diagnostics().last());
.find(|diag| diag.range.start < cursor_pos);
let selection = match diag {
// NOTE: the selection is reversed because we're jumping to the