Skip to content

Commit

Permalink
[C#] fix using top level statements when using a type instead of "var" (
Browse files Browse the repository at this point in the history
  • Loading branch information
keith-hall authored Jan 28, 2024
1 parent 9c5677c commit 0647aa3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
6 changes: 5 additions & 1 deletion C#/C#.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,11 @@ contexts:
captures:
1: keyword.control.using.cs
push: var_declaration
- match: \b(using)\s+(?={{name}}\s*=\s*)
- match: \b(using)\s+(?={{name}}\s+{{name}}\s*=)
captures:
1: keyword.control.using.cs
push: var_declaration
- match: \b(using)\s+(?={{name}}\s*=)
captures:
1: keyword.control.import.cs
push: using_namespace
Expand Down
18 changes: 18 additions & 0 deletions C#/tests/syntax_test_C#9.cs
Original file line number Diff line number Diff line change
Expand Up @@ -422,3 +422,21 @@ public class MyClass { public record MyRecord <T> (int nums) { public const int
/// ^^^^ variable.other.member
/// ^ punctuation.section.block.end
/// ^ punctuation.section.block.end

using ServiceProvider sp = services.BuildServiceProvider();
/// ^ keyword.control.using
/// ^^^^^^^^^^^^^^^ support.type
/// ^^ variable.other
/// ^ keyword.operator.assignment
/// ^^^^^^^^ variable.other
/// ^ punctuation.accessor.dot
/// ^^^^^^^^^^^^^^^^^^^^^^ meta.function-call
/// ^^^^^^^^^^^^^^^^^^^^ variable.function
/// ^ punctuation.section.group.begin - invalid
/// ^ punctuation.section.group.end - invalid
using IDisposable sub = pageContentObservable.Subscribe(Console.WriteLine);
/// ^ keyword.control.using
/// ^^^^^^^^^^^ support.type
/// ^^^ variable.other
/// ^ keyword.operator.assignment
/// ^^^^^^^^^^^^^^^^^^^^^ variable.other

0 comments on commit 0647aa3

Please sign in to comment.