Skip to content

Commit aaab409

Browse files
authored
[REPL] Meta-e: Don't execute the edited code when exiting editor (#46153)
1 parent b4e6b03 commit aaab409

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

stdlib/REPL/src/LineEdit.jl

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1357,19 +1357,22 @@ function edit_input(s, f = (filename, line, column) -> InteractiveUtils.edit(fil
13571357
col += 1
13581358
end
13591359

1360+
# Write current input to temp file, edit, read back
13601361
write(filename, str)
13611362
f(filename, line, col)
13621363
str_mod = readchomp(filename)
13631364
rm(filename)
1364-
if str != str_mod # something was changed, run the input
1365-
write(buf, str_mod)
1366-
commit_line(s)
1367-
:done
1368-
else # no change, the edit session probably unsuccessful
1369-
write(buf, str)
1370-
seek(buf, pos) # restore state from before edit
1371-
refresh_line(s)
1365+
1366+
# Write updated content
1367+
write(buf, str_mod)
1368+
if str == str_mod
1369+
# If input was not modified: reset cursor
1370+
seek(buf, pos)
1371+
else
1372+
# If input was modified: move cursor to end
1373+
move_input_end(s)
13721374
end
1375+
refresh_line(s)
13731376
end
13741377

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

0 commit comments

Comments
 (0)