Skip to content

Commit 9575ffd

Browse files
committed
Handle numeric command correctly
1 parent b348461 commit 9575ffd

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

helix-term/src/application.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -392,22 +392,23 @@ impl Application {
392392
scroll: None,
393393
jobs: &mut self.jobs,
394394
};
395-
let parts = command.split_whitespace().collect::<Vec<&str>>();
395+
let mut parts = command.split_whitespace().collect::<Vec<&str>>();
396396
if parts.is_empty() {
397397
return;
398398
}
399399

400400
let event = crate::ui::PromptEvent::Validate;
401401
// Handle numeric commands
402-
let cmd = if parts.len() == 1 && parts[0].parse::<usize>().ok().is_some() {
403-
"goto"
402+
let command = if parts.len() == 1 && parts[0].parse::<usize>().ok().is_some() {
403+
parts.insert(0, "goto");
404+
format!("goto {}", parts[1])
404405
} else {
405-
parts[0]
406+
command.to_string()
406407
};
407408

408409
// Handle typable commands
409-
if let Some(cmd) = typed::TYPABLE_COMMAND_MAP.get(cmd) {
410-
let shellwords = Shellwords::from(command);
410+
if let Some(cmd) = typed::TYPABLE_COMMAND_MAP.get(parts[0]) {
411+
let shellwords = Shellwords::from(command.as_str());
411412
let args = shellwords.words();
412413

413414
if let Err(e) = (cmd.fun)(&mut cx, &args[1..], event) {

0 commit comments

Comments
 (0)