File tree Expand file tree Collapse file tree 3 files changed +36
-7
lines changed Expand file tree Collapse file tree 3 files changed +36
-7
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,17 @@ class InvalidInputrc < RuntimeError
29
29
attr_accessor :autocompletion
30
30
31
31
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
32
43
@additional_key_bindings = { # from inputrc
33
44
emacs : Reline ::KeyActor ::Base . new ,
34
45
vi_insert : Reline ::KeyActor ::Base . new ,
@@ -54,13 +65,7 @@ def initialize
54
65
@convert_meta = true if seven_bit_encoding? ( Reline ::IOGate . encoding )
55
66
@loaded = false
56
67
@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
64
69
end
65
70
66
71
def editing_mode
@@ -360,6 +365,11 @@ def parse_keyseq(str)
360
365
ret
361
366
end
362
367
368
+ def reload
369
+ reset_variables
370
+ read
371
+ end
372
+
363
373
private def seven_bit_encoding? ( encoding )
364
374
encoding == Encoding ::US_ASCII
365
375
end
Original file line number Diff line number Diff line change @@ -2554,4 +2554,8 @@ def finish
2554
2554
private def set_next_action_state ( type , value )
2555
2555
@next_action_state = [ type , value ]
2556
2556
end
2557
+
2558
+ private def re_read_init_file ( _key )
2559
+ @config . reload
2560
+ end
2557
2561
end
Original file line number Diff line number Diff line change @@ -13,13 +13,15 @@ def setup
13
13
Dir . chdir ( @tmpdir )
14
14
Reline . test_mode
15
15
@config = Reline ::Config . new
16
+ @inputrc_backup = ENV [ 'INPUTRC' ]
16
17
end
17
18
18
19
def teardown
19
20
Dir . chdir ( @pwd )
20
21
FileUtils . rm_rf ( @tmpdir )
21
22
Reline . test_reset
22
23
@config . reset
24
+ ENV [ 'INPUTRC' ] = @inputrc_backup
23
25
end
24
26
25
27
def additional_key_bindings ( keymap_label )
@@ -562,4 +564,17 @@ def test_relative_xdg_config_home
562
564
ENV [ 'XDG_CONFIG_HOME' ] = xdg_config_home_backup
563
565
ENV [ 'HOME' ] = home_backup
564
566
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
565
580
end
You can’t perform that action at this time.
0 commit comments