Skip to content

🐞 Flickering on cursor move and text editing #293

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

Closed
nkleemann opened this issue Feb 5, 2025 · 4 comments · Fixed by #310
Closed

🐞 Flickering on cursor move and text editing #293

nkleemann opened this issue Feb 5, 2025 · 4 comments · Fixed by #310
Labels
bug Something isn't working

Comments

@nkleemann
Copy link

Description

Since 0.10.0 the syntax highlighting flickers on and off for a split second for any action performed inside the view, meaning:

  • arrow keys (navigation)
  • space, return
  • text insert / delete

This was not the case with the previous version of CodeEditSourceEditor (0.9x)

To Reproduce

  1. Create a CodeEditSourceEditor instance where text is handled by a @Obsersvable viewmodel and start to edit text

Expected Behavior

The syntax highlighting should not flicker.

Version Information

CodeEditSourceEditor: [e.g. 0.10.0]
macOS: 14.7 (23H124)
Xcode: Version 16.2 (16C5032a)

Additional Context

No response

Screenshots

See video:

Screen.Recording.2025-02-05.at.08.53.45.mov
@nkleemann nkleemann added the bug Something isn't working label Feb 5, 2025
@huyphams
Copy link

huyphams commented Apr 3, 2025

Same issue, I'm testing the example and it is flickering. Looks like it's trying to set highlight provider non-stop

Also the example is completely broken, as it always use plaintext and not support dark theme (I barely see the gutter in dark theme).

  if !areHighlightProvidersEqual(controller: controller) {
        controller.setHighlightProviders(highlightProviders)
  }

@austincondiff austincondiff changed the title 🐞 Flickering on curser move and text editing 🐞 Flickering on cursor move and text editing Apr 19, 2025
@austincondiff
Copy link
Collaborator

I have personally not experienced this as of recent. @thecoolwinter has this been fixed recently?

@thecoolwinter
Copy link
Collaborator

thecoolwinter commented Apr 21, 2025

I don't think this has been fixed. Iirc 10.0 introduced a new api that diffs highlight providers. It sounds like that's accidental resetting the default tree sitter highlighter when text changes.

As a temporary workaround, use a state variable to make a TreeSitterClient and pass it to the editor. That'll keep it around while typing.

@State var treeSitterClient = TreeSitterClient

//...

CodeEditSourceEditor(
    //...
    highlightProviders: [treeSitterClient],
    //...
)

@thecoolwinter
Copy link
Collaborator

I've got a fix for this, my hunch was correct that there was some mismanagement of the default tree sitter highlight provider. I've opened a PR to make CESE correctly detect when the default highlight provider is wanted, and to keep around the tree-sitter provider between view updates.

@github-project-automation github-project-automation bot moved this from 🆕 New to 🏁 Complete in CodeEdit Project Apr 21, 2025
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: 🏁 Complete
Development

Successfully merging a pull request may close this issue.

4 participants