Skip to content

Commit

Permalink
Avoid unwanted escaping in :CommandTCommand and :CommandTTag
Browse files Browse the repository at this point in the history
Also adjusting `:CommandTHistory` to use the same approach, for
consistency.
  • Loading branch information
wincent committed Sep 7, 2017
1 parent 9c00e84 commit 06bf93c
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 3 deletions.
4 changes: 4 additions & 0 deletions doc/command-t.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1558,6 +1558,10 @@ master (not yet released)
- Fix a RangeError on 64-bit Windows (#304, patch from Adrian Keet).
- Fix issue switching back to previously opened file in another tab (#306).
- Fix inability to open some help targets with |:CommandTHelp| (#307).
- Similar to #307, make |:CommandTCommand| work with commands containing
special characters.
- Again similar to #307, prevent special characters in tags from being escaped
when using |:CommandTTag|.

5.0.1 (18 August 2017) ~

Expand Down
8 changes: 8 additions & 0 deletions ruby/command-t/lib/command-t/finder/command_finder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,17 @@ def initialize(options = {})
end

def open_selection(command, selection, options = {})
escaped = VIM.escape_for_single_quotes selection
::VIM::command "call feedkeys(':#{selection} ', 'nt')"
end

def prepare_selection(selection)
# Pass selection through as-is, bypassing path-based stuff that the
# controller would otherwise do, like `expand_path`,
# `sanitize_path_string` and `relative_path_under_working_directory`.
selection
end

def flush; end

def name
Expand Down
11 changes: 8 additions & 3 deletions ruby/command-t/lib/command-t/finder/history_finder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,17 @@ def initialize(options = {})
end

def open_selection(command, selection, options = {})
# Need to unescape to reverse the work done by `#sanitize_path_string`.
unescaped = selection.gsub(/\\(.)/, '\1')
escaped = VIM.escape_for_single_quotes unescaped
escaped = VIM.escape_for_single_quotes(selection)
::VIM::command "call feedkeys('#{@history_type}#{escaped} ', 'nt')"
end

def prepare_selection(selection)
# Pass selection through as-is, bypassing path-based stuff that the
# controller would otherwise do, like `expand_path`,
# `sanitize_path_string` and `relative_path_under_working_directory`.
selection
end

def flush; end

def name
Expand Down
7 changes: 7 additions & 0 deletions ruby/command-t/lib/command-t/finder/tag_finder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ def open_selection(command, selection, options = {})
::VIM::command "silent! tag #{selection} | :normal zz"
end

def prepare_selection(selection)
# Pass selection through as-is, bypassing path-based stuff that the
# controller would otherwise do, like `expand_path`,
# `sanitize_path_string` and `relative_path_under_working_directory`.
selection
end

def flush
@scanner.flush
end
Expand Down

0 comments on commit 06bf93c

Please sign in to comment.