mirror of
https://github.com/junegunn/vim-plug.git
synced 2024-12-19 02:25:35 -07:00
PlugDiff: Press enter on the name of a plugin to see the full diff
Close #1174
This commit is contained in:
parent
be55ec46b5
commit
8fdabfba0b
20
plug.vim
20
plug.vim
@ -2621,26 +2621,34 @@ function! s:preview_commit()
|
|||||||
|
|
||||||
let sha = matchstr(getline('.'), '^ \X*\zs[0-9a-f]\{7,9}')
|
let sha = matchstr(getline('.'), '^ \X*\zs[0-9a-f]\{7,9}')
|
||||||
if empty(sha)
|
if empty(sha)
|
||||||
return
|
let name = matchstr(getline('.'), '^- \zs[^:]*\ze:$')
|
||||||
|
if empty(name)
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
let title = 'HEAD@{1}..'
|
||||||
|
let command = 'git diff --no-color HEAD@{1}'
|
||||||
|
else
|
||||||
|
let title = sha
|
||||||
|
let command = 'git show --no-color --pretty=medium '.sha
|
||||||
|
let name = s:find_name(line('.'))
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let name = s:find_name(line('.'))
|
|
||||||
if empty(name) || !has_key(g:plugs, name) || !isdirectory(g:plugs[name].dir)
|
if empty(name) || !has_key(g:plugs, name) || !isdirectory(g:plugs[name].dir)
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if exists('g:plug_pwindow') && !s:is_preview_window_open()
|
if exists('g:plug_pwindow') && !s:is_preview_window_open()
|
||||||
execute g:plug_pwindow
|
execute g:plug_pwindow
|
||||||
execute 'e' sha
|
execute 'e' title
|
||||||
else
|
else
|
||||||
execute 'pedit' sha
|
execute 'pedit' title
|
||||||
wincmd P
|
wincmd P
|
||||||
endif
|
endif
|
||||||
setlocal previewwindow filetype=git buftype=nofile nobuflisted modifiable
|
setlocal previewwindow filetype=git buftype=nofile bufhidden=wipe nobuflisted modifiable
|
||||||
let batchfile = ''
|
let batchfile = ''
|
||||||
try
|
try
|
||||||
let [sh, shellcmdflag, shrd] = s:chsh(1)
|
let [sh, shellcmdflag, shrd] = s:chsh(1)
|
||||||
let cmd = 'cd '.plug#shellescape(g:plugs[name].dir).' && git show --no-color --pretty=medium '.sha
|
let cmd = 'cd '.plug#shellescape(g:plugs[name].dir).' && '.command
|
||||||
if s:is_win
|
if s:is_win
|
||||||
let [batchfile, cmd] = s:batchfile(cmd)
|
let [batchfile, cmd] = s:batchfile(cmd)
|
||||||
endif
|
endif
|
||||||
|
@ -393,6 +393,14 @@ Execute (New commits on remote, PlugUpdate, then PlugDiff):
|
|||||||
let lnum = line('.')
|
let lnum = line('.')
|
||||||
AssertEqual 3, col('.')
|
AssertEqual 3, col('.')
|
||||||
|
|
||||||
|
" Open full diff (empty)
|
||||||
|
execute "normal \<cr>"
|
||||||
|
wincmd P
|
||||||
|
AssertEqual 1, &previewwindow
|
||||||
|
AssertEqual 'git', &filetype
|
||||||
|
AssertEqual [''], getline(1, '$')
|
||||||
|
pclose
|
||||||
|
|
||||||
" Open commit preview
|
" Open commit preview
|
||||||
execute "normal j\<cr>"
|
execute "normal j\<cr>"
|
||||||
wincmd P
|
wincmd P
|
||||||
|
Loading…
Reference in New Issue
Block a user