Skip to content

Commit

Permalink
Fix rescue token without explicit class
Browse files Browse the repository at this point in the history
  • Loading branch information
vinistock committed Sep 19, 2024
1 parent a4be389 commit fc4698c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion vscode/grammars/ruby.cson.json
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@
"name": "variable.ruby"
}
},
"match": "^\\s*([a-z]([A-Za-z0-9_])*)\\s*=[^=]",
"match": "^\\s*([a-z]([A-Za-z0-9_])*)\\s*=[^=>]",
"comment": "A local variable assignment"
},
{
Expand Down
14 changes: 14 additions & 0 deletions vscode/src/test/suite/grammars.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,20 @@ suite("Grammars", () => {
});
});

suite("Local variables", () => {
test("rescue is not confused", () => {
const ruby = "rescue => e";
const expectedTokens = [
["rescue", ["source.ruby", "keyword.control.ruby"]],
[" ", ["source.ruby"]],
["=>", ["source.ruby", "punctuation.separator.key-value"]],
[" e", ["source.ruby"]],
];
const actualTokens = tokenizeRuby(ruby);
assert.deepStrictEqual(actualTokens, expectedTokens);
});
});

function tokenizeRuby(ruby: string): [string, string[]][] {
if (!rubyGrammar) {
throw new Error("Ruby grammar not loaded");
Expand Down

0 comments on commit fc4698c

Please sign in to comment.