Skip to content

Commit

Permalink
[REPL] Meta-e: Don't execute the edited code when exiting editor (#46153
Browse files Browse the repository at this point in the history
)

(cherry picked from commit aaab409)
  • Loading branch information
fredrikekre authored and KristofferC committed Feb 20, 2023
1 parent ceacba1 commit 6213bb8
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions stdlib/REPL/src/LineEdit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1357,19 +1357,22 @@ function edit_input(s, f = (filename, line, column) -> InteractiveUtils.edit(fil
col += 1
end

# Write current input to temp file, edit, read back
write(filename, str)
f(filename, line, col)
str_mod = readchomp(filename)
rm(filename)
if str != str_mod # something was changed, run the input
write(buf, str_mod)
commit_line(s)
:done
else # no change, the edit session probably unsuccessful
write(buf, str)
seek(buf, pos) # restore state from before edit
refresh_line(s)

# Write updated content
write(buf, str_mod)
if str == str_mod
# If input was not modified: reset cursor
seek(buf, pos)
else
# If input was modified: move cursor to end
move_input_end(s)
end
refresh_line(s)
end

# return the identifier under the cursor, possibly with other words concatenated
Expand Down

0 comments on commit 6213bb8

Please sign in to comment.