editor: Add trailing whitespace rendering (#32329)

Closes #5237

- Adds "trailing" option for "show_whitespaces" in settings.json
- Supports importing this setting from vscode

The option in question will render only whitespace characters that
appear after every non-whitespace character in a given line.

Release Notes:

- Added trailing whitespace rendering
This commit is contained in:
JonasKaplan 2025-06-09 16:48:49 -04:00 committed by GitHub
parent f0345df479
commit f0ce62ead8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 15 additions and 1 deletions

View file

@ -765,6 +765,8 @@ pub enum ShowWhitespaceSetting {
/// - It is adjacent to an edge (start or end)
/// - It is adjacent to a whitespace (left or right)
Boundary,
/// Draw whitespaces only after non-whitespace characters.
Trailing,
}
/// Controls which formatter should be used when formatting code.
@ -1452,7 +1454,8 @@ impl settings::Settings for AllLanguageSettings {
vscode.bool_setting("editor.inlineSuggest.enabled", &mut d.show_edit_predictions);
vscode.enum_setting("editor.renderWhitespace", &mut d.show_whitespaces, |s| {
Some(match s {
"boundary" | "trailing" => ShowWhitespaceSetting::Boundary,
"boundary" => ShowWhitespaceSetting::Boundary,
"trailing" => ShowWhitespaceSetting::Trailing,
"selection" => ShowWhitespaceSetting::Selection,
"all" => ShowWhitespaceSetting::All,
_ => ShowWhitespaceSetting::None,