Skip to content

🐞 Syntax highlights not applied to end of file #142

@thecoolwinter

Description

@thecoolwinter

Description

When appending text to the end of a file the highlighter doesn't apply fonts. If you resize the window or scroll away it will apply the fonts. After some investigation it looks like the visibleSet isn't being updated with new characters, so new characters are being removed from any actionable sets when highlights are being applied.

An easy fix would be to recalculate the visible set every edit, but that would be quite inefficient. A possible solution may be to check whether an edit is being applied to the end of the visible set, and if it's exactly on the end extend the visible set.

To Reproduce

  • Open a blank code file (or one you can see the bottom of without scrolling)
  • Type some code, you'll notice there's no fonts/colors being applied.

Expected behavior

Should apply fonts/colors to edits made at the end of the file.

Version information

CodeEditTextView: [main]
macOS: [e.g. 13.2]
Xcode: [e.g. 14.2]

Additional context

Screen.Recording.2023-02-14.at.8.07.12.PM.mov

This video shows the issue. I deleted exactly 5 characters from the file (4 lines and a tab) before typing this. So the visible set originally included the class text. After that the visible set no longer contains the edited indices.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

Status

🏁 Complete

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions