Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions stdlib/REPL/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"
version = "1.11.0"

[deps]
FileWatching = "7b1f6079-737a-58dc-b8bc-7a2ca5c1b5ee"
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
JuliaSyntaxHighlighting = "ac6e5ff7-fb65-4e79-a425-ec3bc9c03011"
Markdown = "d6f4376e-aef5-505a-96c1-9c027394607a"
Expand Down
13 changes: 10 additions & 3 deletions stdlib/REPL/src/REPL.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ end
using Base.Meta, Sockets, StyledStrings
using JuliaSyntaxHighlighting
import InteractiveUtils
import FileWatching

export
AbstractREPL,
Expand Down Expand Up @@ -907,7 +908,6 @@ function add_history(hist::REPLHistoryProvider, s::PromptState)
# mode: $mode
$(replace(str, r"^"ms => "\t"))
"""
# TODO: write-lock history file
try
seekend(hist.history_file)
catch err
Expand All @@ -916,8 +916,15 @@ function add_history(hist::REPLHistoryProvider, s::PromptState)
# If this doesn't fix it (e.g. when file is deleted), we'll end up rethrowing anyway
hist_open_file(hist)
end
print(hist.history_file, entry)
flush(hist.history_file)
if isfile(hist.file_path)
FileWatching.mkpidlock(hist.file_path * ".pid", stale_age=3) do
print(hist.history_file, entry)
flush(hist.history_file)
end
else # handle eg devnull
print(hist.history_file, entry)
flush(hist.history_file)
end
nothing
end

Expand Down