Skip to content

Commit

Permalink
fix: escape percent character when yanking to search register (#12886)
Browse files Browse the repository at this point in the history
Co-authored-by: Michael Davis <[email protected]>
  • Loading branch information
jrvidal and the-mikedavis authored Feb 26, 2025
1 parent e1060a2 commit 0ba2e05
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion helix-term/src/ui/picker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1079,7 +1079,15 @@ impl<I: 'static + Send + Sync, D: 'static + Send + Sync> Component for Picker<I,
.first_history_completion(ctx.editor)
.filter(|_| self.prompt.line().is_empty())
{
self.prompt.set_line(completion.to_string(), ctx.editor);
// The percent character is used by the query language and needs to be
// escaped with a backslash.
let completion = if completion.contains('%') {
completion.replace('%', "\\%")
} else {
completion.into_owned()
};
self.prompt.set_line(completion, ctx.editor);

// Inserting from the history register is a paste.
self.handle_prompt_change(true);
} else {
Expand Down

0 comments on commit 0ba2e05

Please sign in to comment.