Commit ba95d7b
committed
Require terminator before function definition
The current grammar assumes it found a function whenever it encounters the keyword `function` followed by any word, which is too aggressive and can lead to false positives.
This change requires that the function definition is preceded by a terminator (`^|;|&`) and (optional) whitespace.
This approach can still produce false positives (it doesn’t recognise when the line break was escaped, for example) but should work well enough.
It also now includes the preceding whitespace in the `meta.function.shell` scope (due to the limitations on variable-width look-behinds), which I don’t like but also don’t see a way around.
We might want to consider doing something similar for loop constructs.
Closes #361 parent ed8de7e commit ba95d7b
1 file changed
+2
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
336 | 336 | | |
337 | 337 | | |
338 | 338 | | |
339 | | - | |
| 339 | + | |
340 | 340 | | |
341 | 341 | | |
342 | 342 | | |
| |||
377 | 377 | | |
378 | 378 | | |
379 | 379 | | |
380 | | - | |
| 380 | + | |
381 | 381 | | |
382 | 382 | | |
383 | 383 | | |
| |||
0 commit comments