lib/textbringer/utils.rb in textbringer-1.1.1 vs lib/textbringer/utils.rb in textbringer-1.1.2

- old
+ new

@@ -135,23 +135,25 @@ original_buffer: nil, completions_window: nil } def read_from_minibuffer(prompt, completion_proc: nil, default: nil, - initial_value: nil, + initial_value: nil, completion_ignore_case: false, keymap: MINIBUFFER_LOCAL_MAP) if Window.echo_area.active? raise EditorError, "Command attempted to use minibuffer while in minibuffer" end old_buffer = Buffer.current old_window = Window.current old_completion_proc = Buffer.minibuffer[:completion_proc] + old_completion_ignore_case = Buffer.minibuffer[:completion_ignore_case] old_current_prefix_arg = Controller.current.current_prefix_arg old_minibuffer_map = Buffer.minibuffer.keymap Buffer.minibuffer.keymap = keymap Buffer.minibuffer[:completion_proc] = completion_proc + Buffer.minibuffer[:completion_ignore_case] = completion_ignore_case Window.echo_area.active = true begin Window.current = Window.echo_area Buffer.minibuffer.clear Buffer.minibuffer.insert(initial_value) if initial_value @@ -175,10 +177,11 @@ Window.echo_area.active = false Window.current = old_window # Just in case old_window has been deleted by resize, # in which case Window.current is set to the first window. Window.current.buffer = Buffer.current = old_buffer + Buffer.minibuffer[:completion_ignore_case] = old_completion_ignore_case Buffer.minibuffer[:completion_proc] = old_completion_proc Buffer.minibuffer.keymap = old_minibuffer_map Buffer.minibuffer.disable_input_method Controller.current.current_prefix_arg = old_current_prefix_arg if COMPLETION[:original_buffer] @@ -199,12 +202,14 @@ file end } } initial_value = default&.sub(%r"\A#{Regexp.quote(Dir.pwd)}/", "") + ignore_case = CONFIG[:read_file_name_completion_ignore_case] file = read_from_minibuffer(prompt, completion_proc: f, - initial_value: initial_value) + initial_value: initial_value, + completion_ignore_case: ignore_case) File.expand_path(file) end def complete_for_minibuffer(s, candidates) candidates.select { |i| i.start_with?(s) } @@ -221,11 +226,13 @@ } read_from_minibuffer(prompt, completion_proc: f) end def read_encoding(prompt, **opts) + encoding_names = (Encoding.list.map(&:name) + Encoding.aliases.keys). + map(&:downcase).uniq f = ->(s) { - complete_for_minibuffer(s.upcase, Encoding.list.map(&:name)) + complete_for_minibuffer(s.downcase, encoding_names) } read_from_minibuffer(prompt, completion_proc: f, **opts) end def yes_or_no?(prompt)