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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.


// "Column heading": plaintext followed by "~".
// Intended for table column names per `:help help-writing`.
Expand Down
2 changes: 1 addition & 1 deletion src/grammar.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading