-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Align view for background buffer opened with alt-ret
#7691
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
* symbol pickers * diagnostick pickers This is done using the already patched `jump_to_location` method.
This comment was marked as resolved.
This comment was marked as resolved.
Here we go again. Now all the lsp pickers work correctly because under the hood I added a cc @pascalkuthe pr is ready for viewing when you have free time 🤓 |
if current_path.as_ref() == Some(url) { | ||
let (view, doc) = current!(cx.editor); | ||
push_jump(view, doc); | ||
} else { | ||
let path = url.to_file_path().unwrap(); | ||
cx.editor.open(&path, action).expect("editor.open failed"); | ||
} | ||
|
||
let (view, doc) = current!(cx.editor); | ||
|
||
if let Some(range) = lsp_range_to_range(doc.text(), diag.range, *offset_encoding) { | ||
// we flip the range so that the cursor sits on the start of the symbol | ||
// (for example start of the function). | ||
doc.set_selection(view.id, Selection::single(range.head, range.anchor)); | ||
align_view(doc, view, Align::Center); | ||
} | ||
jump_to_location( | ||
cx.editor, | ||
&lsp::Location::new(url.clone(), diag.range), | ||
*offset_encoding, | ||
action, | ||
) |
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.
this is not quite the same thing. The diagnostic picker only seems to create a jumplist entry if not opening a new file. Admittetly this is a bit strange I would expect the various Lsp pickers to behavhe consistently. Do you know the history here @the-mikedavis?
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.
I think it's just an oversight: pushing a jump all of the time makes sense to me.
dcbd4bb
to
01af29a
Compare
Added basic integrational test for |
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.
LGTM, except the change to the diagnostic picker I am not sure about. Let's wait for @the-mikedavis review
if current_path.as_ref() == Some(url) { | ||
let (view, doc) = current!(cx.editor); | ||
push_jump(view, doc); | ||
} else { | ||
let path = url.to_file_path().unwrap(); | ||
cx.editor.open(&path, action).expect("editor.open failed"); | ||
} | ||
|
||
let (view, doc) = current!(cx.editor); | ||
|
||
if let Some(range) = lsp_range_to_range(doc.text(), diag.range, *offset_encoding) { | ||
// we flip the range so that the cursor sits on the start of the symbol | ||
// (for example start of the function). | ||
doc.set_selection(view.id, Selection::single(range.head, range.anchor)); | ||
align_view(doc, view, Align::Center); | ||
} | ||
jump_to_location( | ||
cx.editor, | ||
&lsp::Location::new(url.clone(), diag.range), | ||
*offset_encoding, | ||
action, | ||
) |
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.
I think it's just an oversight: pushing a jump all of the time makes sense to me.
alt-ret
…7691) * fix(picker): `alt-ret' changes cursor pos of current file, not new one Closes helix-editor#7673 * fix other pickers * symbol pickers * diagnostick pickers This is done using the already patched `jump_to_location` method. * fix global and jumplist pickers * use `view` as old_id; make `align_view` method of `Action` * test(picker): basic <alt-ret> functionality * fix: picker integrational test * fix nit Co-authored-by: Michael Davis <mcarsondavis@gmail.com> --------- Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
…7691) * fix(picker): `alt-ret' changes cursor pos of current file, not new one Closes helix-editor#7673 * fix other pickers * symbol pickers * diagnostick pickers This is done using the already patched `jump_to_location` method. * fix global and jumplist pickers * use `view` as old_id; make `align_view` method of `Action` * test(picker): basic <alt-ret> functionality * fix: picker integrational test * fix nit Co-authored-by: Michael Davis <mcarsondavis@gmail.com> --------- Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
…7691) * fix(picker): `alt-ret' changes cursor pos of current file, not new one Closes helix-editor#7673 * fix other pickers * symbol pickers * diagnostick pickers This is done using the already patched `jump_to_location` method. * fix global and jumplist pickers * use `view` as old_id; make `align_view` method of `Action` * test(picker): basic <alt-ret> functionality * fix: picker integrational test * fix nit Co-authored-by: Michael Davis <mcarsondavis@gmail.com> --------- Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
Closes #7673
Now if
alt-ret
is pressed, it opens the selected file and places the cursor on the selected line (if path contained a line number), but in the background (i. e the focused document remains unchanged).