File tree Expand file tree Collapse file tree 1 file changed +4
-6
lines changed
lua/diffview/scene/views/diff Expand file tree Collapse file tree 1 file changed +4
-6
lines changed Original file line number Diff line number Diff line change @@ -526,17 +526,15 @@ end
526526--- Returns nil if no file is open in the view, or there is no entry under the
527527--- cursor in the file panel.
528528--- @param allow_dir ? boolean Allow directory nodes from the file tree.
529- --- @return FileEntry | DirData | nil
529+ --- @return ( FileEntry | DirData ) ?
530530function DiffView :infer_cur_file (allow_dir )
531531 if self .panel :is_focused () then
532532 --- @type any
533533 local item = self .panel :get_item_at_cursor ()
534+ if not item then return end
535+ if not allow_dir and type (item .collapsed ) == " boolean" then return end
534536
535- if FileEntry .__get ():ancestorof (item )
536- or (allow_dir and type (item .collapsed ) == " boolean" )
537- then
538- return item
539- end
537+ return item
540538 else
541539 return self .panel .cur_file
542540 end
You can’t perform that action at this time.
0 commit comments