From f30e62a431cbf01b15b8d35a11910a97c2edaa93 Mon Sep 17 00:00:00 2001 From: tanvirtin Date: Thu, 21 Nov 2024 00:18:42 -0500 Subject: [PATCH] fix(project_diff_preview): fix toggle issues --- lua/vgit/features/screens/ProjectDiffScreen/Store.lua | 1 + lua/vgit/features/screens/ProjectDiffScreen/init.lua | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lua/vgit/features/screens/ProjectDiffScreen/Store.lua b/lua/vgit/features/screens/ProjectDiffScreen/Store.lua index 5ea166e8..a21eb47f 100644 --- a/lua/vgit/features/screens/ProjectDiffScreen/Store.lua +++ b/lua/vgit/features/screens/ProjectDiffScreen/Store.lua @@ -142,6 +142,7 @@ end function Store:get_filepath() local reponame = self.state.reponame local filename = self:get_filename() + if not filename then return nil, { 'entry not found' } end filename = fs.make_relative(reponame, filename) filename = string.format('%s/%s', reponame, filename) diff --git a/lua/vgit/features/screens/ProjectDiffScreen/init.lua b/lua/vgit/features/screens/ProjectDiffScreen/init.lua index 6541cdb0..4f510dc8 100644 --- a/lua/vgit/features/screens/ProjectDiffScreen/init.lua +++ b/lua/vgit/features/screens/ProjectDiffScreen/init.lua @@ -395,7 +395,7 @@ function ProjectDiffScreen:show() mode = 'n', key = '', handler = loop.coroutine(function() - local mark, _ = self.diff_view:get_current_mark_under_cursor() + local mark = self.diff_view:get_current_mark_under_cursor() if not mark then return end local filepath = self.store:get_filepath() @@ -479,7 +479,6 @@ function ProjectDiffScreen:show() mode = 'n', key = '', handler = loop.coroutine(function() - local mark, _ = self.diff_view:get_current_mark_under_cursor() local filename = self.store:get_filepath() loop.free_textlock() @@ -489,6 +488,8 @@ function ProjectDiffScreen:show() return end + local mark = self.diff_view:get_current_mark_under_cursor() + self:destroy() fs.open(filename)