Coder Social home page Coder Social logo

Comments (7)

CKolkey avatar CKolkey commented on August 22, 2024 2

Yeah, good point. That frame_key thing was one of the first things I added to this codebase, and needless to say, I've learned a lot since then. My thinking was to do something like rate-limit redrawing, but I don't think that really makes any difference, and clearly causes some issues. So, let's just ditch the idea, and see how that goes.

#1068

from neogit.

CKolkey avatar CKolkey commented on August 22, 2024 1

Damn. Alright, I'll be able to take a look sometime in the next few days. Holidays, and all that :)

from neogit.

CnsMaple avatar CnsMaple commented on August 22, 2024

same question

from neogit.

AThePeanut4 avatar AThePeanut4 commented on August 22, 2024

@CKolkey I'm getting a very similar error, on both master and nightly. I'm running the latest neovim dev version (v0.10.0-dev-1947+gab2aad509d).

It happens after viewing a commit (<CR> on a commit), closing the Commit View window (q), and then moving the cursor. On master, the specific error is

Error in decoration provider NeogitBufferViewDecorNeogitCommitView.end:
Error executing lua: .../.local/share/nvim/lazy/neogit/lua/neogit/lib/buffer.lua:520: Invalid buffer id: 54
stack traceback:
        [C]: in function 'get_changedtick'
        .../.local/share/nvim/lazy/neogit/lua/neogit/lib/buffer.lua:520: in function 'frame_key'
        .../.local/share/nvim/lazy/neogit/lua/neogit/lib/buffer.lua:530: in function <.../.local/share/nvim/lazy/neogit/lua/neogit/lib/buffer.lua:529>

On nightly, the error is very slightly different:

Error in decoration provider neogit-buffer-26-ViewDecor.end:
Error executing lua: .../.local/share/nvim/lazy/neogit/lua/neogit/lib/buffer.lua:577: Invalid buffer id: 26
stack traceback:
        [C]: in function 'get_changedtick'
        .../.local/share/nvim/lazy/neogit/lua/neogit/lib/buffer.lua:577: in function 'frame_key'
        .../.local/share/nvim/lazy/neogit/lua/neogit/lib/buffer.lua:587: in function <.../.local/share/nvim/lazy/neogit/lua/neogit/lib/buffer.lua:586>

from neogit.

AThePeanut4 avatar AThePeanut4 commented on August 22, 2024

Simply pcalling buffer:get_changedtick() in the same way as #1065 seems to at least get rid of the error for me (this diff is on nightly):

diff --git a/lua/neogit/lib/buffer.lua b/lua/neogit/lib/buffer.lua
index ec099527..9977e5c6 100644
--- a/lua/neogit/lib/buffer.lua
+++ b/lua/neogit/lib/buffer.lua
@@ -574,7 +574,12 @@ function Buffer.create(config)
 
     buffer:call(function()
       local function frame_key()
-        return table.concat { fn.line("w0"), fn.line("w$"), fn.getcurpos()[2], buffer:get_changedtick() }
+        local ok, tick = pcall(buffer.get_changedtick, buffer)
+        if ok then
+          return table.concat { fn.line("w0"), fn.line("w$"), fn.getcurpos()[2], tick }
+        else
+          return table.concat { fn.line("w0"), fn.line("w$"), fn.getcurpos()[2], "0" }
+        end
       end
 
       local last_frame_key = frame_key()

No idea if the change is correct or makes sense here, but the error at least goes away. Currently, once the error message appears, clicking any key just re-triggers the error, so it makes neovim entirely unusable.

from neogit.

CKolkey avatar CKolkey commented on August 22, 2024

Yeah, just didn't have a chance to merge master into nightly. I have now :)

from neogit.

AThePeanut4 avatar AThePeanut4 commented on August 22, 2024

Yeah, just didn't have a chance to merge master into nightly. I have now :)

#1065 doesn't fix my issue, unfortunately - that's in status.lua whereas my error is coming from lib/buffer.lua. My fix above is basically just making the same change as #1065 but in a different file.

I've also added a test print() inside frame_key() just to see when the function is actually being called, like so:

diff --git a/lua/neogit/lib/buffer.lua b/lua/neogit/lib/buffer.lua
index ec09952..e5528f7 100644
--- a/lua/neogit/lib/buffer.lua
+++ b/lua/neogit/lib/buffer.lua
@@ -573,8 +573,17 @@ function Buffer.create(config)
     buffer:create_namespace("ViewDecor")
 
     buffer:call(function()
+      local i = 0
+
       local function frame_key()
-        return table.concat { fn.line("w0"), fn.line("w$"), fn.getcurpos()[2], buffer:get_changedtick() }
+        local ok, tick = pcall(buffer.get_changedtick, buffer)
+        print("call", buffer.handle, i)
+        i = i + 1
+        if ok then
+          return table.concat { fn.line("w0"), fn.line("w$"), fn.getcurpos()[2], tick }
+        else
+          return table.concat { fn.line("w0"), fn.line("w$"), fn.getcurpos()[2], "0" }
+        end
       end
 
       local last_frame_key = frame_key()

And from that I can see that the frame_key function is called every time the cursor moves or anything happens onscreen, even after the commit view and all other neogit views have been closed. I can't imagine this is intentional, so adding pcall isn't fixing the root cause, just the symptom.

from neogit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.