-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add goto next/prev error (bound to ]e/[e) #6331
base: master
Are you sure you want to change the base?
Conversation
helix-term/src/commands.rs
Outdated
goto_next_error, "Goto next error diagnostic", | ||
goto_prev_error, "Goto prev error diagnostic", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
goto_next_error, "Goto next error diagnostic", | |
goto_prev_error, "Goto prev error diagnostic", | |
goto_next_error, "Goto next error", | |
goto_prev_error, "Goto prev error", |
I guess error should be enough?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thx! Ill update the pr with the suggestions when i have time
helix-term/src/commands.rs
Outdated
let diag = match direction { | ||
Direction::Forward => iter | ||
.clone() | ||
.find(|diag| diag.range.start > cursor_pos) | ||
.or_else(|| iter.next()), | ||
Direction::Backward => { | ||
let mut iter = iter.rev(); | ||
iter.clone() | ||
.find(|diag| diag.range.start < cursor_pos) | ||
.or_else(|| iter.next()) | ||
} | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let diag = match direction { | |
Direction::Forward => iter | |
.clone() | |
.find(|diag| diag.range.start > cursor_pos) | |
.or_else(|| iter.next()), | |
Direction::Backward => { | |
let mut iter = iter.rev(); | |
iter.clone() | |
.find(|diag| diag.range.start < cursor_pos) | |
.or_else(|| iter.next()) | |
} | |
}; | |
let diag = match direction { | |
Direction::Forward => iter | |
.find(|diag| diag.range.start > cursor_pos) | |
.or_else(|| iter.next()), | |
Direction::Backward => { | |
let mut iter = iter.rev(); | |
iter.find(|diag| diag.range.start < cursor_pos) | |
.or_else(|| iter.next()) | |
} | |
}; |
Unnecessary clone
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The clone is necessary as find exhausts the iterator, thus in the suggestion or_else(|| iter.next()) will always return None
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we leave a comment here so we know it shouldn't exhaust the iterator?
helix-term/src/commands.rs
Outdated
let selection = match diag { | ||
Some(diag) => Selection::single(diag.range.start, diag.range.end), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please change this to let else?
let Some(diag) = diag else { return };
@pickfire thx for the review! sorry about the delay. I've applied your feedback. |
|
some of my projects have a warnings from very verbose linters, this helps navigate the files when fixes errors.