Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'helix-term/src/commands/typed.rs')
| -rw-r--r-- | helix-term/src/commands/typed.rs | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/helix-term/src/commands/typed.rs b/helix-term/src/commands/typed.rs index 6685691f..6354e68f 100644 --- a/helix-term/src/commands/typed.rs +++ b/helix-term/src/commands/typed.rs @@ -3976,6 +3976,22 @@ pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[ ..Signature::DEFAULT }, }, + TypableCommand { + name: "workspace-trust", + aliases: &[], + doc: "Add current workspace to the list of trusted workspaces.", + fun: trust_workspace, + completer: CommandCompleter::none(), + signature: Signature { positionals: (0, None), ..Signature::DEFAULT }, + }, + TypableCommand { + name: "workspace-untrust", + aliases: &[], + doc: "Remove current workspace from the list of trusted workspaces.", + fun: untrust_workspace, + completer: CommandCompleter::none(), + signature: Signature { positionals: (0, None), ..Signature::DEFAULT }, + } ]; pub static TYPABLE_COMMAND_MAP: Lazy<HashMap<&'static str, &'static TypableCommand>> = @@ -4386,3 +4402,32 @@ fn complete_expansion_kind(content: &str, offset: usize) -> Vec<ui::prompt::Comp .map(|(name, _)| (offset.., (*name).into())) .collect() } + +fn trust_workspace( + cx: &mut compositor::Context, + args: Args<'_>, + event: PromptEvent, +) -> anyhow::Result<()> { + if event != PromptEvent::Validate { + return Ok(()); + } + + helix_loader::workspace_trust::WorkspaceTrust::load(false).trust_workspace(); + + cx.editor.config_events.0.send(ConfigEvent::Refresh)?; + // HACK + lsp_restart(cx, args, event) +} + +fn untrust_workspace( + _cx: &mut compositor::Context, + _args: Args<'_>, + event: PromptEvent, +) -> anyhow::Result<()> { + if event != PromptEvent::Validate { + return Ok(()); + } + + helix_loader::workspace_trust::WorkspaceTrust::load(false).untrust_workspace(); + Ok(()) +} |