Skip to content
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

fix: don't capture leading whitespace in modeline #129

Merged
merged 1 commit into from
Mar 19, 2024
Merged

Conversation

clason
Copy link
Member

@clason clason commented Mar 19, 2024

Problem: Including leading whitespace in modeline leads (somehow) to
leading whitespace being included in other nodes, especially taglink,
and thus concealed. This breaks right-aligned taglinks in Neovim
documentation.

Solution: Do not include whitespace in modeline.

Problem: Including leading whitespace in modeline leads (somehow) to
leading whitespace being included in other nodes, especially `taglink`,
and thus concealed. This breaks right-aligned taglinks in Neovim
documentation.

Solution: Do not include whitespace in modeline.
@clason clason merged commit 6ec0d20 into master Mar 19, 2024
3 checks passed
@clason clason deleted the fix/modeline branch March 19, 2024 18:11
@@ -171,7 +171,7 @@ module.exports = grammar({
),

// Modeline: must start with "vim:" (optionally preceded by whitespace)
modeline: ($) => token(prec(2, /[\t ]*vim:[^\n]+\n/)),
modeline: ($) => token(prec(2, /vim:[^\n]+\n/)),
Copy link
Member

@justinmk justinmk Mar 20, 2024

Choose a reason for hiding this comment

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

Yeah, explicitly matching whitespace in the token always causes problems. And it's not needed here anyway, because modeline is defined as a top-level ("block") token:

help_file: ($) =>
seq(
repeat($._blank), // Eat blank lines at top of file.
repeat($.block),
repeat($.modeline),

Copy link
Member Author

Choose a reason for hiding this comment

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

Yup. This slipped by me in review.

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