@@ -28,6 +28,8 @@ include("compat.jl")
2828# REPL mode creation #
2929# #####################
3030
31+ const BRACKET_INSERT_SUPPORTED = hasfield (REPL. Options, :auto_insert_closing_bracket )
32+
3133struct PkgCompletionProvider <: LineEdit.CompletionProvider end
3234
3335function LineEdit. complete_line (c:: PkgCompletionProvider , s; hint:: Bool = false )
@@ -181,10 +183,11 @@ function create_mode(repl::REPL.AbstractREPL, main::LineEdit.Prompt)
181183 end
182184 end
183185
184- b = Dict{Any, Any}[
185- skeymap, repl_keymap, mk, prefix_keymap, LineEdit. history_keymap,
186- LineEdit. default_keymap, LineEdit. escape_defaults,
187- ]
186+ b = Dict{Any, Any}[skeymap, repl_keymap]
187+ if BRACKET_INSERT_SUPPORTED && repl. options. auto_insert_closing_bracket
188+ push! (b, LineEdit. bracket_insert_keymap)
189+ end
190+ push! (b, mk, prefix_keymap, LineEdit. history_keymap, LineEdit. default_keymap, LineEdit. escape_defaults)
188191 pkg_mode. keymap_dict = LineEdit. keymap (b)
189192 return pkg_mode
190193end
@@ -195,14 +198,18 @@ function repl_init(repl::REPL.LineEditREPL)
195198 push! (repl. interface. modes, pkg_mode)
196199 keymap = Dict {Any, Any} (
197200 ' ]' => function (s, args... )
198- return if isempty (s) || position (LineEdit. buffer (s)) == 0
201+ if isempty (s) || position (LineEdit. buffer (s)) == 0
199202 buf = copy (LineEdit. buffer (s))
200- LineEdit. transition (s, pkg_mode) do
203+ return LineEdit. transition (s, pkg_mode) do
201204 LineEdit. state (s, pkg_mode). input_buffer = buf
202205 end
203206 else
204- LineEdit. edit_insert (s, ' ]' )
205- LineEdit. check_show_hint (s)
207+ if BRACKET_INSERT_SUPPORTED && repl. options. auto_insert_closing_bracket
208+ return LineEdit. bracket_insert_keymap[' ]' ](s, args... )
209+ else
210+ LineEdit. edit_insert (s, ' ]' )
211+ return LineEdit. check_show_hint (s)
212+ end
206213 end
207214 end
208215 )
0 commit comments