fix: escape percent character when yanking to search register (#12886)

Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
This commit is contained in:
Roberto Vidal 2025-02-27 00:22:41 +01:00 committed by GitHub
parent e1060a2785
commit 0ba2e05a6f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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 {