mirror of
https://github.com/helix-editor/helix.git
synced 2024-11-24 02:16:18 +04:00
feat: add support for lsp workspace command arguments in prompt
This commit is contained in:
parent
6cca98264f
commit
68d07ea7cb
@ -1426,19 +1426,28 @@ fn lsp_workspace_command(
|
|||||||
};
|
};
|
||||||
cx.jobs.callback(callback);
|
cx.jobs.callback(callback);
|
||||||
} else {
|
} else {
|
||||||
let command = args.join(" ");
|
let command = args.first().unwrap().to_string();
|
||||||
|
|
||||||
let matches: Vec<_> = ls_id_commands
|
let matches: Vec<_> = ls_id_commands
|
||||||
.filter(|(_ls_id, c)| *c == &command)
|
.filter(|(_ls_id, c)| *c == &command)
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
match matches.as_slice() {
|
match matches.as_slice() {
|
||||||
[(ls_id, _command)] => {
|
[(ls_id, _command)] => {
|
||||||
|
let lsp_command_args: Vec<Value> = args[1..]
|
||||||
|
.iter()
|
||||||
|
.map(|s| Value::String(s.to_string()))
|
||||||
|
.collect();
|
||||||
execute_lsp_command(
|
execute_lsp_command(
|
||||||
cx.editor,
|
cx.editor,
|
||||||
*ls_id,
|
*ls_id,
|
||||||
helix_lsp::lsp::Command {
|
helix_lsp::lsp::Command {
|
||||||
title: command.clone(),
|
title: command.clone(),
|
||||||
arguments: None,
|
arguments: if lsp_command_args.is_empty() {
|
||||||
|
None
|
||||||
|
} else {
|
||||||
|
Some(lsp_command_args)
|
||||||
|
},
|
||||||
command,
|
command,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user