Skip to content

Fix history search appending to typed text instead of replacing (#60938)#61039

Merged
adienes merged 3 commits intoJuliaLang:masterfrom
riazation42:fix-history-search-append-issue-60938
Feb 17, 2026
Merged

Fix history search appending to typed text instead of replacing (#60938)#61039
adienes merged 3 commits intoJuliaLang:masterfrom
riazation42:fix-history-search-append-issue-60938

Conversation

@riazation42
Copy link
Copy Markdown
Contributor

Fixes #60938

When typing text and then using Ctrl+R to search history, the selected result was appending to the typed text instead of replacing it.

For example:

  • Type prin
  • Press Ctrl+R, select println("test")
  • Got: prinprintln("test")
  • Expected: println("test")

Changes:

  • LineEdit.jl line 2713: Clear last_buffer instead of copying current input
  • REPL.jl line 918: Same fix for consistency
  • LineEdit.jl line 2732: Use replace_line instead of edit_insert

The issue was that the current buffer was being saved and then concatenated with the search result instead of being replaced by it.


No AI tools were used in developing this fix.

When using Ctrl+R to search REPL history with existing text typed,
the search result was incorrectly appending to the typed text instead
of replacing it.

Fixed by:
1. Clearing last_buffer instead of copying current buffer (LineEdit.jl line 2713)
2. Clearing last_buffer in history_move (REPL.jl line 918)
3. Using replace_line instead of edit_insert for result (LineEdit.jl line 2732)

Fixes JuliaLang#60938
@riazation42 riazation42 force-pushed the fix-history-search-append-issue-60938 branch from 3a788e1 to 78a56a1 Compare February 16, 2026 04:29
@adienes
Copy link
Copy Markdown
Member

adienes commented Feb 16, 2026

thanks!

actually, before approving fully, I noticed another thing: when Ctrl-C is hit during the history search, arguably we should keep the current input; this PR would be a regression in that regard

that is we'd want to observe

julia> foo[^R]↑↑↑↑↑↑[Ctrl-C]

julia> foo

rather than

julia> foo[^R]↑↑↑↑↑↑[Ctrl-C]

julia>

(same goes for Esc-Esc)

When using Ctrl+R to search history with existing text typed:
- Accepting result (Enter): Replaces typed text with search result
- Canceling (Ctrl+C/Esc): Restores original typed text

The fix clears the input buffer before inserting the search result,
but only when result is not empty (i.e., user accepted a selection).

Fixes JuliaLang#60938
@riazation42
Copy link
Copy Markdown
Contributor Author

The previous version broke Ctrl+C cancellation.

Updated the fix to:

  • Keep saving the original buffer (for Ctrl+C restore)
  • Only clear and replace the buffer when a result is actually selected

Now both scenarios work correctly:

  • Accept (Enter): Replaces typed text with search result
  • Cancel (Ctrl+C/Esc): Restores original typed text

@adienes adienes added REPL Julia's REPL (Read Eval Print Loop) display and printing Aesthetics and correctness of printed representations of objects. backport 1.13 Change should be backported to release-1.13 labels Feb 16, 2026
@adienes adienes merged commit 719df26 into JuliaLang:master Feb 17, 2026
10 checks passed
@adienes
Copy link
Copy Markdown
Member

adienes commented Feb 17, 2026

thank you!

KristofferC pushed a commit that referenced this pull request Mar 3, 2026
…) (#61039)

Fixes #60938

When typing text and then using Ctrl+R to search history, the selected
result was appending to the typed text instead of replacing it.

For example:
- Type `prin`
- Press Ctrl+R, select `println("test")`
- Got: `prinprintln("test")` ❌
- Expected: `println("test")` ✅

**Changes:**
- LineEdit.jl line 2713: Clear `last_buffer` instead of copying current
input
- REPL.jl line 918: Same fix for consistency
- LineEdit.jl line 2732: Use `replace_line` instead of `edit_insert`

The issue was that the current buffer was being saved and then
concatenated with the search result instead of being replaced by it.

---
*No AI tools were used in developing this fix.*

---------

Co-authored-by: Andy Dienes <51664769+adienes@users.noreply.github.com>
(cherry picked from commit 719df26)
@KristofferC KristofferC mentioned this pull request Mar 3, 2026
56 tasks
@KristofferC KristofferC removed the backport 1.13 Change should be backported to release-1.13 label Mar 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

display and printing Aesthetics and correctness of printed representations of objects. REPL Julia's REPL (Read Eval Print Loop)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

selecting a line in REPL history search should overwrite not append

4 participants