Skip to content

Commit

Permalink
Open in split if opening normally would fail
Browse files Browse the repository at this point in the history
If the user has 'hidden' turned off and the current window has
modifications, then opening with the standard ":edit" command will fail
with an error:

  E37: No write since last change (add ! to override)

So, in these cases, fall back to opening in a split, which should work
without warnings or errors.

See:

  https://wincent.com/issues/1514

Signed-off-by: Wincent Colaiuta <win@wincent.com>
  • Loading branch information
wincent committed Mar 24, 2010
1 parent eaa312d commit 13a1999
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion ruby/command-t/controller.rb
Expand Up @@ -158,8 +158,16 @@ def sanitize_path_string str
str.gsub(/[ \\|%#"]/, '\\\\\0')
end

def default_open_command
if !get_bool('&hidden') && get_bool('&modified')
'sp'
else
'e'
end
end

def open_selection selection, options = {}
command = options[:command] || 'e'
command = options[:command] || default_open_command
selection = sanitize_path_string selection
VIM::command "silent #{command} #{selection}"
end
Expand Down

0 comments on commit 13a1999

Please sign in to comment.