Skip to content

Commit c5a06ef

Browse files
committed
expand_args to variable::expand
1 parent 8b1d522 commit c5a06ef

File tree

3 files changed

+9
-13
lines changed

3 files changed

+9
-13
lines changed

helix-term/src/commands.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
pub(crate) mod dap;
2-
pub(crate) mod expansions;
32
pub(crate) mod lsp;
43
pub(crate) mod typed;
4+
pub(crate) mod variables;
55

66
pub use dap::*;
77
use futures_util::FutureExt;
@@ -252,7 +252,7 @@ impl MappableCommand {
252252
scroll: None,
253253
};
254254

255-
match expand_args(cx.editor, args.into(), true) {
255+
match variables::expand(cx.editor, args.into(), true) {
256256
Ok(args) => {
257257
if let Err(err) = (command.fun)(
258258
&mut cx,
@@ -724,8 +724,6 @@ fn move_impl(cx: &mut Context, move_fn: MoveFn, dir: Direction, behaviour: Movem
724724

725725
use helix_core::movement::{move_horizontally, move_vertically};
726726

727-
use self::expansions::expand_args;
728-
729727
fn move_char_left(cx: &mut Context) {
730728
move_impl(cx, move_horizontally, Direction::Backward, Movement::Move)
731729
}

helix-term/src/commands/typed.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::ops::Deref;
44

55
use crate::job::Job;
66

7-
use super::expansions::expand_args;
7+
use super::variables;
88
use super::*;
99

1010
use helix_core::fuzzy::fuzzy_match;
@@ -3122,7 +3122,7 @@ pub(super) fn command_mode(cx: &mut Context) {
31223122
}
31233123
}, // completion
31243124
move |cx: &mut compositor::Context, input: &str, event: PromptEvent| {
3125-
match expand_args(cx.editor, input.into(), true) {
3125+
match variables::expand(cx.editor, input.into(), true) {
31263126
Ok(args) => {
31273127
let shellwords = Shellwords::from(args.as_ref());
31283128
let command = shellwords.command();

helix-term/src/commands/expansions.rs renamed to helix-term/src/commands/variables.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,7 @@ use anyhow::Result;
44
use helix_core::coords_at_pos;
55
use helix_view::Editor;
66

7-
pub fn expand_args<'a>(
8-
editor: &Editor,
9-
input: Cow<'a, str>,
10-
expand_sh: bool,
11-
) -> Result<Cow<'a, str>> {
7+
pub fn expand<'a>(editor: &Editor, input: Cow<'a, str>, expand_sh: bool) -> Result<Cow<'a, str>> {
128
let (view, doc) = current_ref!(editor);
139
let shell = &editor.config().shell;
1410

@@ -106,7 +102,9 @@ pub fn expand_args<'a>(
106102
.primary()
107103
.fragment(doc.text().slice(..))
108104
.to_string(),
109-
_ => anyhow::bail!("Unknown variable"),
105+
_ => {
106+
anyhow::bail!("Unknown variable {}", &input[index + 2..end])
107+
}
110108
};
111109

112110
o.push_str(value.trim());
@@ -128,7 +126,7 @@ pub fn expand_args<'a>(
128126
}
129127

130128
if let Some(o) = output.as_mut() {
131-
let body = expand_args(
129+
let body = expand(
132130
editor,
133131
Cow::Borrowed(&input[index + 4..end]),
134132
expand_sh,

0 commit comments

Comments
 (0)