summaryrefslogtreecommitdiff
path: root/helix-term/src/commands
diff options
context:
space:
mode:
authorBob2022-07-18 01:17:13 +0000
committerGitHub2022-07-18 01:17:13 +0000
commite5c7aaed91c0b3d533a04840fedb88ecabc8f6a8 (patch)
tree7b615802e6a9a49faa58e34cf43db3fa7a0606f0 /helix-term/src/commands
parent55b45ec4a4cb958b241a93cc7c3f4e499379890e (diff)
support prefilling prompt (#2459)
* support prefilling prompt * introduce with_line builder method in Prompt * extract show_prompt * use textobject_word as fallback input
Diffstat (limited to 'helix-term/src/commands')
-rw-r--r--helix-term/src/commands/lsp.rs14
1 files changed, 13 insertions, 1 deletions
diff --git a/helix-term/src/commands/lsp.rs b/helix-term/src/commands/lsp.rs
index 630c47e1..a91e3792 100644
--- a/helix-term/src/commands/lsp.rs
+++ b/helix-term/src/commands/lsp.rs
@@ -885,9 +885,21 @@ pub fn hover(cx: &mut Context) {
}
pub fn rename_symbol(cx: &mut Context) {
- ui::prompt(
+ let (view, doc) = current_ref!(cx.editor);
+ let text = doc.text().slice(..);
+ let primary_selection = doc.selection(view.id).primary();
+ let prefill = if primary_selection.len() > 1 {
+ primary_selection
+ } else {
+ use helix_core::textobject::{textobject_word, TextObject};
+ textobject_word(text, primary_selection, TextObject::Inside, 1, false)
+ }
+ .fragment(text)
+ .into();
+ ui::prompt_with_input(
cx,
"rename-to:".into(),
+ prefill,
None,
ui::completers::none,
move |cx: &mut compositor::Context, input: &str, event: PromptEvent| {