diff --git a/.git-blame-ignore b/.git-blame-ignore-revs similarity index 86% rename from .git-blame-ignore rename to .git-blame-ignore-revs index 457d2604f3c50..c0c9a544148a9 100644 --- a/.git-blame-ignore +++ b/.git-blame-ignore-revs @@ -1,4 +1,5 @@ # https://git-scm.com/docs/git-blame#Documentation/git-blame.txt---ignore-revs-fileltfilegt +# https://docs.github.com/en/repositories/working-with-files/using-files/viewing-a-file#ignore-commits-in-the-blame-view # mjbvz: Fix spacing 13f4f052582bcec3d6c6c6a70d995c9dee2cac13 @@ -23,6 +24,5 @@ ae1452eea678f5266ef513f22dacebb90955d6c9 a3cb14be7f2cceadb17adf843675b1a59537dbbd ee1655a82ebdfd38bf8792088a6602c69f7bbd94 - # jrieken: new eslint-rule 4a130c40ed876644ed8af2943809d08221375408 diff --git a/build/gulpfile.vscode.js b/build/gulpfile.vscode.js index 4ae98a9557756..857114fea15db 100644 --- a/build/gulpfile.vscode.js +++ b/build/gulpfile.vscode.js @@ -64,7 +64,7 @@ const vscodeResources = [ 'out-build/vs/base/node/{stdForkStart.js,terminateProcess.sh,cpuUsage.sh,ps.sh}', 'out-build/vs/base/browser/ui/codicons/codicon/**', 'out-build/vs/base/parts/sandbox/electron-sandbox/preload.js', - 'out-build/vs/base/parts/sandbox/electron-sandbox/preload-slim.js', + 'out-build/vs/base/parts/sandbox/electron-sandbox/preload-aux.js', 'out-build/vs/workbench/browser/media/*-theme.css', 'out-build/vs/workbench/contrib/debug/**/*.json', 'out-build/vs/workbench/contrib/externalTerminal/**/*.scpt', diff --git a/build/npm/postinstall.js b/build/npm/postinstall.js index 09df602a3bf5d..07b4412c45800 100644 --- a/build/npm/postinstall.js +++ b/build/npm/postinstall.js @@ -112,4 +112,4 @@ for (let dir of dirs) { } cp.execSync('git config pull.rebase merges'); -cp.execSync('git config blame.ignoreRevsFile .git-blame-ignore'); +cp.execSync('git config blame.ignoreRevsFile .git-blame-ignore-revs'); diff --git a/extensions/csharp/cgmanifest.json b/extensions/csharp/cgmanifest.json index 176ee56da4856..ad27f27b271dc 100644 --- a/extensions/csharp/cgmanifest.json +++ b/extensions/csharp/cgmanifest.json @@ -6,7 +6,7 @@ "git": { "name": "dotnet/csharp-tmLanguage", "repositoryUrl": "https://github.com/dotnet/csharp-tmLanguage", - "commitHash": "772323937fedd65c6dc1c8ce6ea41d97415ed7d1" + "commitHash": "6666eb1d5e6fb565a4110d6db645cc534fb3c6d2" } }, "license": "MIT", @@ -15,4 +15,4 @@ } ], "version": 1 -} +} \ No newline at end of file diff --git a/extensions/csharp/syntaxes/csharp.tmLanguage.json b/extensions/csharp/syntaxes/csharp.tmLanguage.json index c4266da462d3e..9b6cf2e9664f4 100644 --- a/extensions/csharp/syntaxes/csharp.tmLanguage.json +++ b/extensions/csharp/syntaxes/csharp.tmLanguage.json @@ -4,7 +4,7 @@ "If you want to provide a fix or improvement, please create a pull request against the original repository.", "Once accepted there, we are happy to receive an update request." ], - "version": "https://github.com/dotnet/csharp-tmLanguage/commit/772323937fedd65c6dc1c8ce6ea41d97415ed7d1", + "version": "https://github.com/dotnet/csharp-tmLanguage/commit/6666eb1d5e6fb565a4110d6db645cc534fb3c6d2", "name": "C#", "scopeName": "source.cs", "patterns": [ @@ -210,9 +210,6 @@ { "include": "#else-part" }, - { - "include": "#switch-statement" - }, { "include": "#goto-statement" }, @@ -238,10 +235,10 @@ "include": "#checked-unchecked-statement" }, { - "include": "#lock-statement" + "include": "#context-control-statement" }, { - "include": "#using-statement" + "include": "#context-control-paren-statement" }, { "include": "#labeled-statement" @@ -278,13 +275,10 @@ "include": "#comment" }, { - "include": "#checked-unchecked-expression" + "include": "#expression-operator-expression" }, { - "include": "#typeof-or-default-expression" - }, - { - "include": "#nameof-expression" + "include": "#type-operator-expression" }, { "include": "#default-literal-expression" @@ -305,14 +299,20 @@ "include": "#type-builtin" }, { - "include": "#this-or-base-expression" + "include": "#language-variable" + }, + { + "include": "#switch-statement-or-expression" }, { - "include": "#switch-expression" + "include": "#with-expression" }, { "include": "#conditional-operator" }, + { + "include": "#assignment-expression" + }, { "include": "#expression-operators" }, @@ -370,36 +370,39 @@ ] }, "extern-alias-directive": { - "begin": "\\s*(extern)\\b\\s*(alias)\\b\\s*(@?[_[:alpha:]][_[:alnum:]]*)", + "begin": "\\b(extern)\\s+(alias)\\b", "beginCaptures": { "1": { - "name": "keyword.other.extern.cs" + "name": "keyword.other.directive.extern.cs" }, "2": { - "name": "keyword.other.alias.cs" - }, - "3": { - "name": "variable.other.alias.cs" + "name": "keyword.other.directive.alias.cs" } }, - "end": "(?=;)" + "end": "(?=;)", + "patterns": [ + { + "match": "\\@?[_[:alpha:]][_[:alnum:]]*", + "name": "variable.other.alias.cs" + } + ] }, "using-directive": { "patterns": [ { - "begin": "(\\b(global)\\b\\s+)?\\b(using)\\b\\s+(static)\\b\\s+(\\b(unsafe)\\b\\s+)?", + "begin": "\\b(?:(global)\\s+)?(using)\\s+(static)\\b\\s*(?:(unsafe)\\b\\s*)?", "beginCaptures": { + "1": { + "name": "keyword.other.directive.global.cs" + }, "2": { - "name": "keyword.other.global.cs" + "name": "keyword.other.directive.using.cs" }, "3": { - "name": "keyword.other.using.cs" + "name": "keyword.other.directive.static.cs" }, "4": { - "name": "keyword.other.static.cs" - }, - "6": { - "name": "storage.modifier.cs" + "name": "storage.modifier.unsafe.cs" } }, "end": "(?=;)", @@ -410,19 +413,22 @@ ] }, { - "begin": "(\\b(global)\\b\\s+)?\\b(using)\\b\\s+(\\b(unsafe)\\b\\s+)?(?=(@?[_[:alpha:]][_[:alnum:]]*)\\s*=)", + "begin": "\\b(?:(global)\\s+)?(using)\\b\\s*(?:(unsafe)\\b\\s*)?(@?[_[:alpha:]][_[:alnum:]]*)\\s*(=)", "beginCaptures": { + "1": { + "name": "keyword.other.directive.global.cs" + }, "2": { - "name": "keyword.other.global.cs" + "name": "keyword.other.directive.using.cs" }, "3": { - "name": "keyword.other.using.cs" - }, - "5": { - "name": "storage.modifier.cs" + "name": "storage.modifier.unsafe.cs" }, - "6": { + "4": { "name": "entity.name.type.alias.cs" + }, + "5": { + "name": "keyword.operator.assignment.cs" } }, "end": "(?=;)", @@ -432,20 +438,17 @@ }, { "include": "#type" - }, - { - "include": "#operator-assignment" } ] }, { - "begin": "(\\b(global)\\b\\s+)?\\b(using)\\s*(?!\\(|\\s|var)", + "begin": "\\b(?:(global)\\s+)?(using)\\b\\s*+(?!\\(|var\\b)", "beginCaptures": { - "2": { - "name": "keyword.other.global.cs" + "1": { + "name": "keyword.other.directive.global.cs" }, - "3": { - "name": "keyword.other.using.cs" + "2": { + "name": "keyword.other.directive.using.cs" } }, "end": "(?=;)", @@ -455,7 +458,10 @@ }, { "name": "entity.name.type.namespace.cs", - "match": "@?[_[:alpha:]][_[:alnum:]]*" + "match": "\\@?[_[:alpha:]][_[:alnum:]]*" + }, + { + "include": "#punctuation-accessor" }, { "include": "#operator-assignment" @@ -551,7 +557,7 @@ "begin": "\\b(namespace)\\s+", "beginCaptures": { "1": { - "name": "keyword.other.namespace.cs" + "name": "storage.type.namespace.cs" } }, "end": "(?<=\\})|(?=;)", @@ -594,7 +600,7 @@ ] }, "storage-modifier": { - "name": "storage.modifier.cs", + "name": "storage.modifier.$1.cs", "match": "(?\n (?:\n (?:ref\\s+(?:readonly\\s+)?)? # ref return\n (?:\n (?:(?@?[_[:alpha:]][_[:alnum:]]*)\\s*\\:\\:\\s*)? # alias-qualification\n (? # identifier + type arguments (if any)\n \\g\\s*\n (?\\s*<(?:[^<>]|\\g)+>\\s*)?\n )\n (?:\\s*\\.\\s*\\g)* | # Are there any more names being dotted into?\n (?\\s*\\((?:[^\\(\\)]|\\g)+\\))\n )\n (?:\\s*\\?\\s*)? # nullable suffix?\n (?:\\s* # array suffix?\n \\[\n (?:\\s*,\\s*)* # commata for multi-dimensional arrays\n \\]\n \\s*\n (?:\\?)? # arrays can be nullable reference types\n \\s*\n )*\n )\n)\\s+\n(\\g)\\s*\n(<([^<>]+)>)?\\s*\n(?=\\()", "beginCaptures": { "1": { - "name": "keyword.other.delegate.cs" + "name": "storage.type.delegate.cs" }, "2": { "patterns": [ @@ -712,7 +718,7 @@ "match": "(enum)\\s+(@?[_[:alpha:]][_[:alnum:]]*)", "captures": { "1": { - "name": "keyword.other.enum.cs" + "name": "storage.type.enum.cs" }, "2": { "name": "entity.name.type.enum.cs" @@ -796,7 +802,7 @@ "begin": "(?x)\n(interface)\\b\\s+\n(@?[_[:alpha:]][_[:alnum:]]*)", "beginCaptures": { "1": { - "name": "keyword.other.interface.cs" + "name": "storage.type.interface.cs" }, "2": { "name": "entity.name.type.interface.cs" @@ -853,7 +859,7 @@ "begin": "(?x)\n(record)\\b\\s+\n(@?[_[:alpha:]][_[:alnum:]]*)", "beginCaptures": { "1": { - "name": "keyword.other.record.cs" + "name": "storage.type.record.cs" }, "2": { "name": "entity.name.type.class.cs" @@ -913,10 +919,10 @@ "begin": "(?x)\n(\\b(record)\\b\\s+)?\n(struct)\\b\\s+\n(@?[_[:alpha:]][_[:alnum:]]*)", "beginCaptures": { "2": { - "name": "keyword.other.record.cs" + "name": "storage.type.record.cs" }, "3": { - "name": "keyword.other.struct.cs" + "name": "storage.type.struct.cs" }, "4": { "name": "entity.name.type.struct.cs" @@ -984,19 +990,11 @@ "patterns": [ { "match": "\\b(in|out)\\b", - "captures": { - "1": { - "name": "storage.modifier.cs" - } - } + "name": "storage.modifier.$1.cs" }, { "match": "(@?[_[:alpha:]][_[:alnum:]]*)\\b", - "captures": { - "1": { - "name": "entity.name.type.type-parameter.cs" - } - } + "name": "entity.name.type.type-parameter.cs" }, { "include": "#comment" @@ -1033,7 +1031,7 @@ "begin": "(where)\\s+(@?[_[:alpha:]][_[:alnum:]]*)\\s*(:)", "beginCaptures": { "1": { - "name": "keyword.other.where.cs" + "name": "storage.modifier.where.cs" }, "2": { "name": "entity.name.type.type-parameter.cs" @@ -1045,18 +1043,18 @@ "end": "(?=\\{|where|;|=>)", "patterns": [ { - "name": "keyword.other.class.cs", + "name": "storage.type.class.cs", "match": "\\bclass\\b" }, { - "name": "keyword.other.struct.cs", + "name": "storage.type.struct.cs", "match": "\\bstruct\\b" }, { "match": "(new)\\s*(\\()\\s*(\\))", "captures": { "1": { - "name": "keyword.other.new.cs" + "name": "keyword.operator.expression.new.cs" }, "2": { "name": "punctuation.parenthesis.open.cs" @@ -1112,7 +1110,7 @@ ] }, "property-declaration": { - "begin": "(?x)\n\n# The negative lookahead below ensures that we don't match nested types\n# or other declarations as properties.\n(?![[:word:][:space:]]*\\b(?:class|interface|struct|enum|event)\\b)\n\n(?\n (?\n (?:\n (?:ref\\s+(?:readonly\\s+)?)? # ref return\n (?:\n (?:(?@?[_[:alpha:]][_[:alnum:]]*)\\s*\\:\\:\\s*)? # alias-qualification\n (? # identifier + type arguments (if any)\n \\g\\s*\n (?\\s*<(?:[^<>]|\\g)+>\\s*)?\n )\n (?:\\s*\\.\\s*\\g)* | # Are there any more names being dotted into?\n (?\\s*\\((?:[^\\(\\)]|\\g)+\\))\n )\n (?:\\s*\\?\\s*)? # nullable suffix?\n (?:\\s* # array suffix?\n \\[\n (?:\\s*,\\s*)* # commata for multi-dimensional arrays\n \\]\n \\s*\n (?:\\?)? # arrays can be nullable reference types\n \\s*\n )*\n )\n )\\s+\n)\n(?\\g\\s*\\.\\s*)?\n(?\\g)\\s*\n(?=\\{|=>|$)", + "begin": "(?x)\n\n# The negative lookahead below ensures that we don't match nested types\n# or other declarations as properties.\n(?![[:word:][:space:]]*\\b(?:class|interface|struct|enum|event)\\b)\n\n(?\n (?\n (?:\n (?:ref\\s+(?:readonly\\s+)?)? # ref return\n (?:\n (?:(?@?[_[:alpha:]][_[:alnum:]]*)\\s*\\:\\:\\s*)? # alias-qualification\n (? # identifier + type arguments (if any)\n \\g\\s*\n (?\\s*<(?:[^<>]|\\g)+>\\s*)?\n )\n (?:\\s*\\.\\s*\\g)* | # Are there any more names being dotted into?\n (?\\s*\\((?:[^\\(\\)]|\\g)+\\))\n )\n (?:\\s*\\?\\s*)? # nullable suffix?\n (?:\\s* # array suffix?\n \\[\n (?:\\s*,\\s*)* # commata for multi-dimensional arrays\n \\]\n \\s*\n (?:\\?)? # arrays can be nullable reference types\n \\s*\n )*\n )\n )\\s+\n)\n(?\\g\\s*\\.\\s*)?\n(?\\g)\\s*\n(?=\\{|=>|//|/\\*|$)", "beginCaptures": { "1": { "patterns": [ @@ -1144,7 +1142,7 @@ "include": "#property-accessors" }, { - "include": "#expression-body" + "include": "#accessor-getter-expression" }, { "include": "#variable-initializer" @@ -1175,7 +1173,7 @@ ] }, "8": { - "name": "keyword.other.this.cs" + "name": "variable.language.this.cs" } }, "end": "(?<=\\})|(?=;)", @@ -1190,7 +1188,7 @@ "include": "#property-accessors" }, { - "include": "#expression-body" + "include": "#accessor-getter-expression" }, { "include": "#variable-initializer" @@ -1198,10 +1196,10 @@ ] }, "event-declaration": { - "begin": "(?x)\n\\b(event)\\b\\s*\n(?\n (?\n (?:\n (?:\n (?:(?@?[_[:alpha:]][_[:alnum:]]*)\\s*\\:\\:\\s*)? # alias-qualification\n (? # identifier + type arguments (if any)\n \\g\\s*\n (?\\s*<(?:[^<>]|\\g)+>\\s*)?\n )\n (?:\\s*\\.\\s*\\g)* | # Are there any more names being dotted into?\n (?\\s*\\((?:[^\\(\\)]|\\g)+\\))\n )\n (?:\\s*\\?\\s*)? # nullable suffix?\n (?:\\s* # array suffix?\n \\[\n (?:\\s*,\\s*)* # commata for multi-dimensional arrays\n \\]\n \\s*\n (?:\\?)? # arrays can be nullable reference types\n \\s*\n )*\n )\n )\\s+\n)\n(?\\g\\s*\\.\\s*)?\n(?\\g(?:\\s*,\\s*\\g)*)\\s*\n(?=\\{|;|$)", + "begin": "(?x)\n\\b(event)\\b\\s*\n(?\n (?\n (?:\n (?:\n (?:(?@?[_[:alpha:]][_[:alnum:]]*)\\s*\\:\\:\\s*)? # alias-qualification\n (? # identifier + type arguments (if any)\n \\g\\s*\n (?\\s*<(?:[^<>]|\\g)+>\\s*)?\n )\n (?:\\s*\\.\\s*\\g)* | # Are there any more names being dotted into?\n (?\\s*\\((?:[^\\(\\)]|\\g)+\\))\n )\n (?:\\s*\\?\\s*)? # nullable suffix?\n (?:\\s* # array suffix?\n \\[\n (?:\\s*,\\s*)* # commata for multi-dimensional arrays\n \\]\n \\s*\n (?:\\?)? # arrays can be nullable reference types\n \\s*\n )*\n )\n )\\s+\n)\n(?\\g\\s*\\.\\s*)?\n(\\g)\\s* # first event name\n(?=\\{|;|,|=|//|/\\*|$)", "beginCaptures": { "1": { - "name": "keyword.other.event.cs" + "name": "storage.type.event.cs" }, "2": { "patterns": [ @@ -1221,15 +1219,7 @@ ] }, "9": { - "patterns": [ - { - "name": "entity.name.variable.event.cs", - "match": "@?[_[:alpha:]][_[:alnum:]]*" - }, - { - "include": "#punctuation-comma" - } - ] + "name": "entity.name.variable.event.cs" } }, "end": "(?<=\\})|(?=;)", @@ -1240,8 +1230,29 @@ { "include": "#event-accessors" }, + { + "name": "entity.name.variable.event.cs", + "match": "@?[_[:alpha:]][_[:alnum:]]*" + }, { "include": "#punctuation-comma" + }, + { + "begin": "=", + "beginCaptures": { + "0": { + "name": "keyword.operator.assignment.cs" + } + }, + "end": "(?<=,)|(?=;)", + "patterns": [ + { + "include": "#expression" + }, + { + "include": "#punctuation-comma" + } + ] } ] }, @@ -1259,22 +1270,6 @@ } }, "patterns": [ - { - "name": "storage.modifier.cs", - "match": "\\b(private|protected|internal)\\b" - }, - { - "name": "keyword.other.get.cs", - "match": "\\b(get)\\b" - }, - { - "name": "keyword.other.set.cs", - "match": "\\b(set)\\b" - }, - { - "name": "keyword.other.init.cs", - "match": "\\b(init)\\b" - }, { "include": "#comment" }, @@ -1282,13 +1277,36 @@ "include": "#attribute-section" }, { - "include": "#expression-body" + "name": "storage.modifier.$1.cs", + "match": "\\b(private|protected|internal)\\b" }, { - "include": "#block" + "begin": "\\b(get)\\b\\s*(?=\\{|;|=>|//|/\\*|$)", + "beginCaptures": { + "1": { + "name": "storage.type.accessor.$1.cs" + } + }, + "end": "(?<=\\}|;)|(?=\\})", + "patterns": [ + { + "include": "#accessor-getter" + } + ] }, { - "include": "#punctuation-semicolon" + "begin": "\\b(set|init)\\b\\s*(?=\\{|;|=>|//|/\\*|$)", + "beginCaptures": { + "1": { + "name": "storage.type.accessor.$1.cs" + } + }, + "end": "(?<=\\}|;)|(?=\\})", + "patterns": [ + { + "include": "#accessor-setter" + } + ] } ] }, @@ -1307,24 +1325,114 @@ }, "patterns": [ { - "name": "keyword.other.add.cs", - "match": "\\b(add)\\b" + "include": "#comment" }, { - "name": "keyword.other.remove.cs", - "match": "\\b(remove)\\b" + "include": "#attribute-section" }, { - "include": "#comment" + "begin": "\\b(add|remove)\\b\\s*(?=\\{|;|=>|//|/\\*|$)", + "beginCaptures": { + "1": { + "name": "storage.type.accessor.$1.cs" + } + }, + "end": "(?<=\\}|;)|(?=\\})", + "patterns": [ + { + "include": "#accessor-setter" + } + ] + } + ] + }, + "accessor-getter": { + "patterns": [ + { + "begin": "\\{", + "beginCaptures": { + "0": { + "name": "punctuation.curlybrace.open.cs" + } + }, + "end": "\\}", + "endCaptures": { + "0": { + "name": "punctuation.curlybrace.close.cs" + } + }, + "contentName": "meta.accessor.getter.cs", + "patterns": [ + { + "include": "#statement" + } + ] }, { - "include": "#attribute-section" + "include": "#accessor-getter-expression" }, { - "include": "#expression-body" + "include": "#punctuation-semicolon" + } + ] + }, + "accessor-getter-expression": { + "begin": "=>", + "beginCaptures": { + "0": { + "name": "keyword.operator.arrow.cs" + } + }, + "end": "(?=;|\\})", + "contentName": "meta.accessor.getter.cs", + "patterns": [ + { + "include": "#ref-modifier" }, { - "include": "#block" + "include": "#expression" + } + ] + }, + "accessor-setter": { + "patterns": [ + { + "begin": "\\{", + "beginCaptures": { + "0": { + "name": "punctuation.curlybrace.open.cs" + } + }, + "end": "\\}", + "endCaptures": { + "0": { + "name": "punctuation.curlybrace.close.cs" + } + }, + "contentName": "meta.accessor.setter.cs", + "patterns": [ + { + "include": "#statement" + } + ] + }, + { + "begin": "=>", + "beginCaptures": { + "0": { + "name": "keyword.operator.arrow.cs" + } + }, + "end": "(?=;|\\})", + "contentName": "meta.accessor.setter.cs", + "patterns": [ + { + "include": "#ref-modifier" + }, + { + "include": "#expression" + } + ] }, { "include": "#punctuation-semicolon" @@ -1425,13 +1533,10 @@ ] }, "constructor-initializer": { - "begin": "\\b(?:(base)|(this))\\b\\s*(?=\\()", + "begin": "\\b(base|this)\\b\\s*(?=\\()", "beginCaptures": { "1": { - "name": "keyword.other.base.cs" - }, - "2": { - "name": "keyword.other.this.cs" + "name": "variable.language.$1.cs" } }, "end": "(?<=\\))", @@ -1468,7 +1573,7 @@ ] }, "operator-declaration": { - "begin": "(?x)\n(?\n (?:\n (?:ref\\s+(?:readonly\\s+)?)? # ref return\n (?:\n (?:(?@?[_[:alpha:]][_[:alnum:]]*)\\s*\\:\\:\\s*)? # alias-qualification\n (? # identifier + type arguments (if any)\n \\g\\s*\n (?\\s*<(?:[^<>]|\\g)+>\\s*)?\n )\n (?:\\s*\\.\\s*\\g)* | # Are there any more names being dotted into?\n (?\\s*\\((?:[^\\(\\)]|\\g)+\\))\n )\n (?:\\s*\\?\\s*)? # nullable suffix?\n (?:\\s* # array suffix?\n \\[\n (?:\\s*,\\s*)* # commata for multi-dimensional arrays\n \\]\n \\s*\n (?:\\?)? # arrays can be nullable reference types\n \\s*\n )*\n )\n)\\s*\n(?(?:\\b(?:operator)))\\s*\n(?(?:\\+|-|\\*|/|%|&|\\||\\^|\\<\\<|\\>\\>|==|!=|\\>|\\<|\\>=|\\<=|!|~|\\+\\+|--|true|false))\\s*\n(?=\\()", + "begin": "(?x)\n(?\n (?:\n (?:ref\\s+(?:readonly\\s+)?)? # ref return\n (?:\n (?:(?@?[_[:alpha:]][_[:alnum:]]*)\\s*\\:\\:\\s*)? # alias-qualification\n (? # identifier + type arguments (if any)\n \\g\\s*\n (?\\s*<(?:[^<>]|\\g)+>\\s*)?\n )\n (?:\\s*\\.\\s*\\g)* | # Are there any more names being dotted into?\n (?\\s*\\((?:[^\\(\\)]|\\g)+\\))\n )\n (?:\\s*\\?\\s*)? # nullable suffix?\n (?:\\s* # array suffix?\n \\[\n (?:\\s*,\\s*)* # commata for multi-dimensional arrays\n \\]\n \\s*\n (?:\\?)? # arrays can be nullable reference types\n \\s*\n )*\n )\n)\\s*\n\\b(?operator)\\b\\s*\n(?[+\\-*/%&|\\^!=~<>]+|true|false)\\s*\n(?=\\()", "beginCaptures": { "1": { "patterns": [ @@ -1478,7 +1583,7 @@ ] }, "6": { - "name": "keyword.other.operator-decl.cs" + "name": "storage.type.operator.cs" }, "7": { "name": "entity.name.function.cs" @@ -1509,7 +1614,7 @@ "match": "\\b(explicit)\\b", "captures": { "1": { - "name": "keyword.other.explicit.cs" + "name": "storage.modifier.explicit.cs" } } }, @@ -1517,14 +1622,14 @@ "match": "\\b(implicit)\\b", "captures": { "1": { - "name": "keyword.other.implicit.cs" + "name": "storage.modifier.implicit.cs" } } } ] }, "2": { - "name": "keyword.other.operator-decl.cs" + "name": "storage.type.operator.cs" }, "3": { "patterns": [ @@ -1607,19 +1712,19 @@ "begin": "(?\n (?:\n (?:\n (?:(?@?[_[:alpha:]][_[:alnum:]]*)\\s*\\:\\:\\s*)? # alias-qualification\n (? # identifier + type arguments (if any)\n \\g\\s*\n (?\\s*<(?:[^<>]|\\g)+>\\s*)?\n )\n (?:\\s*\\.\\s*\\g)* | # Are there any more names being dotted into?\n (?\\s*\\((?:[^\\(\\)]|\\g)+\\))\n )\n (?:\\s*\\?\\s*)? # nullable suffix?\n (?:\\s* # array suffix?\n \\[\n (?:\\s*,\\s*)* # commata for multi-dimensional arrays\n \\]\n \\s*\n (?:\\?)? # arrays can be nullable reference types\n \\s*\n )*\n )\n)\\s+\n(\\g)\\b\\s*", + "switch-expression": { + "begin": "\\{", "beginCaptures": { - "1": { + "0": { + "name": "punctuation.curlybrace.open.cs" + } + }, + "end": "\\}", + "endCaptures": { + "0": { + "name": "punctuation.curlybrace.close.cs" + } + }, + "patterns": [ + { + "include": "#punctuation-comma" + }, + { + "begin": "=>", + "beginCaptures": { + "0": { + "name": "keyword.operator.arrow.cs" + } + }, + "end": "(?=,|})", "patterns": [ { - "include": "#type" + "include": "#expression" } ] }, - "2": { - "name": "entity.name.variable.local.cs" + { + "begin": "\\b(when)\\b", + "beginCaptures": { + "1": { + "name": "keyword.control.conditional.when.cs" + } + }, + "end": "(?==>|,|})", + "patterns": [ + { + "include": "#case-guard" + } + ] + }, + { + "begin": "(?!\\s)", + "end": "(?=\\bwhen\\b|=>|,|})", + "patterns": [ + { + "include": "#pattern" + } + ] + } + ] + }, + "case-guard": { + "patterns": [ + { + "include": "#parenthesized-expression" + }, + { + "include": "#expression" + } + ] + }, + "is-expression": { + "begin": "(?)", + "end": "(?=[)}\\],;:?=&|^]|!=)", "patterns": [ { - "include": "#comment" + "include": "#pattern" + } + ] + }, + "pattern": { + "patterns": [ + { + "include": "#intrusive" + }, + { + "include": "#combinator-pattern" + }, + { + "include": "#discard-pattern" + }, + { + "include": "#constant-pattern" + }, + { + "include": "#relational-pattern" }, { - "include": "#switch-when-clause" + "include": "#var-pattern" + }, + { + "include": "#type-pattern" + }, + { + "include": "#positional-pattern" + }, + { + "include": "#property-pattern" + }, + { + "include": "#list-pattern" + }, + { + "include": "#slice-pattern" + } + ] + }, + "combinator-pattern": { + "match": "\\b(and|or|not)\\b", + "name": "keyword.operator.expression.pattern.combinator.$1.cs" + }, + "discard-pattern": { + "match": "_(?![_[:alnum:]])", + "name": "variable.language.discard.cs" + }, + "constant-pattern": { + "patterns": [ + { + "include": "#boolean-literal" + }, + { + "include": "#null-literal" + }, + { + "include": "#numeric-literal" + }, + { + "include": "#char-literal" + }, + { + "include": "#string-literal" + }, + { + "include": "#raw-string-literal" + }, + { + "include": "#verbatim-string-literal" + }, + { + "include": "#type-operator-expression" + }, + { + "include": "#expression-operator-expression" + }, + { + "include": "#expression-operators" + }, + { + "include": "#casted-constant-pattern" } ] }, - "switch-property-expression": { - "begin": "(?x) # e.g. int x OR var x\n(?\n (?:\n (?:\n (?:(?@?[_[:alpha:]][_[:alnum:]]*)\\s*\\:\\:\\s*)? # alias-qualification\n (? # identifier + type arguments (if any)\n \\g\\s*\n (?\\s*<(?:[^<>]|\\g)+>\\s*)?\n )\n (?:\\s*\\.\\s*\\g)* | # Are there any more names being dotted into?\n (?\\s*\\((?:[^\\(\\)]|\\g)+\\))\n )\n (?:\\s*\\?\\s*)? # nullable suffix?\n (?:\\s* # array suffix?\n \\[\n (?:\\s*,\\s*)* # commata for multi-dimensional arrays\n \\]\n \\s*\n (?:\\?)? # arrays can be nullable reference types\n \\s*\n )*\n )\n)?\\s*\n(\\{)", + "casted-constant-pattern": { + "begin": "(?x)\n(\\()\n ([\\s.:@_[:alnum:]]+)\n(\\))\n(?=[\\s+\\-!~]*@?[_[:alnum:]('\"]+)", "beginCaptures": { "1": { + "name": "punctuation.parenthesis.open.cs" + }, + "2": { "patterns": [ { - "include": "#type" + "include": "#type-builtin" + }, + { + "include": "#type-name" } ] }, - "6": { - "name": "punctuation.curlybrace.open.cs" + "3": { + "name": "punctuation.parenthesis.close.cs" } }, - "end": "\\}", - "endCaptures": { + "end": "(?=[)}\\],;:?=&|^]|!=|\\b(and|or|when)\\b)", + "patterns": [ + { + "include": "#casted-constant-pattern" + }, + { + "begin": "\\(", + "beginCaptures": { + "0": { + "name": "punctuation.parenthesis.open.cs" + } + }, + "end": "\\)", + "endCaptures": { + "0": { + "name": "punctuation.parenthesis.close.cs" + } + }, + "patterns": [ + { + "include": "#constant-pattern" + } + ] + }, + { + "include": "#constant-pattern" + }, + { + "match": "(@?[_[:alpha:]][_[:alnum:]]*)\\s*(\\:\\:)", + "captures": { + "1": { + "name": "entity.name.type.alias.cs" + }, + "2": { + "name": "punctuation.separator.coloncolon.cs" + } + } + }, + { + "match": "(@?[_[:alpha:]][_[:alnum:]]*)\\s*(\\.)", + "captures": { + "1": { + "name": "entity.name.type.cs" + }, + "2": { + "name": "punctuation.accessor.cs" + } + } + }, + { + "match": "\\@?[_[:alpha:]][_[:alnum:]]*", + "name": "variable.other.constant.cs" + } + ] + }, + "relational-pattern": { + "begin": "<=?|>=?", + "beginCaptures": { "0": { - "name": "punctuation.curlybrace.close.cs" + "name": "keyword.operator.relational.cs" } }, + "end": "(?=[)}\\],;:?=&|^]|!=|\\b(and|or|when)\\b)", "patterns": [ { "include": "#expression" - }, - { - "include": "#punctuation-comma" } ] }, - "switch-var-pattern": { - "begin": "(?x) # match foreach (var (x, y) in ...)\n(?:\\b(var)\\b\\s*)\n(?\\((?:[^\\(\\)]|\\g)+\\))\\s*", + "var-pattern": { + "begin": "\\b(var)\\b", "beginCaptures": { "1": { - "name": "keyword.other.var.cs" + "name": "storage.type.var.cs" + } + }, + "end": "(?=[)}\\],;:?=&|^]|!=|\\b(and|or|when)\\b)", + "patterns": [ + { + "include": "#designation-pattern" + } + ] + }, + "designation-pattern": { + "patterns": [ + { + "include": "#intrusive" }, - "2": { + { + "begin": "\\(", + "beginCaptures": { + "0": { + "name": "punctuation.parenthesis.open.cs" + } + }, + "end": "\\)", + "endCaptures": { + "0": { + "name": "punctuation.parenthesis.close.cs" + } + }, + "patterns": [ + { + "include": "#punctuation-comma" + }, + { + "include": "#designation-pattern" + } + ] + }, + { + "include": "#simple-designation-pattern" + } + ] + }, + "simple-designation-pattern": { + "patterns": [ + { + "include": "#discard-pattern" + }, + { + "match": "@?[_[:alpha:]][_[:alnum:]]*", + "name": "entity.name.variable.local.cs" + } + ] + }, + "type-pattern": { + "begin": "(?=@?[_[:alpha:]][_[:alnum:]]*)", + "end": "(?=[)}\\],;:?=&|^]|!=|\\b(and|or|when)\\b)", + "patterns": [ + { + "begin": "\\G", + "end": "(?!\\G[@_[:alpha:]])(?=[\\({@_[:alpha:])}\\],;:=&|^]|(?:\\s|^)\\?|!=|\\b(and|or|when)\\b)", + "patterns": [ + { + "include": "#intrusive" + }, + { + "include": "#type-subpattern" + } + ] + }, + { + "begin": "(?=[\\({@_[:alpha:]])", + "end": "(?=[)}\\],;:?=&|^]|!=|\\b(and|or|when)\\b)", + "patterns": [ + { + "include": "#intrusive" + }, + { + "include": "#positional-pattern" + }, + { + "include": "#property-pattern" + }, + { + "include": "#simple-designation-pattern" + } + ] + } + ] + }, + "type-subpattern": { + "patterns": [ + { + "include": "#type-builtin" + }, + { + "begin": "(@?[_[:alpha:]][_[:alnum:]]*)\\s*(::)", + "beginCaptures": { + "1": { + "name": "entity.name.type.alias.cs" + }, + "2": { + "name": "punctuation.separator.coloncolon.cs" + } + }, + "end": "(?<=[_[:alnum:]])|(?=[.<\\[\\({)}\\],;:?=&|^]|!=|\\b(and|or|when)\\b)", + "patterns": [ + { + "include": "#intrusive" + }, + { + "match": "\\@?[_[:alpha:]][_[:alnum:]]*", + "name": "entity.name.type.cs" + } + ] + }, + { + "match": "\\@?[_[:alpha:]][_[:alnum:]]*", + "name": "entity.name.type.cs" + }, + { + "begin": "\\.", + "beginCaptures": { + "0": { + "name": "punctuation.accessor.cs" + } + }, + "end": "(?<=[_[:alnum:]])|(?=[<\\[\\({)}\\],;:?=&|^]|!=|\\b(and|or|when)\\b)", + "patterns": [ + { + "include": "#intrusive" + }, + { + "match": "\\@?[_[:alpha:]][_[:alnum:]]*", + "name": "entity.name.type.cs" + } + ] + }, + { + "include": "#type-arguments" + }, + { + "include": "#type-array-suffix" + }, + { + "match": "(?)", - "patterns": [ - { - "include": "#comment" }, { - "include": "#switch-when-clause" + "begin": "(?<=\\})", + "end": "(?=[)}\\],;:?=&|^]|!=|\\b(and|or|when)\\b)", + "patterns": [ + { + "include": "#intrusive" + }, + { + "include": "#simple-designation-pattern" + } + ] } ] }, - "switch-when-clause": { - "begin": "(?)", + "subpattern": { "patterns": [ { - "include": "#comment" - }, - { - "include": "#expression" - }, - { - "include": "#punctuation-comma" - }, - { - "match": "\\(", + "match": "(@?[_[:alpha:]][_[:alnum:]]*(?:\\s*\\.\\s*@?[_[:alpha:]][_[:alnum:]]*)*)\\s*(:)", "captures": { - "0": { - "name": "punctuation.parenthesis.open.cs" + "1": { + "patterns": [ + { + "match": "\\@?[_[:alpha:]][_[:alnum:]]*", + "name": "variable.other.object.property.cs" + }, + { + "include": "#punctuation-accessor" + } + ] + }, + "2": { + "name": "punctuation.separator.colon.cs" } } }, { - "match": "\\)", - "captures": { - "0": { - "name": "punctuation.parenthesis.close.cs" - } - } + "include": "#pattern" } ] }, - "switch-label": { + "list-pattern": { + "begin": "(?=\\[)", + "end": "(?=[)}\\],;:?=&|^]|!=|\\b(and|or|when)\\b)", "patterns": [ { - "begin": "(?\n (?:\n (?:\n (?:(?@?[_[:alpha:]][_[:alnum:]]*)\\s*\\:\\:\\s*)? # alias-qualification\n (? # identifier + type arguments (if any)\n \\g\\s*\n (?\\s*<(?:[^<>]|\\g)+>\\s*)?\n )\n (?:\\s*\\.\\s*\\g)* | # Are there any more names being dotted into?\n (?\\s*\\((?:[^\\(\\)]|\\g)+\\))\n )\n (?:\\s*\\?\\s*)? # nullable suffix?\n (?:\\s* # array suffix?\n \\[\n (?:\\s*,\\s*)* # commata for multi-dimensional arrays\n \\]\n \\s*\n (?:\\?)? # arrays can be nullable reference types\n \\s*\n )*\n )\n )\n)\\s+\n(\\g)\\s+\n\\b(in)\\b", "captures": { "1": { - "name": "keyword.other.var.cs" + "name": "storage.type.var.cs" }, "2": { "patterns": [ @@ -2176,7 +2719,7 @@ "match": "(?x) # match foreach (var (x, y) in ...)\n(?:\\b(var)\\b\\s*)?\n(?\\((?:[^\\(\\)]|\\g)+\\))\\s+\n\\b(in)\\b", "captures": { "1": { - "name": "keyword.other.var.cs" + "name": "storage.type.var.cs" }, "2": { "patterns": [ @@ -2194,9 +2737,6 @@ "include": "#expression" } ] - }, - { - "include": "#statement" } ] }, @@ -2217,7 +2757,7 @@ "begin": "(?\n (?:\n (?:ref\\s+(?:readonly\\s+)?)? # ref local\n (?:\n (?:(?@?[_[:alpha:]][_[:alnum:]]*)\\s*\\:\\:\\s*)? # alias-qualification\n (? # identifier + type arguments (if any)\n \\g\\s*\n (?\\s*<(?:[^<>]|\\g)+>\\s*)?\n )\n (?:\\s*\\.\\s*\\g)* | # Are there any more names being dotted into?\n (?\\s*\\((?:[^\\(\\)]|\\g)+\\))\n )\n (?:\\s*\\?\\s*)? # nullable suffix?\n (?:\\s* # array suffix?\n \\[\n (?:\\s*,\\s*)* # commata for multi-dimensional arrays\n \\]\n \\s*\n (?:\\?)? # arrays can be nullable reference types\n \\s*\n )*\n )\n )\n)\\s+\n(\\g)\\s*\n(?!=>)\n(?=,|;|=|\\))", + "begin": "(?x)\n(?:\n (?:(\\bref)\\s+(?:(\\breadonly)\\s+)?)?(\\bvar\\b)| # ref local\n (?\n (?:\n (?:ref\\s+(?:readonly\\s+)?)? # ref local\n (?:\n (?:(?@?[_[:alpha:]][_[:alnum:]]*)\\s*\\:\\:\\s*)? # alias-qualification\n (? # identifier + type arguments (if any)\n \\g\\s*\n (?\\s*<(?:[^<>]|\\g)+>\\s*)?\n )\n (?:\\s*\\.\\s*\\g)* | # Are there any more names being dotted into?\n (?\\s*\\((?:[^\\(\\)]|\\g)+\\))\n )\n (?:\\s*[?*]\\s*)? # nullable or pointer suffix?\n (?:\\s* # array suffix?\n \\[\n (?:\\s*,\\s*)* # commata for multi-dimensional arrays\n \\]\n \\s*\n (?:\\?)? # arrays can be nullable reference types\n \\s*\n )*\n )\n )\n)\\s+\n(\\g)\\s*\n(?!=>)\n(?=,|;|=|\\))", "beginCaptures": { "1": { - "name": "keyword.other.using.cs" + "name": "storage.modifier.ref.cs" }, "2": { - "name": "storage.modifier.cs" + "name": "storage.modifier.readonly.cs" }, "3": { - "name": "storage.modifier.cs" + "name": "storage.type.var.cs" }, "4": { - "name": "keyword.other.var.cs" - }, - "5": { "patterns": [ { "include": "#type" } ] }, - "10": { + "9": { "name": "entity.name.variable.local.cs" } }, - "end": "(?=;|\\))", + "end": "(?=[;)}])", "patterns": [ { "name": "entity.name.variable.local.cs", @@ -2486,7 +3068,7 @@ "begin": "(?x)\n(?\\b(?:const)\\b)\\s*\n(?\n (?:\n (?:\n (?:(?@?[_[:alpha:]][_[:alnum:]]*)\\s*\\:\\:\\s*)? # alias-qualification\n (? # identifier + type arguments (if any)\n \\g\\s*\n (?\\s*<(?:[^<>]|\\g)+>\\s*)?\n )\n (?:\\s*\\.\\s*\\g)* | # Are there any more names being dotted into?\n (?\\s*\\((?:[^\\(\\)]|\\g)+\\))\n )\n (?:\\s*\\?\\s*)? # nullable suffix?\n (?:\\s* # array suffix?\n \\[\n (?:\\s*,\\s*)* # commata for multi-dimensional arrays\n \\]\n \\s*\n (?:\\?)? # arrays can be nullable reference types\n \\s*\n )*\n )\n)\\s+\n(\\g)\\s*\n(?=,|;|=)", "beginCaptures": { "1": { - "name": "storage.modifier.cs" + "name": "storage.modifier.const.cs" }, "2": { "patterns": [ @@ -2517,9 +3099,49 @@ ] }, "local-function-declaration": { + "begin": "(?x)\n\\b((?:(?:async|unsafe|static|extern)\\s+)*)\n(?\n (?:ref\\s+(?:readonly\\s+)?)? # ref return\n (?:\n (?:(?@?[_[:alpha:]][_[:alnum:]]*)\\s*\\:\\:\\s*)? # alias-qualification\n (? # identifier + type arguments (if any)\n \\g\\s*\n (?\\s*<(?:[^<>]|\\g)+>\\s*)?\n )\n (?:\\s*\\.\\s*\\g)* | # Are there any more names being dotted into?\n (?\\s*\\((?:[^\\(\\)]|\\g)+\\))\n )\n (?:\\s*\\?)? # nullable suffix?\n (?:\\s* # array suffix?\n \\[\n \\s*(?:,\\s*)* # commata for multi-dimensional arrays\n \\]\n (?:\\s*\\?)? # arrays can be nullable reference types\n )*\n)\\s+\n(\\g)\\s*\n(<[^<>]+>)?\\s*\n(?=\\()", + "beginCaptures": { + "1": { + "patterns": [ + { + "include": "#storage-modifier" + } + ] + }, + "2": { + "patterns": [ + { + "include": "#type" + } + ] + }, + "7": { + "name": "entity.name.function.cs" + }, + "8": { + "patterns": [ + { + "include": "#type-parameter-list" + } + ] + } + }, + "end": "(?<=\\})|(?=;)", "patterns": [ { - "include": "#method-declaration" + "include": "#comment" + }, + { + "include": "#parenthesized-parameter-list" + }, + { + "include": "#generic-constraints" + }, + { + "include": "#expression-body" + }, + { + "include": "#block" } ] }, @@ -2527,7 +3149,7 @@ "begin": "(?x) # e.g. var (x, y) = GetPoint();\n(?:\\b(var)\\b\\s*)\n(?\\((?:[^\\(\\)]|\\g)+\\))\\s*\n(?=;|=|\\))", "beginCaptures": { "1": { - "name": "keyword.other.var.cs" + "name": "storage.type.var.cs" }, "2": { "patterns": [ @@ -2635,7 +3257,7 @@ "match": "(?x) # e.g. int x OR var x\n(?:\n \\b(var)\\b|\n (?\n (?:\n (?:\n (?:(?@?[_[:alpha:]][_[:alnum:]]*)\\s*\\:\\:\\s*)? # alias-qualification\n (? # identifier + type arguments (if any)\n \\g\\s*\n (?\\s*<(?:[^<>]|\\g)+>\\s*)?\n )\n (?:\\s*\\.\\s*\\g)* | # Are there any more names being dotted into?\n (?\\s*\\((?:[^\\(\\)]|\\g)+\\))\n )\n (?:\\s*\\?\\s*)? # nullable suffix?\n (?:\\s* # array suffix?\n \\[\n (?:\\s*,\\s*)* # commata for multi-dimensional arrays\n \\]\n \\s*\n (?:\\?)? # arrays can be nullable reference types\n \\s*\n )*\n )\n )\n)\\s+\n(\\g)\\b\\s*\n(?=[,)\\]])", "captures": { "1": { - "name": "keyword.other.var.cs" + "name": "storage.type.var.cs" }, "2": { "patterns": [ @@ -2653,7 +3275,7 @@ "match": "(?x) # e.g. int x OR var x\n(?:\n \\b(var)\\b|\n (?\n (?:\n (?:\n (?:(?@?[_[:alpha:]][_[:alnum:]]*)\\s*\\:\\:\\s*)? # alias-qualification\n (? # identifier + type arguments (if any)\n \\g\\s*\n (?\\s*<(?:[^<>]|\\g)+>\\s*)?\n )\n (?:\\s*\\.\\s*\\g)* | # Are there any more names being dotted into?\n (?\\s*\\((?:[^\\(\\)]|\\g)+\\))\n )\n (?:\\s*\\?\\s*)? # nullable suffix?\n (?:\\s* # array suffix?\n \\[\n (?:\\s*,\\s*)* # commata for multi-dimensional arrays\n \\]\n \\s*\n (?:\\?)? # arrays can be nullable reference types\n \\s*\n )*\n )\n )\n)\\s+\n(\\g)\\b\\s*\n(?=[,)])", "captures": { "1": { - "name": "keyword.other.var.cs" + "name": "storage.type.var.cs" }, "2": { "patterns": [ @@ -2667,16 +3289,13 @@ } } }, - "checked-unchecked-expression": { - "begin": "(?>>?|\\|)?=(?!=|>)", + "beginCaptures": { + "0": { + "patterns": [ + { + "include": "#assignment-operators" + } + ] + } + }, + "end": "(?=[,\\)\\];}])", + "patterns": [ + { + "include": "#ref-modifier" + }, + { + "include": "#expression" + } + ] + }, + "assignment-operators": { "patterns": [ { "name": "keyword.operator.assignment.compound.cs", @@ -3391,11 +4006,19 @@ }, { "name": "keyword.operator.assignment.compound.bitwise.cs", - "match": "\\&=|\\^=|<<=|>>=|\\|=" + "match": "\\&=|\\^=|<<=|>>>?=|\\|=" }, + { + "name": "keyword.operator.assignment.cs", + "match": "\\=" + } + ] + }, + "expression-operators": { + "patterns": [ { "name": "keyword.operator.bitwise.shift.cs", - "match": "<<|>>" + "match": "<<|>>>?" }, { "name": "keyword.operator.comparison.cs", @@ -3413,10 +4036,6 @@ "name": "keyword.operator.bitwise.cs", "match": "\\&|~|\\^|\\|" }, - { - "name": "keyword.operator.assignment.cs", - "match": "\\=" - }, { "name": "keyword.operator.decrement.cs", "match": "--" @@ -3427,56 +4046,50 @@ }, { "name": "keyword.operator.arithmetic.cs", - "match": "%|\\*|/|-|\\+" + "match": "\\+|-(?!>)|\\*|/|%" }, { "name": "keyword.operator.null-coalescing.cs", "match": "\\?\\?" + }, + { + "name": "keyword.operator.range.cs", + "match": "\\.\\." } ] }, - "switch-literal": { - "name": "constant.language.null.cs", - "match": "(?\n (?:\n (?:\n (?:(?@?[_[:alpha:]][_[:alnum:]]*)\\s*\\:\\:\\s*)? # alias-qualification\n (? # identifier + type arguments (if any)\n \\g\\s*\n (?\\s*<(?:[^<>]|\\g)+>\\s*)?\n )\n (?:\\s*\\.\\s*\\g)* | # Are there any more names being dotted into?\n (?\\s*\\((?:[^\\(\\)]|\\g)+\\))\n )\n (?:\\s*\\?\\s*)? # nullable suffix?\n (?:\\s* # array suffix?\n \\[\n (?:\\s*,\\s*)* # commata for multi-dimensional arrays\n \\]\n \\s*\n (?:\\?)? # arrays can be nullable reference types\n \\s*\n )*\n )\n)?", - "captures": { - "1": { - "name": "keyword.other.as.cs" - }, - "2": { - "patterns": [ - { - "include": "#type" - } - ] - } - } - }, - "is-expression": { - "match": "(?x)\n(?\n (?:\n (?:\n (?:(?@?[_[:alpha:]][_[:alnum:]]*)\\s*\\:\\:\\s*)? # alias-qualification\n (? # identifier + type arguments (if any)\n \\g\\s*\n (?\\s*<(?:[^<>]|\\g)+>\\s*)?\n )\n (?:\\s*\\.\\s*\\g)* | # Are there any more names being dotted into?\n (?\\s*\\((?:[^\\(\\)]|\\g)+\\))\n )\n (?:\\s*\\?\\s*)? # nullable suffix?\n (?:\\s* # array suffix?\n \\[\n (?:\\s*,\\s*)* # commata for multi-dimensional arrays\n \\]\n \\s*\n (?:\\?)? # arrays can be nullable reference types\n \\s*\n )*\n )\n)?", + "match": "(?x)\n(?\n (?:\n (?:\n (?:(?@?[_[:alpha:]][_[:alnum:]]*)\\s*\\:\\:\\s*)? # alias-qualification\n (? # identifier + type arguments (if any)\n \\g\\s*\n (?\\s*<(?:[^<>]|\\g)+>\\s*)?\n )\n (?:\\s*\\.\\s*\\g)* | # Are there any more names being dotted into?\n (?\\s*\\((?:[^\\(\\)]|\\g)+\\))\n )\n (?:\\s*\\?(?!\\?))? # nullable suffix?\n (?:\\s* # array suffix?\n \\[\n \\s*(?:,\\s*)* # commata for multi-dimensional arrays\n \\]\n (?:\\s*\\?(?!\\?))? # arrays can be nullable reference types\n )*\n )\n)?", "captures": { "1": { - "name": "keyword.other.is.cs" + "name": "keyword.operator.expression.as.cs" }, "2": { "patterns": [ @@ -3571,19 +4169,20 @@ } } }, - "this-or-base-expression": { - "match": "\\b(?:(base)|(this))\\b", - "captures": { - "1": { - "name": "keyword.other.base.cs" + "language-variable": { + "patterns": [ + { + "name": "variable.language.$1.cs", + "match": "\\b(base|this)\\b" }, - "2": { - "name": "keyword.other.this.cs" + { + "name": "variable.other.$1.cs", + "match": "\\b(value)\\b" } - } + ] }, "invocation-expression": { - "begin": "(?x)\n(?:(\\?)\\s*)? # preceding null-conditional operator?\n(?:(\\.)\\s*)? # preceding dot?\n(@?[_[:alpha:]][_[:alnum:]]*)\\s* # method name\n(?\\s*<([^<>]|\\g)+>\\s*)?\\s* # type arguments\n(?=\\() # open paren of argument list", + "begin": "(?x)\n(?:\n (?:(\\?)\\s*)? # preceding null-conditional operator?\n (\\.)\\s*| # preceding dot?\n (->)\\s* # preceding pointer arrow?\n)?\n(@?[_[:alpha:]][_[:alnum:]]*)\\s* # method name\n(\n <\n (?\n [^<>()]++|\n <\\g*+>|\n \\(\\g*+\\)\n )*+\n >\\s*\n)? # type arguments\n(?=\\() # open paren of argument list", "beginCaptures": { "1": { "name": "keyword.operator.null-conditional.cs" @@ -3592,9 +4191,12 @@ "name": "punctuation.accessor.cs" }, "3": { - "name": "entity.name.function.cs" + "name": "punctuation.accessor.pointer.cs" }, "4": { + "name": "entity.name.function.cs" + }, + "5": { "patterns": [ { "include": "#type-arguments" @@ -3610,7 +4212,7 @@ ] }, "element-access-expression": { - "begin": "(?x)\n(?:(\\?)\\s*)? # preceding null-conditional operator?\n(?:(\\.)\\s*)? # preceding dot?\n(?:(@?[_[:alpha:]][_[:alnum:]]*)\\s*)? # property name\n(?:(\\?)\\s*)? # null-conditional operator?\n(?=\\[) # open bracket of argument list", + "begin": "(?x)\n(?:\n (?:(\\?)\\s*)? # preceding null-conditional operator?\n (\\.)\\s*| # preceding dot?\n (->)\\s* # preceding pointer arrow?\n)?\n(?:(@?[_[:alpha:]][_[:alnum:]]*)\\s*)? # property name\n(?:(\\?)\\s*)? # null-conditional operator?\n(?=\\[) # open bracket of argument list", "beginCaptures": { "1": { "name": "keyword.operator.null-conditional.cs" @@ -3619,9 +4221,12 @@ "name": "punctuation.accessor.cs" }, "3": { - "name": "variable.other.object.property.cs" + "name": "punctuation.accessor.pointer.cs" }, "4": { + "name": "variable.other.object.property.cs" + }, + "5": { "name": "keyword.operator.null-conditional.cs" } }, @@ -3635,7 +4240,7 @@ "member-access-expression": { "patterns": [ { - "match": "(?x)\n(?:(\\?)\\s*)? # preceding null-conditional operator?\n(\\.)\\s* # preceding dot\n(@?[_[:alpha:]][_[:alnum:]]*)\\s* # property name\n(?![_[:alnum:]]|\\(|(\\?)?\\[|<) # next character is not alpha-numeric, nor a (, [, or <. Also, test for ?[", + "match": "(?x)\n(?:\n (?:(\\?)\\s*)? # preceding null-conditional operator?\n (\\.)\\s*| # preceding dot?\n (->)\\s* # preceding pointer arrow?\n)\n(@?[_[:alpha:]][_[:alnum:]]*)\\s* # property name\n(?![_[:alnum:]]|\\(|(\\?)?\\[|<) # next character is not alpha-numeric, nor a (, [, or <. Also, test for ?[", "captures": { "1": { "name": "keyword.operator.null-conditional.cs" @@ -3644,6 +4249,9 @@ "name": "punctuation.accessor.cs" }, "3": { + "name": "punctuation.accessor.pointer.cs" + }, + "4": { "name": "variable.other.object.property.cs" } } @@ -3667,7 +4275,7 @@ } }, { - "match": "(?x)\n(@?[_[:alpha:]][_[:alnum:]]*)\n(?=\n (\\s*\\?)?\n \\s*\\.\\s*@?[_[:alpha:]][_[:alnum:]]*\n)", + "match": "(?x)\n(@?[_[:alpha:]][_[:alnum:]]*)\n(?=\n \\s*(?:(?:\\?\\s*)?\\.|->)\n \\s*@?[_[:alpha:]][_[:alnum:]]*\n)", "captures": { "1": { "name": "variable.other.object.cs" @@ -3690,7 +4298,7 @@ "begin": "(?x)\n(new)(?:\\s+\n(?\n (?:\n (?:\n (?:(?@?[_[:alpha:]][_[:alnum:]]*)\\s*\\:\\:\\s*)? # alias-qualification\n (? # identifier + type arguments (if any)\n \\g\\s*\n (?\\s*<(?:[^<>]|\\g)+>\\s*)?\n )\n (?:\\s*\\.\\s*\\g)* | # Are there any more names being dotted into?\n (?\\s*\\((?:[^\\(\\)]|\\g)+\\))\n )\n (?:\\s*\\?\\s*)? # nullable suffix?\n (?:\\s* # array suffix?\n \\[\n (?:\\s*,\\s*)* # commata for multi-dimensional arrays\n \\]\n \\s*\n (?:\\?)? # arrays can be nullable reference types\n \\s*\n )*\n )\n))?\\s*\n(?=\\()", "beginCaptures": { "1": { - "name": "keyword.other.new.cs" + "name": "keyword.operator.expression.new.cs" }, "2": { "patterns": [ @@ -3708,10 +4316,10 @@ ] }, "object-creation-expression-with-no-parameters": { - "match": "(?x)\n(new)\\s+\n(?\n (?:\n (?:\n (?:(?@?[_[:alpha:]][_[:alnum:]]*)\\s*\\:\\:\\s*)? # alias-qualification\n (? # identifier + type arguments (if any)\n \\g\\s*\n (?\\s*<(?:[^<>]|\\g)+>\\s*)?\n )\n (?:\\s*\\.\\s*\\g)* | # Are there any more names being dotted into?\n (?\\s*\\((?:[^\\(\\)]|\\g)+\\))\n )\n (?:\\s*\\?\\s*)? # nullable suffix?\n (?:\\s* # array suffix?\n \\[\n (?:\\s*,\\s*)* # commata for multi-dimensional arrays\n \\]\n \\s*\n (?:\\?)? # arrays can be nullable reference types\n \\s*\n )*\n )\n)\\s*\n(?=\\{|$)", + "match": "(?x)\n(new)\\s+\n(?\n (?:\n (?:\n (?:(?@?[_[:alpha:]][_[:alnum:]]*)\\s*\\:\\:\\s*)? # alias-qualification\n (? # identifier + type arguments (if any)\n \\g\\s*\n (?\\s*<(?:[^<>]|\\g)+>\\s*)?\n )\n (?:\\s*\\.\\s*\\g)* | # Are there any more names being dotted into?\n (?\\s*\\((?:[^\\(\\)]|\\g)+\\))\n )\n (?:\\s*\\?\\s*)? # nullable suffix?\n (?:\\s* # array suffix?\n \\[\n (?:\\s*,\\s*)* # commata for multi-dimensional arrays\n \\]\n \\s*\n (?:\\?)? # arrays can be nullable reference types\n \\s*\n )*\n )\n)\\s*\n(?=\\{|//|/\\*|$)", "captures": { "1": { - "name": "keyword.other.new.cs" + "name": "keyword.operator.expression.new.cs" }, "2": { "patterns": [ @@ -3726,7 +4334,7 @@ "begin": "(?x)\n\\b(new|stackalloc)\\b\\s*\n(?\n (?:\n (?:\n (?:(?@?[_[:alpha:]][_[:alnum:]]*)\\s*\\:\\:\\s*)? # alias-qualification\n (? # identifier + type arguments (if any)\n \\g\\s*\n (?\\s*<(?:[^<>]|\\g)+>\\s*)?\n )\n (?:\\s*\\.\\s*\\g)* | # Are there any more names being dotted into?\n (?\\s*\\((?:[^\\(\\)]|\\g)+\\))\n )\n (?:\\s*\\?\\s*)? # nullable suffix?\n (?:\\s* # array suffix?\n \\[\n (?:\\s*,\\s*)* # commata for multi-dimensional arrays\n \\]\n \\s*\n (?:\\?)? # arrays can be nullable reference types\n \\s*\n )*\n )\n)?\\s*\n(?=\\[)", "beginCaptures": { "1": { - "name": "keyword.other.new.cs" + "name": "keyword.operator.expression.$1.cs" }, "2": { "patterns": [ @@ -3744,14 +4352,17 @@ ] }, "anonymous-object-creation-expression": { - "begin": "\\b(new)\\b\\s*(?=\\{|$)", + "begin": "\\b(new)\\b\\s*(?=\\{|//|/\\*|$)", "beginCaptures": { "1": { - "name": "keyword.other.new.cs" + "name": "keyword.operator.expression.new.cs" } }, "end": "(?<=\\})", "patterns": [ + { + "include": "#comment" + }, { "include": "#initializer-expression" } @@ -3826,10 +4437,10 @@ ] }, "parameter": { - "match": "(?x)\n(?:(?:\\b(ref|params|out|in|this)\\b)\\s+)?\n(?\n (?:\n (?:ref\\s+)? # ref return\n (?:\n (?:(?@?[_[:alpha:]][_[:alnum:]]*)\\s*\\:\\:\\s*)? # alias-qualification\n (? # identifier + type arguments (if any)\n \\g\\s*\n (?\\s*<(?:[^<>]|\\g)+>\\s*)?\n )\n (?:\\s*\\.\\s*\\g)* | # Are there any more names being dotted into?\n (?\\s*\\((?:[^\\(\\)]|\\g)+\\))\n )\n (?:\\s*\\?\\s*)? # nullable suffix?\n (?:\\s* # array suffix?\n \\[\n (?:\\s*,\\s*)* # commata for multi-dimensional arrays\n \\]\n \\s*\n (?:\\?)? # arrays can be nullable reference types\n \\s*\n )*\n )\n)\\s+\n(\\g)", + "match": "(?x)\n(?:(?:\\b(ref|params|out|in|this)\\b)\\s+)?\n(?\n (?:\n (?:ref\\s+)? # ref return\n (?:\n (?:(?@?[_[:alpha:]][_[:alnum:]]*)\\s*\\:\\:\\s*)? # alias-qualification\n (? # identifier + type arguments (if any)\n \\g\\s*\n (?\\s*<(?:[^<>]|\\g)+>\\s*)?\n )\n (?:\\s*\\.\\s*\\g)* | # Are there any more names being dotted into?\n (?\\s*\\((?:[^()]|\\g)+\\))\n )\n (?:\\s*\\?\\s*)? # nullable suffix?\n (?:\\s* # array suffix?\n \\[\n (?:\\s*,\\s*)* # commata for multi-dimensional arrays\n \\]\n \\s*\n (?:\\?)? # arrays can be nullable reference types\n \\s*\n )*\n )\n)\\s+\n(\\g)", "captures": { "1": { - "name": "storage.modifier.cs" + "name": "storage.modifier.$1.cs" }, "2": { "patterns": [ @@ -3913,11 +4524,25 @@ "argument": { "patterns": [ { - "name": "storage.modifier.cs", - "match": "\\b(ref|out|in)\\b" + "name": "storage.modifier.$1.cs", + "match": "\\b(ref|in)\\b" }, { - "include": "#declaration-expression-local" + "begin": "\\b(out)\\b", + "beginCaptures": { + "1": { + "name": "storage.modifier.out.cs" + } + }, + "end": "(?=,|\\)|\\])", + "patterns": [ + { + "include": "#declaration-expression-local" + }, + { + "include": "#expression" + } + ] }, { "include": "#expression" @@ -3928,7 +4553,7 @@ "begin": "(?x)\n\\b(from)\\b\\s*\n(?\n (?:\n (?:\n (?:(?@?[_[:alpha:]][_[:alnum:]]*)\\s*\\:\\:\\s*)? # alias-qualification\n (? # identifier + type arguments (if any)\n \\g\\s*\n (?\\s*<(?:[^<>]|\\g)+>\\s*)?\n )\n (?:\\s*\\.\\s*\\g)* | # Are there any more names being dotted into?\n (?\\s*\\((?:[^\\(\\)]|\\g)+\\))\n )\n (?:\\s*\\?\\s*)? # nullable suffix?\n (?:\\s* # array suffix?\n \\[\n (?:\\s*,\\s*)* # commata for multi-dimensional arrays\n \\]\n \\s*\n (?:\\?)? # arrays can be nullable reference types\n \\s*\n )*\n )\n)?\n\\s+(\\g)\\b\\s*\n\\b(in)\\b\\s*", "beginCaptures": { "1": { - "name": "keyword.query.from.cs" + "name": "keyword.operator.expression.query.from.cs" }, "2": { "patterns": [ @@ -3941,7 +4566,7 @@ "name": "entity.name.variable.range-variable.cs" }, "8": { - "name": "keyword.query.in.cs" + "name": "keyword.operator.expression.query.in.cs" } }, "end": "(?=;|\\))", @@ -3980,7 +4605,7 @@ "begin": "(?x)\n\\b(let)\\b\\s*\n(@?[_[:alpha:]][_[:alnum:]]*)\\b\\s*\n(=)\\s*", "beginCaptures": { "1": { - "name": "keyword.query.let.cs" + "name": "keyword.operator.expression.query.let.cs" }, "2": { "name": "entity.name.variable.range-variable.cs" @@ -4003,7 +4628,7 @@ "begin": "(?x)\n\\b(where)\\b\\s*", "beginCaptures": { "1": { - "name": "keyword.query.where.cs" + "name": "keyword.operator.expression.query.where.cs" } }, "end": "(?=;|\\))", @@ -4020,7 +4645,7 @@ "begin": "(?x)\n\\b(join)\\b\\s*\n(?\n (?:\n (?:\n (?:(?@?[_[:alpha:]][_[:alnum:]]*)\\s*\\:\\:\\s*)? # alias-qualification\n (? # identifier + type arguments (if any)\n \\g\\s*\n (?\\s*<(?:[^<>]|\\g)+>\\s*)?\n )\n (?:\\s*\\.\\s*\\g)* | # Are there any more names being dotted into?\n (?\\s*\\((?:[^\\(\\)]|\\g)+\\))\n )\n (?:\\s*\\?\\s*)? # nullable suffix?\n (?:\\s* # array suffix?\n \\[\n (?:\\s*,\\s*)* # commata for multi-dimensional arrays\n \\]\n \\s*\n (?:\\?)? # arrays can be nullable reference types\n \\s*\n )*\n )\n)?\n\\s+(\\g)\\b\\s*\n\\b(in)\\b\\s*", "beginCaptures": { "1": { - "name": "keyword.query.join.cs" + "name": "keyword.operator.expression.query.join.cs" }, "2": { "patterns": [ @@ -4033,7 +4658,7 @@ "name": "entity.name.variable.range-variable.cs" }, "8": { - "name": "keyword.query.in.cs" + "name": "keyword.operator.expression.query.in.cs" } }, "end": "(?=;|\\))", @@ -4059,7 +4684,7 @@ "match": "\\b(on)\\b\\s*", "captures": { "1": { - "name": "keyword.query.on.cs" + "name": "keyword.operator.expression.query.on.cs" } } }, @@ -4067,7 +4692,7 @@ "match": "\\b(equals)\\b\\s*", "captures": { "1": { - "name": "keyword.query.equals.cs" + "name": "keyword.operator.expression.query.equals.cs" } } }, @@ -4075,7 +4700,7 @@ "match": "(?x)\n\\b(into)\\b\\s*\n(@?[_[:alpha:]][_[:alnum:]]*)\\b\\s*", "captures": { "1": { - "name": "keyword.query.into.cs" + "name": "keyword.operator.expression.query.into.cs" }, "2": { "name": "entity.name.variable.range-variable.cs" @@ -4086,7 +4711,7 @@ "begin": "\\b(orderby)\\b\\s*", "beginCaptures": { "1": { - "name": "keyword.query.orderby.cs" + "name": "keyword.operator.expression.query.orderby.cs" } }, "end": "(?=;|\\))", @@ -4106,13 +4731,10 @@ ] }, "ordering-direction": { - "match": "\\b(?:(ascending)|(descending))\\b", + "match": "\\b(ascending|descending)\\b", "captures": { "1": { - "name": "keyword.query.ascending.cs" - }, - "2": { - "name": "keyword.query.descending.cs" + "name": "keyword.operator.expression.query.$1.cs" } } }, @@ -4120,7 +4742,7 @@ "begin": "\\b(select)\\b\\s*", "beginCaptures": { "1": { - "name": "keyword.query.select.cs" + "name": "keyword.operator.expression.query.select.cs" } }, "end": "(?=;|\\))", @@ -4137,7 +4759,7 @@ "begin": "\\b(group)\\b\\s*", "beginCaptures": { "1": { - "name": "keyword.query.group.cs" + "name": "keyword.operator.expression.query.group.cs" } }, "end": "(?=;|\\))", @@ -4160,7 +4782,7 @@ "match": "\\b(by)\\b\\s*", "captures": { "1": { - "name": "keyword.query.by.cs" + "name": "keyword.operator.expression.query.by.cs" } } }, @@ -4168,7 +4790,7 @@ "match": "(?x)\n\\b(into)\\b\\s*\n(@?[_[:alpha:]][_[:alnum:]]*)\\b\\s*", "captures": { "1": { - "name": "keyword.query.into.cs" + "name": "keyword.operator.expression.query.into.cs" }, "2": { "name": "entity.name.variable.range-variable.cs" @@ -4178,119 +4800,138 @@ "anonymous-method-expression": { "patterns": [ { - "begin": "(?x)\n(?:\\b(async)\\b\\s*)?\n(@?[_[:alpha:]][_[:alnum:]]*)\\b\\s*\n(=>)", + "begin": "(?x)\n((?:\\b(?:async|static)\\b\\s*)*)\n(?:\n (@?[_[:alpha:]][_[:alnum:]]*)\\b|\n (\\()\n (?(?:[^()]|\\(\\g\\))*)\n (\\))\n)\\s*\n(=>)", "beginCaptures": { "1": { - "name": "storage.modifier.cs" + "patterns": [ + { + "match": "async|static", + "name": "storage.modifier.$0.cs" + } + ] }, "2": { "name": "entity.name.variable.parameter.cs" }, "3": { - "name": "keyword.operator.arrow.cs" - } - }, - "end": "(?=\\)|;|}|,)", - "patterns": [ - { - "include": "#block" - }, - { - "include": "#ref-modifier" - }, - { - "include": "#expression" - } - ] - }, - { - "begin": "(?x)\n(?:\\b(async)\\b\\s*)?\n(\\(.*?\\))\\s*\n(=>)", - "beginCaptures": { - "1": { - "name": "storage.modifier.cs" + "name": "punctuation.parenthesis.open.cs" }, - "2": { + "4": { "patterns": [ { - "include": "#lambda-parameter-list" + "include": "#comment" + }, + { + "include": "#explicit-anonymous-function-parameter" + }, + { + "include": "#implicit-anonymous-function-parameter" + }, + { + "include": "#default-argument" + }, + { + "include": "#punctuation-comma" } ] }, - "3": { + "5": { + "name": "punctuation.parenthesis.close.cs" + }, + "6": { "name": "keyword.operator.arrow.cs" } }, - "end": "(?=\\)|;|}|,)", + "end": "(?=[,;)}])", "patterns": [ { - "include": "#block" + "include": "#intrusive" }, { - "include": "#ref-modifier" + "begin": "(?={)", + "end": "(?=[,;)}])", + "patterns": [ + { + "include": "#block" + }, + { + "include": "#intrusive" + } + ] }, { - "include": "#expression" + "begin": "\\b(ref)\\b|(?=\\S)", + "beginCaptures": { + "1": { + "name": "storage.modifier.ref.cs" + } + }, + "end": "(?=[,;)}])", + "patterns": [ + { + "include": "#expression" + } + ] } ] }, { - "begin": "(?x)\n(?:\\b(async)\\b\\s*)?\n(?:\\b(delegate)\\b\\s*)", + "begin": "(?x)\n((?:\\b(?:async|static)\\b\\s*)*)\n\\b(delegate)\\b\\s*", "beginCaptures": { "1": { - "name": "storage.modifier.cs" + "patterns": [ + { + "match": "async|static", + "name": "storage.modifier.$0.cs" + } + ] }, "2": { - "name": "keyword.other.delegate.cs" + "name": "storage.type.delegate.cs" } }, - "end": "(?=\\)|;|}|,)", + "end": "(?<=})|(?=[,;)}])", "patterns": [ { - "include": "#parenthesized-parameter-list" + "include": "#intrusive" }, { - "include": "#block" + "begin": "\\(", + "beginCaptures": { + "0": { + "name": "punctuation.parenthesis.open.cs" + } + }, + "end": "\\)", + "endCaptures": { + "0": { + "name": "punctuation.parenthesis.close.cs" + } + }, + "patterns": [ + { + "include": "#intrusive" + }, + { + "include": "#explicit-anonymous-function-parameter" + }, + { + "include": "#punctuation-comma" + } + ] }, { - "include": "#expression" + "include": "#block" } ] } ] }, - "lambda-parameter-list": { - "begin": "\\(", - "beginCaptures": { - "0": { - "name": "punctuation.parenthesis.open.cs" - } - }, - "end": "\\)", - "endCaptures": { - "0": { - "name": "punctuation.parenthesis.close.cs" - } - }, - "patterns": [ - { - "include": "#comment" - }, - { - "include": "#attribute-section" - }, - { - "include": "#lambda-parameter" - }, - { - "include": "#punctuation-comma" - } - ] - }, - "lambda-parameter": { - "match": "(?x)\n(?:\\b(ref|out|in)\\b)?\\s*\n(?:(?\n (?:\n (?:\n (?:(?@?[_[:alpha:]][_[:alnum:]]*)\\s*\\:\\:\\s*)? # alias-qualification\n (? # identifier + type arguments (if any)\n \\g\\s*\n (?\\s*<(?:[^<>]|\\g)+>\\s*)?\n )\n (?:\\s*\\.\\s*\\g)* | # Are there any more names being dotted into?\n (?\\s*\\((?:[^\\(\\)]|\\g)+\\))\n )\n (?:\\s*\\?\\s*)? # nullable suffix?\n (?:\\s* # array suffix?\n \\[\n (?:\\s*,\\s*)* # commata for multi-dimensional arrays\n \\]\n \\s*\n (?:\\?)? # arrays can be nullable reference types\n \\s*\n )*\n )\n)\\s+)?\n(\\g)\\b\\s*\n(?=[,)])", + "explicit-anonymous-function-parameter": { + "match": "(?x)\n(?:\\b(ref|params|out|in)\\b\\s*)?\n(?\n (?:\n (?:\n (?:(?@?[_[:alpha:]][_[:alnum:]]*)\\s*\\:\\:\\s*)? # alias-qualification\n (? # identifier + type arguments (if any)\n \\g\\s*\n (?<(?:[^<>]|\\g)*>\\s*)?\n )\n (?:\\s*\\.\\s*\\g)* | # Are there any more names being dotted into?\n (?\\s*\\((?:[^()]|\\g)*\\))\n )\n (?:\\s*\\?\\s*)? # nullable suffix?\n (?:\\s* # array suffix?\n \\[\n (?:\\s*,\\s*)* # commata for multi-dimensional arrays\n \\]\n \\s*\n (?:\\?)? # arrays can be nullable reference types\n \\s*\n )*\n )\n)\\s*\n\\b(\\g)\\b", "captures": { "1": { - "name": "storage.modifier.cs" + "name": "storage.modifier.$1.cs" }, "2": { "patterns": [ @@ -4304,8 +4945,25 @@ } } }, + "implicit-anonymous-function-parameter": { + "match": "\\@?[_[:alpha:]][_[:alnum:]]*\\b", + "name": "entity.name.variable.parameter.cs" + }, + "default-argument": { + "begin": "=", + "beginCaptures": { + "0": { + "name": "keyword.operator.assignment.cs" + } + }, + "end": "(?=,|\\))", + "patterns": [ + { + "include": "#expression" + } + ] + }, "type": { - "name": "meta.type.cs", "patterns": [ { "include": "#comment" @@ -4333,16 +4991,19 @@ }, { "include": "#type-nullable-suffix" + }, + { + "include": "#type-pointer-suffix" } ] }, "ref-modifier": { - "name": "storage.modifier.cs", - "match": "\\b(ref)\\b" + "name": "storage.modifier.ref.cs", + "match": "\\bref\\b" }, "readonly-modifier": { - "name": "storage.modifier.cs", - "match": "\\b(readonly)\\b" + "name": "storage.modifier.readonly.cs", + "match": "\\breadonly\\b" }, "tuple-type": { "begin": "\\(", @@ -4382,10 +5043,10 @@ } }, "type-builtin": { - "match": "\\b(bool|byte|char|decimal|double|float|int|long|object|sbyte|short|string|uint|ulong|ushort|void|dynamic)\\b", + "match": "\\b(bool|s?byte|u?short|n?u?int|u?long|float|double|decimal|char|string|object|void|dynamic)\\b", "captures": { "1": { - "name": "keyword.type.cs" + "name": "keyword.type.$1.cs" } } }, @@ -4444,9 +5105,6 @@ } }, "patterns": [ - { - "include": "#comment" - }, { "include": "#type" }, @@ -4469,6 +5127,9 @@ } }, "patterns": [ + { + "include": "#intrusive" + }, { "include": "#punctuation-comma" } @@ -4476,11 +5137,11 @@ }, "type-nullable-suffix": { "match": "\\?", - "captures": { - "0": { - "name": "punctuation.separator.question-mark.cs" - } - } + "name": "punctuation.separator.question-mark.cs" + }, + "type-pointer-suffix": { + "match": "\\*", + "name": "punctuation.separator.asterisk.cs" }, "operator-assignment": { "name": "keyword.operator.assignment.cs", @@ -4498,6 +5159,16 @@ "name": "punctuation.accessor.cs", "match": "\\." }, + "intrusive": { + "patterns": [ + { + "include": "#preprocessor" + }, + { + "include": "#comment" + } + ] + }, "preprocessor": { "name": "meta.preprocessor.cs", "begin": "^\\s*(\\#)\\s*", @@ -4803,38 +5474,47 @@ "comment": { "patterns": [ { - "name": "comment.block.cs", - "begin": "/\\*", - "beginCaptures": { - "0": { + "name": "comment.block.documentation.cs", + "begin": "(^\\s+)?(///)(?!/)", + "while": "^(\\s*)(///)(?!/)", + "captures": { + "1": { + "name": "punctuation.whitespace.comment.leading.cs" + }, + "2": { "name": "punctuation.definition.comment.cs" } }, - "end": "\\*/", - "endCaptures": { - "0": { - "name": "punctuation.definition.comment.cs" + "patterns": [ + { + "include": "#xml-doc-comment" } - } + ] }, { - "begin": "(^\\s+)?(?=//)", - "beginCaptures": { + "name": "comment.block.documentation.cs", + "begin": "(^\\s+)?(/\\*\\*)(?!/)", + "end": "(^\\s+)?(\\*/)", + "captures": { "1": { "name": "punctuation.whitespace.comment.leading.cs" + }, + "2": { + "name": "punctuation.definition.comment.cs" } }, - "end": "(?=$)", "patterns": [ { - "name": "comment.block.documentation.cs", - "begin": "(??@^|/])///(?!/)", + "while": "(??@^|/])///(?!/)", "patterns": [ { "include": "text.html.markdown" @@ -600,7 +600,7 @@ }, { "name": "comment.line.double-slash.fsharp", - "match": "//.*$" + "match": "(??@^|/])//(?![!%&+-.<=>?@^|]).*$" } ] }, @@ -1125,7 +1125,7 @@ }, { "name": "keyword.symbol.fsharp", - "match": "(&&&|\\|\\|\\||\\^\\^\\^|~~~|<<<|>>>|\\|>|:>|:\\?>|:|\\[|\\]|\\;|<>|=|@|\\|\\||&&|{|}|\\||_|\\.\\.|\\,|\\+|\\-|\\*|\\/|\\^|\\!|\\>|\\>\\=|\\>\\>|\\<|\\<\\=|\\(|\\)|\\<\\<)" + "match": "(&&&|\\|\\|\\||\\^\\^\\^|~~~|~\\+|~\\-|<<<|>>>|\\|>|:>|:\\?>|:|\\[|\\]|\\;|<>|=|@|\\|\\||&&|&|%|{|}|\\||_|\\.\\.|\\,|\\+|\\-|\\*|\\/|\\^|\\!|\\>|\\>\\=|\\>\\>|\\<|\\<\\=|\\(|\\)|\\<\\<)" } ] }, @@ -1133,7 +1133,7 @@ "patterns": [ { "name": "entity.name.section.fsharp", - "begin": "\\b(namespace global)|\\b(namespace|module)\\s*(public|internal|private|rec)?\\s+([[:alpha:]][[:alpha:]0-9'_. ]*)", + "begin": "\\b(namespace global)|\\b(namespace|module)\\s*(public|internal|private|rec)?\\s+([[:alpha:]|``][[:alpha:]0-9'_. ]*)", "end": "(\\s?=|\\s|$)", "beginCaptures": { "1": { @@ -1171,7 +1171,7 @@ }, { "name": "namespace.open.fsharp", - "begin": "\\b(open type|open)\\s+([[:alpha:]][[:alpha:]0-9'_]*)(?=(\\.[A-Z][[:alpha:]0-9_]*)*)", + "begin": "\\b(open type|open)\\s+([[:alpha:]|``][[:alpha:]0-9'_]*)(?=(\\.[A-Z][[:alpha:]0-9_]*)*)", "end": "(\\s|$)", "beginCaptures": { "1": { @@ -1331,7 +1331,7 @@ "match": "\\(\\)" }, { - "match": "(\\?{0,1})(``[[:alpha:]0-9'`^:,._ ]+``|(?!private\\b)\\b[\\w[:alpha:]0-9'`<>^._ ]+)", + "match": "(\\?{0,1})(``[[:alpha:]0-9'`^:,._ ]+``|(?!private|struct\\b)\\b[\\w[:alpha:]0-9'`<>^._ ]+)", "captures": { "1": { "name": "keyword.symbol.fsharp" diff --git a/extensions/git/src/model.ts b/extensions/git/src/model.ts index 250008ee31167..4632cd83bb3e3 100644 --- a/extensions/git/src/model.ts +++ b/extensions/git/src/model.ts @@ -602,8 +602,8 @@ export class Model implements IRepositoryResolver, IBranchProtectionProviderRegi } async openParentRepository(repoPath: string): Promise { - await this.openRepository(repoPath); this._parentRepositoriesManager.openRepository(repoPath); + await this.openRepository(repoPath); } private async getRepositoryRoot(repoPath: string): Promise<{ repositoryRoot: string; unsafeRepositoryMatch: RegExpMatchArray | null }> { diff --git a/extensions/r/syntaxes/r.tmLanguage.json b/extensions/r/syntaxes/r.tmLanguage.json index 88de4fd07d97f..d50ab5b6d78f3 100644 --- a/extensions/r/syntaxes/r.tmLanguage.json +++ b/extensions/r/syntaxes/r.tmLanguage.json @@ -639,4 +639,4 @@ ] } } -} +} \ No newline at end of file diff --git a/extensions/razor/build/update-grammar.mjs b/extensions/razor/build/update-grammar.mjs index db0ac9dbd6fb6..cacb9e79abc18 100644 --- a/extensions/razor/build/update-grammar.mjs +++ b/extensions/razor/build/update-grammar.mjs @@ -12,7 +12,7 @@ function patchGrammar(grammar) { } const razorGrammarRepo = 'dotnet/razor'; -const grammarPath = 'src/Razor/src/Microsoft.AspNetCore.Razor.VSCode.Extension/syntaxes/aspnetcorerazor.tmLanguage.json'; +const grammarPath = 'src/Razor/src/Microsoft.VisualStudio.RazorExtension/EmbeddedGrammars/aspnetcorerazor.tmLanguage.json'; vscodeGrammarUpdater.update(razorGrammarRepo, grammarPath, './syntaxes/cshtml.tmLanguage.json', grammar => patchGrammar(grammar), 'main'); diff --git a/extensions/razor/cgmanifest.json b/extensions/razor/cgmanifest.json index 799e12cf32529..e90c7d75d8c3a 100644 --- a/extensions/razor/cgmanifest.json +++ b/extensions/razor/cgmanifest.json @@ -6,7 +6,7 @@ "git": { "name": "dotnet/razor", "repositoryUrl": "https://github.com/dotnet/razor", - "commitHash": "69f60231df08319b544d3d32a588575acbb58ff0" + "commitHash": "b44d0a906d054d2d343adc3f58cbea11d97d7488" } }, "license": "MIT", diff --git a/extensions/razor/syntaxes/cshtml.tmLanguage.json b/extensions/razor/syntaxes/cshtml.tmLanguage.json index 0b5463ee3ca25..4594037960ac6 100644 --- a/extensions/razor/syntaxes/cshtml.tmLanguage.json +++ b/extensions/razor/syntaxes/cshtml.tmLanguage.json @@ -1,10 +1,10 @@ { "information_for_contributors": [ - "This file has been converted from https://github.com/dotnet/razor/blob/master/src/Razor/src/Microsoft.AspNetCore.Razor.VSCode.Extension/syntaxes/aspnetcorerazor.tmLanguage.json", + "This file has been converted from https://github.com/dotnet/razor/blob/master/src/Razor/src/Microsoft.VisualStudio.RazorExtension/EmbeddedGrammars/aspnetcorerazor.tmLanguage.json", "If you want to provide a fix or improvement, please create a pull request against the original repository.", "Once accepted there, we are happy to receive an update request." ], - "version": "https://github.com/dotnet/razor/commit/69f60231df08319b544d3d32a588575acbb58ff0", + "version": "https://github.com/dotnet/razor/commit/b44d0a906d054d2d343adc3f58cbea11d97d7488", "name": "ASP.NET Razor", "scopeName": "text.html.cshtml", "patterns": [ diff --git a/extensions/rust/cgmanifest.json b/extensions/rust/cgmanifest.json index 512dc80a65bb6..46bf27cd4543a 100644 --- a/extensions/rust/cgmanifest.json +++ b/extensions/rust/cgmanifest.json @@ -6,7 +6,7 @@ "git": { "name": "rust-syntax", "repositoryUrl": "https://github.com/dustypomerleau/rust-syntax", - "commitHash": "328a68299533bc2b8c71028be741cce78a9e0d53" + "commitHash": "20730dff3c367cb40a7edd278fdaf0239ea50833" } }, "license": "MIT", diff --git a/extensions/rust/syntaxes/rust.tmLanguage.json b/extensions/rust/syntaxes/rust.tmLanguage.json index 8fcbdc5082f20..542e8ec1fd136 100644 --- a/extensions/rust/syntaxes/rust.tmLanguage.json +++ b/extensions/rust/syntaxes/rust.tmLanguage.json @@ -4,7 +4,7 @@ "If you want to provide a fix or improvement, please create a pull request against the original repository.", "Once accepted there, we are happy to receive an update request." ], - "version": "https://github.com/dustypomerleau/rust-syntax/commit/328a68299533bc2b8c71028be741cce78a9e0d53", + "version": "https://github.com/dustypomerleau/rust-syntax/commit/20730dff3c367cb40a7edd278fdaf0239ea50833", "name": "Rust", "scopeName": "source.rust", "patterns": [ @@ -119,54 +119,6 @@ } } }, - { - "comment": "attributes", - "name": "meta.attribute.rust", - "begin": "(#)(\\!?)(\\[)", - "beginCaptures": { - "1": { - "name": "punctuation.definition.attribute.rust" - }, - "2": { - "name": "keyword.operator.attribute.inner.rust" - }, - "3": { - "name": "punctuation.brackets.attribute.rust" - } - }, - "end": "\\]", - "endCaptures": { - "0": { - "name": "punctuation.brackets.attribute.rust" - } - }, - "patterns": [ - { - "include": "#block-comments" - }, - { - "include": "#comments" - }, - { - "include": "#keywords" - }, - { - "include": "#lifetimes" - }, - { - "include": "#punctuation" - }, - { - "include": "#strings" - }, - { - "include": "#gtypes" - }, - { - "include": "#types" - } - ] - }, { "comment": "modules", "match": "(mod)\\s+((?:r#(?!crate|[Ss]elf|super))?[a-z][A-Za-z0-9_]*)", @@ -257,6 +209,9 @@ { "include": "#comments" }, + { + "include": "#attributes" + }, { "include": "#lvariables" }, @@ -421,7 +376,7 @@ "escapes": { "comment": "escapes: ASCII, byte, Unicode, quote, regex", "name": "constant.character.escape.rust", - "match": "(\\\\)(?:(?:(x[0-7][0-7a-fA-F])|(u(\\{)[\\da-fA-F]{4,6}(\\}))|.))", + "match": "(\\\\)(?:(?:(x[0-7][\\da-fA-F])|(u(\\{)[\\da-fA-F]{4,6}(\\}))|.))", "captures": { "1": { "name": "constant.character.escape.backslash.rust" @@ -440,6 +395,51 @@ } } }, + "attributes": { + "comment": "attributes", + "name": "meta.attribute.rust", + "begin": "(#)(\\!?)(\\[)", + "beginCaptures": { + "1": { + "name": "punctuation.definition.attribute.rust" + }, + "3": { + "name": "punctuation.brackets.attribute.rust" + } + }, + "end": "\\]", + "endCaptures": { + "0": { + "name": "punctuation.brackets.attribute.rust" + } + }, + "patterns": [ + { + "include": "#block-comments" + }, + { + "include": "#comments" + }, + { + "include": "#keywords" + }, + { + "include": "#lifetimes" + }, + { + "include": "#punctuation" + }, + { + "include": "#strings" + }, + { + "include": "#gtypes" + }, + { + "include": "#types" + } + ] + }, "functions": { "patterns": [ { @@ -548,6 +548,9 @@ { "include": "#comments" }, + { + "include": "#attributes" + }, { "include": "#keywords" }, @@ -608,6 +611,9 @@ { "include": "#comments" }, + { + "include": "#attributes" + }, { "include": "#keywords" }, @@ -913,7 +919,7 @@ }, { "comment": "parameterized types", - "begin": "\\b([A-Z][A-Za-z0-9]*)(<)", + "begin": "\\b(_?[A-Z][A-Za-z0-9_]*)(<)", "beginCaptures": { "1": { "name": "entity.name.type.rust" @@ -962,7 +968,7 @@ }, { "comment": "trait declarations", - "match": "\\b(trait)\\s+([A-Z][A-Za-z0-9]*)\\b", + "match": "\\b(trait)\\s+(_?[A-Z][A-Za-z0-9_]*)\\b", "captures": { "1": { "name": "keyword.declaration.trait.rust storage.type.rust" @@ -974,7 +980,7 @@ }, { "comment": "struct declarations", - "match": "\\b(struct)\\s+([A-Z][A-Za-z0-9]*)\\b", + "match": "\\b(struct)\\s+(_?[A-Z][A-Za-z0-9_]*)\\b", "captures": { "1": { "name": "keyword.declaration.struct.rust storage.type.rust" @@ -986,7 +992,7 @@ }, { "comment": "enum declarations", - "match": "\\b(enum)\\s+([A-Z][A-Za-z0-9_]*)\\b", + "match": "\\b(enum)\\s+(_?[A-Z][A-Za-z0-9_]*)\\b", "captures": { "1": { "name": "keyword.declaration.enum.rust storage.type.rust" @@ -998,7 +1004,7 @@ }, { "comment": "type declarations", - "match": "\\b(type)\\s+([A-Z][A-Za-z0-9_]*)\\b", + "match": "\\b(type)\\s+(_?[A-Z][A-Za-z0-9_]*)\\b", "captures": { "1": { "name": "keyword.declaration.type.rust storage.type.rust" @@ -1011,7 +1017,7 @@ { "comment": "types", "name": "entity.name.type.rust", - "match": "\\b[A-Z][A-Za-z0-9]*\\b(?!!)" + "match": "\\b_?[A-Z][A-Za-z0-9_]*\\b(?!!)" } ] }, diff --git a/extensions/vscode-colorize-tests/test/colorize-results/test_cs.json b/extensions/vscode-colorize-tests/test/colorize-results/test_cs.json index bf42bc29b6de7..7f4bbb7758be6 100644 --- a/extensions/vscode-colorize-tests/test/colorize-results/test_cs.json +++ b/extensions/vscode-colorize-tests/test/colorize-results/test_cs.json @@ -1,16 +1,16 @@ [ { "c": "using", - "t": "source.cs keyword.other.using.cs", + "t": "source.cs keyword.other.directive.using.cs", "r": { - "dark_plus": "keyword.other.using: #C586C0", - "light_plus": "keyword.other.using: #AF00DB", + "dark_plus": "keyword.other.directive.using: #C586C0", + "light_plus": "keyword.other.directive.using: #AF00DB", "dark_vs": "keyword: #569CD6", "light_vs": "keyword: #0000FF", - "hc_black": "keyword.other.using: #C586C0", - "dark_modern": "keyword.other.using: #C586C0", - "hc_light": "keyword.other.using: #B5200D", - "light_modern": "keyword.other.using: #AF00DB" + "hc_black": "keyword.other.directive.using: #C586C0", + "dark_modern": "keyword.other.directive.using: #C586C0", + "hc_light": "keyword.other.directive.using: #B5200D", + "light_modern": "keyword.other.directive.using: #AF00DB" } }, { @@ -57,16 +57,16 @@ }, { "c": "namespace", - "t": "source.cs keyword.other.namespace.cs", + "t": "source.cs storage.type.namespace.cs", "r": { - "dark_plus": "keyword: #569CD6", - "light_plus": "keyword: #0000FF", - "dark_vs": "keyword: #569CD6", - "light_vs": "keyword: #0000FF", - "hc_black": "keyword: #569CD6", - "dark_modern": "keyword: #569CD6", - "hc_light": "keyword: #0F4A85", - "light_modern": "keyword: #0000FF" + "dark_plus": "storage.type: #569CD6", + "light_plus": "storage.type: #0000FF", + "dark_vs": "storage.type: #569CD6", + "light_vs": "storage.type: #0000FF", + "hc_black": "storage.type: #569CD6", + "dark_modern": "storage.type: #569CD6", + "hc_light": "storage.type: #0F4A85", + "light_modern": "storage.type: #0000FF" } }, { @@ -127,16 +127,16 @@ }, { "c": "class", - "t": "source.cs keyword.other.class.cs", + "t": "source.cs storage.type.class.cs", "r": { - "dark_plus": "keyword: #569CD6", - "light_plus": "keyword: #0000FF", - "dark_vs": "keyword: #569CD6", - "light_vs": "keyword: #0000FF", - "hc_black": "keyword: #569CD6", - "dark_modern": "keyword: #569CD6", - "hc_light": "keyword: #0F4A85", - "light_modern": "keyword: #0000FF" + "dark_plus": "storage.type: #569CD6", + "light_plus": "storage.type: #0000FF", + "dark_vs": "storage.type: #569CD6", + "light_vs": "storage.type: #0000FF", + "hc_black": "storage.type: #569CD6", + "dark_modern": "storage.type: #569CD6", + "hc_light": "storage.type: #0F4A85", + "light_modern": "storage.type: #0000FF" } }, { @@ -211,7 +211,7 @@ }, { "c": "static", - "t": "source.cs storage.modifier.cs", + "t": "source.cs storage.modifier.static.cs", "r": { "dark_plus": "storage.modifier: #569CD6", "light_plus": "storage.modifier: #0000FF", @@ -239,7 +239,7 @@ }, { "c": "void", - "t": "source.cs keyword.type.cs", + "t": "source.cs keyword.type.void.cs", "r": { "dark_plus": "keyword: #569CD6", "light_plus": "keyword: #0000FF", @@ -295,7 +295,7 @@ }, { "c": "string", - "t": "source.cs keyword.type.cs", + "t": "source.cs keyword.type.string.cs", "r": { "dark_plus": "keyword: #569CD6", "light_plus": "keyword: #0000FF", @@ -925,7 +925,7 @@ }, { "c": "int", - "t": "source.cs keyword.type.cs", + "t": "source.cs keyword.type.int.cs", "r": { "dark_plus": "keyword: #569CD6", "light_plus": "keyword: #0000FF", @@ -1303,7 +1303,7 @@ }, { "c": "const", - "t": "source.cs storage.modifier.cs", + "t": "source.cs storage.modifier.const.cs", "r": { "dark_plus": "storage.modifier: #569CD6", "light_plus": "storage.modifier: #0000FF", @@ -1331,7 +1331,7 @@ }, { "c": "double", - "t": "source.cs keyword.type.cs", + "t": "source.cs keyword.type.double.cs", "r": { "dark_plus": "keyword: #569CD6", "light_plus": "keyword: #0000FF", @@ -1527,7 +1527,7 @@ }, { "c": "int", - "t": "source.cs keyword.type.cs", + "t": "source.cs keyword.type.int.cs", "r": { "dark_plus": "keyword: #569CD6", "light_plus": "keyword: #0000FF", @@ -1681,7 +1681,7 @@ }, { "c": "double", - "t": "source.cs keyword.type.cs", + "t": "source.cs keyword.type.double.cs", "r": { "dark_plus": "keyword: #569CD6", "light_plus": "keyword: #0000FF", @@ -1933,16 +1933,16 @@ }, { "c": " ", - "t": "source.cs punctuation.whitespace.comment.leading.cs", + "t": "source.cs comment.line.double-slash.cs punctuation.whitespace.comment.leading.cs", "r": { - "dark_plus": "default: #D4D4D4", - "light_plus": "default: #000000", - "dark_vs": "default: #D4D4D4", - "light_vs": "default: #000000", - "hc_black": "default: #FFFFFF", - "dark_modern": "default: #CCCCCC", - "hc_light": "default: #292929", - "light_modern": "default: #3B3B3B" + "dark_plus": "comment: #6A9955", + "light_plus": "comment: #008000", + "dark_vs": "comment: #6A9955", + "light_vs": "comment: #008000", + "hc_black": "comment: #7CA668", + "dark_modern": "comment: #6A9955", + "hc_light": "comment: #515151", + "light_modern": "comment: #008000" } }, { @@ -2255,7 +2255,7 @@ }, { "c": "public", - "t": "source.cs storage.modifier.cs", + "t": "source.cs storage.modifier.public.cs", "r": { "dark_plus": "storage.modifier: #569CD6", "light_plus": "storage.modifier: #0000FF", @@ -2283,7 +2283,7 @@ }, { "c": "void", - "t": "source.cs keyword.type.cs", + "t": "source.cs keyword.type.void.cs", "r": { "dark_plus": "keyword: #569CD6", "light_plus": "keyword: #0000FF", @@ -2451,16 +2451,16 @@ }, { "c": "new", - "t": "source.cs keyword.other.new.cs", + "t": "source.cs keyword.operator.expression.new.cs", "r": { - "dark_plus": "keyword: #569CD6", - "light_plus": "keyword: #0000FF", - "dark_vs": "keyword: #569CD6", - "light_vs": "keyword: #0000FF", - "hc_black": "keyword: #569CD6", - "dark_modern": "keyword: #569CD6", - "hc_light": "keyword: #0F4A85", - "light_modern": "keyword: #0000FF" + "dark_plus": "keyword.operator.expression: #569CD6", + "light_plus": "keyword.operator.expression: #0000FF", + "dark_vs": "keyword.operator.expression: #569CD6", + "light_vs": "keyword.operator.expression: #0000FF", + "hc_black": "keyword.operator.expression: #569CD6", + "dark_modern": "keyword.operator.expression: #569CD6", + "hc_light": "keyword.operator.expression: #0F4A85", + "light_modern": "keyword.operator.expression: #0000FF" } }, { @@ -2507,7 +2507,7 @@ }, { "c": "int", - "t": "source.cs keyword.type.cs", + "t": "source.cs keyword.type.int.cs", "r": { "dark_plus": "keyword: #569CD6", "light_plus": "keyword: #0000FF", @@ -2619,7 +2619,7 @@ }, { "c": "int", - "t": "source.cs keyword.type.cs", + "t": "source.cs keyword.type.int.cs", "r": { "dark_plus": "keyword: #569CD6", "light_plus": "keyword: #0000FF", @@ -2759,16 +2759,16 @@ }, { "c": "new", - "t": "source.cs keyword.other.new.cs", + "t": "source.cs keyword.operator.expression.new.cs", "r": { - "dark_plus": "keyword: #569CD6", - "light_plus": "keyword: #0000FF", - "dark_vs": "keyword: #569CD6", - "light_vs": "keyword: #0000FF", - "hc_black": "keyword: #569CD6", - "dark_modern": "keyword: #569CD6", - "hc_light": "keyword: #0F4A85", - "light_modern": "keyword: #0000FF" + "dark_plus": "keyword.operator.expression: #569CD6", + "light_plus": "keyword.operator.expression: #0000FF", + "dark_vs": "keyword.operator.expression: #569CD6", + "light_vs": "keyword.operator.expression: #0000FF", + "hc_black": "keyword.operator.expression: #569CD6", + "dark_modern": "keyword.operator.expression: #569CD6", + "hc_light": "keyword.operator.expression: #0F4A85", + "light_modern": "keyword.operator.expression: #0000FF" } }, { @@ -2815,7 +2815,7 @@ }, { "c": "int", - "t": "source.cs keyword.type.cs", + "t": "source.cs keyword.type.int.cs", "r": { "dark_plus": "keyword: #569CD6", "light_plus": "keyword: #0000FF", @@ -2927,7 +2927,7 @@ }, { "c": "int", - "t": "source.cs keyword.type.cs", + "t": "source.cs keyword.type.int.cs", "r": { "dark_plus": "keyword: #569CD6", "light_plus": "keyword: #0000FF", @@ -3025,16 +3025,16 @@ }, { "c": "new", - "t": "source.cs keyword.other.new.cs", + "t": "source.cs keyword.operator.expression.new.cs", "r": { - "dark_plus": "keyword: #569CD6", - "light_plus": "keyword: #0000FF", - "dark_vs": "keyword: #569CD6", - "light_vs": "keyword: #0000FF", - "hc_black": "keyword: #569CD6", - "dark_modern": "keyword: #569CD6", - "hc_light": "keyword: #0F4A85", - "light_modern": "keyword: #0000FF" + "dark_plus": "keyword.operator.expression: #569CD6", + "light_plus": "keyword.operator.expression: #0000FF", + "dark_vs": "keyword.operator.expression: #569CD6", + "light_vs": "keyword.operator.expression: #0000FF", + "hc_black": "keyword.operator.expression: #569CD6", + "dark_modern": "keyword.operator.expression: #569CD6", + "hc_light": "keyword.operator.expression: #0F4A85", + "light_modern": "keyword.operator.expression: #0000FF" } }, { @@ -3081,7 +3081,7 @@ }, { "c": "int", - "t": "source.cs keyword.type.cs", + "t": "source.cs keyword.type.int.cs", "r": { "dark_plus": "keyword: #569CD6", "light_plus": "keyword: #0000FF", diff --git a/extensions/vscode-colorize-tests/test/colorize-results/test_cshtml.json b/extensions/vscode-colorize-tests/test/colorize-results/test_cshtml.json index 5923b8411fe27..4307f03ed1ee2 100644 --- a/extensions/vscode-colorize-tests/test/colorize-results/test_cshtml.json +++ b/extensions/vscode-colorize-tests/test/colorize-results/test_cshtml.json @@ -43,16 +43,16 @@ }, { "c": "var", - "t": "text.html.cshtml meta.structure.razor.codeblock source.cs keyword.other.var.cs", + "t": "text.html.cshtml meta.structure.razor.codeblock source.cs storage.type.var.cs", "r": { - "dark_plus": "keyword: #569CD6", - "light_plus": "keyword: #0000FF", - "dark_vs": "keyword: #569CD6", - "light_vs": "keyword: #0000FF", - "hc_black": "keyword: #569CD6", - "dark_modern": "keyword: #569CD6", - "hc_light": "keyword: #0F4A85", - "light_modern": "keyword: #0000FF" + "dark_plus": "storage.type: #569CD6", + "light_plus": "storage.type: #0000FF", + "dark_vs": "storage.type: #569CD6", + "light_vs": "storage.type: #0000FF", + "hc_black": "storage.type: #569CD6", + "dark_modern": "storage.type: #569CD6", + "hc_light": "storage.type: #0F4A85", + "light_modern": "storage.type: #0000FF" } }, { @@ -169,16 +169,16 @@ }, { "c": "var", - "t": "text.html.cshtml meta.structure.razor.codeblock source.cs keyword.other.var.cs", + "t": "text.html.cshtml meta.structure.razor.codeblock source.cs storage.type.var.cs", "r": { - "dark_plus": "keyword: #569CD6", - "light_plus": "keyword: #0000FF", - "dark_vs": "keyword: #569CD6", - "light_vs": "keyword: #0000FF", - "hc_black": "keyword: #569CD6", - "dark_modern": "keyword: #569CD6", - "hc_light": "keyword: #0F4A85", - "light_modern": "keyword: #0000FF" + "dark_plus": "storage.type: #569CD6", + "light_plus": "storage.type: #0000FF", + "dark_vs": "storage.type: #569CD6", + "light_vs": "storage.type: #0000FF", + "hc_black": "storage.type: #569CD6", + "dark_modern": "storage.type: #569CD6", + "hc_light": "storage.type: #0F4A85", + "light_modern": "storage.type: #0000FF" } }, { @@ -505,16 +505,16 @@ }, { "c": " ", - "t": "text.html.cshtml meta.structure.razor.codeblock source.cs meta.statement.if.razor meta.structure.razor.csharp.codeblock punctuation.whitespace.comment.leading.cs", + "t": "text.html.cshtml meta.structure.razor.codeblock source.cs meta.statement.if.razor meta.structure.razor.csharp.codeblock comment.line.double-slash.cs punctuation.whitespace.comment.leading.cs", "r": { - "dark_plus": "default: #D4D4D4", - "light_plus": "default: #000000", - "dark_vs": "default: #D4D4D4", - "light_vs": "default: #000000", - "hc_black": "default: #FFFFFF", - "dark_modern": "default: #CCCCCC", - "hc_light": "default: #292929", - "light_modern": "default: #3B3B3B" + "dark_plus": "comment: #6A9955", + "light_plus": "comment: #008000", + "dark_vs": "comment: #6A9955", + "light_vs": "comment: #008000", + "hc_black": "comment: #7CA668", + "dark_modern": "comment: #6A9955", + "hc_light": "comment: #515151", + "light_modern": "comment: #008000" } }, { @@ -561,16 +561,16 @@ }, { "c": "var", - "t": "text.html.cshtml meta.structure.razor.codeblock source.cs meta.statement.if.razor meta.structure.razor.csharp.codeblock keyword.other.var.cs", + "t": "text.html.cshtml meta.structure.razor.codeblock source.cs meta.statement.if.razor meta.structure.razor.csharp.codeblock storage.type.var.cs", "r": { - "dark_plus": "keyword: #569CD6", - "light_plus": "keyword: #0000FF", - "dark_vs": "keyword: #569CD6", - "light_vs": "keyword: #0000FF", - "hc_black": "keyword: #569CD6", - "dark_modern": "keyword: #569CD6", - "hc_light": "keyword: #0F4A85", - "light_modern": "keyword: #0000FF" + "dark_plus": "storage.type: #569CD6", + "light_plus": "storage.type: #0000FF", + "dark_vs": "storage.type: #569CD6", + "light_vs": "storage.type: #0000FF", + "hc_black": "storage.type: #569CD6", + "dark_modern": "storage.type: #569CD6", + "hc_light": "storage.type: #0F4A85", + "light_modern": "storage.type: #0000FF" } }, { @@ -757,16 +757,16 @@ }, { "c": "var", - "t": "text.html.cshtml meta.structure.razor.codeblock source.cs meta.statement.if.razor meta.structure.razor.csharp.codeblock keyword.other.var.cs", + "t": "text.html.cshtml meta.structure.razor.codeblock source.cs meta.statement.if.razor meta.structure.razor.csharp.codeblock storage.type.var.cs", "r": { - "dark_plus": "keyword: #569CD6", - "light_plus": "keyword: #0000FF", - "dark_vs": "keyword: #569CD6", - "light_vs": "keyword: #0000FF", - "hc_black": "keyword: #569CD6", - "dark_modern": "keyword: #569CD6", - "hc_light": "keyword: #0F4A85", - "light_modern": "keyword: #0000FF" + "dark_plus": "storage.type: #569CD6", + "light_plus": "storage.type: #0000FF", + "dark_vs": "storage.type: #569CD6", + "light_vs": "storage.type: #0000FF", + "hc_black": "storage.type: #569CD6", + "dark_modern": "storage.type: #569CD6", + "hc_light": "storage.type: #0F4A85", + "light_modern": "storage.type: #0000FF" } }, { @@ -939,16 +939,16 @@ }, { "c": " ", - "t": "text.html.cshtml meta.structure.razor.codeblock source.cs meta.statement.if.razor meta.structure.razor.csharp.codeblock punctuation.whitespace.comment.leading.cs", + "t": "text.html.cshtml meta.structure.razor.codeblock source.cs meta.statement.if.razor meta.structure.razor.csharp.codeblock comment.line.double-slash.cs punctuation.whitespace.comment.leading.cs", "r": { - "dark_plus": "default: #D4D4D4", - "light_plus": "default: #000000", - "dark_vs": "default: #D4D4D4", - "light_vs": "default: #000000", - "hc_black": "default: #FFFFFF", - "dark_modern": "default: #CCCCCC", - "hc_light": "default: #292929", - "light_modern": "default: #3B3B3B" + "dark_plus": "comment: #6A9955", + "light_plus": "comment: #008000", + "dark_vs": "comment: #6A9955", + "light_vs": "comment: #008000", + "hc_black": "comment: #7CA668", + "dark_modern": "comment: #6A9955", + "hc_light": "comment: #515151", + "light_modern": "comment: #008000" } }, { @@ -4535,4 +4535,4 @@ "light_modern": "punctuation.definition.tag: #800000" } } -] +] \ No newline at end of file diff --git a/package.json b/package.json index e6fb8906f4939..714bf79209e47 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "code-oss-dev", - "version": "1.84.0", - "distro": "9cdc4175a8604751edba6baf46edfdf56d93173f", + "version": "1.85.0", + "distro": "ff0198cd90b25ba7ca853279cea9b8bb3cf5164d", "author": { "name": "Microsoft Corporation" }, diff --git a/src/vs/base/browser/dom.ts b/src/vs/base/browser/dom.ts index 764008eaf5800..aaf950b4c1fd1 100644 --- a/src/vs/base/browser/dom.ts +++ b/src/vs/base/browser/dom.ts @@ -17,7 +17,7 @@ import { FileAccess, RemoteAuthorities, Schemas } from 'vs/base/common/network'; import * as platform from 'vs/base/common/platform'; import { URI } from 'vs/base/common/uri'; -export const { registerWindow, getWindows, onDidRegisterWindow, onWillUnregisterWindow, onDidUnregisterWindow } = (function () { +export const { registerWindow, getWindows, getWindowsCount, onDidRegisterWindow, onWillUnregisterWindow, onDidUnregisterWindow } = (function () { const windows = new Set([window]); const onDidRegisterWindow = new event.Emitter<{ window: Window & typeof globalThis; disposables: DisposableStore }>(); const onDidUnregisterWindow = new event.Emitter(); @@ -51,6 +51,9 @@ export const { registerWindow, getWindows, onDidRegisterWindow, onWillUnregister }, getWindows(): Iterable { return windows; + }, + getWindowsCount(): number { + return windows.size; } }; })(); @@ -737,6 +740,13 @@ export function isAncestorOfActiveElement(ancestor: Element): boolean { return isAncestor(ancestor.ownerDocument.activeElement, ancestor); } +/** + * Returns whether the element is in the active `document`. + */ +export function isActiveDocument(element: Element): boolean { + return element.ownerDocument === getActiveDocument(); +} + /** * Returns the active document across all child windows. * Use this instead of `document` when reacting to dom events to handle multiple windows. @@ -795,12 +805,11 @@ export function createStyleSheet(container: HTMLElement = document.head, beforeA continue; // main window is already tracked } - const clone = cloneGlobalStyleSheet(style, targetWindow); - clonedGlobalStylesheets.add(clone); + const disposable = cloneGlobalStyleSheet(style, targetWindow); event.Event.once(onDidUnregisterWindow)(unregisteredWindow => { if (unregisteredWindow === targetWindow) { - clonedGlobalStylesheets.delete(clone); + disposable.dispose(); } }); } @@ -816,17 +825,14 @@ export function isGlobalStylesheet(node: Node): boolean { export function cloneGlobalStylesheets(targetWindow: Window & typeof globalThis): IDisposable { const disposables = new DisposableStore(); - for (const [globalStylesheet, clonedGlobalStylesheets] of globalStylesheets) { - const clone = cloneGlobalStyleSheet(globalStylesheet, targetWindow); - - clonedGlobalStylesheets.add(clone); - disposables.add(toDisposable(() => clonedGlobalStylesheets.delete(clone))); + for (const [globalStylesheet] of globalStylesheets) { + disposables.add(cloneGlobalStyleSheet(globalStylesheet, targetWindow)); } return disposables; } -function cloneGlobalStyleSheet(globalStylesheet: HTMLStyleElement, targetWindow: Window & typeof globalThis): HTMLStyleElement { +function cloneGlobalStyleSheet(globalStylesheet: HTMLStyleElement, targetWindow: Window & typeof globalThis): IDisposable { const clone = globalStylesheet.cloneNode(true) as HTMLStyleElement; targetWindow.document.head.appendChild(clone); @@ -834,7 +840,19 @@ function cloneGlobalStyleSheet(globalStylesheet: HTMLStyleElement, targetWindow: clone.sheet?.insertRule(rule.cssText, clone.sheet?.cssRules.length); } - return clone; + const observer = new MutationObserver(() => { + clone.textContent = globalStylesheet.textContent; + }); + observer.observe(globalStylesheet, { childList: true }); + + globalStylesheets.get(globalStylesheet)?.add(clone); + + return toDisposable(() => { + observer.disconnect(); + targetWindow.document.head.removeChild(clone); + + globalStylesheets.get(globalStylesheet)?.delete(clone); + }); } export function createMetaElement(container: HTMLElement = document.head): HTMLMetaElement { diff --git a/src/vs/base/common/product.ts b/src/vs/base/common/product.ts index 379e47bb7197d..61a1623d76dcf 100644 --- a/src/vs/base/common/product.ts +++ b/src/vs/base/common/product.ts @@ -293,8 +293,9 @@ export interface IAiGeneratedWorkspaceTrust { export interface IGitHubEntitlement { providerId: string; command: { title: string; titleWithoutPlaceHolder: string; action: string; when: string }; - altCommand: { title: string; action: string; when: string }; entitlementUrl: string; extensionId: string; enablementKey: string; + confirmationMessage: string; + confirmationAction: string; } diff --git a/src/vs/base/parts/sandbox/electron-sandbox/globals.ts b/src/vs/base/parts/sandbox/electron-sandbox/globals.ts index d0ae5a5ff0efd..2fd7a08808ac4 100644 --- a/src/vs/base/parts/sandbox/electron-sandbox/globals.ts +++ b/src/vs/base/parts/sandbox/electron-sandbox/globals.ts @@ -121,31 +121,11 @@ export const webFrame: WebFrame = globals.vscode.webFrame; export const process: ISandboxNodeProcess = globals.vscode.process; export const context: ISandboxContext = globals.vscode.context; -export interface IGlobalsSlim { - readonly ipcRenderer: Pick; - readonly webFrame: import('vs/base/parts/sandbox/electron-sandbox/electronTypes').WebFrame; -} - /** - * Get the globals that are available in the given window. Since - * this method supports auxiliary windows, only a subset of globals - * is returned. + * A set of globals that are available in all windows that either + * depend on `preload.js` or `preload-aux.js`. */ -export function getGlobals(win: Window): IGlobalsSlim | undefined { - if (win === window) { - return { ipcRenderer, webFrame }; - } - - const auxiliaryWindowCandidate = win as unknown as { - vscode: { - ipcRenderer: Pick; - webFrame: import('vs/base/parts/sandbox/electron-sandbox/electronTypes').WebFrame; - }; - }; - - if (auxiliaryWindowCandidate?.vscode?.ipcRenderer && auxiliaryWindowCandidate?.vscode?.webFrame) { - return auxiliaryWindowCandidate.vscode; - } - - return undefined; +export interface ISandboxGlobals { + readonly ipcRenderer: Pick; + readonly webFrame: import('vs/base/parts/sandbox/electron-sandbox/electronTypes').WebFrame; } diff --git a/src/vs/base/parts/sandbox/electron-sandbox/preload-slim.js b/src/vs/base/parts/sandbox/electron-sandbox/preload-aux.js similarity index 93% rename from src/vs/base/parts/sandbox/electron-sandbox/preload-slim.js rename to src/vs/base/parts/sandbox/electron-sandbox/preload-aux.js index 7b6256756ac92..c73cabcdfa5ba 100644 --- a/src/vs/base/parts/sandbox/electron-sandbox/preload-slim.js +++ b/src/vs/base/parts/sandbox/electron-sandbox/preload-aux.js @@ -46,12 +46,12 @@ /** * @param {string} channel * @param {any[]} args - * @returns {Promise | never} + * @returns {Promise} */ invoke(channel, ...args) { - if (validateIPC(channel)) { - return ipcRenderer.invoke(channel, ...args); - } + validateIPC(channel); + + return ipcRenderer.invoke(channel, ...args); } }, diff --git a/src/vs/base/parts/sandbox/electron-sandbox/preload.js b/src/vs/base/parts/sandbox/electron-sandbox/preload.js index 0494b7ddda76e..90ac940861fb4 100644 --- a/src/vs/base/parts/sandbox/electron-sandbox/preload.js +++ b/src/vs/base/parts/sandbox/electron-sandbox/preload.js @@ -56,24 +56,23 @@ } try { - if (validateIPC(windowConfigIpcChannel)) { + validateIPC(windowConfigIpcChannel); - // Resolve configuration from electron-main - configuration = await ipcRenderer.invoke(windowConfigIpcChannel); + // Resolve configuration from electron-main + const resolvedConfiguration = configuration = await ipcRenderer.invoke(windowConfigIpcChannel); - // Apply `userEnv` directly - Object.assign(process.env, configuration.userEnv); + // Apply `userEnv` directly + Object.assign(process.env, resolvedConfiguration.userEnv); - // Apply zoom level early before even building the - // window DOM elements to avoid UI flicker. We always - // have to set the zoom level from within the window - // because Chrome has it's own way of remembering zoom - // settings per origin (if vscode-file:// is used) and - // we want to ensure that the user configuration wins. - webFrame.setZoomLevel(configuration.zoomLevel ?? 0); + // Apply zoom level early before even building the + // window DOM elements to avoid UI flicker. We always + // have to set the zoom level from within the window + // because Chrome has it's own way of remembering zoom + // settings per origin (if vscode-file:// is used) and + // we want to ensure that the user configuration wins. + webFrame.setZoomLevel(resolvedConfiguration.zoomLevel ?? 0); - return configuration; - } + return resolvedConfiguration; } catch (error) { throw new Error(`Preload: unable to fetch vscode-window-config: ${error}`); } @@ -145,51 +144,51 @@ /** * @param {string} channel * @param {any[]} args - * @returns {Promise | never} + * @returns {Promise} */ invoke(channel, ...args) { - if (validateIPC(channel)) { - return ipcRenderer.invoke(channel, ...args); - } + validateIPC(channel); + + return ipcRenderer.invoke(channel, ...args); }, /** * @param {string} channel * @param {(event: IpcRendererEvent, ...args: any[]) => void} listener - * @returns {IpcRenderer | never} + * @returns {IpcRenderer} */ on(channel, listener) { - if (validateIPC(channel)) { - ipcRenderer.on(channel, listener); + validateIPC(channel); - return this; - } + ipcRenderer.on(channel, listener); + + return this; }, /** * @param {string} channel * @param {(event: IpcRendererEvent, ...args: any[]) => void} listener - * @returns {IpcRenderer | never} + * @returns {IpcRenderer} */ once(channel, listener) { - if (validateIPC(channel)) { - ipcRenderer.once(channel, listener); + validateIPC(channel); - return this; - } + ipcRenderer.once(channel, listener); + + return this; }, /** * @param {string} channel * @param {(event: IpcRendererEvent, ...args: any[]) => void} listener - * @returns {IpcRenderer | never} + * @returns {IpcRenderer} */ removeListener(channel, listener) { - if (validateIPC(channel)) { - ipcRenderer.removeListener(channel, listener); + validateIPC(channel); - return this; - } + ipcRenderer.removeListener(channel, listener); + + return this; } }, diff --git a/src/vs/editor/common/viewModel/viewModelImpl.ts b/src/vs/editor/common/viewModel/viewModelImpl.ts index eb18dced3c1f6..00e3ffb0de027 100644 --- a/src/vs/editor/common/viewModel/viewModelImpl.ts +++ b/src/vs/editor/common/viewModel/viewModelImpl.ts @@ -491,7 +491,12 @@ export class ViewModel extends Disposable implements IViewModel { this.viewLayout.onFlushed(this.getLineCount()); this.viewLayout.onHeightMaybeChanged(); } - stableViewport.recoverViewportStart(this.coordinatesConverter, this.viewLayout); + + const firstModelLineInViewPort = stableViewport.viewportStartModelPosition?.lineNumber; + const firstModelLineIsHidden = firstModelLineInViewPort && mergedRanges.some(range => range.startLineNumber <= firstModelLineInViewPort && firstModelLineInViewPort <= range.endLineNumber); + if (!firstModelLineIsHidden) { + stableViewport.recoverViewportStart(this.coordinatesConverter, this.viewLayout); + } } finally { this._eventDispatcher.endEmitViewEvents(); } diff --git a/src/vs/editor/contrib/zoneWidget/browser/zoneWidget.ts b/src/vs/editor/contrib/zoneWidget/browser/zoneWidget.ts index a003de17958f1..a1e82f322d539 100644 --- a/src/vs/editor/contrib/zoneWidget/browser/zoneWidget.ts +++ b/src/vs/editor/contrib/zoneWidget/browser/zoneWidget.ts @@ -321,6 +321,19 @@ export abstract class ZoneWidget implements IHorizontalSashLayoutProvider { this._positionMarkerId.set([{ range, options: ModelDecorationOptions.EMPTY }]); } + updatePositionAndHeight(rangeOrPos: IRange | IPosition, heightInLines?: number): void { + if (this._viewZone) { + rangeOrPos = Range.isIRange(rangeOrPos) ? Range.getStartPosition(rangeOrPos) : rangeOrPos; + this._viewZone.afterLineNumber = rangeOrPos.lineNumber; + this._viewZone.afterColumn = rangeOrPos.column; + this._viewZone.heightInLines = heightInLines ?? this._viewZone.heightInLines; + + this.editor.changeViewZones(accessor => { + accessor.layoutZone(this._viewZone!.id); + }); + } + } + hide(): void { if (this._viewZone) { this.editor.changeViewZones(accessor => { diff --git a/src/vs/editor/standalone/browser/quickInput/standaloneQuickInputService.ts b/src/vs/editor/standalone/browser/quickInput/standaloneQuickInputService.ts index 549a1d85c775b..2c45263ca24a3 100644 --- a/src/vs/editor/standalone/browser/quickInput/standaloneQuickInputService.ts +++ b/src/vs/editor/standalone/browser/quickInput/standaloneQuickInputService.ts @@ -4,6 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import 'vs/css!./standaloneQuickInput'; +import { Event } from 'vs/base/common/event'; import { ICodeEditor, IOverlayWidget, IOverlayWidgetPosition, OverlayWidgetPositionPreference } from 'vs/editor/browser/editorBrowser'; import { EditorContributionInstantiation, registerEditorContribution } from 'vs/editor/browser/editorExtensions'; import { IEditorContribution } from 'vs/editor/common/editorCommon'; @@ -42,10 +43,14 @@ class EditorScopedQuickInputService extends QuickInputService { get container() { return widget.getDomNode(); }, get containers() { return [widget.getDomNode()]; }, get activeContainer() { return widget.getDomNode(); }, - get dimension() { return editor.getLayoutInfo(); }, - get onDidLayout() { return editor.onDidLayoutChange; }, - focus: () => editor.focus(), - offset: { top: 0, quickPickTop: 0 } + get mainContainerDimension() { return editor.getLayoutInfo(); }, + get activeContainerDimension() { return editor.getLayoutInfo(); }, + get onDidLayoutMainContainer() { return editor.onDidLayoutChange; }, + get onDidLayoutActiveContainer() { return editor.onDidLayoutChange; }, + get onDidChangeActiveContainer() { return Event.None; }, + get mainContainerOffset() { return { top: 0, quickPickTop: 0 }; }, + get activeContainerOffset() { return { top: 0, quickPickTop: 0 }; }, + focus: () => editor.focus() }; } else { this.host = undefined; diff --git a/src/vs/editor/standalone/browser/standaloneLayoutService.ts b/src/vs/editor/standalone/browser/standaloneLayoutService.ts index 361d84f23579e..86aeb14e2ab83 100644 --- a/src/vs/editor/standalone/browser/standaloneLayoutService.ts +++ b/src/vs/editor/standalone/browser/standaloneLayoutService.ts @@ -13,10 +13,12 @@ import { coalesce } from 'vs/base/common/arrays'; class StandaloneLayoutService implements ILayoutService { declare readonly _serviceBrand: undefined; - public onDidLayout = Event.None; + readonly onDidLayoutMainContainer = Event.None; + readonly onDidLayoutActiveContainer = Event.None; + readonly onDidChangeActiveContainer = Event.None; private _dimension?: dom.IDimension; - get dimension(): dom.IDimension { + get mainContainerDimension(): dom.IDimension { if (!this._dimension) { this._dimension = dom.getClientArea(window.document.body); } @@ -24,6 +26,11 @@ class StandaloneLayoutService implements ILayoutService { return this._dimension; } + get activeContainerDimension() { return this.mainContainerDimension; } + + readonly mainContainerOffset: ILayoutOffsetInfo = { top: 0, quickPickTop: 0 }; + readonly activeContainerOffset: ILayoutOffsetInfo = { top: 0, quickPickTop: 0 }; + get hasContainer(): boolean { return false; } @@ -51,8 +58,6 @@ class StandaloneLayoutService implements ILayoutService { this._codeEditorService.getFocusedCodeEditor()?.focus(); } - readonly offset: ILayoutOffsetInfo = { top: 0, quickPickTop: 0 }; - constructor( @ICodeEditorService private _codeEditorService: ICodeEditorService ) { } diff --git a/src/vs/platform/auxiliaryWindow/electron-main/auxiliaryWindowsMainService.ts b/src/vs/platform/auxiliaryWindow/electron-main/auxiliaryWindowsMainService.ts index 01718d334ccb7..983494e1cf6d7 100644 --- a/src/vs/platform/auxiliaryWindow/electron-main/auxiliaryWindowsMainService.ts +++ b/src/vs/platform/auxiliaryWindow/electron-main/auxiliaryWindowsMainService.ts @@ -42,7 +42,7 @@ export class AuxiliaryWindowsMainService implements IAuxiliaryWindowsMainService createWindow(): BrowserWindowConstructorOptions { return this.instantiationService.invokeFunction(defaultBrowserWindowOptions, undefined, { webPreferences: { - preload: FileAccess.asFileUri('vs/base/parts/sandbox/electron-sandbox/preload-slim.js').fsPath + preload: FileAccess.asFileUri('vs/base/parts/sandbox/electron-sandbox/preload-aux.js').fsPath } }); } diff --git a/src/vs/platform/contextview/browser/contextViewService.ts b/src/vs/platform/contextview/browser/contextViewService.ts index ed305ef388142..beb879021a022 100644 --- a/src/vs/platform/contextview/browser/contextViewService.ts +++ b/src/vs/platform/contextview/browser/contextViewService.ts @@ -25,7 +25,7 @@ export class ContextViewService extends Disposable implements IContextViewServic this.contextView = this._register(new ContextView(this.container, ContextViewDOMPosition.ABSOLUTE)); this.layout(); - this._register(layoutService.onDidLayout(() => this.layout())); + this._register(layoutService.onDidLayoutMainContainer(() => this.layout())); } // ContextView diff --git a/src/vs/platform/extensions/electron-main/extensionHostStarter.ts b/src/vs/platform/extensions/electron-main/extensionHostStarter.ts index 2d5a39fa1daa0..19fcb4dd70a66 100644 --- a/src/vs/platform/extensions/electron-main/extensionHostStarter.ts +++ b/src/vs/platform/extensions/electron-main/extensionHostStarter.ts @@ -78,6 +78,21 @@ export class ExtensionHostStarter implements IDisposable, IExtensionHostStarter extHost.dispose(); this._extHosts.delete(id); }); + + // See https://github.com/microsoft/vscode/issues/194477 + // We have observed that sometimes the process sends an exit + // event, but does not really exit and is stuck in an endless + // loop. In these cases we kill the process forcefully after + // a certain timeout. + setTimeout(() => { + try { + process.kill(pid, 0); // will throw if the process doesn't exist anymore. + this._logService.error(`Extension host with pid ${pid} still exists, forcefully killing it...`); + process.kill(pid); + } catch (er) { + // ignore, as the process is already gone + } + }, 1000); }); return { id }; } diff --git a/src/vs/platform/layout/browser/layoutService.ts b/src/vs/platform/layout/browser/layoutService.ts index e84f9f3107fae..74d4ef4b801ac 100644 --- a/src/vs/platform/layout/browser/layoutService.ts +++ b/src/vs/platform/layout/browser/layoutService.ts @@ -10,10 +10,12 @@ import { createDecorator } from 'vs/platform/instantiation/common/instantiation' export const ILayoutService = createDecorator('layoutService'); export interface ILayoutOffsetInfo { + /** * Generic top offset */ readonly top: number; + /** * Quick pick specific top offset. */ @@ -25,15 +27,29 @@ export interface ILayoutService { readonly _serviceBrand: undefined; /** - * An event that is emitted when the container is layed out. The - * event carries the dimensions of the container as part of it. + * An event that is emitted when the main container is layed out. + */ + readonly onDidLayoutMainContainer: Event; + + /** + * An event that is emitted when the active container is layed out. + */ + readonly onDidLayoutActiveContainer: Event; + + /** + * An event that is emitted when the active container changes. + */ + readonly onDidChangeActiveContainer: Event; + + /** + * The dimensions of the main container. */ - readonly onDidLayout: Event; + readonly mainContainerDimension: IDimension; /** - * The dimensions of the container. + * The dimensions of the active container. */ - readonly dimension: IDimension; + readonly activeContainerDimension: IDimension; /** * Does the application have a single container? @@ -41,7 +57,7 @@ export interface ILayoutService { readonly hasContainer: boolean; /** - * Container of the application. + * Main container of the application. * * **NOTE**: In the standalone editor case, multiple editors can be created on a page. * Therefore, in the standalone editor case, there are multiple containers, not just @@ -65,10 +81,15 @@ export interface ILayoutService { */ readonly containers: Iterable; + /** + * An offset to use for positioning elements inside the main container. + */ + readonly mainContainerOffset: ILayoutOffsetInfo; + /** * An offset to use for positioning elements inside the container. */ - readonly offset: ILayoutOffsetInfo; + readonly activeContainerOffset: ILayoutOffsetInfo; /** * Focus the primary component of the container. diff --git a/src/vs/platform/quickinput/browser/quickInputController.ts b/src/vs/platform/quickinput/browser/quickInputController.ts index 86976df649fad..a2f2e4cb1b92b 100644 --- a/src/vs/platform/quickinput/browser/quickInputController.ts +++ b/src/vs/platform/quickinput/browser/quickInputController.ts @@ -81,12 +81,14 @@ export class QuickInputController extends Disposable { } } - private getUI() { + private getUI(showInActiveContainer?: boolean) { if (this.ui) { // In order to support aux windows, re-parent the controller // if the original event is from a different document - if (this.parentElement.ownerDocument !== this.layoutService.activeContainer.ownerDocument) { - this.reparentUI(this.layoutService.activeContainer); + if (showInActiveContainer) { + if (this.parentElement.ownerDocument !== this.layoutService.activeContainer.ownerDocument) { + this.reparentUI(this.layoutService.activeContainer); + } } return this.ui; @@ -506,22 +508,22 @@ export class QuickInputController extends Disposable { backButton = backButton; createQuickPick(): IQuickPick { - const ui = this.getUI(); + const ui = this.getUI(true); return new QuickPick(ui); } createInputBox(): IInputBox { - const ui = this.getUI(); + const ui = this.getUI(true); return new InputBox(ui); } createQuickWidget(): IQuickWidget { - const ui = this.getUI(); + const ui = this.getUI(true); return new QuickWidget(ui); } private show(controller: IQuickInput) { - const ui = this.getUI(); + const ui = this.getUI(true); this.onShowEmitter.fire(); const oldController = this.controller; this.controller = controller; @@ -559,6 +561,10 @@ export class QuickInputController extends Disposable { ui.inputBox.setFocus(); } + isVisible(): boolean { + return !!this.ui && this.ui.container.style.display !== 'none'; + } + private setVisibilities(visibilities: Visibilities) { const ui = this.getUI(); ui.title.style.display = visibilities.title ? '' : 'none'; @@ -605,7 +611,9 @@ export class QuickInputController extends Disposable { const focusChanged = container && !dom.isAncestorOfActiveElement(container); this.controller = null; this.onHideEmitter.fire(); - this.getUI().container.style.display = 'none'; + if (container) { + container.style.display = 'none'; + } if (!focusChanged) { let currentElement = this.previousFocusElement; while (currentElement && !currentElement.offsetParent) { @@ -622,7 +630,7 @@ export class QuickInputController extends Disposable { } focus() { - if (this.isDisplayed()) { + if (this.isVisible()) { const ui = this.getUI(); if (ui.inputBox.enabled) { ui.inputBox.setFocus(); @@ -633,13 +641,13 @@ export class QuickInputController extends Disposable { } toggle() { - if (this.isDisplayed() && this.controller instanceof QuickPick && this.controller.canSelectMany) { + if (this.isVisible() && this.controller instanceof QuickPick && this.controller.canSelectMany) { this.getUI().list.toggleCheckbox(); } } navigate(next: boolean, quickNavigate?: IQuickNavigateConfiguration) { - if (this.isDisplayed() && this.getUI().list.isDisplayed()) { + if (this.isVisible() && this.getUI().list.isDisplayed()) { this.getUI().list.focus(next ? QuickInputListFocus.Next : QuickInputListFocus.Previous); if (quickNavigate && this.controller instanceof QuickPick) { this.controller.quickNavigate = quickNavigate; @@ -673,7 +681,7 @@ export class QuickInputController extends Disposable { } private updateLayout() { - if (this.ui && this.isDisplayed()) { + if (this.ui && this.isVisible()) { this.ui.container.style.top = `${this.titleBarOffset}px`; const style = this.ui.container.style; @@ -745,10 +753,6 @@ export class QuickInputController extends Disposable { } } } - - private isDisplayed() { - return this.ui && this.ui.container.style.display !== 'none'; - } } export interface IQuickInputControllerHost extends ILayoutService { } diff --git a/src/vs/platform/quickinput/browser/quickInputService.ts b/src/vs/platform/quickinput/browser/quickInputService.ts index a5892ba0281bb..0d6884730e186 100644 --- a/src/vs/platform/quickinput/browser/quickInputService.ts +++ b/src/vs/platform/quickinput/browser/quickInputService.ts @@ -67,7 +67,7 @@ export class QuickInputService extends Themable implements IQuickInputService { protected createController(host: IQuickInputControllerHost = this.layoutService, options?: Partial): QuickInputController { const defaultOptions: IQuickInputOptions = { idPrefix: 'quickInput_', - container: host.container, + container: host.activeContainer, ignoreFocusOut: () => false, backKeybindingLabel: () => undefined, setContextKey: (id?: string) => this.setContextKey(id), @@ -94,12 +94,20 @@ export class QuickInputService extends Themable implements IQuickInputService { ...options }, this.themeService, - this.layoutService)); + this.layoutService + )); - controller.layout(host.dimension, host.offset.quickPickTop); + controller.layout(host.activeContainerDimension, host.activeContainerOffset.quickPickTop); // Layout changes - this._register(host.onDidLayout(dimension => controller.layout(dimension, host.offset.quickPickTop))); + this._register(host.onDidLayoutActiveContainer(dimension => controller.layout(dimension, host.activeContainerOffset.quickPickTop))); + this._register(host.onDidChangeActiveContainer(() => { + if (controller.isVisible()) { + return; + } + + controller.layout(host.activeContainerDimension, host.activeContainerOffset.quickPickTop); + })); // Context keys this._register(controller.onShow(() => { diff --git a/src/vs/platform/window/electron-sandbox/window.ts b/src/vs/platform/window/electron-sandbox/window.ts index b4c27b676f035..28968b4f9ccbe 100644 --- a/src/vs/platform/window/electron-sandbox/window.ts +++ b/src/vs/platform/window/electron-sandbox/window.ts @@ -5,7 +5,7 @@ import { getZoomLevel, setZoomFactor, setZoomLevel } from 'vs/base/browser/browser'; import { getWindows } from 'vs/base/browser/dom'; -import { getGlobals } from 'vs/base/parts/sandbox/electron-sandbox/globals'; +import { ISandboxGlobals, ipcRenderer, webFrame } from 'vs/base/parts/sandbox/electron-sandbox/globals'; import { zoomLevelToZoomFactor } from 'vs/platform/window/common/window'; /** @@ -20,6 +20,21 @@ export function applyZoom(zoomLevel: number): void { setZoomLevel(zoomLevel); } +function getGlobals(win: Window): ISandboxGlobals | undefined { + if (win === window) { + // main window + return { ipcRenderer, webFrame }; + } else { + // auxiliary window + const auxiliaryWindow = win as unknown as { vscode: ISandboxGlobals }; + if (auxiliaryWindow?.vscode?.ipcRenderer && auxiliaryWindow?.vscode?.webFrame) { + return auxiliaryWindow.vscode; + } + } + + return undefined; +} + export function zoomIn(): void { applyZoom(getZoomLevel() + 1); } diff --git a/src/vs/workbench/browser/layout.ts b/src/vs/workbench/browser/layout.ts index a3adccf549172..1554dfade7bdf 100644 --- a/src/vs/workbench/browser/layout.ts +++ b/src/vs/workbench/browser/layout.ts @@ -5,7 +5,7 @@ import { Disposable, DisposableStore, toDisposable } from 'vs/base/common/lifecycle'; import { Event, Emitter } from 'vs/base/common/event'; -import { EventType, addDisposableListener, getClientArea, Dimension, position, size, IDimension, isAncestorUsingFlowTo, computeScreenAwareSize, getActiveDocument, getWindows, getActiveWindow, focusWindow } from 'vs/base/browser/dom'; +import { EventType, addDisposableListener, getClientArea, Dimension, position, size, IDimension, isAncestorUsingFlowTo, computeScreenAwareSize, getActiveDocument, getWindows, getActiveWindow, focusWindow, isActiveDocument } from 'vs/base/browser/dom'; import { onDidChangeFullscreen, isFullscreen, isWCOEnabled } from 'vs/base/browser/browser'; import { IWorkingCopyBackupService } from 'vs/workbench/services/workingCopy/common/workingCopyBackup'; import { isWindows, isLinux, isMacintosh, isWeb, isNative, isIOS } from 'vs/base/common/platform'; @@ -145,8 +145,11 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi private readonly _onDidChangeNotificationsVisibility = this._register(new Emitter()); readonly onDidChangeNotificationsVisibility = this._onDidChangeNotificationsVisibility.event; - private readonly _onDidLayout = this._register(new Emitter()); - readonly onDidLayout = this._onDidLayout.event; + private readonly _onDidLayoutMainContainer = this._register(new Emitter()); + readonly onDidLayoutMainContainer = this._onDidLayoutMainContainer.event; + + private readonly _onDidLayoutActiveContainer = this._register(new Emitter()); + readonly onDidLayoutActiveContainer = this._onDidLayoutActiveContainer.event; private readonly _onDidAddContainer = this._register(new Emitter()); readonly onDidAddContainer = this._onDidAddContainer.event; @@ -154,6 +157,9 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi private readonly _onDidRemoveContainer = this._register(new Emitter()); readonly onDidRemoveContainer = this._onDidRemoveContainer.event; + private readonly _onDidChangeActiveContainer = this._register(new Emitter()); + readonly onDidChangeActiveContainer = this._onDidChangeActiveContainer.event; + //#endregion //#region Properties @@ -180,27 +186,54 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi } } - private _dimension!: IDimension; - get dimension(): IDimension { return this._dimension; } + private _mainContainerDimension!: IDimension; + get mainContainerDimension(): IDimension { return this._mainContainerDimension; } + + get activeContainerDimension(): IDimension { + const activeContainer = this.activeContainer; + if (activeContainer === this.container) { + // main window + return this.mainContainerDimension; + } else { + // auxiliary window + return getClientArea(activeContainer); + } + } - get offset() { + get mainContainerOffset() { let top = 0; let quickPickTop = 0; + if (this.isVisible(Parts.BANNER_PART)) { top = this.getPart(Parts.BANNER_PART).maximumHeight; quickPickTop = top; } + if (this.isVisible(Parts.TITLEBAR_PART)) { top += this.getPart(Parts.TITLEBAR_PART).maximumHeight; quickPickTop = top; } - // If the command center is visible then the quickinput should go over the title bar and the banner + if (this.titleService.isCommandCenterVisible) { + // If the command center is visible then the quickinput + // should go over the title bar and the banner quickPickTop = 6; } + return { top, quickPickTop }; } + get activeContainerOffset() { + const activeContainer = this.activeContainer; + if (activeContainer === this.container) { + // main window + return this.mainContainerOffset; + } else { + // TODO@bpasero auxiliary window: no support for custom title bar or banner yet + return { top: 0, quickPickTop: 0 }; + } + } + //#endregion private readonly parts = new Map(); @@ -346,6 +379,7 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi this._register(this.auxiliaryWindowService.onDidOpenAuxiliaryWindow(({ window, disposables }) => { this._onDidAddContainer.fire(window.container); + disposables.add(window.onDidLayout(dimension => this.handleContainerDidLayout(window.container, dimension))); disposables.add(toDisposable(() => this._onDidRemoveContainer.fire(window.container))); })); } @@ -369,7 +403,17 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi // Move layout call to any time the menubar // is toggled to update consumers of offset // see issue #115267 - this._onDidLayout.fire(this._dimension); + this.handleContainerDidLayout(this.container, this._mainContainerDimension); + } + } + + private handleContainerDidLayout(container: HTMLElement, dimension: IDimension): void { + if (container === this.container) { + this._onDidLayoutMainContainer.fire(dimension); + } + + if (isActiveDocument(container)) { + this._onDidLayoutActiveContainer.fire(dimension); } } @@ -406,12 +450,17 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi } private onWindowFocusChanged(hasFocus: boolean): void { - if (this.state.runtime.hasFocus === hasFocus) { - return; + if (hasFocus) { + // This is a bit simplified: we assume that the active container + // has changed when receiving focus, but we might end up with + // the same active container as before... + this._onDidChangeActiveContainer.fire(); } - this.state.runtime.hasFocus = hasFocus; - this.updateWindowBorder(); + if (this.state.runtime.hasFocus !== hasFocus) { + this.state.runtime.hasFocus = hasFocus; + this.updateWindowBorder(); + } } private doUpdateLayoutConfiguration(skipLayout?: boolean): void { @@ -1187,8 +1236,8 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi (this.isVisible(Parts.STATUSBAR_PART) ? this.statusBarPartView.minimumHeight : 0) + (this.isVisible(Parts.PANEL_PART) && !isColumn ? this.panelPartView.minimumHeight : 0); - const availableWidth = this.dimension.width - takenWidth; - const availableHeight = this.dimension.height - takenHeight; + const availableWidth = this._mainContainerDimension.width - takenWidth; + const availableHeight = this._mainContainerDimension.height - takenHeight; return new Dimension(availableWidth, availableHeight); } @@ -1401,7 +1450,7 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi this.setEditorHidden(!visible, true); } this._onDidChangePartVisibility.fire(); - this._onDidLayout.fire(this._dimension); + this.handleContainerDidLayout(this.container, this._mainContainerDimension); })); } @@ -1430,24 +1479,20 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi })); } - private getClientArea(): Dimension { - return getClientArea(this.parent); - } - layout(): void { if (!this.disposed) { - this._dimension = this.getClientArea(); - this.logService.trace(`Layout#layout, height: ${this._dimension.height}, width: ${this._dimension.width}`); + this._mainContainerDimension = getClientArea(this.parent); + this.logService.trace(`Layout#layout, height: ${this._mainContainerDimension.height}, width: ${this._mainContainerDimension.width}`); position(this.container, 0, 0, 0, 0, 'relative'); - size(this.container, this._dimension.width, this._dimension.height); + size(this.container, this._mainContainerDimension.width, this._mainContainerDimension.height); // Layout the grid widget - this.workbenchGrid.layout(this._dimension.width, this._dimension.height); + this.workbenchGrid.layout(this._mainContainerDimension.width, this._mainContainerDimension.height); this.initialized = true; // Emit as event - this._onDidLayout.fire(this._dimension); + this.handleContainerDidLayout(this.container, this._mainContainerDimension); } } diff --git a/src/vs/workbench/browser/parts/auxiliarybar/auxiliaryBarPart.ts b/src/vs/workbench/browser/parts/auxiliarybar/auxiliaryBarPart.ts index 684c704ffc376..5ad1c648d6fce 100644 --- a/src/vs/workbench/browser/parts/auxiliarybar/auxiliaryBarPart.ts +++ b/src/vs/workbench/browser/parts/auxiliarybar/auxiliaryBarPart.ts @@ -46,7 +46,7 @@ export class AuxiliaryBarPart extends AbstractPaneCompositePart { get preferredHeight(): number | undefined { // Don't worry about titlebar or statusbar visibility // The difference is minimal and keeps this function clean - return this.layoutService.dimension.height * 0.4; + return this.layoutService.mainContainerDimension.height * 0.4; } get preferredWidth(): number | undefined { diff --git a/src/vs/workbench/browser/parts/editor/editorPanes.ts b/src/vs/workbench/browser/parts/editor/editorPanes.ts index ff42c12e1f47e..571f022421742 100644 --- a/src/vs/workbench/browser/parts/editor/editorPanes.ts +++ b/src/vs/workbench/browser/parts/editor/editorPanes.ts @@ -10,7 +10,7 @@ import Severity from 'vs/base/common/severity'; import { Disposable, DisposableStore } from 'vs/base/common/lifecycle'; import { EditorExtensions, EditorInputCapabilities, IEditorOpenContext, IVisibleEditorPane, createEditorOpenError, isEditorOpenError } from 'vs/workbench/common/editor'; import { EditorInput } from 'vs/workbench/common/editor/editorInput'; -import { Dimension, show, hide, IDomNodePagePosition, isAncestor, getWindow, getActiveWindow } from 'vs/base/browser/dom'; +import { Dimension, show, hide, IDomNodePagePosition, isAncestor, getWindow } from 'vs/base/browser/dom'; import { Registry } from 'vs/platform/registry/common/platform'; import { IEditorPaneRegistry, IEditorPaneDescriptor } from 'vs/workbench/browser/editor'; import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService'; @@ -277,10 +277,7 @@ export class EditorPanes extends Disposable { if (focus && this.shouldRestoreFocus(activeElement)) { pane.focus(); } else if (!internalOptions?.preserveWindowOrder) { - const paneWindow = getWindow(pane.getContainer()); - if (paneWindow !== getActiveWindow()) { - this.hostService.moveTop(paneWindow); - } + this.hostService.moveTop(getWindow(pane.getContainer())); } } diff --git a/src/vs/workbench/browser/parts/editor/editorParts.ts b/src/vs/workbench/browser/parts/editor/editorParts.ts index 42bffcb5bb2c2..7b52a57a3039b 100644 --- a/src/vs/workbench/browser/parts/editor/editorParts.ts +++ b/src/vs/workbench/browser/parts/editor/editorParts.ts @@ -61,7 +61,7 @@ export class EditorParts extends Disposable implements IEditorGroupsService, IEd disposables.add(this.instantiationService.createInstance(WindowTitle, auxiliaryWindow.window, editorPart)); - disposables.add(auxiliaryWindow.onWillLayout(dimension => editorPart.layout(dimension.width, dimension.height, 0, 0))); + disposables.add(auxiliaryWindow.onDidLayout(dimension => editorPart.layout(dimension.width, dimension.height, 0, 0))); auxiliaryWindow.layout(); this._onDidAddGroup.fire(editorPart.activeGroup); diff --git a/src/vs/workbench/browser/parts/media/paneCompositePart.css b/src/vs/workbench/browser/parts/media/paneCompositePart.css index 4f55e904f651f..c4c160fcfe6a3 100644 --- a/src/vs/workbench/browser/parts/media/paneCompositePart.css +++ b/src/vs/workbench/browser/parts/media/paneCompositePart.css @@ -185,9 +185,10 @@ } .monaco-workbench .pane-composite-part > .title > .composite-bar-container > .composite-bar > .monaco-action-bar .action-item.icon .badge.compact.progress-badge .badge-content::before { - mask-size: 12px; - -webkit-mask-size: 12px; - top: 2px; + mask-size: 11px; + -webkit-mask-size: 11px; + top: 3px; + left: 1px; } /* active item indicator */ diff --git a/src/vs/workbench/browser/parts/notifications/notificationsCenter.ts b/src/vs/workbench/browser/parts/notifications/notificationsCenter.ts index 51115350f9436..8ff0cdd81d1ba 100644 --- a/src/vs/workbench/browser/parts/notifications/notificationsCenter.ts +++ b/src/vs/workbench/browser/parts/notifications/notificationsCenter.ts @@ -65,7 +65,7 @@ export class NotificationsCenter extends Themable implements INotificationsCente private registerListeners(): void { this._register(this.model.onDidChangeNotification(e => this.onDidChangeNotification(e))); - this._register(this.layoutService.onDidLayout(dimension => this.layout(Dimension.lift(dimension)))); + this._register(this.layoutService.onDidLayoutMainContainer(dimension => this.layout(Dimension.lift(dimension)))); this._register(this.notificationService.onDidChangeDoNotDisturbMode(() => this.onDidChangeDoNotDisturbMode())); } diff --git a/src/vs/workbench/browser/parts/notifications/notificationsToasts.ts b/src/vs/workbench/browser/parts/notifications/notificationsToasts.ts index f6fa63e49f259..c3f0490bedd45 100644 --- a/src/vs/workbench/browser/parts/notifications/notificationsToasts.ts +++ b/src/vs/workbench/browser/parts/notifications/notificationsToasts.ts @@ -93,7 +93,7 @@ export class NotificationsToasts extends Themable implements INotificationsToast private registerListeners(): void { // Layout - this._register(this.layoutService.onDidLayout(dimension => this.layout(Dimension.lift(dimension)))); + this._register(this.layoutService.onDidLayoutMainContainer(dimension => this.layout(Dimension.lift(dimension)))); // Delay some tasks until after we have restored // to reduce UI pressure from the startup phase diff --git a/src/vs/workbench/browser/parts/panel/panelPart.ts b/src/vs/workbench/browser/parts/panel/panelPart.ts index 05e15a7698b43..00b10081e8a56 100644 --- a/src/vs/workbench/browser/parts/panel/panelPart.ts +++ b/src/vs/workbench/browser/parts/panel/panelPart.ts @@ -42,7 +42,7 @@ export class PanelPart extends AbstractPaneCompositePart { get preferredHeight(): number | undefined { // Don't worry about titlebar or statusbar visibility // The difference is minimal and keeps this function clean - return this.layoutService.dimension.height * 0.4; + return this.layoutService.mainContainerDimension.height * 0.4; } get preferredWidth(): number | undefined { diff --git a/src/vs/workbench/browser/parts/titlebar/commandCenterControl.ts b/src/vs/workbench/browser/parts/titlebar/commandCenterControl.ts index e9b53aef62ed5..8b2176b6466ac 100644 --- a/src/vs/workbench/browser/parts/titlebar/commandCenterControl.ts +++ b/src/vs/workbench/browser/parts/titlebar/commandCenterControl.ts @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { reset } from 'vs/base/browser/dom'; +import { isActiveDocument, reset } from 'vs/base/browser/dom'; import { BaseActionViewItem, IBaseActionViewItemOptions } from 'vs/base/browser/ui/actionbar/actionViewItems'; import { IHoverDelegate } from 'vs/base/browser/ui/iconLabel/iconHoverDelegate'; import { setupCustomHover } from 'vs/base/browser/ui/iconLabel/iconLabelHover'; @@ -57,8 +57,8 @@ export class CommandCenterControl { } }); - this._disposables.add(quickInputService.onShow(this._setVisibility.bind(this, false))); - this._disposables.add(quickInputService.onHide(this._setVisibility.bind(this, true))); + this._disposables.add(Event.filter(quickInputService.onShow, () => isActiveDocument(this.element), this._disposables)(this._setVisibility.bind(this, false))); + this._disposables.add(Event.filter(quickInputService.onHide, () => isActiveDocument(this.element), this._disposables)(this._setVisibility.bind(this, true))); this._disposables.add(titleToolbar); } diff --git a/src/vs/workbench/browser/workbench.contribution.ts b/src/vs/workbench/browser/workbench.contribution.ts index ee33ba1f914a2..8e1e052f18c27 100644 --- a/src/vs/workbench/browser/workbench.contribution.ts +++ b/src/vs/workbench/browser/workbench.contribution.ts @@ -479,7 +479,7 @@ const registry = Registry.as(ConfigurationExtensions.Con 'type': 'string', 'enum': ['side', 'top', 'hidden'], 'default': 'side', - 'markdownDescription': localize({ comment: ['This is the description for a setting'], key: 'activityBarLocation' }, "Controls the location of the activity bar. It can either show to the `side` or `top` (requires `{0}`) of the primary side bar or `hidden`.", '#window.commandCenter#'), + 'markdownDescription': localize({ comment: ['This is the description for a setting'], key: 'activityBarLocation' }, "Controls the location of the activity bar. It can either show to the `side` or `top` (requires {0} set to {1}) of the primary side bar or `hidden`.", '`#window.titleBarStyle#`', '`custom`'), 'enumDescriptions': [ localize('workbench.activityBar.location.side', "Show the activity bar to the side of the primary side bar."), localize('workbench.activityBar.location.top', "Show the activity bar on top of the primary side bar."), diff --git a/src/vs/workbench/contrib/accessibility/browser/accessibleNotificationService.ts b/src/vs/workbench/contrib/accessibility/browser/accessibleNotificationService.ts index 407af81c487c9..5afd59cd2e330 100644 --- a/src/vs/workbench/contrib/accessibility/browser/accessibleNotificationService.ts +++ b/src/vs/workbench/contrib/accessibility/browser/accessibleNotificationService.ts @@ -57,6 +57,10 @@ export class AccessibleNotificationService extends Disposable implements IAccess this._audioCueService.playSound(audioCue.sound.getSound(), true); return; } + if (audioCueSetting !== 'never') { + // Never do both sound and alert + return; + } const alertSettingValue: NotificationSetting = this._configurationService.getValue(alertSetting); if (this._shouldNotify(alertSettingValue, userGesture)) { this._logService.debug('AccessibleNotificationService alerting: ', alertMessage); diff --git a/src/vs/workbench/contrib/accessibility/browser/accessibleView.ts b/src/vs/workbench/contrib/accessibility/browser/accessibleView.ts index a844abc46075a..3757bda1c5894 100644 --- a/src/vs/workbench/contrib/accessibility/browser/accessibleView.ts +++ b/src/vs/workbench/contrib/accessibility/browser/accessibleView.ts @@ -265,7 +265,7 @@ export class AccessibleView extends Disposable { return; } const delegate: IContextViewDelegate = { - getAnchor: () => { return { x: (getActiveWindow().innerWidth / 2) - ((Math.min(this._layoutService.dimension.width * 0.62 /* golden cut */, DIMENSIONS.MAX_WIDTH)) / 2), y: this._layoutService.offset.quickPickTop }; }, + getAnchor: () => { return { x: (getActiveWindow().innerWidth / 2) - ((Math.min(this._layoutService.activeContainerDimension.width * 0.62 /* golden cut */, DIMENSIONS.MAX_WIDTH)) / 2), y: this._layoutService.activeContainerOffset.quickPickTop }; }, render: (container) => { container.classList.add('accessible-view-container'); return this._render(provider!, container, showAccessibleViewHelp); @@ -531,7 +531,7 @@ export class AccessibleView extends Disposable { } })); disposableStore.add(this._editorWidget.onDidContentSizeChange(() => this._layout())); - disposableStore.add(this._layoutService.onDidLayout(() => this._layout())); + disposableStore.add(this._layoutService.onDidLayoutActiveContainer(() => this._layout())); return disposableStore; } @@ -552,7 +552,7 @@ export class AccessibleView extends Disposable { } private _layout(): void { - const dimension = this._layoutService.dimension; + const dimension = this._layoutService.activeContainerDimension; const maxHeight = dimension.height && dimension.height * .4; const height = Math.min(maxHeight, this._editorWidget.getContentHeight()); const width = Math.min(dimension.width * 0.62 /* golden cut */, DIMENSIONS.MAX_WIDTH); diff --git a/src/vs/workbench/contrib/accessibility/browser/unfocusedViewDimmingContribution.ts b/src/vs/workbench/contrib/accessibility/browser/unfocusedViewDimmingContribution.ts index 0cd7d8981475c..9319c21af7f9f 100644 --- a/src/vs/workbench/contrib/accessibility/browser/unfocusedViewDimmingContribution.ts +++ b/src/vs/workbench/contrib/accessibility/browser/unfocusedViewDimmingContribution.ts @@ -3,6 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ +import { createStyleSheet } from 'vs/base/browser/dom'; import { Event } from 'vs/base/common/event'; import { Disposable, toDisposable } from 'vs/base/common/lifecycle'; import { clamp } from 'vs/base/common/numbers'; @@ -73,9 +74,8 @@ export class UnfocusedViewDimmingContribution extends Disposable implements IWor private _getStyleElement(): HTMLStyleElement { if (!this._styleElement) { - this._styleElement = document.createElement('style'); + this._styleElement = createStyleSheet(); this._styleElement.className = 'accessibilityUnfocusedViewOpacity'; - document.head.appendChild(this._styleElement); } return this._styleElement; } diff --git a/src/vs/workbench/contrib/accountEntitlements/browser/accountsEntitlements.contribution.ts b/src/vs/workbench/contrib/accountEntitlements/browser/accountsEntitlements.contribution.ts index 6013c1c2af21c..44169a0024274 100644 --- a/src/vs/workbench/contrib/accountEntitlements/browser/accountsEntitlements.contribution.ts +++ b/src/vs/workbench/contrib/accountEntitlements/browser/accountsEntitlements.contribution.ts @@ -7,11 +7,10 @@ import { LifecyclePhase } from 'vs/workbench/services/lifecycle/common/lifecycle import { Registry } from 'vs/platform/registry/common/platform'; import { Extensions as WorkbenchExtensions, IWorkbenchContributionsRegistry, IWorkbenchContribution } from 'vs/workbench/common/contributions'; import { Disposable, MutableDisposable } from 'vs/base/common/lifecycle'; -import { ContextKeyExpr, ContextKeyTrueExpr, IContextKeyService, RawContextKey } from 'vs/platform/contextkey/common/contextkey'; -import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation'; +import { ContextKeyExpr, IContextKeyService, RawContextKey } from 'vs/platform/contextkey/common/contextkey'; +import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation'; import { ICommandService } from 'vs/platform/commands/common/commands'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; -import { IOpenerService } from 'vs/platform/opener/common/opener'; import { AuthenticationSession, IAuthenticationService } from 'vs/workbench/services/authentication/common/authentication'; import { Action2, MenuId, registerAction2 } from 'vs/platform/actions/common/actions'; import { IActivityService, NumberBadge } from 'vs/workbench/services/activity/common/activity'; @@ -26,19 +25,30 @@ import { localize } from 'vs/nls'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { IRequestService, asText } from 'vs/platform/request/common/request'; import { CancellationToken } from 'vs/base/common/cancellation'; +import { IDialogService } from 'vs/platform/dialogs/common/dialogs'; const configurationKey = 'workbench.accounts.experimental.showEntitlements'; +type EntitlementEnablementClassification = { + enabled: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; isMeasurement: true; comment: 'Flag indicating if the account entitlement is enabled' }; + owner: 'bhavyaus'; + comment: 'Reporting when the account entitlement is shown'; +}; + +type EntitlementActionClassification = { + command: { classification: 'PublicNonPersonalData'; purpose: 'FeatureInsight'; comment: 'The command being executed by the entitlement action' }; + owner: 'bhavyaus'; + comment: 'Reporting the account entitlement action'; +}; + class AccountsEntitlement extends Disposable implements IWorkbenchContribution { private isInitialized = false; private contextKey = new RawContextKey(configurationKey, true).bindTo(this.contextService); constructor( @IContextKeyService readonly contextService: IContextKeyService, - @IInstantiationService readonly instantiationService: IInstantiationService, @ICommandService readonly commandService: ICommandService, @ITelemetryService readonly telemetryService: ITelemetryService, - @IOpenerService readonly openerService: IOpenerService, @IAuthenticationService readonly authenticationService: IAuthenticationService, @IProductService readonly productService: IProductService, @IStorageService readonly storageService: IStorageService, @@ -138,15 +148,17 @@ class AccountsEntitlement extends Disposable implements IWorkbenchContribution { return; } - const accountsMenuBadgeDisposable = this._register(new MutableDisposable()); - this.contextKey.set(true); - const badge = new NumberBadge(1, () => menuTitle); - accountsMenuBadgeDisposable.value = this.activityService.showAccountsActivity({ badge, }); + this.telemetryService.publicLog2<{ enabled: boolean }, EntitlementEnablementClassification>(configurationKey, { enabled: true }); const orgs = parsedResult['organization_login_list'] as any[]; const menuTitle = orgs ? this.productService.gitHubEntitlement!.command.title.replace('{{org}}', orgs[orgs.length - 1]) : this.productService.gitHubEntitlement!.command.titleWithoutPlaceHolder; + const badge = new NumberBadge(1, () => menuTitle); + const accountsMenuBadgeDisposable = this._register(new MutableDisposable()); + accountsMenuBadgeDisposable.value = this.activityService.showAccountsActivity({ badge, }); + + registerAction2(class extends Action2 { constructor() { super({ @@ -168,40 +180,32 @@ class AccountsEntitlement extends Disposable implements IWorkbenchContribution { const commandService = accessor.get(ICommandService); const contextKeyService = accessor.get(IContextKeyService); const storageService = accessor.get(IStorageService); - commandService.executeCommand(productService.gitHubEntitlement!.command.action, productService.gitHubEntitlement!.extensionId!); + const dialogService = accessor.get(IDialogService); + const telemetryService = accessor.get(ITelemetryService); + + const confirmation = await dialogService.confirm({ + type: 'question', + message: productService.gitHubEntitlement!.confirmationMessage, + primaryButton: productService.gitHubEntitlement!.confirmationAction, + }); + + if (confirmation.confirmed) { + commandService.executeCommand(productService.gitHubEntitlement!.command.action, productService.gitHubEntitlement!.extensionId!); + telemetryService.publicLog2<{ command: string }, EntitlementActionClassification>('accountsEntitlements.action', { + command: productService.gitHubEntitlement!.command.action, + }); + } else { + telemetryService.publicLog2<{ command: string }, EntitlementActionClassification>('accountsEntitlements.action', { + command: productService.gitHubEntitlement!.command.action + '-dismissed', + }); + } + accountsMenuBadgeDisposable.clear(); const contextKey = new RawContextKey(configurationKey, true).bindTo(contextKeyService); contextKey.set(false); storageService.store(configurationKey, false, StorageScope.APPLICATION, StorageTarget.MACHINE); } }); - - const altMenuTitle = this.productService.gitHubEntitlement!.altCommand.title!; - const altContextKey = this.productService.gitHubEntitlement!.altCommand.when; - - registerAction2(class extends Action2 { - constructor() { - super({ - id: 'workbench.action.entitlementAltAction', - title: altMenuTitle, - f1: false, - toggled: ContextKeyTrueExpr.INSTANCE, - menu: { - id: MenuId.AccountsContext, - group: '5_AccountsEntitlements', - when: ContextKeyExpr.equals(altContextKey, true), - } - }); - } - - public async run( - accessor: ServicesAccessor - ) { - const productService = accessor.get(IProductService); - const commandService = accessor.get(ICommandService); - commandService.executeCommand(productService.gitHubEntitlement!.altCommand.action, productService.gitHubEntitlement!.extensionId!); - } - }); } } diff --git a/src/vs/workbench/contrib/chat/browser/chatQuick.ts b/src/vs/workbench/contrib/chat/browser/chatQuick.ts index 18e04b212807a..170c2ae89e6d9 100644 --- a/src/vs/workbench/contrib/chat/browser/chatQuick.ts +++ b/src/vs/workbench/contrib/chat/browser/chatQuick.ts @@ -236,11 +236,11 @@ class QuickChat extends Disposable { } private get maxHeight(): number { - return this.layoutService.dimension.height - QuickChat.DEFAULT_HEIGHT_OFFSET; + return this.layoutService.mainContainerDimension.height - QuickChat.DEFAULT_HEIGHT_OFFSET; } private registerListeners(parent: HTMLElement): void { - this._register(this.layoutService.onDidLayout(() => { + this._register(this.layoutService.onDidLayoutMainContainer(() => { if (this.widget.visible) { this.widget.updateDynamicChatTreeItemLayout(2, this.maxHeight); } else { diff --git a/src/vs/workbench/contrib/chat/browser/media/chat.css b/src/vs/workbench/contrib/chat/browser/media/chat.css index 519c9564e7c6a..2d524d8172da0 100644 --- a/src/vs/workbench/contrib/chat/browser/media/chat.css +++ b/src/vs/workbench/contrib/chat/browser/media/chat.css @@ -116,6 +116,7 @@ .interactive-item-container .header .agent-avatar-container { margin-left: -30px; transition: margin 0.15s ease-out; + transition-delay: 0.5s; z-index: -1; } diff --git a/src/vs/workbench/contrib/chat/common/chatModel.ts b/src/vs/workbench/contrib/chat/common/chatModel.ts index 373065274f9b3..471764b058f1a 100644 --- a/src/vs/workbench/contrib/chat/common/chatModel.ts +++ b/src/vs/workbench/contrib/chat/common/chatModel.ts @@ -522,12 +522,12 @@ export class ChatModel extends Disposable implements IChatModel { private readonly _initialRequesterAvatarIconUri: URI | undefined; get requesterAvatarIconUri(): URI | undefined { - return this._session?.requesterAvatarIconUri ?? this._initialRequesterAvatarIconUri; + return this._session ? this._session.requesterAvatarIconUri : this._initialRequesterAvatarIconUri; } private readonly _initialResponderAvatarIconUri: URI | undefined; get responderAvatarIconUri(): URI | undefined { - return this._session?.responderAvatarIconUri ?? this._initialResponderAvatarIconUri; + return this._session ? this._session.responderAvatarIconUri : this._initialResponderAvatarIconUri; } get initState(): ChatModelInitState { diff --git a/src/vs/workbench/contrib/debug/browser/debugToolBar.ts b/src/vs/workbench/contrib/debug/browser/debugToolBar.ts index fec7dc3a7869e..83372ce963791 100644 --- a/src/vs/workbench/contrib/debug/browser/debugToolBar.ts +++ b/src/vs/workbench/contrib/debug/browser/debugToolBar.ts @@ -72,7 +72,7 @@ export class DebugToolBar extends Themable implements IWorkbenchContribution { super(themeService); this.$el = dom.$('div.debug-toolbar'); - this.$el.style.top = `${layoutService.offset.top}px`; + this.$el.style.top = `${layoutService.mainContainerOffset.top}px`; this.dragArea = dom.append(this.$el, dom.$('div.drag-area' + ThemeIcon.asCSSSelector(icons.debugGripper))); @@ -163,7 +163,7 @@ export class DebugToolBar extends Themable implements IWorkbenchContribution { // Prevent default to stop editor selecting text #8524 mouseMoveEvent.preventDefault(); // Reduce x by width of drag handle to reduce jarring #16604 - this.setCoordinates(mouseMoveEvent.posx - 14, mouseMoveEvent.posy - (this.layoutService.offset.top)); + this.setCoordinates(mouseMoveEvent.posx - 14, mouseMoveEvent.posy - (this.layoutService.mainContainerOffset.top)); }); const mouseUpListener = dom.addDisposableGenericMouseUpListener(window, (e: MouseEvent) => { @@ -209,7 +209,7 @@ export class DebugToolBar extends Themable implements IWorkbenchContribution { } private setYCoordinate(y = this.yCoordinate): void { - const titlebarOffset = this.layoutService.offset.top; + const titlebarOffset = this.layoutService.mainContainerOffset.top; this.$el.style.top = `${titlebarOffset + y}px`; this.yCoordinate = y; } diff --git a/src/vs/workbench/contrib/inlineChat/browser/inlineChatController.ts b/src/vs/workbench/contrib/inlineChat/browser/inlineChatController.ts index ac8682ce0efdb..9f620df3117be 100644 --- a/src/vs/workbench/contrib/inlineChat/browser/inlineChatController.ts +++ b/src/vs/workbench/contrib/inlineChat/browser/inlineChatController.ts @@ -273,8 +273,12 @@ export class InlineChatController implements IEditorContribution { if (this._strategy) { needsMargin = this._strategy.needsMargin(); } - this._zone.value.setWidgetMargins(widgetPosition, !needsMargin ? 0 : undefined); - this._zone.value.show(widgetPosition); + if (!this._zone.value.position) { + this._zone.value.setWidgetMargins(widgetPosition, !needsMargin ? 0 : undefined); + this._zone.value.show(widgetPosition); + } else { + this._zone.value.updatePositionAndHeight(widgetPosition); + } } protected async _nextState(state: State, options: InlineChatRunOptions): Promise { diff --git a/src/vs/workbench/contrib/inlineChat/browser/inlineChatDecorations.ts b/src/vs/workbench/contrib/inlineChat/browser/inlineChatDecorations.ts index 53ecd4bd9ae55..a5aa54bb1e5a8 100644 --- a/src/vs/workbench/contrib/inlineChat/browser/inlineChatDecorations.ts +++ b/src/vs/workbench/contrib/inlineChat/browser/inlineChatDecorations.ts @@ -145,6 +145,11 @@ export class InlineChatDecorationsContribution extends Disposable implements IEd } GutterActionsRegistry.registerGutterActionsGenerator(({ lineNumber, editor, accessor }, result) => { + const inlineChatService = accessor.get(IInlineChatService); + const noProviders = Iterable.isEmpty(inlineChatService.getAllProvider()); + if (noProviders) { + return; + } const configurationService = accessor.get(IConfigurationService); result.push(new Action( 'inlineChat.toggleShowGutterIcon', diff --git a/src/vs/workbench/contrib/inlineChat/browser/inlineChatLivePreviewWidget.ts b/src/vs/workbench/contrib/inlineChat/browser/inlineChatLivePreviewWidget.ts index c1081af9cb125..31bf2d50717c3 100644 --- a/src/vs/workbench/contrib/inlineChat/browser/inlineChatLivePreviewWidget.ts +++ b/src/vs/workbench/contrib/inlineChat/browser/inlineChatLivePreviewWidget.ts @@ -21,7 +21,7 @@ import { LineRange } from 'vs/editor/common/core/lineRange'; import { LineRangeMapping } from 'vs/editor/common/diff/rangeMapping'; import { Position } from 'vs/editor/common/core/position'; import { EditorExtensionsRegistry } from 'vs/editor/browser/editorExtensions'; -import { IEditorDecorationsCollection, ScrollType } from 'vs/editor/common/editorCommon'; +import { IEditorDecorationsCollection } from 'vs/editor/common/editorCommon'; import { ILogService } from 'vs/platform/log/common/log'; import { lineRangeAsRange, invertLineRange } from 'vs/workbench/contrib/inlineChat/browser/utils'; import { ResourceLabel } from 'vs/workbench/browser/labels'; @@ -57,7 +57,7 @@ export class InlineChatLivePreviewWidget extends ZoneWidget { @ILogService private readonly _logService: ILogService, @IAccessibilityService private readonly accessibilityService: IAccessibilityService, ) { - super(editor, { showArrow: false, showFrame: false, isResizeable: false, isAccessible: true, allowUnlimitedHeight: true, showInHiddenAreas: true, ordinal: 10000 + 1 }); + super(editor, { showArrow: false, showFrame: false, isResizeable: false, isAccessible: true, allowUnlimitedHeight: true, showInHiddenAreas: true, keepEditorSelection: true, ordinal: 10000 + 1 }); super.create(); assertType(editor.hasModel()); @@ -203,7 +203,7 @@ export class InlineChatLivePreviewWidget extends ZoneWidget { this._hideEditorRanges(this._diffEditor.getOriginalEditor(), ranges.originalDiffHidden); this._hideEditorRanges(this._diffEditor.getModifiedEditor(), ranges.modifiedDiffHidden); - this._diffEditor.revealLine(ranges.modifiedHidden.startLineNumber, ScrollType.Immediate); + // this._diffEditor.revealLine(ranges.modifiedHidden.startLineNumber, ScrollType.Immediate); const lineCountModified = ranges.modifiedHidden.length; const lineCountOriginal = ranges.originalHidden.length; diff --git a/src/vs/workbench/contrib/preferences/browser/settingsEditor2.ts b/src/vs/workbench/contrib/preferences/browser/settingsEditor2.ts index 190ae19245fba..ee6eb4c4a989b 100644 --- a/src/vs/workbench/contrib/preferences/browser/settingsEditor2.ts +++ b/src/vs/workbench/contrib/preferences/browser/settingsEditor2.ts @@ -62,7 +62,6 @@ import { ISettingOverrideClickEvent } from 'vs/workbench/contrib/preferences/bro import { ConfigurationScope, Extensions, IConfigurationRegistry } from 'vs/platform/configuration/common/configurationRegistry'; import { Registry } from 'vs/platform/registry/common/platform'; import { defaultButtonStyles } from 'vs/platform/theme/browser/defaultStyles'; -import { IWorkbenchAssignmentService } from 'vs/workbench/services/assignment/common/assignmentService'; import { IProductService } from 'vs/platform/product/common/productService'; import { IEnvironmentService } from 'vs/platform/environment/common/environment'; import { registerNavigableContainer } from 'vs/workbench/browser/actions/widgetNavigationCommands'; @@ -237,7 +236,6 @@ export class SettingsEditor2 extends EditorPane { @IExtensionService private readonly extensionService: IExtensionService, @ILanguageService private readonly languageService: ILanguageService, @IExtensionManagementService extensionManagementService: IExtensionManagementService, - @IWorkbenchAssignmentService private readonly workbenchAssignmentService: IWorkbenchAssignmentService, @IProductService private readonly productService: IProductService, @IEnvironmentService private readonly environmentService: IEnvironmentService, @IExtensionGalleryService private readonly extensionGalleryService: IExtensionGalleryService, @@ -1291,7 +1289,7 @@ export class SettingsEditor2 extends EditorPane { } const additionalGroups: ISettingsGroup[] = []; - const toggleData = await getExperimentalExtensionToggleData(this.extensionGalleryService, this.workbenchAssignmentService, this.environmentService, this.productService); + const toggleData = await getExperimentalExtensionToggleData(this.extensionGalleryService, this.environmentService, this.productService); if (toggleData && groups.filter(g => g.extensionInfo).length) { for (const key in toggleData.settingsEditorRecommendedExtensions) { const extension = toggleData.recommendedExtensionsGalleryInfo[key]; diff --git a/src/vs/workbench/contrib/preferences/common/preferences.ts b/src/vs/workbench/contrib/preferences/common/preferences.ts index 589a55cad972f..c741a93849d6f 100644 --- a/src/vs/workbench/contrib/preferences/common/preferences.ts +++ b/src/vs/workbench/contrib/preferences/common/preferences.ts @@ -11,7 +11,6 @@ import { IEnvironmentService } from 'vs/platform/environment/common/environment' import { IExtensionGalleryService, IGalleryExtension } from 'vs/platform/extensionManagement/common/extensionManagement'; import { createDecorator } from 'vs/platform/instantiation/common/instantiation'; import { IProductService } from 'vs/platform/product/common/productService'; -import { IWorkbenchAssignmentService } from 'vs/workbench/services/assignment/common/assignmentService'; import { ISearchResult, ISettingsEditorModel } from 'vs/workbench/services/preferences/common/preferences'; export interface IWorkbenchSettingsConfiguration { @@ -108,7 +107,7 @@ export type ExtensionToggleData = { let cachedExtensionToggleData: ExtensionToggleData | undefined; -export async function getExperimentalExtensionToggleData(extensionGalleryService: IExtensionGalleryService, workbenchAssignmentService: IWorkbenchAssignmentService, environmentService: IEnvironmentService, productService: IProductService): Promise { +export async function getExperimentalExtensionToggleData(extensionGalleryService: IExtensionGalleryService, environmentService: IEnvironmentService, productService: IProductService): Promise { if (!ENABLE_EXTENSION_TOGGLE_SETTINGS) { return undefined; } @@ -121,8 +120,7 @@ export async function getExperimentalExtensionToggleData(extensionGalleryService return cachedExtensionToggleData; } - const isTreatment = await workbenchAssignmentService.getTreatment('ExtensionToggleSettings'); - if ((isTreatment || !environmentService.isBuilt) && productService.extensionRecommendations && productService.commonlyUsedSettings) { + if (!environmentService.isBuilt && productService.extensionRecommendations && productService.commonlyUsedSettings) { const settingsEditorRecommendedExtensions: IStringDictionary = {}; Object.keys(productService.extensionRecommendations).forEach(extensionId => { const extensionInfo = productService.extensionRecommendations![extensionId]; diff --git a/src/vs/workbench/contrib/search/browser/searchView.ts b/src/vs/workbench/contrib/search/browser/searchView.ts index 6bc3f38e68078..593545994a1f4 100644 --- a/src/vs/workbench/contrib/search/browser/searchView.ts +++ b/src/vs/workbench/contrib/search/browser/searchView.ts @@ -30,7 +30,7 @@ import { IEditor } from 'vs/editor/common/editorCommon'; import { CommonFindController } from 'vs/editor/contrib/find/browser/findController'; import { MultiCursorSelectionController } from 'vs/editor/contrib/multicursor/browser/multicursor'; import * as nls from 'vs/nls'; -import { IAccessibilityService } from 'vs/platform/accessibility/common/accessibility'; +import { AccessibleNotificationEvent, IAccessibilityService, IAccessibleNotificationService } from 'vs/platform/accessibility/common/accessibility'; import { MenuId } from 'vs/platform/actions/common/actions'; import { ICommandService } from 'vs/platform/commands/common/commands'; import { IConfigurationChangeEvent, IConfigurationService } from 'vs/platform/configuration/common/configuration'; @@ -189,6 +189,7 @@ export class SearchView extends ViewPane { @ITelemetryService telemetryService: ITelemetryService, @INotebookService private readonly notebookService: INotebookService, @ILogService private readonly logService: ILogService, + @IAccessibleNotificationService private readonly accessibleNotificationService: IAccessibleNotificationService ) { super(options, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, instantiationService, openerService, themeService, telemetryService); @@ -1245,7 +1246,7 @@ export class SearchView extends ViewPane { this.viewModel.cancelSearch(); this.tree.ariaLabel = nls.localize('emptySearch', "Empty Search"); - aria.status(nls.localize('ariaSearchResultsClearStatus', "The search results have been cleared")); + this.accessibleNotificationService.notify(AccessibleNotificationEvent.Clear); this.reLayout(); } diff --git a/src/vs/workbench/contrib/splash/browser/partsSplash.ts b/src/vs/workbench/contrib/splash/browser/partsSplash.ts index d8a0657f0f034..08fd7e5a8d518 100644 --- a/src/vs/workbench/contrib/splash/browser/partsSplash.ts +++ b/src/vs/workbench/contrib/splash/browser/partsSplash.ts @@ -37,7 +37,7 @@ export class PartsSplash { @IConfigurationService private readonly _configService: IConfigurationService, @ISplashStorageService private readonly _partSplashService: ISplashStorageService ) { - Event.once(_layoutService.onDidLayout)(() => { + Event.once(_layoutService.onDidLayoutMainContainer)(() => { this._removePartsSplash(); perf.mark('code/didRemovePartsSplash'); }, undefined, this._disposables); diff --git a/src/vs/workbench/contrib/surveys/browser/nps.contribution.ts b/src/vs/workbench/contrib/surveys/browser/nps.contribution.ts index f3cea74430c22..170b8e82ff0d4 100644 --- a/src/vs/workbench/contrib/surveys/browser/nps.contribution.ts +++ b/src/vs/workbench/contrib/surveys/browser/nps.contribution.ts @@ -11,7 +11,7 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { IStorageService, StorageScope, StorageTarget } from 'vs/platform/storage/common/storage'; import { IProductService } from 'vs/platform/product/common/productService'; import { LifecyclePhase } from 'vs/workbench/services/lifecycle/common/lifecycle'; -import { Severity, INotificationService } from 'vs/platform/notification/common/notification'; +import { Severity, INotificationService, NotificationPriority } from 'vs/platform/notification/common/notification'; import { IOpenerService } from 'vs/platform/opener/common/opener'; import { URI } from 'vs/base/common/uri'; import { platform } from 'vs/base/common/process'; @@ -85,7 +85,7 @@ class NPSContribution implements IWorkbenchContribution { storageService.store(SKIP_VERSION_KEY, productService.version, StorageScope.APPLICATION, StorageTarget.USER); } }], - { sticky: true } + { sticky: true, priority: NotificationPriority.URGENT } ); } } diff --git a/src/vs/workbench/contrib/tasks/browser/taskQuickPick.ts b/src/vs/workbench/contrib/tasks/browser/taskQuickPick.ts index 3ae4804392eec..3c15935f60aad 100644 --- a/src/vs/workbench/contrib/tasks/browser/taskQuickPick.ts +++ b/src/vs/workbench/contrib/tasks/browser/taskQuickPick.ts @@ -19,7 +19,7 @@ import { IThemeService } from 'vs/platform/theme/common/themeService'; import { ThemeIcon } from 'vs/base/common/themables'; import { registerIcon } from 'vs/platform/theme/common/iconRegistry'; import { IDialogService } from 'vs/platform/dialogs/common/dialogs'; -import { getColorClass, getColorStyleElement } from 'vs/workbench/contrib/terminal/browser/terminalIcon'; +import { getColorClass, createColorStyleElement } from 'vs/workbench/contrib/terminal/browser/terminalIcon'; import { TaskQuickPickEntryType } from 'vs/workbench/contrib/tasks/browser/abstractTaskService'; import { showWithPinnedItems } from 'vs/platform/quickinput/browser/quickPickPin'; import { IStorageService } from 'vs/platform/storage/common/storage'; @@ -93,9 +93,8 @@ export class TaskQuickPick extends Disposable { public static applyColorStyles(task: Task | ConfiguringTask, entry: TaskQuickPickEntryType | ITaskTwoLevelQuickPickEntry, themeService: IThemeService): void { if (task.configurationProperties.icon?.color) { const colorTheme = themeService.getColorTheme(); - const styleElement = getColorStyleElement(colorTheme); + createColorStyleElement(colorTheme); entry.iconClasses = [getColorClass(task.configurationProperties.icon.color)]; - document.body.appendChild(styleElement); } } diff --git a/src/vs/workbench/contrib/terminal/browser/terminalIcon.ts b/src/vs/workbench/contrib/terminal/browser/terminalIcon.ts index 178224f230cea..07b474a831fe7 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalIcon.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalIcon.ts @@ -14,6 +14,8 @@ import { ThemeIcon } from 'vs/base/common/themables'; import { ITerminalInstance } from 'vs/workbench/contrib/terminal/browser/terminal'; import { ITerminalProfileResolverService } from 'vs/workbench/contrib/terminal/common/terminal'; import { ansiColorMap } from 'vs/workbench/contrib/terminal/common/terminalColorRegistry'; +import { createStyleSheet } from 'vs/base/browser/dom'; +import { IDisposable, toDisposable } from 'vs/base/common/lifecycle'; export function getColorClass(colorKey: string): string; @@ -47,9 +49,9 @@ export function getStandardColors(colorTheme: IColorTheme): string[] { return standardColors; } -export function getColorStyleElement(colorTheme: IColorTheme): HTMLElement { +export function createColorStyleElement(colorTheme: IColorTheme): IDisposable { const standardColors = getStandardColors(colorTheme); - const styleElement = document.createElement('style'); + const styleElement = createStyleSheet(); let css = ''; for (const colorKey of standardColors) { const colorClass = getColorClass(colorKey); @@ -62,7 +64,7 @@ export function getColorStyleElement(colorTheme: IColorTheme): HTMLElement { } } styleElement.textContent = css; - return styleElement; + return toDisposable(() => styleElement.remove()); } export function getColorStyleContent(colorTheme: IColorTheme, editor?: boolean): string { diff --git a/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts b/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts index 751c368ded3c5..1b001ae943306 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts @@ -63,7 +63,7 @@ import { TerminalLaunchHelpAction } from 'vs/workbench/contrib/terminal/browser/ import { TerminalConfigHelper } from 'vs/workbench/contrib/terminal/browser/terminalConfigHelper'; import { TerminalEditorInput } from 'vs/workbench/contrib/terminal/browser/terminalEditorInput'; import { TerminalExtensionsRegistry } from 'vs/workbench/contrib/terminal/browser/terminalExtensions'; -import { getColorClass, getColorStyleElement, getStandardColors } from 'vs/workbench/contrib/terminal/browser/terminalIcon'; +import { getColorClass, createColorStyleElement, getStandardColors } from 'vs/workbench/contrib/terminal/browser/terminalIcon'; import { TerminalProcessManager } from 'vs/workbench/contrib/terminal/browser/terminalProcessManager'; import { showRunRecentQuickPick } from 'vs/workbench/contrib/terminal/browser/terminalRunRecentQuickPick'; import { ITerminalStatusList, TerminalStatus, TerminalStatusList } from 'vs/workbench/contrib/terminal/browser/terminalStatusList'; @@ -2200,7 +2200,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance { } const colorTheme = this._themeService.getColorTheme(); const standardColors: string[] = getStandardColors(colorTheme); - const styleElement = getColorStyleElement(colorTheme); + const colorStyleDisposable = createColorStyleElement(colorTheme); const items: QuickPickItem[] = []; for (const colorKey of standardColors) { const colorClass = getColorClass(colorKey); @@ -2211,7 +2211,6 @@ export class TerminalInstance extends Disposable implements ITerminalInstance { items.push({ type: 'separator' }); const showAllColorsItem = { label: 'Reset to default' }; items.push(showAllColorsItem); - document.body.appendChild(styleElement); const quickPick = this._quickInputService.createQuickPick(); quickPick.items = items; @@ -2231,7 +2230,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance { } quickPick.hide(); - document.body.removeChild(styleElement); + colorStyleDisposable.dispose(); } selectPreviousSuggestion(): void { diff --git a/src/vs/workbench/contrib/terminal/browser/terminalProfileQuickpick.ts b/src/vs/workbench/contrib/terminal/browser/terminalProfileQuickpick.ts index 5701de1746eab..b7afa342a6721 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalProfileQuickpick.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalProfileQuickpick.ts @@ -7,7 +7,7 @@ import { Codicon } from 'vs/base/common/codicons'; import { ConfigurationTarget, IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { IQuickInputService, IKeyMods, IPickOptions, IQuickPickSeparator, IQuickInputButton, IQuickPickItem } from 'vs/platform/quickinput/common/quickInput'; import { IExtensionTerminalProfile, ITerminalProfile, ITerminalProfileObject, TerminalSettingPrefix } from 'vs/platform/terminal/common/terminal'; -import { getUriClasses, getColorClass, getColorStyleElement } from 'vs/workbench/contrib/terminal/browser/terminalIcon'; +import { getUriClasses, getColorClass, createColorStyleElement } from 'vs/workbench/contrib/terminal/browser/terminalIcon'; import { configureTerminalProfileIcon } from 'vs/workbench/contrib/terminal/browser/terminalIcons'; import * as nls from 'vs/nls'; import { IThemeService } from 'vs/platform/theme/common/themeService'; @@ -196,11 +196,10 @@ export class TerminalProfileQuickpick { quickPickItems.push({ type: 'separator', label: nls.localize('terminalProfiles.detected', "detected") }); quickPickItems.push(...this._sortProfileQuickPickItems(autoDetectedProfiles.map(e => this._createProfileQuickPickItem(e)), defaultProfileName!)); } - const styleElement = getColorStyleElement(this._themeService.getColorTheme()); - document.body.appendChild(styleElement); + const colorStyleDisposable = createColorStyleElement(this._themeService.getColorTheme()); const result = await this._quickInputService.pick(quickPickItems, options); - document.body.removeChild(styleElement); + colorStyleDisposable.dispose(); if (!result) { return undefined; } diff --git a/src/vs/workbench/contrib/terminal/browser/terminalService.ts b/src/vs/workbench/contrib/terminal/browser/terminalService.ts index e8c703a704db1..0b03a49122d66 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalService.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalService.ts @@ -1195,8 +1195,7 @@ class TerminalEditorStyle extends Themable { ) { super(_themeService); this._registerListeners(); - this._styleElement = document.createElement('style'); - container.appendChild(this._styleElement); + this._styleElement = dom.createStyleSheet(container); this._register(toDisposable(() => container.removeChild(this._styleElement))); this.updateStyles(); } diff --git a/src/vs/workbench/contrib/terminal/browser/terminalView.ts b/src/vs/workbench/contrib/terminal/browser/terminalView.ts index c96ffb835c495..2c775e3963905 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalView.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalView.ts @@ -49,7 +49,6 @@ import { IHoverService } from 'vs/workbench/services/hover/browser/hover'; import { IAccessibilityService } from 'vs/platform/accessibility/common/accessibility'; export class TerminalViewPane extends ViewPane { - private _fontStyleElement: HTMLElement | undefined; private _parentDomElement: HTMLElement | undefined; private _terminalTabbedView?: TerminalTabbedView; get terminalTabbedView(): TerminalTabbedView | undefined { return this._terminalTabbedView; } @@ -178,15 +177,13 @@ export class TerminalViewPane extends ViewPane { } this._parentDomElement = container; this._parentDomElement.classList.add('integrated-terminal'); - this._fontStyleElement = document.createElement('style'); + dom.createStyleSheet(this._parentDomElement); this._instantiationService.createInstance(TerminalThemeIconStyle, this._parentDomElement); if (!this.shouldShowWelcome()) { this._createTabsView(); } - this._parentDomElement.appendChild(this._fontStyleElement); - this._register(this.configurationService.onDidChangeConfiguration(e => { if (e.affectsConfiguration(TerminalSettingId.FontFamily) || e.affectsConfiguration('editor.fontFamily')) { const configHelper = this._terminalService.configHelper; @@ -558,8 +555,7 @@ class TerminalThemeIconStyle extends Themable { ) { super(_themeService); this._registerListeners(); - this._styleElement = document.createElement('style'); - container.appendChild(this._styleElement); + this._styleElement = dom.createStyleSheet(container); this._register(toDisposable(() => container.removeChild(this._styleElement))); this.updateStyles(); } diff --git a/src/vs/workbench/electron-sandbox/actions/windowActions.ts b/src/vs/workbench/electron-sandbox/actions/windowActions.ts index b174c469230d0..6535966e5b9ed 100644 --- a/src/vs/workbench/electron-sandbox/actions/windowActions.ts +++ b/src/vs/workbench/electron-sandbox/actions/windowActions.ts @@ -62,6 +62,11 @@ export class CloseWindowAction extends Action2 { override async run(accessor: ServicesAccessor): Promise { const nativeHostService = accessor.get(INativeHostService); + const window = getActiveWindow(); + if (isAuxiliaryWindow(window)) { + return nativeHostService.closeWindowById(window.vscodeWindowId); + } + return nativeHostService.closeWindow(); } } @@ -363,7 +368,7 @@ export class ExperimentalSplitWindowAction extends Action2 { let activeWindowId: number; const activeWindow = getActiveWindow(); if (isAuxiliaryWindow(activeWindow)) { - activeWindowId = await activeWindow.vscodeWindowId; + activeWindowId = activeWindow.vscodeWindowId; } else { activeWindowId = environmentService.window.id; } diff --git a/src/vs/workbench/electron-sandbox/window.ts b/src/vs/workbench/electron-sandbox/window.ts index dbdae46a49f40..0c606c68a2c91 100644 --- a/src/vs/workbench/electron-sandbox/window.ts +++ b/src/vs/workbench/electron-sandbox/window.ts @@ -679,14 +679,12 @@ export class NativeWindow extends Disposable { // https://github.com/electron/electron/issues/25578 const that = this; const originalWindowFocus = window.focus.bind(window); - window.focus = async function () { - if (getActiveWindow() === window) { - return; - } - + window.focus = function () { originalWindowFocus(); - await that.nativeHostService.focusWindow(); + if (getActiveWindow() !== window) { + that.nativeHostService.focusWindow(); + } }; } diff --git a/src/vs/workbench/services/auxiliaryWindow/browser/auxiliaryWindowService.ts b/src/vs/workbench/services/auxiliaryWindow/browser/auxiliaryWindowService.ts index c91995c436a67..8c1a57c8aa806 100644 --- a/src/vs/workbench/services/auxiliaryWindow/browser/auxiliaryWindowService.ts +++ b/src/vs/workbench/services/auxiliaryWindow/browser/auxiliaryWindowService.ts @@ -5,7 +5,7 @@ import { localize } from 'vs/nls'; import { Emitter, Event } from 'vs/base/common/event'; -import { Dimension, EventHelper, EventType, addDisposableListener, cloneGlobalStylesheets, copyAttributes, getActiveWindow, getClientArea, isGlobalStylesheet, position, registerWindow, size, trackAttributes } from 'vs/base/browser/dom'; +import { Dimension, EventHelper, EventType, addDisposableListener, cloneGlobalStylesheets, copyAttributes, createMetaElement, getActiveWindow, getClientArea, isGlobalStylesheet, position, registerWindow, size, trackAttributes } from 'vs/base/browser/dom'; import { Disposable, DisposableStore, IDisposable, toDisposable } from 'vs/base/common/lifecycle'; import { InstantiationType, registerSingleton } from 'vs/platform/instantiation/common/extensions'; import { createDecorator } from 'vs/platform/instantiation/common/instantiation'; @@ -34,7 +34,7 @@ export interface IAuxiliaryWindowService { export interface IAuxiliaryWindow extends IDisposable { - readonly onWillLayout: Event; + readonly onDidLayout: Event; readonly onDidClose: Event; readonly window: Window & typeof globalThis; @@ -72,14 +72,14 @@ export class BrowserAuxiliaryWindowService extends Disposable implements IAuxili disposables.add(registerWindow(auxiliaryWindow)); disposables.add(toDisposable(() => auxiliaryWindow.close())); - const { container, onWillLayout, onDidClose } = this.create(auxiliaryWindow, disposables); + const { container, onDidLayout, onDidClose } = this.create(auxiliaryWindow, disposables); - const result = { + const result: IAuxiliaryWindow = { window: auxiliaryWindow, container, - onWillLayout: onWillLayout.event, + onDidLayout: onDidLayout.event, onDidClose: onDidClose.event, - layout: () => onWillLayout.fire(getClientArea(container)), + layout: () => onDidLayout.fire(getClientArea(container)), dispose: () => disposables.dispose() }; @@ -129,18 +129,18 @@ export class BrowserAuxiliaryWindowService extends Disposable implements IAuxili const container = this.applyHTML(auxiliaryWindow, disposables); - const { onWillLayout, onDidClose } = this.registerListeners(auxiliaryWindow, container, disposables); + const { onDidLayout, onDidClose } = this.registerListeners(auxiliaryWindow, container, disposables); - return { container, onWillLayout, onDidClose }; + return { container, onDidLayout, onDidClose }; } private applyMeta(auxiliaryWindow: AuxiliaryWindow): void { - const metaCharset = auxiliaryWindow.document.head.appendChild(document.createElement('meta')); + const metaCharset = createMetaElement(auxiliaryWindow.document.head); metaCharset.setAttribute('charset', 'utf-8'); const originalCSPMetaTag = document.querySelector('meta[http-equiv="Content-Security-Policy"]'); if (originalCSPMetaTag) { - const csp = auxiliaryWindow.document.head.appendChild(document.createElement('meta')); + const csp = createMetaElement(auxiliaryWindow.document.head); copyAttributes(originalCSPMetaTag, csp); const content = csp.getAttribute('content'); @@ -240,13 +240,13 @@ export class BrowserAuxiliaryWindowService extends Disposable implements IAuxili e.preventDefault(); })); - const onWillLayout = disposables.add(new Emitter()); + const onDidLayout = disposables.add(new Emitter()); disposables.add(addDisposableListener(auxiliaryWindow, EventType.RESIZE, () => { const dimension = getClientArea(auxiliaryWindow.document.body); position(container, 0, 0, 0, 0, 'relative'); size(container, dimension.width, dimension.height); - onWillLayout.fire(dimension); + onDidLayout.fire(dimension); })); this._register(addDisposableListener(container, EventType.SCROLL, () => container.scrollTop = 0)); // // Prevent container from scrolling (#55456) @@ -260,7 +260,7 @@ export class BrowserAuxiliaryWindowService extends Disposable implements IAuxili disposables.add(addDisposableListener(auxiliaryWindow.document.body, EventType.DROP, (e: DragEvent) => EventHelper.stop(e))); // Prevent default navigation on drop } - return { onWillLayout, onDidClose }; + return { onDidLayout, onDidClose }; } protected patchMethods(auxiliaryWindow: AuxiliaryWindow): void { diff --git a/src/vs/workbench/services/auxiliaryWindow/electron-sandbox/auxiliaryWindowService.ts b/src/vs/workbench/services/auxiliaryWindow/electron-sandbox/auxiliaryWindowService.ts index dc2bd94711ad8..717e29eabd973 100644 --- a/src/vs/workbench/services/auxiliaryWindow/electron-sandbox/auxiliaryWindowService.ts +++ b/src/vs/workbench/services/auxiliaryWindow/electron-sandbox/auxiliaryWindowService.ts @@ -6,23 +6,23 @@ import { InstantiationType, registerSingleton } from 'vs/platform/instantiation/common/extensions'; import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService'; import { BrowserAuxiliaryWindowService, IAuxiliaryWindowService, AuxiliaryWindow as BaseAuxiliaryWindow } from 'vs/workbench/services/auxiliaryWindow/browser/auxiliaryWindowService'; -import { getGlobals } from 'vs/base/parts/sandbox/electron-sandbox/globals'; +import { ISandboxGlobals } from 'vs/base/parts/sandbox/electron-sandbox/globals'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { IWindowsConfiguration } from 'vs/platform/window/common/window'; import { DisposableStore } from 'vs/base/common/lifecycle'; import { INativeHostService } from 'vs/platform/native/common/native'; -import { DeferredPromise } from 'vs/base/common/async'; import { IDialogService } from 'vs/platform/dialogs/common/dialogs'; import { getActiveWindow } from 'vs/base/browser/dom'; type AuxiliaryWindow = BaseAuxiliaryWindow & { - readonly vscodeWindowId: Promise; + readonly vscode: ISandboxGlobals; + readonly vscodeWindowId: number; }; export function isAuxiliaryWindow(obj: unknown): obj is AuxiliaryWindow { const candidate = obj as AuxiliaryWindow | undefined; - return candidate?.vscodeWindowId instanceof Promise; + return !!candidate?.vscode && Object.hasOwn(candidate, 'vscodeWindowId'); } export class NativeAuxiliaryWindowService extends BrowserAuxiliaryWindowService { @@ -41,7 +41,7 @@ export class NativeAuxiliaryWindowService extends BrowserAuxiliaryWindowService // Zoom level const windowConfig = this.configurationService.getValue(); const windowZoomLevel = typeof windowConfig.window?.zoomLevel === 'number' ? windowConfig.window.zoomLevel : 0; - getGlobals(auxiliaryWindow)?.webFrame?.setZoomLevel(windowZoomLevel); + auxiliaryWindow.vscode.webFrame.setZoomLevel(windowZoomLevel); return super.create(auxiliaryWindow, disposables); } @@ -50,17 +50,14 @@ export class NativeAuxiliaryWindowService extends BrowserAuxiliaryWindowService super.patchMethods(auxiliaryWindow); // Obtain window identifier - const windowId = new DeferredPromise(); + let resolvedWindowId: number; (async () => { - windowId.complete(await getGlobals(auxiliaryWindow)?.ipcRenderer.invoke('vscode:getWindowId')); + resolvedWindowId = await auxiliaryWindow.vscode.ipcRenderer.invoke('vscode:getWindowId'); })(); // Add a `windowId` property Object.defineProperty(auxiliaryWindow, 'vscodeWindowId', { - value: windowId.p, - writable: false, - enumerable: false, - configurable: false + get: () => resolvedWindowId }); // Enable `window.focus()` to work in Electron by @@ -68,14 +65,12 @@ export class NativeAuxiliaryWindowService extends BrowserAuxiliaryWindowService // https://github.com/electron/electron/issues/25578 const that = this; const originalWindowFocus = auxiliaryWindow.focus.bind(auxiliaryWindow); - auxiliaryWindow.focus = async function () { - if (getActiveWindow() === auxiliaryWindow) { - return; - } - + auxiliaryWindow.focus = function () { originalWindowFocus(); - await that.nativeHostService.focusWindow({ targetWindowId: await windowId.p }); + if (getActiveWindow() !== auxiliaryWindow) { + that.nativeHostService.focusWindow({ targetWindowId: resolvedWindowId }); + } }; } } diff --git a/src/vs/workbench/services/host/electron-sandbox/nativeHostService.ts b/src/vs/workbench/services/host/electron-sandbox/nativeHostService.ts index 47b619b855f53..8909c6bd0f5a5 100644 --- a/src/vs/workbench/services/host/electron-sandbox/nativeHostService.ts +++ b/src/vs/workbench/services/host/electron-sandbox/nativeHostService.ts @@ -15,7 +15,7 @@ import { NativeHostService } from 'vs/platform/native/electron-sandbox/nativeHos import { INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-sandbox/environmentService'; import { IMainProcessService } from 'vs/platform/ipc/common/mainProcessService'; import { isAuxiliaryWindow } from 'vs/workbench/services/auxiliaryWindow/electron-sandbox/auxiliaryWindowService'; -import { getActiveDocument, getActiveWindow, onDidRegisterWindow, trackFocus } from 'vs/base/browser/dom'; +import { getActiveDocument, getWindowsCount, onDidRegisterWindow, trackFocus } from 'vs/base/browser/dom'; import { DomEmitter } from 'vs/base/browser/event'; import { memoize } from 'vs/base/common/decorators'; @@ -134,11 +134,11 @@ class WorkbenchHostService extends Disposable implements IHostService { } async moveTop(window: Window & typeof globalThis): Promise { - if (getActiveWindow() === window) { - return; + if (getWindowsCount() <= 1) { + return; // does not apply when only one window is opened } - return this.nativeHostService.moveWindowTop(isAuxiliaryWindow(window) ? { targetWindowId: await window.vscodeWindowId } : undefined); + return this.nativeHostService.moveWindowTop(isAuxiliaryWindow(window) ? { targetWindowId: window.vscodeWindowId } : undefined); } //#endregion diff --git a/src/vs/workbench/services/themes/browser/workbenchThemeService.ts b/src/vs/workbench/services/themes/browser/workbenchThemeService.ts index e82e03d208ab4..102ed180103d0 100644 --- a/src/vs/workbench/services/themes/browser/workbenchThemeService.ts +++ b/src/vs/workbench/services/themes/browser/workbenchThemeService.ts @@ -873,11 +873,9 @@ class ThemeFileWatcher { function _applyRules(styleSheetContent: string, rulesClassName: string) { const themeStyles = document.head.getElementsByClassName(rulesClassName); if (themeStyles.length === 0) { - const elStyle = document.createElement('style'); - elStyle.type = 'text/css'; + const elStyle = createStyleSheet(); elStyle.className = rulesClassName; elStyle.textContent = styleSheetContent; - document.head.appendChild(elStyle); } else { (themeStyles[0]).textContent = styleSheetContent; } diff --git a/src/vs/workbench/test/browser/workbenchTestServices.ts b/src/vs/workbench/test/browser/workbenchTestServices.ts index 6e4e93422e832..c225393802587 100644 --- a/src/vs/workbench/test/browser/workbenchTestServices.ts +++ b/src/vs/workbench/test/browser/workbenchTestServices.ts @@ -588,8 +588,10 @@ export class TestLayoutService implements IWorkbenchLayoutService { openedDefaultEditors = false; - dimension: IDimension = { width: 800, height: 600 }; - offset: ILayoutOffsetInfo = { top: 0, quickPickTop: 0 }; + mainContainerDimension: IDimension = { width: 800, height: 600 }; + activeContainerDimension: IDimension = { width: 800, height: 600 }; + mainContainerOffset: ILayoutOffsetInfo = { top: 0, quickPickTop: 0 }; + activeContainerOffset: ILayoutOffsetInfo = { top: 0, quickPickTop: 0 }; hasContainer = true; container: HTMLElement = window.document.body; @@ -603,10 +605,12 @@ export class TestLayoutService implements IWorkbenchLayoutService { onDidChangePanelPosition: Event = Event.None; onDidChangePanelAlignment: Event = Event.None; onDidChangePartVisibility: Event = Event.None; - onDidLayout = Event.None; + onDidLayoutMainContainer = Event.None; + onDidLayoutActiveContainer = Event.None; onDidChangeNotificationsVisibility = Event.None; onDidAddContainer = Event.None; onDidRemoveContainer = Event.None; + onDidChangeActiveContainer = Event.None; layout(): void { } isRestored(): boolean { return true; }