File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -29,6 +29,17 @@ class InvalidInputrc < RuntimeError
2929 attr_accessor :autocompletion
3030
3131 def initialize
32+ reset_variables
33+ end
34+
35+ def reset
36+ if editing_mode_is? ( :vi_command )
37+ @editing_mode_label = :vi_insert
38+ end
39+ @oneshot_key_bindings . clear
40+ end
41+
42+ def reset_variables
3243 @additional_key_bindings = { # from inputrc
3344 emacs : Reline ::KeyActor ::Base . new ,
3445 vi_insert : Reline ::KeyActor ::Base . new ,
@@ -54,13 +65,7 @@ def initialize
5465 @convert_meta = true if seven_bit_encoding? ( Reline ::IOGate . encoding )
5566 @loaded = false
5667 @enable_bracketed_paste = true
57- end
58-
59- def reset
60- if editing_mode_is? ( :vi_command )
61- @editing_mode_label = :vi_insert
62- end
63- @oneshot_key_bindings . clear
68+ @show_mode_in_prompt = false
6469 end
6570
6671 def editing_mode
@@ -360,6 +365,11 @@ def parse_keyseq(str)
360365 ret
361366 end
362367
368+ def reload
369+ reset_variables
370+ read
371+ end
372+
363373 private def seven_bit_encoding? ( encoding )
364374 encoding == Encoding ::US_ASCII
365375 end
Original file line number Diff line number Diff line change @@ -2554,4 +2554,8 @@ def finish
25542554 private def set_next_action_state ( type , value )
25552555 @next_action_state = [ type , value ]
25562556 end
2557+
2558+ private def re_read_init_file ( _key )
2559+ @config . reload
2560+ end
25572561end
Original file line number Diff line number Diff line change @@ -13,13 +13,15 @@ def setup
1313 Dir . chdir ( @tmpdir )
1414 Reline . test_mode
1515 @config = Reline ::Config . new
16+ @inputrc_backup = ENV [ 'INPUTRC' ]
1617 end
1718
1819 def teardown
1920 Dir . chdir ( @pwd )
2021 FileUtils . rm_rf ( @tmpdir )
2122 Reline . test_reset
2223 @config . reset
24+ ENV [ 'INPUTRC' ] = @inputrc_backup
2325 end
2426
2527 def additional_key_bindings ( keymap_label )
@@ -562,4 +564,17 @@ def test_relative_xdg_config_home
562564 ENV [ 'XDG_CONFIG_HOME' ] = xdg_config_home_backup
563565 ENV [ 'HOME' ] = home_backup
564566 end
567+
568+ def test_reload
569+ inputrc = "#{ @tmpdir } /inputrc"
570+ ENV [ 'INPUTRC' ] = inputrc
571+
572+ File . write ( inputrc , "set emacs-mode-string !" )
573+ @config . read
574+ assert_equal '!' , @config . emacs_mode_string
575+
576+ File . write ( inputrc , "set emacs-mode-string ?" )
577+ @config . reload
578+ assert_equal '?' , @config . emacs_mode_string
579+ end
565580end
You can’t perform that action at this time.
0 commit comments