Skip to content

Commit

Permalink
Avoid reading .inputrc repeatedly
Browse files Browse the repository at this point in the history
  • Loading branch information
ima1zumi committed Apr 30, 2024
1 parent 3f27286 commit 0bbdc92
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/reline.rb
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ def readline(prompt = '', add_hist = false)
end
end

unless config.test_mode
unless config.test_mode or config.loaded?
config.read
config.reset_default_key_bindings
io_gate.set_default_key_bindings(config)
Expand Down
6 changes: 6 additions & 0 deletions lib/reline/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ def initialize
@test_mode = false
@autocompletion = false
@convert_meta = true if seven_bit_encoding?(Reline::IOGate.encoding)
@loaded = false
end

def reset
Expand Down Expand Up @@ -98,6 +99,10 @@ def keymap
@key_actors[@keymap_label]
end

def loaded?
@loaded
end

def inputrc_path
case ENV['INPUTRC']
when nil, ''
Expand Down Expand Up @@ -219,6 +224,7 @@ def read_lines(lines, file = nil)
unless if_stack.empty?
raise InvalidInputrc, "#{file}:#{if_stack.last[0]}: unclosed if"
end
@loaded = true
end

def handle_directive(directive, file, no, if_stack)
Expand Down

0 comments on commit 0bbdc92

Please sign in to comment.