GithubHelp home page GithubHelp logo

Comments (5)

raphlinus avatar raphlinus commented on June 30, 2024 1

I don't think it's a huge mystery, the current linewrap code overinvalidates, which can mask the underlying problem.

Vitali's approach seems good to me, let's get it merged.

from xi-mac.

cmyr avatar cmyr commented on June 30, 2024

@vlovich just caught up on the irc logs; it makes sense to me that this is related to the auto-indent stuff in syntect; at least, that's why you're seeing two updates. We shouldn't be sending the second update in syntect if there is no previous indentation level; I'll open a separate issue for that.
Annoyingly I'm also not able to reproduce consistently right now?

from xi-mac.

vlovich avatar vlovich commented on June 30, 2024

So I've tracked it down. There's some kind of bug with the lineCache. If I disable it

            //if let assoc = lineCache.get(lineIx)?.assoc {
                //textLine = assoc.textLine
                //textLines.append(assoc.textLine)
            //} else {

then the line numbers are fine. FWIW I see no noticeable performance difference. I'm not sure I understand yet what lineCache is trying to do. My guess is that the performance implications are for when you have more complex styles being applied. I'll look into the problem. My hunch on how the fix is going to look like is that it's going to be a bit involved moving some things around. The gutterTL and the textLine cache needs to be split up better.

from xi-mac.

vlovich avatar vlovich commented on June 30, 2024

This hack fixes the issue:

@@ -466,6 +466,14 @@ class EditView: NSView, NSTextInputClient, TextPlaneDelegate {
             if let assoc = lineCache.get(lineIx)?.assoc {
                 textLine = assoc.textLine
                 textLines.append(assoc.textLine)
+
+                let gutterText = "\(lineIx + 1)"
+                let gBuilder = TextLineBuilder(gutterText, font: font)
+                gBuilder.setFgColor(argb: line.containsCursor ? foregroundArgb: gutterArgb)
+                let gutterTL = gBuilder.build(fontCache: renderer.fontCache)
+
+                let fixupGutter = LineAssoc(textLine: assoc.textLine, gutterTL: gutterTL);
+                lineCache.setAssoc(lineIx, assoc: fixupGutter);
             } else {
                 let builder = TextLineBuilder(line.text, font: font)
                 builder.setFgColor(argb: foregroundArgb)

The less hacky way I'm thinking of doing it is to have 2 LineAssoc. 1 for the text itself and 1 for the gutter. Then move the rendering of the gutter lower. Not sure how involved that is or if there's a simpler fix.

from xi-mac.

cmyr avatar cmyr commented on June 30, 2024

Interestingly, this is not an issue if linewrap is enabled (this was my reproduction problem). I don't know too much about that code, but I guess it's sending a different update. It's not immediately clear to me that that should be expected in this case?

from xi-mac.

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.