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] Meta-e: Don't execute the edited code when exiting editor #46153

Merged
merged 1 commit into from
Feb 13, 2023
Merged
Changes from all commits
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
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