Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pipe only preloads your last command once #3246

Closed
EricCrosson opened this issue Jul 29, 2022 · 1 comment · Fixed by #3259
Closed

Pipe only preloads your last command once #3246

EricCrosson opened this issue Jul 29, 2022 · 1 comment · Fixed by #3259
Labels
A-helix-term Area: Helix term improvements C-bug Category: This is a bug

Comments

@EricCrosson
Copy link
Contributor

Summary

What I did

  1. open hx
  2. press | and type a command, say fmt -72
  3. press | again (this preloads as a default command, the last command I ran (fmt -72)). Hit enter
  4. press | again

What I Expected to Happen

The pipe prompt would again preload as a default command the last command I ran, which was the preloaded fmt -72

What Actually Happens

The pipe prompt has no preloaded text (possibly because I didn't type anything before I hit enter last time!)

Reproduction Steps

https://asciinema.org/a/ZcpjTOOH3p1v9TEgtzPnu2dSe

Helix log

n/a

Platform

Linux (Ubuntu 22)

Terminal Emulator

kitty

Helix Version

26501af

@EricCrosson EricCrosson added the C-bug Category: This is a bug label Jul 29, 2022
@the-mikedavis the-mikedavis added the A-helix-term Area: Helix term improvements label Jul 29, 2022
@the-mikedavis
Copy link
Member

It looks like this happens for all prompts, for example with search as well.

// handle executing with last command in history if nothing entered
let input: Cow<str> = if self.line.is_empty() {
// latest value in the register list
self.history_register
.and_then(|reg| cx.editor.registers.last(reg).cloned())
.map(|entry| entry.into())
.unwrap_or_else(|| Cow::from(""))
} else {
self.line.as_str().into()
};
(self.callback_fn)(cx, &input, PromptEvent::Validate);
if let Some(register) = self.history_register {
// store in history
let register = cx.editor.registers.get_mut(register);
register.push(self.line.clone());
}
return close_fn;
}

We should probably check that self.line is not empty before pushing it to the history register.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-helix-term Area: Helix term improvements C-bug Category: This is a bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants