Skip to content

Commit 2a8c5f8

Browse files
committed
Show directory content in changelist
1 parent 640cd5c commit 2a8c5f8

3 files changed

Lines changed: 15 additions & 10 deletions

File tree

autoload/project.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2680,7 +2680,7 @@ function! project#ShortenDate(origin)
26802680
return date
26812681
endfunction
26822682

2683-
function! project#HideNewlines()
2683+
function! project#RemoveEmptyLines()
26842684
silent! %s/$//g
26852685
endfunction
26862686

autoload/project/find_in_files.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ endfunction
107107

108108
function! s:ShowResult(display, search, replace, full_input, id)
109109
call project#ShowInListBuffer(a:display, a:search)
110-
call project#HideNewlines()
110+
call project#RemoveEmptyLines()
111111
call project#HighlightCurrentLine(len(a:display))
112112
call s:HighlightSearchAsPattern(a:search)
113113
call s:HighlightReplaceChars(a:search, a:replace)

autoload/project/git.vim

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ function! s:AddDiffDetails(hash, file)
156156
setlocal modifiable
157157
call append(0, changes)
158158
normal! gg
159-
call project#HideNewlines()
159+
call project#RemoveEmptyLines()
160160
silent! g/^new file mode/d _
161161
if is_diff_line
162162
silent! 1,3d _
@@ -417,16 +417,16 @@ function! s:ShowDiffOnChangelist()
417417
endif
418418

419419
let file = s:GetCurrentFile()
420+
if empty(file)
421+
call s:CloseBuffer(s:diff_buffer)
422+
return
423+
endif
420424
" Avoid E242
421425
try
422426
call s:OpenBuffer(s:diff_buffer, 'vertical')
423427
call s:SetupDiffBuffer(s:GetAbsolutePath(file))
424428
wincmd p
425429

426-
if empty(file)
427-
call s:CloseBuffer(s:diff_buffer)
428-
return
429-
endif
430430
call s:AddChangeDetails(file)
431431
catch
432432
call project#Warn(v:exception)
@@ -437,6 +437,8 @@ function! s:AddChangeDetails(file)
437437
let diff_file = s:TryGetDiffFile(a:file)
438438
if !empty(diff_file)
439439
let cmd = 'cat '.diff_file
440+
elseif isdirectory(s:GetAbsolutePath(a:file))
441+
let cmd = 'ls -F '.a:file
440442
elseif s:IsStagedFile(a:file)
441443
let cmd = 'git diff --staged -- "'.a:file.'"'
442444
elseif s:IsUntrackedFile(a:file)
@@ -516,9 +518,12 @@ function! VimProjectAddChangeDetails(job, data, ...)
516518
call append(0, a:data)
517519
endif
518520

519-
call project#HideNewlines()
520-
silent! g/^new file mode/d _
521-
silent! 1,4d _
521+
call project#RemoveEmptyLines()
522+
silent! 1,g/^new file mode/d _ | break
523+
silent! 1,g/^diff --git/d _ | break
524+
silent! 1,g/^index /d _ | break
525+
silent! 1,g/^--- a/d _ | break
526+
silent! 1,g/^+++ b/d _ | break
522527
normal! gg
523528
setlocal nomodifiable
524529
call s:SwitchBuffer(s:changelist_buffer)

0 commit comments

Comments
 (0)