Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐞 Crash when deleting text #196

Open
Wouter01 opened this issue Jun 14, 2023 · 13 comments
Open

🐞 Crash when deleting text #196

Wouter01 opened this issue Jun 14, 2023 · 13 comments
Labels
bug Something isn't working

Comments

@Wouter01
Copy link
Member

Wouter01 commented Jun 14, 2023

Description

I deleted a bunch of text from a file (select text + backspace), this caused CodeEdit to crash with the following error:

Thread 57: Fatal error: Duplicate elements of type 'LanguageLayer' were found in a Set.
This usually means either that the type violates Hashable's requirements, or
that members of such a set were mutated after insertion.

at editState.touchedLayers.insert(layer) (line 63 in TreeSitterClient+Edit)

To Reproduce

Open file, delete bunch of text. I'm not sure if it's easily reproducible

Expected Behavior

No crash

Version Information

CodeEditTextView: 0.6.4
macOS: 14.0 beta 1
Xcode: 15.0 beta 1

Additional Context

I attached a video showing the issue. It crashes when I press backspace.
I'm not sure, but it seems to only happen when I delete text that is at the start of the file. I haven't seen it happen when I delete text in the middle of the file.

Screenshots

Screen.Recording.2023-06-14.at.20.19.00.mov

No response

@Wouter01 Wouter01 added the bug Something isn't working label Jun 14, 2023
@nicholasss
Copy link

Should there be debugging for beta versions of Xcode and macOS - with future changes and all?

It may not apply to this, due to the error text.

@thecoolwinter
Copy link
Collaborator

This should be a simple fix, it just needs a check to the editState if the layer has been marked as touched yet. Someone could maybe look at the hashable implementation on LanguageLayer but it should just be hashing a unique UUID.

@thecoolwinter
Copy link
Collaborator

Should there be debugging for beta versions of Xcode and macOS - with future changes and all?

It may not apply to this, due to the error text.

Could you clarify? Do you mean debugging in the editor?

@TheNightmanCodeth
Copy link

I'm also experiencing this. It seems like adding a "guard set doesn't contain what we're adding" or similar would fix this

@thecoolwinter
Copy link
Collaborator

I have a hunch this is fixed with #263. My guess is that two async operations were inserting into the same dictionary and causing a conflict that way. We'll keep it open for a bit and if it doesn't re-appear I'll close this.

@ignaciojuarez
Copy link

ignaciojuarez commented Feb 1, 2025

Im getting a similar problem. There is no crash. The code and line numbers become invisible. If I completely change the code by selecting another snippet (and the id changes). The code becomes visible again.
Bug only happens when I delete a lot of code at the same time (multiple line). (latest version 0.9.1)
I can also create another issue post with more information.

I attached a video of my problem and a picture of my code. Maybe I am using it wrong.

video (bug):

Screen.Recording.2025-02-01.at.9.56.48.AM.mov

my code:
Image

@ignaciojuarez
Copy link

When I delete a big chunk of code and that code is deleting the first line. All the code becomes invisible. And when it's invisible and I press enter, and then delete. It becomes visible again.

Screen.Recording.2025-02-02.at.8.20.14.PM.mov

@ignaciojuarez
Copy link

Also I sometimes get this error. When the code/numbers are invisible, and I keep typing or deleting.

Image

@nkleemann
Copy link

I still get the same crashes very often, exactly how @ignaciojuarez is desribing them. For example, after selecting all and hitting delete. Or deleting the first or last line.

@thecoolwinter
Copy link
Collaborator

@ignaciojuarez @nkleemann That crash you posted looks like what #263 fixes. I'll be making a release tonight that'll include that patch.

The layout bug I'd guess is different. I've been able to reproduce it sporadically, but that screen recording may help.

I'll take another look at it now, it may be an issue with CodeEditTextView rather than this package but I'll update this issue when I have more info.

@thecoolwinter
Copy link
Collaborator

Sorry, meant #285

@thecoolwinter
Copy link
Collaborator

thecoolwinter commented Feb 5, 2025

That release is live (tagged as 0.10.0), @ignaciojuarez does that fix your editing crash?

@ignaciojuarez
Copy link

ignaciojuarez commented Feb 5, 2025

Hello @thecoolwinter. Thanks for the help!
The problem is still there. Same as the video. ;(
I just updated to 0.10.0 and updated to using Attributes for the ThemeEditor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: 🆕 New
Development

No branches or pull requests

6 participants