GithubHelp home page GithubHelp logo

Comments (7)

mattmassicotte avatar mattmassicotte commented on May 20, 2024 1

Thank you for reporting this! As a very short-term fix, I think you may be able to work around this with a two-step operation:

view.text = ""
view.text = text

I'm going to try to set up a test so I can figure out what's going on.

Update: Nope, that fix will not work. I think I undesrtand what's wrong. But I have to think harder about what a solution could be. I'm travelling right now, but will get back to you later in the week.

from neon.

varkrishna avatar varkrishna commented on May 20, 2024

Hi @mattmassicotte , Thanks for quick reply, really appreciate. Is it possible to explain what's going on, may be I will change my approach till the time this is fixed permanently.

from neon.

mattmassicotte avatar mattmassicotte commented on May 20, 2024

The issue is RangeProcessor.didChangeContent has a serious bug. This crash will happen if a range is ever changed that is past its maximum processed location. I think this situation can only occur with programmatic text mutation, like what you are doing here. But, I wouldn't be surprised if other paths could lead to this.

To avoid this, you'd have to make sure that the entire content was always processed. And TextViewHighlighter doesn't provide any good API to achieve that. Perhaps by also programmically scrolling to the end first? It's hacky and I don't know if it will work reliably.

from neon.

varkrishna avatar varkrishna commented on May 20, 2024

Yes, you are right. Programmatically scrolling to bottom to make sure that whole text is processed, preventing the crash. Thanks.

Also , if I have a check like below before updating the text, directly updating the text still leading to crash.

func updateNSView(_ view: JSONEditor, context: Context) { view.updateFont(newValue: font) if view.text != text { view.text = text } }

from neon.

mattmassicotte avatar mattmassicotte commented on May 20, 2024

I think I have this fixed now. Could you please update to the latest main and try again? And thanks so much for your patience here.

from neon.

varkrishna avatar varkrishna commented on May 20, 2024

Yes @mattmassicotte , the crash I was getting is fixed now after updating to latest code. Thanks a lot.

from neon.

mattmassicotte avatar mattmassicotte commented on May 20, 2024

Wonderful! Thanks again for filing this issue.

from neon.

Related Issues (17)

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.