-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Implement window/showMessageRequest #5492
base: master
Are you sure you want to change the base?
Implement window/showMessageRequest #5492
Conversation
A menu would probably be more appropriate for this than a picker: helix/helix-term/src/commands/lsp.rs Lines 627 to 654 in 927fa11
|
I agree with @ayoub-benali here. In fact I originally suggested the picker on matrix. Nvim also handles this as a larger popup: I think reusing the picker here is nice so there are fewer specical cased UI elements (and the PR is easier to review). |
9e05bd3
to
a67c281
Compare
After discussion with @pascalkuthe I moved the LSP message to the right. This way we can better handle messages that could span over one line. Usually LSP messages are short, but I will enable softwrap once #5420 is merged. For metals this how the build message is displayed: And this is for the file creation: |
Is there anything still missing? Otherwise you can mark this PR as ready for review. |
almost, I am just working on sending the response to the server when the file picker is dismissed. I had to add a function to the constructor and update all the call sites ^^ |
helix-term/src/ui/picker.rs
Outdated
} | ||
|
||
impl<T: Item> Picker<T> { | ||
pub fn new( | ||
options: Vec<T>, | ||
editor_data: T::Data, | ||
callback_fn: impl Fn(&mut Context, &T, Action) + 'static, | ||
on_close_fn: impl Fn(&mut Context) + 'static, |
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 added this function so that we can run it when the picker is dismissed but since it is not needed in the other context, I don't know if there is a better way
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 this mostly works fine but I think you could merge these two callbacks here and pass None
when the picker is closed:
callback_fn: impl Fn(&mut Context, &T, Option<Action>) + 'static,
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.
So callback_fn
should be invoked here with None
just before close_fn
?
helix/helix-term/src/ui/picker.rs
Lines 619 to 621 in b633139
key!(Esc) | ctrl!('c') => { | |
return close_fn; | |
} |
EDIT: done in 267af0d and made the item &T
optional rather than the action
@@ -36,6 +36,7 @@ pub const MAX_FILE_SIZE_FOR_PREVIEW: u64 = 10 * 1024 * 1024; | |||
pub enum PathOrId { | |||
Id(DocumentId), | |||
Path(PathBuf), | |||
Text(Rope), |
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 to show the same message in the "preview" part of the file picker
If your favorite language server doesn't implement this request, you can still test this feature by:
Once the build is done or you click |
@@ -114,7 +125,7 @@ impl<T: Item> FilePicker<T> { | |||
pub fn new( | |||
options: Vec<T>, | |||
editor_data: T::Data, | |||
callback_fn: impl Fn(&mut Context, &T, Action) + 'static, | |||
callback_fn: impl Fn(&mut Context, Option<&T>, Action) + 'static, |
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 None case allows us to represent when the picker is dismissed, otherwise we have to define a separate on_close
method, you can see the attempt here: 34f1555
EDIT: rebasing on master was a mess because I had several commits for commands.rs
and picker.rs
so I squashed my commits to make my life easier.
267af0d
to
3d6a2d3
Compare
return close_fn; | ||
} | ||
alt!(Enter) => { | ||
if let Some(option) = self.selection() { |
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 isn't needed anymore since the None case is handled in the callback function
d3e8b0e
to
ea0abce
Compare
ea0abce
to
567a3d6
Compare
- Opening untrusted_files in NewWindow is not supported, yet? - VS Code empty_window equivalent is a scratch buffer, does it have a cwd? - Manage trusted workspaces as a simple list of paths for now? - Plan for local/remote trusted folders and workspaces - Plan for plugin extensions support (disabled, limited) TODO: - [x] Disable LSP and ? in restricted mode - [x] User configuration (new TOML entry) - [ ] Persist user preferences (trusted folder choices) - [x] Show current workspace status (badge?) - [ ] Add a command to quickly toggle workspace status (Manage Workspace Trust) - [x] Use picker as prompt: helix-editor#5492
567a3d6
to
1b47fa3
Compare
Hi @the-mikedavis, sorry to ping you but Is it possible to give this PR a review ? |
This is done by taking advantage of the preview panel in the file picker to show the request message I changed the Picker callback function to account for when the picker is dismissed
0d398e3
to
d259860
Compare
185cc6b
to
060667b
Compare
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 left some minor comments but otherwise I think this looks good.
In the long run I think I would prefer a custom component for this kind of UI. Using the picker's preview to show a message feels inconsistent to me: the picker preview is otherwise always used for showing supporting information about the currently selected option instead of context about why the picker is open. When I open a picker my eyes are always on the options first and then the preview if needed. This is a relatively small change though to add a feature so I think we can leave that off for future implementation/discussion
Co-authored-by: Michael Davis <[email protected]>
Co-authored-by: Michael Davis <[email protected]>
Co-authored-by: Michael Davis <[email protected]>
Co-authored-by: Michael Davis <[email protected]>
Co-authored-by: Michael Davis <[email protected]>
Hi @archseer, any chance to give this a review ? :) |
Any chance we could get this merged? I would personally find this very useful! |
I would really love to see this merged. I am also using Metals for working with Scala. For now I am building and patching Helix locally like I did with #5535, but I am struggling with rebasing and resolving conflicts in this PR with @ayoub-benali Could you or someone else, please, resolve the conflicts, at least with the latest |
Can we include this into the next release? |
Hello @the-mikedavis, @pascalkuthe and @archseer! 🙂 |
I have tried to rebase this to current master and miserably failed. Currently metals (a scala LSP) is unusable without this PR. I am using neovim as a substitute which is pita. |
Picker does already a good job I think
Todo:
window/showMessageRequest
and show the choices to the userAny pointers regarding how to render the message on top of the input correctly prompt would be really helpful
Fix #4699