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

[C#] fix using top level statements when using a type instead of "var" #3910

Merged
merged 1 commit into from
Jan 28, 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
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
Loading