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

Don't error when transposing a single character #45420

Merged

Conversation

perryprog
Copy link
Contributor

This fixes an issue where an error would be thrown in the REPL if you tried to transpose an input that was a single character while your cursor was to the right of that character (e.g., "A|"). To fix this, let's move left once before we check for if we're at the start of a line. This does change behavior slightly in that the cursor can move left once without actually transposing anything, but this seems to match what Emacs does with M-x transpose-chars in an equivalent situation.

Fixes #45417.

This fixes an issue where an error would be thrown in the REPL if you tried to
transpose an input that was a single character while your cursor was to the
right of that character (e.g., "A|"). To fix this, let's move left once before
we check for if we're at the start of a line. This does change behavior slightly
in that the cursor can move left once without actually transposing anything, but
this seems to match what Emacs does with M-x transpose-chars in an equivalent
situation.
@@ -375,6 +375,16 @@ let buf = IOBuffer()
@test content(buf) == "βγαεδ"
LineEdit.edit_transpose_chars(buf)
@test content(buf) == "βγαδε"

seek(buf, 0)
@inferred(LineEdit.edit_clear(buf))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And a quick question: this probably doesn't need to have a @inferred, right? (Though I imagine it doesn't really matter.)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it was added to the other places as some type instabilities in the REPL was addressed.

@KristofferC KristofferC added backport 1.8 Change should be backported to release-1.8 REPL Julia's REPL (Read Eval Print Loop) bugfix This change fixes an existing bug labels May 23, 2022
@KristofferC KristofferC merged commit 9dd993e into JuliaLang:master May 23, 2022
KristofferC pushed a commit that referenced this pull request May 23, 2022
This fixes an issue where an error would be thrown in the REPL if you tried to
transpose an input that was a single character while your cursor was to the
right of that character (e.g., "A|"). To fix this, let's move left once before
we check for if we're at the start of a line. This does change behavior slightly
in that the cursor can move left once without actually transposing anything, but
this seems to match what Emacs does with M-x transpose-chars in an equivalent
situation.

(cherry picked from commit 9dd993e)
@KristofferC KristofferC mentioned this pull request May 23, 2022
67 tasks
pchintalapudi pushed a commit that referenced this pull request May 25, 2022
This fixes an issue where an error would be thrown in the REPL if you tried to
transpose an input that was a single character while your cursor was to the
right of that character (e.g., "A|"). To fix this, let's move left once before
we check for if we're at the start of a line. This does change behavior slightly
in that the cursor can move left once without actually transposing anything, but
this seems to match what Emacs does with M-x transpose-chars in an equivalent
situation.
@KristofferC KristofferC removed the backport 1.8 Change should be backported to release-1.8 label May 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix This change fixes an existing bug REPL Julia's REPL (Read Eval Print Loop)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

EOFError in the REPL on pressing ctrl+t after typing a single character
2 participants