@@ -434,7 +434,10 @@ function! s:ShowDiffOnChangelist()
434434endfunction
435435
436436function ! s: AddChangeDetails (file )
437- if s: IsStagedFile (a: file )
437+ let diff_file = s: TryGetDiffFile (a: file )
438+ if ! empty (diff_file)
439+ let cmd = ' cat ' .diff_file
440+ elseif s: IsStagedFile (a: file )
438441 let cmd = ' git diff --staged -- "' .a: file .' "'
439442 elseif s: IsUntrackedFile (a: file )
440443 let cmd = ' git diff --no-index -- /dev/null "' .a: file .' "'
@@ -459,6 +462,22 @@ function! s:IsStagedFile(file)
459462 return s: IsStagedFolder (folder)
460463endfunction
461464
465+ function ! s: TryGetDiffFile (file )
466+ let is_shelf = s: Match (a: file , ' \.diff$' )
467+ if ! is_shelf
468+ return 0
469+ endif
470+ let shelf_folder = s: GetShelfFolder ()
471+ let folder = s: GetBelongFolder (line (' .' ))
472+ let shelf_file = shelf_folder.' /' .folder.name.' /' .a: file
473+ let has_shelf_file = filereadable (shelf_file)
474+ if has_shelf_file
475+ return shelf_file
476+ endif
477+
478+ return 0
479+ endfunction
480+
462481function ! s: RunJob (cmd, exit_cb, buf_nr)
463482 let can_run = exists (' *job_start' ) || exists (' *jobstart' )
464483 if ! can_run
@@ -788,16 +807,16 @@ function! s:ShelfFile() range
788807 endif
789808
790809 for file in files
791- let cmd = ' git diff "' .file .' " > ' .folder.' /' .file .' .patch '
810+ let cmd = ' git diff "' .file .' " > ' .folder.' /' .file .' .diff '
792811 call project#RunShellCmd (cmd)
793812 if v: shell_error
794813 return
795814 endif
796815
797- let patch_files = map (files , {idx, v - > v .' .patch ' })
816+ let diff_files = map (files , {idx, v - > v .' .diff ' })
798817 let target = {
799818 \' name' : ' [Shelf] '.name,
800- \' files ': patch_files ,
819+ \' files ': diff_files ,
801820 \' expand ': 1
802821 \}
803822
@@ -825,7 +844,7 @@ function! s:RollbackFile() range
825844 if nr2char (getchar ()) == ' y'
826845 for file in files
827846 if s: IsFileUntracked (file )
828- let cmd = ' rm -r "' .file .' "'
847+ let cmd = ' git clean -fd "' .file .' "'
829848 else
830849 let cmd = ' git restore -- "' .file .' "'
831850 endif
@@ -1246,20 +1265,13 @@ function! s:GetChangedFileDisplay(file, prefix = ' ')
12461265endfunction
12471266
12481267function ! s: GetShelfFileDisplay (file , prefix = ' ' )
1249- let sign = s: GetFileChangeSign (a: file )
12501268 " sign_mark is used by s:HighlightFiles
12511269 let sign_mark = ' '
1252- if sign == ' D'
1253- let sign_mark = ' $' " $ Deleted - Comment
1254- elseif sign == ' A' || sign == ' ?'
1255- let sign_mark = ' !' " ! Add or untrack - diffAdded
1256- endif
12571270 let splitter = ' |'
12581271
12591272 let icon = project#GetIcon (a: file )
12601273
1261- " Use unicode space for highlight
1262- return a: prefix .sign_mark.icon .splitter.a: file .' '
1274+ return a: prefix .sign_mark.icon .splitter.a: file .splitter.' '
12631275endfunction
12641276
12651277function ! s: UpdateChangelist (run_git = 0 )
0 commit comments