浏览代码

Merge pull request #4300 from igordejanovic/vim-escape-fname

[vim-interaction plugin] Escape special chars in filenames.
Robby Russell 9 年之前
父节点
当前提交
3b29132214
共有 1 个文件被更改,包括 4 次插入18 次删除
  1. 4 18
      plugins/vim-interaction/vim-interaction.plugin.zsh

+ 4 - 18
plugins/vim-interaction/vim-interaction.plugin.zsh

@@ -4,17 +4,6 @@
 # Derek Wyatt (derek@{myfirstnamemylastname}.org
 # Derek Wyatt (derek@{myfirstnamemylastname}.org
 # 
 # 
 
 
-function resolveFile
-{
-  if [ -f "$1" ]; then
-    echo $(readlink -f "$1")
-  elif [[ "${1#/}" == "$1" ]]; then
-    echo "$PWD/$1"
-  else
-    echo $1
-  fi
-}
-
 function callvim
 function callvim
 {
 {
   if [[ $# == 0 ]]; then
   if [[ $# == 0 ]]; then
@@ -48,13 +37,10 @@ EOH
   if [[ ${before#:} != $before && ${before%<cr>} == $before ]]; then
   if [[ ${before#:} != $before && ${before%<cr>} == $before ]]; then
     before="$before<cr>"
     before="$before<cr>"
   fi
   fi
-  local files=""
-  for f in $@
-  do
-    files="$files $(resolveFile $f)"
-  done
-  if [[ -n $files ]]; then
-    files=':args! '"$files<cr>"
+  local files
+  if [[ $# -gt 0 ]]; then
+    # absolute path of files resolving symlinks (:A) and quoting special chars (:q)
+    files=':args! '"${@:A:q}<cr>"
   fi
   fi
   cmd="$before$files$after"
   cmd="$before$files$after"
   gvim --remote-send "$cmd"
   gvim --remote-send "$cmd"