Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Unified Diff: tools/gn/misc/vim/autoload/gn.vim

Issue 2657853004: Improve vim's 'gf' for BUILD.gn files (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/misc/vim/autoload/gn.vim
diff --git a/tools/gn/misc/vim/autoload/gn.vim b/tools/gn/misc/vim/autoload/gn.vim
index c1df012149b944e1bcceefde79f5a74467c5efe0..5573efc0af319a22466af73460f6b70488018b07 100644
--- a/tools/gn/misc/vim/autoload/gn.vim
+++ b/tools/gn/misc/vim/autoload/gn.vim
@@ -10,8 +10,17 @@ function! gn#TranslateToBuildFile(name) abort
let l:new_path = substitute(l:new_path, '\v:.*$', '', '')
" Append 'BUILD.gn', only if this is a directory and not a file
- if isdirectory(l:new_path)
- let l:new_path = substitute(l:new_path, '\v/?$', '/BUILD.gn', '')
+ " Prefer using maktaba if it's available, but fallback to an alternative
+ if exists('*maktaba#path#Basename')
+ " Check if the last part of the path appears to be a file
+ if maktaba#path#Basename(l:new_path) !~# '\V.'
+ let l:new_path = maktaba#path#Join([l:new_path, 'BUILD.gn'])
+ endif
+ else
+ " This will break if 'autochdir' is enabled
+ if isdirectory(l:new_path)
+ let l:new_path = substitute(l:new_path, '\v/?$', '/BUILD.gn', '')
+ endif
endif
return l:new_path
endfunction
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698