Skip to content

Commit 5ef0acb

Browse files
authored
fix: support for Julia 1.13 (#171)
* fix: support 1.13 changes to REPL internals * fix: adjust test outputs * ci: run tests on 1.13 * fix: only use history file loading on 1.10+
1 parent 6ff98e2 commit 5ef0acb

29 files changed

+4492
-32
lines changed

.github/workflows/CI.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
runs-on: ${{ matrix.os }}
1111
strategy:
1212
matrix:
13-
channel: ['1.6', '1.7', '1.8', '1.9', '1.10', '1.11', '1.12']
13+
channel: ['1.6', '1.7', '1.8', '1.9', '1.10', '1.11', '1.12', '1.13']
1414
os: [ubuntu-latest]
1515
steps:
1616
- uses: actions/checkout@v6

src/Infiltrator.jl

Lines changed: 78 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -657,26 +657,51 @@ find_infil_hist_file() = get(ENV, "INFILTRATOR_HISTORY", !isempty(DEPOT_PATH) ?
657657
Load the history from the history file found by `find_infil_hist_file()`, i.e. under `ENV["INFILTRATOR_HISTORY"]` or next to the main REPL history (typically `.julia/logs/infil_history.jl`).
658658
Most of the code comes from the REPL stdlib (inlined in `setup_interface`).
659659
"""
660-
function load_history!(hp::REPL.REPLHistoryProvider, repl, cp::REPL.CompletionProvider)
661-
if repl.history_file
662-
try
663-
hist_path = find_infil_hist_file()
664-
mkpath(dirname(hist_path))
665-
hp.file_path = hist_path
666-
REPL.hist_open_file(hp)
667-
finalizer(cp) do cp
668-
close(hp.history_file)
660+
function load_history! end
661+
662+
@static if VERSION >= v"1.13-"
663+
function load_history!(hp::REPL.REPLHistoryProvider, repl, cp::REPL.CompletionProvider)
664+
if repl.history_file
665+
try
666+
path = find_infil_hist_file()
667+
mkpath(dirname(path))
668+
hp.history = REPL.History.HistoryFile(path)
669+
errormonitor(@async REPL.history_do_initialize(hp))
670+
finalizer(cp) do cp
671+
close(hp.history)
672+
end
673+
catch
674+
# use REPL.hascolor to avoid using the local variable with the same name
675+
print_response(repl, Pair{Any, Bool}(current_exceptions(), true), true, REPL.hascolor(repl))
676+
println(REPL.outstream(repl))
677+
@info "Disabling history file for this session"
678+
repl.history_file = false
669679
end
670-
REPL.hist_from_file(hp, hist_path)
671-
catch
672-
# use REPL.hascolor to avoid using the local variable with the same name
673-
print_response(repl, Pair{Any, Bool}(current_exceptions(), true), true, REPL.hascolor(repl))
674-
println(REPL.outstream(repl))
675-
@info "Disabling history file for this session"
676-
repl.history_file = false
677680
end
681+
return
682+
end
683+
else
684+
function load_history!(hp::REPL.REPLHistoryProvider, repl, cp::REPL.CompletionProvider)
685+
if repl.history_file
686+
try
687+
hist_path = find_infil_hist_file()
688+
mkpath(dirname(hist_path))
689+
hp.file_path = hist_path
690+
REPL.hist_open_file(hp)
691+
finalizer(cp) do cp
692+
close(hp.history_file)
693+
end
694+
REPL.hist_from_file(hp, hist_path)
695+
catch
696+
# use REPL.hascolor to avoid using the local variable with the same name
697+
print_response(repl, Pair{Any, Bool}(current_exceptions(), true), true, REPL.hascolor(repl))
698+
println(REPL.outstream(repl))
699+
@info "Disabling history file for this session"
700+
repl.history_file = false
701+
end
702+
end
703+
return
678704
end
679-
return
680705
end
681706

682707
function debugprompt(mod, locals, trace, terminal, repl, ex, bt; nostack = false, file, fileline)
@@ -686,25 +711,32 @@ function debugprompt(mod, locals, trace, terminal, repl, ex, bt; nostack = false
686711

687712
try
688713
if isassigned(PROMPT)
689-
panel = PROMPT[]
690-
panel.complete = InfiltratorCompletionProvider(mod, evalmod)
714+
prompt = PROMPT[]
715+
prompt.complete = InfiltratorCompletionProvider(mod, evalmod)
691716
else
692717
cp = InfiltratorCompletionProvider(mod, evalmod)
693-
panel = PROMPT[] = REPL.LineEdit.Prompt(
718+
prompt = PROMPT[] = REPL.LineEdit.Prompt(
694719
"infil> ";
695720
prompt_prefix = prompt_color,
696721
prompt_suffix = Base.text_colors[:normal],
697722
complete = cp,
698-
on_enter = is_complete
723+
on_enter = is_complete,
724+
repl = repl
699725
)
700-
panel.hist = REPL.REPLHistoryProvider(Dict{Symbol, Any}(:Infiltrator => panel))
701-
load_history!(panel.hist, repl, cp)
702-
REPL.history_reset_state(panel.hist)
726+
727+
prompt.hist = REPL.REPLHistoryProvider(Dict{Symbol, Any}(:infil => prompt))
728+
if VERSION >= v"1.10-"
729+
load_history!(prompt.hist, repl, cp)
730+
end
731+
REPL.history_reset_state(prompt.hist)
703732
end
704-
search_prompt, skeymap = LineEdit.setup_search_keymap(panel.hist)
705-
search_prompt.complete = REPL.LatexCompletions()
706733

707-
panel.on_done = (s, buf, ok) -> begin
734+
if VERSION < v"1.13-"
735+
search_prompt, skeymap = LineEdit.setup_search_keymap(prompt.hist)
736+
search_prompt.complete = REPL.LatexCompletions()
737+
end
738+
739+
prompt.on_done = (s, buf, ok) -> begin
708740
if !ok
709741
LineEdit.transition(s, :abort)
710742
REPL.LineEdit.reset_state(s)
@@ -906,11 +938,27 @@ function debugprompt(mod, locals, trace, terminal, repl, ex, bt; nostack = false
906938
return true
907939
end
908940

909-
prefix_prompt, prefix_keymap = LineEdit.setup_prefix_keymap(panel.hist, panel)
941+
prefix_prompt, prefix_keymap = LineEdit.setup_prefix_keymap(prompt.hist, prompt)
942+
943+
keymaps = Dict{Any, Any}[prefix_keymap, LineEdit.history_keymap, LineEdit.default_keymap, LineEdit.escape_defaults]
944+
945+
if VERSION < v"1.13-"
946+
pushfirst!(keymaps, skeymap)
947+
end
948+
949+
prompt.keymap_dict = LineEdit.keymap(keymaps)
950+
951+
prompts = [prompt, prefix_prompt]
952+
953+
if VERSION < v"1.13-"
954+
push!(prompts, search_prompt)
955+
end
910956

911-
panel.keymap_dict = LineEdit.keymap(Dict{Any, Any}[skeymap, prefix_keymap, LineEdit.history_keymap, LineEdit.default_keymap, LineEdit.escape_defaults])
957+
mi = REPL.LineEdit.ModalInterface(prompts)
958+
mistate = REPL.LineEdit.init_state(terminal, mi)
959+
repl.mistate = mistate
912960

913-
REPL.run_interface(terminal, REPL.LineEdit.ModalInterface([panel, prefix_prompt, search_prompt]))
961+
REPL.run_interface(terminal, mi, mistate)
914962
catch e
915963
e isa InterruptException || rethrow(e)
916964
end

test/generate.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
for version in ["1.6", "1.7", "1.8", "1.9", "1.10", "1.11", "1.12"]
1+
for version in ["1.6", "1.7", "1.8", "1.9", "1.10", "1.11", "1.12", "1.13"]
22
println("Generating outputs with Julia v$version")
33
manifest_path = joinpath(@__DIR__, "..", "Manifest.toml")
44
isfile(manifest_path) && rm(manifest_path)

test/outputs/1.13/anon.multiout

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
++++++++++++++++++++++++++++++++++++++++++++++++++
2+
|Infiltrating <unknown>
3+
|
4+
|infil>
5+
--------------------------------------------------
6+
|AAAAAAAAAAAAAAAAAAAAAA
7+
|
8+
|BBBBBBB
9+
++++++++++++++++++++++++++++++++++++++++++++++++++
10+
|Infiltrating <unknown>
11+
|
12+
|infil> aasdf
13+
|3
14+
|
15+
|infil>
16+
--------------------------------------------------
17+
|AAAAAAAAAAAAAAAAAAAAAA
18+
|
19+
|BBBBBBBCCCCC
20+
|C
21+
|
22+
|BBBBBBB
23+
++++++++++++++++++++++++++++++++++++++++++++++++++
24+
|Infiltrating <unknown>
25+
|
26+
|infil> aasdf
27+
|3
28+
|
29+
|infil> @exfiltrate aasdf
30+
|Exfiltrating 1 local variable into the safehouse.
31+
|
32+
|infil>
33+
--------------------------------------------------
34+
|AAAAAAAAAAAAAAAAAAAAAA
35+
|
36+
|BBBBBBBCCCCC
37+
|C
38+
|
39+
|BBBBBBBCCCCCCCCCCCCCCCCC
40+
|CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
41+
|
42+
|BBBBBBB
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
++++++++++++++++++++++++++++++++++++++++++++++++++
2+
|Infiltrating <unknown>
3+
|
4+
|infil>
5+
--------------------------------------------------
6+
|AAAAAAAAAAAAAAAAAAAAAA
7+
|
8+
|BBBBBBB
9+
++++++++++++++++++++++++++++++++++++++++++++++++++
10+
|Infiltrating <unknown>
11+
|
12+
|infil> σ = 2
13+
|2
14+
|
15+
|infil>
16+
--------------------------------------------------
17+
|AAAAAAAAAAAAAAAAAAAAAA
18+
|
19+
|BBBBBBBCCCCC
20+
|C
21+
|
22+
|BBBBBBB
23+
++++++++++++++++++++++++++++++++++++++++++++++++++
24+
|Infiltrating <unknown>
25+
|
26+
|infil> σ = 2
27+
|2
28+
|
29+
|infil> σ
30+
|2
31+
|
32+
|infil>
33+
--------------------------------------------------
34+
|AAAAAAAAAAAAAAAAAAAAAA
35+
|
36+
|BBBBBBBCCCCC
37+
|C
38+
|
39+
|BBBBBBBC
40+
|C
41+
|
42+
|BBBBBBB
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
++++++++++++++++++++++++++++++++++++++++++++++++++
2+
|Infiltrating <unknown>
3+
|
4+
|infil>
5+
--------------------------------------------------
6+
|AAAAAAAAAAAAAAAAAAAAAA
7+
|
8+
|BBBBBBB
9+
++++++++++++++++++++++++++++++++++++++++++++++++++
10+
|Infiltrating <unknown>
11+
|
12+
|infil> x
13+
|:(%3)
14+
|
15+
|infil>
16+
--------------------------------------------------
17+
|AAAAAAAAAAAAAAAAAAAAAA
18+
|
19+
|BBBBBBBC
20+
|CCCCC
21+
|
22+
|BBBBBBB
23+
++++++++++++++++++++++++++++++++++++++++++++++++++
24+
|Infiltrating <unknown>
25+
|
26+
|infil> x
27+
|:(%3)
28+
|
29+
|infil> @exfiltrate
30+
|Exfiltrating 1 local variable into the safehouse.
31+
|
32+
|infil>
33+
--------------------------------------------------
34+
|AAAAAAAAAAAAAAAAAAAAAA
35+
|
36+
|BBBBBBBC
37+
|CCCCC
38+
|
39+
|BBBBBBBCCCCCCCCCCC
40+
|CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
41+
|
42+
|BBBBBBB

0 commit comments

Comments
 (0)