Skip to content

Fix 1699#1721

Merged
jeremypw merged 9 commits into
elementary:masterfrom
Dipanshusinghh:fix-1698
May 24, 2026
Merged

Fix 1699#1721
jeremypw merged 9 commits into
elementary:masterfrom
Dipanshusinghh:fix-1698

Conversation

@Dipanshusinghh
Copy link
Copy Markdown
Contributor

Fixes #1699

This PR prevents trailing whitespace from being stripped inside string literals (like multiline strings). Currently, strip_trailing_spaces() splits the buffer into lines and runs a regex match to strip whitespace on everything, which changes the semantic value of the strings.

To fix this we check the context class of the iterator at the line end using iter_has_context_class(). If the iterator has the "string" context class, we skip stripping the trailing space. this is similar to how we already skip stripping inside comments in the detect-indent plugin.

Testing

Tested this locally with multiline string literals in a test file. trailing whitespaces inside triple quotes are now preserved, while normal lines of code stil get striped corectly.

Dipanshusinghh and others added 9 commits May 11, 2026 21:02
)

Trigger symbol refresh when the document is reloaded externally (e.g., via git reset) or reverted, rather than relying solely on internal buffer changes.
This fixes the trailing whitespace stripping behavior on save:
- Excludes Markdown and YAML files where trailing whitespace can be semantically meaningful.
- Adds description/subtext in the settings switch to clarify that it only applies to syntax-highlighted files, except Markdown and YAML.

Fixes elementary#1698
Copy link
Copy Markdown
Collaborator

@jeremypw jeremypw left a comment

Choose a reason for hiding this comment

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

Nice concise solution! Thanks

@jeremypw jeremypw merged commit bebe0fc into elementary:master May 24, 2026
4 of 6 checks passed
@Dipanshusinghh
Copy link
Copy Markdown
Contributor Author

@jeremypw
thanks for the review and merge! glad I could help .if anything else comes up or you spot something that could use a fix, feel free to let me know—I'd be happy to contribute.

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.

Trailing whitespace is stripped from string literal containing a line break

3 participants