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

REPL: enable "redo" after "undo" #23590

Merged
merged 3 commits into from
Sep 7, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
REPL undo: fix edit_kill_region and add more tests
  • Loading branch information
rfourquet committed Sep 7, 2017
commit 34df23e8abf91f82cec717494dcb5929d5124459
10 changes: 7 additions & 3 deletions base/repl/LineEdit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -726,10 +726,14 @@ function edit_copy_region(s::MIState)
end

function edit_kill_region(s::MIState)
push_kill!(s, edit_splice!(s)) || return :ignore
push_undo(s)
refresh_line(s)
:edit_kill_region
if push_kill!(s, edit_splice!(s))
refresh_line(s)
:edit_kill_region
else
pop_undo(s)
:ignore
end
end

function edit_transpose_chars(s::MIState)
Expand Down
30 changes: 30 additions & 0 deletions test/lineedit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -644,10 +644,15 @@ end
@test edit!(LineEdit.edit_clear) == ""
@test edit!(edit_undo!) == "one two three"

@test edit!(LineEdit.edit_insert_newline) == "one two three\n"
@test edit!(edit_undo!) == "one two three"

LineEdit.edit_move_left(s)
LineEdit.edit_move_left(s)
@test edit!(LineEdit.edit_transpose_chars) == "one two there"
@test edit!(edit_undo!) == "one two three"
@test edit!(LineEdit.edit_transpose_words) == "one three two"
@test edit!(edit_undo!) == "one two three"

LineEdit.move_line_start(s)
@test edit!(LineEdit.edit_kill_line) == ""
Expand All @@ -661,6 +666,15 @@ end
@test edit!(edit_undo!) == ""
@test edit!(edit_undo!) == "one two three"

LineEdit.setmark(s)
LineEdit.edit_move_word_right(s)
@test edit!(LineEdit.edit_kill_region) == " two three"
@test edit!(LineEdit.edit_yank) == "one two three"
@test edit!(LineEdit.edit_yank_pop) == "one two three two three"
@test edit!(edit_undo!) == "one two three"
@test edit!(edit_undo!) == " two three"
@test edit!(edit_undo!) == "one two three"

LineEdit.move_line_end(s)
LineEdit.edit_backspace(s)
LineEdit.edit_backspace(s)
Expand Down Expand Up @@ -692,6 +706,22 @@ end
@test edit!(edit_undo!) == "one three"
@test edit!(edit_undo!) == "one two three"

LineEdit.move_line_start(s)
@test edit!(LineEdit.edit_upper_case) == "ONE two three"
LineEdit.move_line_start(s)
@test edit!(LineEdit.edit_lower_case) == "one two three"
@test edit!(LineEdit.edit_title_case) == "one Two three"
@test edit!(edit_undo!) == "one two three"
@test edit!(edit_undo!) == "ONE two three"
@test edit!(edit_undo!) == "one two three"

LineEdit.move_line_end(s)
edit_insert(s, " ")
@test edit!(LineEdit.edit_tab) == "one two three "
@test edit!(edit_undo!) == "one two three "
@test edit!(edit_undo!) == "one two three"
# TODO: add tests for complete_line, which don't work directly

# pop initial insert of "one two three"
@test edit!(edit_undo!) == ""
@test edit!(edit_undo!) == "" # nothing more to undo (this "beeps")
Expand Down