Skip to content

Commit

Permalink
DRY up repeated #gsub calls in #get_cursor_highlight
Browse files Browse the repository at this point in the history
  • Loading branch information
wincent committed Feb 9, 2015
1 parent 90f9e31 commit 5c198bb
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions ruby/command-t/match_window.rb
Expand Up @@ -414,14 +414,14 @@ def get_cursor_highlight
if highlight =~ /^Cursor\s+xxx\s+(.+)\blinks to (\w+)/m
[
Highlight.new("Cursor #{$~[1]}"),
Highlight.new("link Cursor #{$~[2]}".gsub(/\s+/, ' '), '!')
Highlight.new("link Cursor #{$~[2]}", '!')
]
elsif highlight =~ /^Cursor\s+xxx\s+links to (\w+)/m
[Highlight.new("link Cursor #{$~[1]}".gsub(/\s+/, ' '))]
[Highlight.new("link Cursor #{$~[1]}")]
elsif highlight =~ /^Cursor\s+xxx\s+cleared/m
[Highlight.new('clear Cursor')]
elsif highlight =~ /Cursor\s+xxx\s+(.+)/m
[Highlight.new("Cursor #{$~[1]}".gsub(/\s+/, ' '))]
[Highlight.new("Cursor #{$~[1]}")]
else # likely cause E411 Cursor highlight group not found
[]
end
Expand All @@ -436,7 +436,8 @@ def hide_cursor
def show_cursor
if @cursor_highlight
@cursor_highlight.each do |highlight|
::VIM::command "highlight#{highlight.bang} #{highlight.highlight}"
config = highlight.highlight.gsub(/\s+/, ' ')
::VIM::command "highlight#{highlight.bang} #{config}"
end
end
end
Expand Down

0 comments on commit 5c198bb

Please sign in to comment.