Skip to content

Draw Invisible Characters #334

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

thecoolwinter
Copy link
Collaborator

@thecoolwinter thecoolwinter commented Jun 12, 2025

Description

Adds a configuration option to draw invisible characters.

By default, draws spaces as a small dot, with emphasis on spaces that align with the user's selected indent width. Draws tabs as a small arrow. Draws line endings (carriage returns and line feeds) as a ¬ character.

Replacement characters are configurable using the config object.

Adds a configuration option to warn users about potentially dangerous/unnecessary characters that may not be visible to the naked eye. This could be used to warn about something like a zero-width space being accidentally copied into a file.

Detailed changes

  • Adds a new InvisibleCharactersConfig type that contains toggles for certain whitespace characters, as well as a set of 'warning' characters to draw warning boxes on.
  • Adds a new InvisibleCharactersCoordinator that tells the text view how to draw characters depending on the current configuration.
  • Adds a new invisibleCharacterConfig option to CodeEditSourceEditor and TextViewController.
  • Adds a new warningCharacters option to CodeEditSourceEditor and TextViewController.
  • Updates TextViewController to correctly update the coordinator when the user's theme, font, or indent option are updated.

Related Issues

Checklist

  • I read and understood the contributing guide as well as the code of conduct
  • The issues this PR addresses are related to each other
  • My changes generate no new warnings
  • My code builds and runs on my machine
  • My changes are all related to the related issue above
  • I documented my code

Screenshots

Example document with tabs, spaces, newlines, and a zero-width character pasted in before the 1. It responds to theme updates and live editing.

Screen.Recording.2025-06-12.at.1.27.39.PM.mov

Adds a configuration option to draw invisible characters.
@thecoolwinter thecoolwinter marked this pull request as draft June 12, 2025 20:05
@thecoolwinter thecoolwinter marked this pull request as ready for review June 13, 2025 16:04
Copy link
Collaborator

@austincondiff austincondiff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment may necessitate change in this PR to have a warning characters setting separate from the invisible characters.

@thecoolwinter
Copy link
Collaborator Author

This comment may necessitate change in this PR to have a warning characters setting separate from the invisible characters.

@austincondiff That's a good point, lets do both.

@thecoolwinter
Copy link
Collaborator Author

@austincondiff updated to split the warning characters into their own parameter and documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants