accept tabs as whitespace

This commit is contained in:
2023-07-04 21:38:19 +00:00
parent ddc7cb75c4
commit d1cb9847d9
2 changed files with 26 additions and 2 deletions

View File

@@ -15,6 +15,26 @@ nix-shell shebang whitespace
#! /usr/bin/env nix-shell #! /usr/bin/env nix-shell
--- ---
(source_file
(first_line))
==================
nix-shell shebang tab
==================
#! /usr/bin/env nix-shell
---
(source_file
(first_line))
==================
nix-shell shebang tabs and spaces
==================
#! /usr/bin/env nix-shell
---
(source_file (source_file
(first_line)) (first_line))

View File

@@ -55,8 +55,12 @@ module.exports = grammar({
'env', 'env',
), ),
_nix_shell: $ => 'nix-shell', _nix_shell: $ => 'nix-shell',
_ws: $ => / +/, // N.B.: this accepts more than it needs to:
_opt_ws: $ => / */, // - shebang parser allows tab characters
// - #!nix-shell directives do not support tabs
// - wherever #!nix-shell directives allow whitespace, it's a *single* space -- never multiple
_ws: $ => /[ \t]+/,
_opt_ws: $ => /[ \t]*/,
_newline: $ => '\n', _newline: $ => '\n',
} }
}); });