Comments (7)
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.
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.
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.
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.
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.
Yes @mattmassicotte , the crash I was getting is fixed now after updating to latest code. Thanks a lot.
from neon.
Wonderful! Thanks again for filing this issue.
from neon.
Related Issues (17)
- Screenshot link for "painting it black" in README broken
- Variable 'version' needs fix HOT 2
- async version of currentTree HOT 1
- Cannot invalidate highlight at startup and/or with manual text settings HOT 4
- Proposal : TextViewSystemInterface to class HOT 9
- Crash on async access HOT 2
- 'staleContent' error in highlighter HOT 2
- Coalesce attribute changes into one block HOT 2
- Direct text storage attribute modifications HOT 13
- SwiftUI example HOT 7
- Rendering HTML HOT 3
- Repo example code returns nil for highlight method HOT 6
- Demo crashes when editing text HOT 9
- Validation/Invalidation coordination problem with TreeSitterClient and TextSystemStyler HOT 2
- Text highlighting after edit does not work HOT 1
- TextStorageSystemInterface does not style textedits that are not at end of string HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from neon.