Skip to content

Commit

Permalink
REPL: enable undo in bracketed paste mode
Browse files Browse the repository at this point in the history
  • Loading branch information
rfourquet committed Sep 5, 2017
1 parent 0e1eb8b commit ac37603
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions base/repl/LineEdit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -812,8 +812,8 @@ function replace_line(s::PromptState, l::IOBuffer)
s.input_buffer = copy(l)
end

function replace_line(s::PromptState, l)
empty_undo(s)
function replace_line(s::PromptState, l, keep_undo=false)
keep_undo || empty_undo(s)
s.input_buffer.ptr = 1
s.input_buffer.size = 0
write(s.input_buffer, l)
Expand Down
4 changes: 3 additions & 1 deletion base/repl/REPL.jl
Original file line number Diff line number Diff line change
Expand Up @@ -849,6 +849,7 @@ function setup_interface(
edit_insert(s, input)
return
end
LineEdit.push_undo(s)
edit_insert(sbuffer, input)
input = String(take!(sbuffer))
oldpos = start(input)
Expand Down Expand Up @@ -892,7 +893,7 @@ function setup_interface(
if isprompt_paste # remove indentation spaces corresponding to the prompt
tail = replace(tail, r"^ {7}"m, "") # 7: jl_prompt_len
end
LineEdit.replace_line(s, tail)
LineEdit.replace_line(s, tail, true)
LineEdit.refresh_line(s)
break
end
Expand All @@ -910,6 +911,7 @@ function setup_interface(
raw!(terminal, false) && disable_bracketed_paste(terminal)
LineEdit.mode(s).on_done(s, LineEdit.buffer(s), true)
raw!(terminal, true) && enable_bracketed_paste(terminal)
LineEdit.push_undo(s) # when the last line is incomplete
end
oldpos = pos
firstline = false
Expand Down

0 comments on commit ac37603

Please sign in to comment.