Skip to content

Commit

Permalink
Implement re-read-init-file
Browse files Browse the repository at this point in the history
  • Loading branch information
ima1zumi committed Aug 29, 2024
1 parent 0851e93 commit f759376
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
25 changes: 18 additions & 7 deletions lib/reline/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,17 @@ class InvalidInputrc < RuntimeError
attr_accessor :autocompletion

def initialize
reset_variables
end

def reset
if editing_mode_is?(:vi_command)
@editing_mode_label = :vi_insert
end
@oneshot_key_bindings.clear
end

def reset_variables
@additional_key_bindings = { # from inputrc
emacs: Reline::KeyActor::Base.new,
vi_insert: Reline::KeyActor::Base.new,
Expand All @@ -54,13 +65,7 @@ def initialize
@convert_meta = true if seven_bit_encoding?(Reline::IOGate.encoding)
@loaded = false
@enable_bracketed_paste = true
end

def reset
if editing_mode_is?(:vi_command)
@editing_mode_label = :vi_insert
end
@oneshot_key_bindings.clear
@show_mode_in_prompt = false
end

def editing_mode
Expand Down Expand Up @@ -360,6 +365,12 @@ def parse_keyseq(str)
ret
end

def reload
reset_variables
@loaded = false
read
end

private def seven_bit_encoding?(encoding)
encoding == Encoding::US_ASCII
end
Expand Down
4 changes: 4 additions & 0 deletions lib/reline/line_editor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2554,4 +2554,8 @@ def finish
private def set_next_action_state(type, value)
@next_action_state = [type, value]
end

private def re_read_init_file(_key)
@config.reload
end
end

0 comments on commit f759376

Please sign in to comment.