diff --git a/extensions/emmet/package.nls.json b/extensions/emmet/package.nls.json index d43ba09bc46..3f3bf912fd8 100644 --- a/extensions/emmet/package.nls.json +++ b/extensions/emmet/package.nls.json @@ -25,10 +25,10 @@ "command.decrementNumberByTen": "Decrement by 10", "emmetSyntaxProfiles": "Define profile for specified syntax or use your own profile with specific rules.", "emmetExclude": "An array of languages where Emmet abbreviations should not be expanded.", - "emmetExtensionsPath": "Path to a folder containing Emmet profiles and snippets.'", - "emmetShowExpandedAbbreviation": "Shows expanded Emmet abbreviations as suggestions.\nThe option \"inMarkupAndStylesheetFilesOnly\" applies to html, haml, jade, slim, xml, xsl, css, scss, sass, less and stylus.\nThe option \"always\" applies to all parts of the file regardless of markup/css.", - "emmetShowAbbreviationSuggestions": "Shows possible Emmet abbreviations as suggestions. Not applicable in stylesheets or when emmet.showExpandedAbbreviation is set to \"never\".", - "emmetIncludeLanguages": "Enable Emmet abbreviations in languages that are not supported by default. Add a mapping here between the language and emmet supported language.\n E.g.: {\"vue-html\": \"html\", \"javascript\": \"javascriptreact\"}", + "emmetExtensionsPath": "Path to a folder containing Emmet profiles and snippets.", + "emmetShowExpandedAbbreviation": "Shows expanded Emmet abbreviations as suggestions.\nThe option `\"inMarkupAndStylesheetFilesOnly\"` applies to html, haml, jade, slim, xml, xsl, css, scss, sass, less and stylus.\nThe option `\"always\"` applies to all parts of the file regardless of markup/css.", + "emmetShowAbbreviationSuggestions": "Shows possible Emmet abbreviations as suggestions. Not applicable in stylesheets or when emmet.showExpandedAbbreviation is set to `\"never\"`.", + "emmetIncludeLanguages": "Enable Emmet abbreviations in languages that are not supported by default. Add a mapping here between the language and emmet supported language.\n E.g.: `{\"vue-html\": \"html\", \"javascript\": \"javascriptreact\"}`", "emmetVariables": "Variables to be used in Emmet snippets", "emmetTriggerExpansionOnTab": "When enabled, Emmet abbreviations are expanded when pressing TAB.", "emmetPreferences": "Preferences used to modify behavior of some actions and resolvers of Emmet.", @@ -40,7 +40,7 @@ "emmetPreferencesCssBetween": "Symbol to be placed at the between CSS property and value when expanding CSS abbreviations", "emmetPreferencesSassBetween": "Symbol to be placed at the between CSS property and value when expanding CSS abbreviations in Sass files", "emmetPreferencesStylusBetween": "Symbol to be placed at the between CSS property and value when expanding CSS abbreviations in Stylus files", - "emmetShowSuggestionsAsSnippets": "If true, then Emmet suggestions will show up as snippets allowing you to order them as per editor.snippetSuggestions setting.", + "emmetShowSuggestionsAsSnippets": "If `true`, then Emmet suggestions will show up as snippets allowing you to order them as per `#editor.snippetSuggestions#` setting.", "emmetPreferencesBemElementSeparator": "Element separator used for classes when using the BEM filter", "emmetPreferencesBemModifierSeparator": "Modifier separator used for classes when using the BEM filter", "emmetPreferencesFilterCommentBefore": "A definition of comment that should be placed before matched element when comment filter is applied.", @@ -54,5 +54,5 @@ "emmetPreferencesCssOProperties": "Comma separated CSS properties that get the 'o' vendor prefix when used in Emmet abbreviation that starts with `-`. Set to empty string to always avoid the 'o' prefix.", "emmetPreferencesCssMsProperties": "Comma separated CSS properties that get the 'ms' vendor prefix when used in Emmet abbreviation that starts with `-`. Set to empty string to always avoid the 'ms' prefix.", "emmetPreferencesCssFuzzySearchMinScore": "The minimum score (from 0 to 1) that fuzzy-matched abbreviation should achieve. Lower values may produce many false-positive matches, higher values may reduce possible matches.", - "emmetOptimizeStylesheetParsing": "When set to false, the whole file is parsed to determine if current position is valid for expanding Emmet abbreviations. When set to true, only the content around the current position in css/scss/less files is parsed." + "emmetOptimizeStylesheetParsing": "When set to `false`, the whole file is parsed to determine if current position is valid for expanding Emmet abbreviations. When set to `true`, only the content around the current position in css/scss/less files is parsed." } diff --git a/extensions/fsharp/syntaxes/fsharp.tmLanguage.json b/extensions/fsharp/syntaxes/fsharp.tmLanguage.json index 84356109cde..4b280955153 100644 --- a/extensions/fsharp/syntaxes/fsharp.tmLanguage.json +++ b/extensions/fsharp/syntaxes/fsharp.tmLanguage.json @@ -4,19 +4,19 @@ "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/ionide/ionide-fsgrammar/commit/bd8d1225f93894a50bc8da6f5a76409b024d3d22", + "version": "https://github.com/ionide/ionide-fsgrammar/commit/67c9f45ebbbd5a12d89ffad1661caf8452f1d552", "name": "fsharp", "scopeName": "source.fsharp", "patterns": [ + { + "include": "#compiler_directives" + }, { "include": "#comments" }, { "include": "#constants" }, - { - "include": "#structure" - }, { "include": "#strings" }, @@ -30,10 +30,10 @@ "include": "#definition" }, { - "include": "#attributes" + "include": "#abstract_definition" }, { - "include": "#method_calls" + "include": "#attributes" }, { "include": "#modules" @@ -44,6 +44,9 @@ { "include": "#du_declaration" }, + { + "include": "#record_declaration" + }, { "include": "#keywords" }, @@ -58,6 +61,96 @@ } ], "repository": { + "generic_declaration": { + "patterns": [ + { + "match": "([^<>,])", + "captures": { + "1": { + "name": "entity.name.type.fsharp" + } + } + }, + { + "begin": "(<)", + "end": "(>)", + "beginCaptures": { + "1": { + "name": "keyword.symbol.fsharp" + } + }, + "endCaptures": { + "1": { + "name": "keyword.symbol.fsharp" + } + }, + "patterns": [ + { + "match": "([^<>,])", + "captures": { + "1": { + "name": "entity.name.type.fsharp" + } + } + }, + { + "include": "#generic_declaration" + } + ] + }, + { + "include": "#keywords" + } + ] + }, + "record_signature": { + "patterns": [ + { + "match": "[[:alpha:]0-9'`^_ ]+(=)([[:alpha:]0-9'`^_ ]+)", + "captures": { + "1": { + "name": "keyword.symbol.fsharp" + }, + "2": { + "name": "variable.parameter.fsharp" + } + } + }, + { + "begin": "({)", + "end": "(})", + "beginCaptures": { + "1": { + "name": "keyword.symbol.fsharp" + } + }, + "endCaptures": { + "1": { + "name": "keyword.symbol.fsharp" + } + }, + "patterns": [ + { + "match": "[[:alpha:]0-9'`^_ ]+(=)([[:alpha:]0-9'`^_ ]+)", + "captures": { + "1": { + "name": "keyword.symbol.fsharp" + }, + "2": { + "name": "variable.parameter.fsharp" + } + } + }, + { + "include": "#record_signature" + } + ] + }, + { + "include": "#keywords" + } + ] + }, "anonymous_functions": { "patterns": [ { @@ -66,15 +159,32 @@ "end": "(->)", "beginCaptures": { "1": { - "name": "keyword.other.function-definition.fsharp" + "name": "keyword.fsharp" } }, "endCaptures": { "1": { - "name": "keyword.other.fsharp" + "name": "keyword.fsharp" } }, "patterns": [ + { + "include": "#comments" + }, + { + "include": "#member_declaration" + }, + { + "match": "(:)(\\s*([?[:alpha:]0-9'`<>^._ ]+))*", + "captures": { + "1": { + "name": "keyword.symbol.fsharp" + }, + "2": { + "name": "entity.name.type.fsharp" + } + } + }, { "include": "#variables" } @@ -87,7 +197,7 @@ { "name": "support.function.attribute.fsharp", "begin": "\\[\\<", - "end": "\\>\\]", + "end": "\\>\\]|\\]", "patterns": [ { "include": "$self" @@ -178,57 +288,189 @@ } ] }, + "abstract_definition": { + "name": "abstract.definition.fsharp", + "begin": "\\b(abstract)\\s+(member)?(\\s+\\[\\<.*\\>\\])?\\s*([_[:alpha:]0-9,\\._`\\s]+)(:)", + "end": "\\s*(with)\\b|=|$", + "beginCaptures": { + "1": { + "name": "keyword.fsharp" + }, + "2": { + "name": "keyword.fsharp" + }, + "3": { + "name": "support.function.attribute.fsharp" + }, + "5": { + "name": "keyword.fsharp" + } + }, + "endCaptures": { + "1": { + "name": "keyword.fsharp" + } + }, + "patterns": [ + { + "include": "#comments" + }, + { + "include": "#common_declaration" + }, + { + "match": "\\?{0,1}([[:alpha:]0-9'`^._ ]+)\\s*(:)(\\s*([?[:alpha:]0-9'`^._ ]+)){0,1}", + "captures": { + "1": { + "name": "variable.parameter.fsharp" + }, + "2": { + "name": "keyword.symbol.fsharp" + }, + "3": { + "name": "entity.name.type.fsharp" + } + } + }, + { + "match": "(?!with|get|set\\b)\\b([\\w0-9'`^._]+)", + "comments": "Here we need the \\w modifier in order to check that the words isn't blacklisted", + "captures": { + "1": { + "name": "entity.name.type.fsharp" + } + } + }, + { + "include": "#keywords" + } + ] + }, "definition": { "patterns": [ { "name": "binding.fsharp", - "begin": "\\b(val mutable|val|let mutable|let inline|let|member|static member|override|let!)(\\s+rec|mutable)?(\\s+\\[\\<.*\\>\\])?\\s*(private|internal|public)?\\s+(\\[[^-=]*\\]|[_[:alpha:]]([_[:alpha:]0-9,\\._]|(?<=,)\\s)*|``[_[:alpha:]]([_[:alpha:]0-9,\\._`\\s]|(?<=,)\\s)*)?", - "end": "((``.*``)|(with)\\b|=|$)", + "begin": "\\b(val mutable|val|let mutable|let inline|let|member val|member|static member|override|let!)(\\s+rec|mutable)?(\\s+\\[\\<.*\\>\\])?\\s*(private|internal|public)?\\s+(\\[[^-=]*\\]|[_[:alpha:]]([_[:alpha:]0-9,\\._]+)*|``[_[:alpha:]]([_[:alpha:]0-9,\\._`\\s]+|(?<=,)\\s)*)?", + "end": "\\s*(with\\b|=|\\n+=)", "beginCaptures": { "1": { - "name": "keyword.other.binding.fsharp" + "name": "keyword.fsharp" }, "2": { - "name": "keyword.other.function-recursive.fsharp" + "name": "keyword.fsharp" }, "3": { "name": "support.function.attribute.fsharp" }, "4": { - "name": "keyword.other.access.fsharp" + "name": "keyword.fsharp" }, "5": { - "name": "variable.other.binding.fsharp" + "name": "variable.fsharp" } }, "endCaptures": { "1": { - "name": "keyword.other.fsharp" - }, - "2": { - "name": "variable.other.binding.fsharp" - }, - "3": { - "name": "keyword.other.fsharp" + "name": "keyword.fsharp" } }, "patterns": [ { - "include": "#variables" + "include": "#comments" }, { - "include": "#member_declaration" - }, - { - "match": "(:)(\\s*([?[:alpha:]0-9'<>^._ ]+))*", + "match": "(:)\\s*(\\()?\\s*(([?[:alpha:]0-9'`^._ ]+))*", "captures": { "1": { - "name": "keyword.other.fsharp" + "name": "keyword.symbol.fsharp" + }, + "2": { + "name": "keyword.symbol.fsharp" + }, + "3": { + "name": "entity.name.type.fsharp" + } + } + }, + { + "match": "(\\*\\s*\\()\\s*(([?[:alpha:]0-9'`^._ ]+))*", + "captures": { + "1": { + "name": "keyword.symbol.fsharp" }, "2": { "name": "entity.name.type.fsharp" } } + }, + { + "match": "(->)\\s*(\\()?\\s*([?[:alpha:]0-9'`^._ ]+)*", + "captures": { + "1": { + "name": "keyword.symbol.fsharp" + }, + "2": { + "name": "keyword.symbol.fsharp" + }, + "3": { + "name": "entity.name.type.fsharp" + } + } + }, + { + "match": "(\\*)(\\s*([?[:alpha:]0-9'`^._ ]+))*", + "captures": { + "1": { + "name": "keyword.symbol.fsharp" + }, + "2": { + "name": "entity.name.type.fsharp" + } + } + }, + { + "begin": "(<)", + "end": "(>)", + "beginCaptures": { + "1": { + "name": "keyword.symbol.fsharp" + } + }, + "endCaptures": { + "1": { + "name": "keyword.symbol.fsharp" + } + }, + "patterns": [ + { + "include": "#generic_declaration" + } + ] + }, + { + "begin": "({)", + "end": "(})", + "beginCaptures": { + "1": { + "name": "keyword.symbol.fsharp" + } + }, + "endCaptures": { + "1": { + "name": "keyword.symbol.fsharp" + } + }, + "patterns": [ + { + "include": "#record_signature" + } + ] + }, + { + "include": "#variables" + }, + { + "include": "#keywords" } ] } @@ -242,23 +484,26 @@ "end": "$|(\\|)", "beginCaptures": { "1": { - "name": "keyword.other.fsharp" + "name": "keyword.fsharp" } }, "endCaptures": { "1": { - "name": "keyword.other.fsharp" + "name": "keyword.symbol.fsharp" } }, "patterns": [ { - "match": "([[:alpha:]0-9'`<>^._]+)\\s*(:)\\s*([[:alpha:]0-9'`<>^._]+)", + "include": "#comments" + }, + { + "match": "([[:alpha:]0-9'`<>^._]+|``[[:alpha:]0-9' <>^._]+``)\\s*(:)\\s*([[:alpha:]0-9'`<>^._]+|``[[:alpha:]0-9' <>^._]+``)", "captures": { "1": { "name": "variable.parameter.fsharp" }, "2": { - "name": "keyword.other.fsharp" + "name": "keyword.symbol.fsharp" }, "3": { "name": "entity.name.type.fsharp" @@ -266,17 +511,7 @@ } }, { - "match": "([[:alpha:]0-9'`<>^._]+)", - "captures": { - "1": { - "name": "entity.name.type.fsharp" - } - } - }, - { - "begin": "\\(", - "end": "\\)", - "match": "([[:alpha:]0-9'`<>^._]+)", + "match": "([[:alpha:]0-9'`^._]+)|``([[:alpha:]0-9'^._ ]+)``", "captures": { "1": { "name": "entity.name.type.fsharp" @@ -293,17 +528,12 @@ "keywords": { "patterns": [ { - "name": "keyword.other.fsharp", + "name": "keyword.fsharp", "match": "\\b(private|to|public|internal|function|yield!|yield|class|exception|match|delegate|of|new|in|as|if|then|else|elif|for|begin|end|inherit|do|let\\!|return\\!|return|interface|with|abstract|property|union|enum|member|try|finally|and|when|use|use\\!|struct|while|mutable)(?!')\\b" }, { - "name": "meta.preprocessor.fsharp", - "begin": "^\\s*#\\s*(light)\\b", - "end": "(\\s|$)" - }, - { - "name": "keyword.other.fsharp", - "match": "(&&&|\\|\\|\\||\\^\\^\\^|~~~|<<<|>>>|\\|>|\\->|\\<\\-|:>|:\\?>|:|\\[|\\]|\\;|<>|=|@|\\|\\||&&|{|}|\\||_|\\.\\.|\\+|\\-|\\*|\\/|\\^|\\!|\\>|\\>\\=|\\>\\>|\\<|\\<\\=|\\<\\<)" + "name": "keyword.symbol.fsharp", + "match": "(&&&|\\|\\|\\||\\^\\^\\^|~~~|<<<|>>>|\\|>|\\->|\\<\\-|:>|:\\?>|:|\\[|\\]|\\;|<>|=|@|\\|\\||&&|{|}|\\||_|\\.\\.|\\,|\\+|\\-|\\*|\\/|\\^|\\!|\\>|\\>\\=|\\>\\>|\\<|\\<\\=|\\(|\\)|\\<\\<)" } ] }, @@ -312,18 +542,23 @@ { "name": "entity.name.section.fsharp", "begin": "\\b(namespace|module)\\s*(public|internal|private)?\\s+([[:alpha:]][[:alpha:]0-9'_. ]*)", - "end": "(\\s|$)", + "end": "(\\s?=|\\s|$)", "beginCaptures": { "1": { - "name": "keyword.other.fsharp" + "name": "keyword.fsharp" }, "2": { - "name": "keyword.other.fsharp" + "name": "keyword.fsharp" }, "3": { "name": "entity.name.section.fsharp" } }, + "endCaptures": { + "1": { + "name": "keyword.symbol.fsharp" + } + }, "patterns": [ { "name": "entity.name.section.fsharp", @@ -345,7 +580,7 @@ "end": "(\\s|$)", "beginCaptures": { "1": { - "name": "keyword.other.fsharp" + "name": "keyword.fsharp" }, "2": { "name": "entity.name.section.fsharp" @@ -372,7 +607,7 @@ "end": "(\\s|$)", "beginCaptures": { "1": { - "name": "keyword.other.namespace-definition.fsharp" + "name": "keyword.fsharp" }, "2": { "name": "entity.name.type.namespace.fsharp" @@ -485,7 +720,7 @@ "match": "(%0?-?(\\d+)?((a|t)|(\\.\\d+)?(f|F|e|E|g|G|M)|(b|c|s|d|i|x|X|o)|(s|b|O)|(\\+?A)))", "captures": { "1": { - "name": "keyword.other.format.specifier.fsharp" + "name": "keyword.format.specifier.fsharp" } } } @@ -499,29 +734,132 @@ }, { "name": "variable.parameter.fsharp", - "match": "[[:alpha:]'_]\\w*" + "match": "[[:alpha:]0-9'`<>^._ ]\\w*" + } + ] + }, + "common_declaration": { + "patterns": [ + { + "begin": "\\s*(->)\\s*([[:alpha:]0-9'`^._ ]+)(<)", + "end": "(>)", + "beginCaptures": { + "1": { + "name": "keyword.symbol.fsharp" + }, + "2": { + "name": "entity.name.type.fsharp" + }, + "3": { + "name": "keyword.symbol.fsharp" + } + }, + "endCaptures": { + "1": { + "name": "keyword.symbol.fsharp" + } + }, + "patterns": [ + { + "match": "([[:alpha:]0-9'`^._ ]+)", + "captures": { + "1": { + "name": "entity.name.type.fsharp" + } + } + }, + { + "include": "#keywords" + } + ] + }, + { + "match": "\\s*(->)\\s*([[:alpha:]0-9'`^._ ]+)", + "captures": { + "1": { + "name": "keyword.symbol.fsharp" + }, + "2": { + "name": "entity.name.type.fsharp" + } + } + }, + { + "begin": "\\?{0,1}([[:alpha:]0-9'`^._ ]+)\\s*(:)(\\s*([?[:alpha:]0-9'`^._ ]+)(<))", + "end": "(>)", + "beginCaptures": { + "1": { + "name": "variable.parameter.fsharp" + }, + "2": { + "name": "keyword.symbol.fsharp" + }, + "3": { + "name": "keyword.symbol.fsharp" + }, + "4": { + "name": "entity.name.type.fsharp" + } + }, + "endCaptures": { + "1": { + "name": "keyword.symbol.fsharp" + } + }, + "patterns": [ + { + "match": "([[:alpha:]0-9'`^._ ]+)", + "captures": { + "1": { + "name": "entity.name.type.fsharp" + } + } + }, + { + "include": "#keywords" + } + ] } ] }, "member_declaration": { "patterns": [ { - "begin": "\\(", - "end": "\\)", + "begin": "(\\()", + "end": "(\\))", + "beginCaptures": { + "1": { + "name": "keyword.symbol.fsharp" + } + }, + "endCaptures": { + "1": { + "name": "keyword.symbol.fsharp" + } + }, "patterns": [ { - "match": "\\?{0,1}([[:alpha:]0-9'`<>^._]+)\\s*(:{0,1})(\\s*([?[:alpha:]0-9'<>^._ ]+)){0,1}", + "include": "#comments" + }, + { + "include": "#common_declaration" + }, + { + "match": "\\?{0,1}([[:alpha:]0-9'`^._ ]+)\\s*(:{0,1})(\\s*([?[:alpha:]0-9'`<>^._ ]+)){0,1}", "captures": { "1": { "name": "variable.parameter.fsharp" }, "2": { - "name": "keyword.other.fsharp" + "name": "keyword.symbol.fsharp" }, "3": { "name": "entity.name.type.fsharp" } } + }, + { + "include": "#keywords" } ] } @@ -550,45 +888,210 @@ "patterns": [ { "name": "record.fsharp", - "begin": "(type)[\\s]+(private|internal|public)?[\\s]*([[:alpha:]0-9'<>^:,._]+)[\\s]?(private|internal|public)?[\\s]*", - "end": "[\\s]*((with)|((as) ([[:alpha:]0-9']+))|(=)|[\\n=]|(\\(\\)))", + "begin": "\\b(type)[\\s]+(private|internal|public)?(\\s*\\[\\<.*\\>\\])?[\\s]*([[:alpha:]0-9'`^:,._]+|``[[:alpha:]0-9'`^:,._ ]+``)(<)", + "end": "\\s*((with)|((as)\\s*([[:alpha:]0-9']+))|(=)|[\\n=]|(\\(\\)))", "beginCaptures": { "1": { - "name": "keyword.other.fsharp" + "name": "keyword.fsharp" }, "2": { - "name": "keyword.other.fsharp" + "name": "keyword.fsharp" }, "3": { - "name": "entity.name.type.fsharp" + "name": "support.function.attribute.fsharp" }, "4": { - "name": "keyword.other.fsharp" + "name": "entity.name.type.fsharp" + }, + "5": { + "name": "keyword.symbol.fsharp" } }, "endCaptures": { "2": { - "name": "keyword.other.fsharp" + "name": "keyword.fsharp" }, "3": { - "name": "keyword.other.fsharp" + "name": "keyword.fsharp" }, "4": { - "name": "keyword.other.fsharp" + "name": "keyword.fsharp" }, "5": { "name": "variable.parameter.fsharp" }, "6": { - "name": "keyword.other.fsharp" + "name": "keyword.symbol.fsharp" }, "7": { "name": "constant.language.unit.fsharp" } }, "patterns": [ + { + "include": "#comments" + }, + { + "match": "\\s*(>)\\s*(private|internal|public)?", + "captures": { + "1": { + "name": "keyword.symbol.fsharp" + }, + "2": { + "name": "keyword.fsharp" + } + } + }, + { + "match": "([[:alpha:]0-9'`^._ ]+)", + "captures": { + "1": { + "name": "entity.name.type.fsharp" + } + } + }, { "include": "#member_declaration" + }, + { + "include": "#keywords" + } + ] + }, + { + "name": "record.fsharp", + "begin": "\\b(type)[\\s]+(private|internal|public)?(\\s*\\[\\<.*\\>\\])?[\\s]*([[:alpha:]0-9'`^:,._]+<(.*)>|[[:alpha:]0-9'^:,._]+|``[[:alpha:]0-9'`^:,._ ]+``)[\\s]?(private|internal|public)?[\\s]*", + "end": "\\s*((with)|((as)\\s*([[:alpha:]0-9']+))|(=)|[\\n=]|(\\(\\)))", + "beginCaptures": { + "1": { + "name": "keyword.fsharp" + }, + "2": { + "name": "keyword.fsharp" + }, + "3": { + "name": "support.function.attribute.fsharp" + }, + "4": { + "name": "entity.name.type.fsharp" + }, + "6": { + "name": "keyword.fsharp" + } + }, + "endCaptures": { + "2": { + "name": "keyword.fsharp" + }, + "3": { + "name": "keyword.fsharp" + }, + "4": { + "name": "keyword.fsharp" + }, + "5": { + "name": "variable.parameter.fsharp" + }, + "6": { + "name": "keyword.symbol.fsharp" + }, + "7": { + "name": "constant.language.unit.fsharp" + } + }, + "patterns": [ + { + "include": "#comments" + }, + { + "include": "#member_declaration" + } + ] + } + ] + }, + "record_declaration": { + "patterns": [ + { + "begin": "(\\{)", + "beginCaptures": { + "1": { + "name": "keyword.symbol.fsharp" + } + }, + "end": "(?<=\\})", + "patterns": [ + { + "include": "#comments" + }, + { + "begin": "(((mutable)\\s[[:alpha:]]+)|[[:alpha:]0-9'`<>^._]*)\\s*((?=", - "t": "source.fsharp keyword.other.fsharp", + "t": "source.fsharp keyword.symbol.fsharp", "r": { "dark_plus": "keyword: #569CD6", "light_plus": "keyword: #0000FF", @@ -925,7 +1046,7 @@ }, { "c": "override", - "t": "source.fsharp binding.fsharp keyword.other.binding.fsharp", + "t": "source.fsharp binding.fsharp keyword.fsharp", "r": { "dark_plus": "keyword: #569CD6", "light_plus": "keyword: #0000FF", @@ -947,7 +1068,7 @@ }, { "c": "this.ToString", - "t": "source.fsharp binding.fsharp variable.other.binding.fsharp", + "t": "source.fsharp binding.fsharp variable.fsharp", "r": { "dark_plus": "variable: #9CDCFE", "light_plus": "variable: #001080", @@ -958,13 +1079,13 @@ }, { "c": " ", - "t": "source.fsharp binding.fsharp", + "t": "source.fsharp binding.fsharp variable.parameter.fsharp", "r": { - "dark_plus": "default: #D4D4D4", - "light_plus": "default: #000000", + "dark_plus": "variable: #9CDCFE", + "light_plus": "variable: #001080", "dark_vs": "default: #D4D4D4", "light_vs": "default: #000000", - "hc_black": "default: #FFFFFF" + "hc_black": "variable: #9CDCFE" } }, { @@ -991,7 +1112,7 @@ }, { "c": "=", - "t": "source.fsharp binding.fsharp keyword.other.fsharp", + "t": "source.fsharp binding.fsharp keyword.fsharp", "r": { "dark_plus": "keyword: #569CD6", "light_plus": "keyword: #0000FF", @@ -1057,7 +1178,7 @@ }, { "c": "+", - "t": "source.fsharp keyword.other.fsharp", + "t": "source.fsharp keyword.symbol.fsharp", "r": { "dark_plus": "keyword: #569CD6", "light_plus": "keyword: #0000FF", @@ -1079,7 +1200,7 @@ }, { "c": "+", - "t": "source.fsharp keyword.other.fsharp", + "t": "source.fsharp keyword.symbol.fsharp", "r": { "dark_plus": "keyword: #569CD6", "light_plus": "keyword: #0000FF", @@ -1145,7 +1266,7 @@ }, { "c": "+", - "t": "source.fsharp keyword.other.fsharp", + "t": "source.fsharp keyword.symbol.fsharp", "r": { "dark_plus": "keyword: #569CD6", "light_plus": "keyword: #0000FF", @@ -1211,7 +1332,7 @@ }, { "c": "+", - "t": "source.fsharp keyword.other.fsharp", + "t": "source.fsharp keyword.symbol.fsharp", "r": { "dark_plus": "keyword: #569CD6", "light_plus": "keyword: #0000FF", @@ -1221,7 +1342,51 @@ } }, { - "c": " (string)internalAge", + "c": " ", + "t": "source.fsharp", + "r": { + "dark_plus": "default: #D4D4D4", + "light_plus": "default: #000000", + "dark_vs": "default: #D4D4D4", + "light_vs": "default: #000000", + "hc_black": "default: #FFFFFF" + } + }, + { + "c": "(", + "t": "source.fsharp keyword.symbol.fsharp", + "r": { + "dark_plus": "keyword: #569CD6", + "light_plus": "keyword: #0000FF", + "dark_vs": "keyword: #569CD6", + "light_vs": "keyword: #0000FF", + "hc_black": "keyword: #569CD6" + } + }, + { + "c": "string", + "t": "source.fsharp", + "r": { + "dark_plus": "default: #D4D4D4", + "light_plus": "default: #000000", + "dark_vs": "default: #D4D4D4", + "light_vs": "default: #000000", + "hc_black": "default: #FFFFFF" + } + }, + { + "c": ")", + "t": "source.fsharp keyword.symbol.fsharp", + "r": { + "dark_plus": "keyword: #569CD6", + "light_plus": "keyword: #0000FF", + "dark_vs": "keyword: #569CD6", + "light_vs": "keyword: #0000FF", + "hc_black": "keyword: #569CD6" + } + }, + { + "c": "internalAge", "t": "source.fsharp", "r": { "dark_plus": "default: #D4D4D4", diff --git a/extensions/git/package.nls.json b/extensions/git/package.nls.json index 7dc623f9c8e..7b56fd9e95a 100644 --- a/extensions/git/package.nls.json +++ b/extensions/git/package.nls.json @@ -51,7 +51,7 @@ "command.stashPop": "Pop Stash...", "command.stashPopLatest": "Pop Latest Stash", "config.enabled": "Whether git is enabled", - "config.path": "Path to the git executable", + "config.path": "Path to the git executable.", "config.autoRepositoryDetection": "Configures when repositories should be automatically detected.", "config.autorefresh": "Whether auto refreshing is enabled", "config.autofetch": "Whether auto fetching is enabled", diff --git a/extensions/git/syntaxes/git-rebase.tmLanguage.json b/extensions/git/syntaxes/git-rebase.tmLanguage.json index 3ee481bede1..a2c116bd09b 100644 --- a/extensions/git/syntaxes/git-rebase.tmLanguage.json +++ b/extensions/git/syntaxes/git-rebase.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/textmate/git.tmbundle/commit/d1db42c2d71948662098183a6df519fb53a7a15b", + "version": "https://github.com/textmate/git.tmbundle/commit/3f6ad2138200db14b57a090ecb2d2e733275ca3e", "name": "Git Rebase Message", "scopeName": "text.git-rebase", "patterns": [ @@ -29,7 +29,23 @@ "name": "meta.commit-message.git-rebase" } }, - "match": "^\\s*(pick|p|reword|r|edit|e|squash|s|fixup|f|exec|x|drop|d)\\s+([0-9a-f]+)\\s+(.*)$", + "match": "^\\s*(pick|p|reword|r|edit|e|squash|s|fixup|f|drop|d)\\s+([0-9a-f]+)\\s+(.*)$", + "name": "meta.commit-command.git-rebase" + }, + { + "captures": { + "1": { + "name": "support.function.git-rebase" + }, + "2": { + "patterns": [ + { + "include": "source.shell" + } + ] + } + }, + "match": "^\\s*(exec|x)\\s+(.*)$", "name": "meta.commit-command.git-rebase" } ] diff --git a/extensions/html-language-features/package.nls.json b/extensions/html-language-features/package.nls.json index 73c94b4acf6..077075780c3 100644 --- a/extensions/html-language-features/package.nls.json +++ b/extensions/html-language-features/package.nls.json @@ -1,12 +1,12 @@ { "displayName": "HTML Language Features", "description": "Provides rich language support for HTML, Razor, and Handlebar files", - "html.format.enable.desc": "Enable/disable default HTML formatter", + "html.format.enable.desc": "Enable/disable default HTML formatter.", "html.format.wrapLineLength.desc": "Maximum amount of characters per line (0 = disable).", "html.format.unformatted.desc": "List of tags, comma separated, that shouldn't be reformatted. 'null' defaults to all tags listed at https://www.w3.org/TR/html5/dom.html#phrasing-content.", "html.format.contentUnformatted.desc": "List of tags, comma separated, where the content shouldn't be reformatted. 'null' defaults to the 'pre' tag.", "html.format.indentInnerHtml.desc": "Indent and sections.", - "html.format.preserveNewLines.desc": "Whether existing line breaks before elements should be preserved. Only works before elements, not inside tags or for text.", + "html.format.preserveNewLines.desc": "Controls whether existing line breaks before elements should be preserved. Only works before elements, not inside tags or for text.", "html.format.maxPreserveNewLines.desc": "Maximum number of line breaks to be preserved in one chunk. Use 'null' for unlimited.", "html.format.indentHandlebars.desc": "Format and indent {{#foo}} and {{/foo}}.", "html.format.endWithNewline.desc": "End with a newline.", @@ -16,11 +16,11 @@ "html.format.wrapAttributes.force": "Wrap each attribute except first.", "html.format.wrapAttributes.forcealign": "Wrap each attribute except first and keep aligned.", "html.format.wrapAttributes.forcemultiline": "Wrap each attribute.", - "html.suggest.angular1.desc": "Configures if the built-in HTML language support suggests Angular V1 tags and properties.", - "html.suggest.ionic.desc": "Configures if the built-in HTML language support suggests Ionic tags, properties and values.", - "html.suggest.html5.desc":"Configures if the built-in HTML language support suggests HTML5 tags, properties and values.", + "html.suggest.angular1.desc": "Controls whether the built-in HTML language support suggests Angular V1 tags and properties.", + "html.suggest.ionic.desc": "Controls whether the built-in HTML language support suggests Ionic tags, properties and values.", + "html.suggest.html5.desc": "Controls whether the built-in HTML language support suggests HTML5 tags, properties and values.", "html.trace.server.desc": "Traces the communication between VS Code and the HTML language server.", - "html.validate.scripts": "Configures if the built-in HTML language support validates embedded scripts.", - "html.validate.styles": "Configures if the built-in HTML language support validates embedded styles.", + "html.validate.scripts": "Controls whether the built-in HTML language support validates embedded scripts.", + "html.validate.styles": "Controls whether the built-in HTML language support validates embedded styles.", "html.autoClosingTags": "Enable/disable autoclosing of HTML tags." } \ No newline at end of file diff --git a/extensions/java/syntaxes/java.tmLanguage.json b/extensions/java/syntaxes/java.tmLanguage.json index b629f66dc70..b19cc7b4754 100644 --- a/extensions/java/syntaxes/java.tmLanguage.json +++ b/extensions/java/syntaxes/java.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/atom/language-java/commit/b9f1a853a69184363b0fb15f52da07c9660bf730", + "version": "https://github.com/atom/language-java/commit/2f20bc5a5b07686ec0139e2969431210d81b6991", "name": "Java", "scopeName": "source.java", "patterns": [ @@ -1424,7 +1424,7 @@ }, "variables": { "begin": "(?x)\n(?=\n (\n (void|boolean|byte|char|short|int|float|long|double)\n |\n (?>(\\w+\\.)*[A-Z]+\\w*) # e.g. `javax.ws.rs.Response`, or `String`\n )\n (\n <[\\w<>,\\.?\\s\\[\\]]*> # e.g. `HashMap`, or `List`\n )?\n (\n (\\[\\])* # int[][]\n )?\n \\s+\n [A-Za-z_$][\\w$]* # At least one identifier after space\n ([\\w\\[\\],$][\\w\\[\\],\\s]*)? # possibly primitive array or additional identifiers\n \\s*(=|;)\n)", - "end": "(?=;)", + "end": "(?=\\=|;)", "name": "meta.definition.variable.java", "patterns": [ { @@ -1438,20 +1438,6 @@ { "include": "#all-types" }, - { - "begin": "=", - "beginCaptures": { - "0": { - "name": "keyword.operator.assignment.java" - } - }, - "end": "(?=;)", - "patterns": [ - { - "include": "#code" - } - ] - }, { "include": "#code" } @@ -1459,7 +1445,7 @@ }, "member-variables": { "begin": "(?=private|protected|public|native|synchronized|abstract|threadsafe|transient|static|final)", - "end": "(?=;)", + "end": "(?=\\=|;)", "patterns": [ { "include": "#storage-modifiers" diff --git a/extensions/java/test/colorize-results/basic_java.json b/extensions/java/test/colorize-results/basic_java.json index 1ef3a8ff324..665268f9e6a 100644 --- a/extensions/java/test/colorize-results/basic_java.json +++ b/extensions/java/test/colorize-results/basic_java.json @@ -727,7 +727,7 @@ }, { "c": "=", - "t": "source.java meta.class.java meta.class.body.java meta.method.java meta.method.body.java meta.definition.variable.java keyword.operator.assignment.java", + "t": "source.java meta.class.java meta.class.body.java meta.method.java meta.method.body.java keyword.operator.assignment.java", "r": { "dark_plus": "keyword.operator: #D4D4D4", "light_plus": "keyword.operator: #000000", @@ -738,7 +738,7 @@ }, { "c": " ", - "t": "source.java meta.class.java meta.class.body.java meta.method.java meta.method.body.java meta.definition.variable.java", + "t": "source.java meta.class.java meta.class.body.java meta.method.java meta.method.body.java", "r": { "dark_plus": "default: #D4D4D4", "light_plus": "default: #000000", @@ -749,7 +749,7 @@ }, { "c": "0.0", - "t": "source.java meta.class.java meta.class.body.java meta.method.java meta.method.body.java meta.definition.variable.java constant.numeric.decimal.java", + "t": "source.java meta.class.java meta.class.body.java meta.method.java meta.method.body.java constant.numeric.decimal.java", "r": { "dark_plus": "constant.numeric: #B5CEA8", "light_plus": "constant.numeric: #09885A", @@ -826,7 +826,7 @@ }, { "c": "=", - "t": "source.java meta.class.java meta.class.body.java meta.method.java meta.method.body.java meta.definition.variable.java keyword.operator.assignment.java", + "t": "source.java meta.class.java meta.class.body.java meta.method.java meta.method.body.java keyword.operator.assignment.java", "r": { "dark_plus": "keyword.operator: #D4D4D4", "light_plus": "keyword.operator: #000000", @@ -837,7 +837,7 @@ }, { "c": " ", - "t": "source.java meta.class.java meta.class.body.java meta.method.java meta.method.body.java meta.definition.variable.java", + "t": "source.java meta.class.java meta.class.body.java meta.method.java meta.method.body.java", "r": { "dark_plus": "default: #D4D4D4", "light_plus": "default: #000000", @@ -848,7 +848,7 @@ }, { "c": "10e3", - "t": "source.java meta.class.java meta.class.body.java meta.method.java meta.method.body.java meta.definition.variable.java constant.numeric.decimal.java", + "t": "source.java meta.class.java meta.class.body.java meta.method.java meta.method.body.java constant.numeric.decimal.java", "r": { "dark_plus": "constant.numeric: #B5CEA8", "light_plus": "constant.numeric: #09885A", @@ -925,7 +925,7 @@ }, { "c": "=", - "t": "source.java meta.class.java meta.class.body.java meta.method.java meta.method.body.java meta.definition.variable.java keyword.operator.assignment.java", + "t": "source.java meta.class.java meta.class.body.java meta.method.java meta.method.body.java keyword.operator.assignment.java", "r": { "dark_plus": "keyword.operator: #D4D4D4", "light_plus": "keyword.operator: #000000", @@ -936,7 +936,7 @@ }, { "c": " ", - "t": "source.java meta.class.java meta.class.body.java meta.method.java meta.method.body.java meta.definition.variable.java", + "t": "source.java meta.class.java meta.class.body.java meta.method.java meta.method.body.java", "r": { "dark_plus": "default: #D4D4D4", "light_plus": "default: #000000", @@ -947,7 +947,7 @@ }, { "c": "134l", - "t": "source.java meta.class.java meta.class.body.java meta.method.java meta.method.body.java meta.definition.variable.java constant.numeric.decimal.java", + "t": "source.java meta.class.java meta.class.body.java meta.method.java meta.method.body.java constant.numeric.decimal.java", "r": { "dark_plus": "constant.numeric: #B5CEA8", "light_plus": "constant.numeric: #09885A", @@ -1398,7 +1398,7 @@ }, { "c": "=", - "t": "source.java meta.class.java meta.class.body.java meta.method.java meta.method.body.java meta.definition.variable.java keyword.operator.assignment.java", + "t": "source.java meta.class.java meta.class.body.java meta.method.java meta.method.body.java keyword.operator.assignment.java", "r": { "dark_plus": "keyword.operator: #D4D4D4", "light_plus": "keyword.operator: #000000", @@ -1409,7 +1409,7 @@ }, { "c": " ", - "t": "source.java meta.class.java meta.class.body.java meta.method.java meta.method.body.java meta.definition.variable.java", + "t": "source.java meta.class.java meta.class.body.java meta.method.java meta.method.body.java", "r": { "dark_plus": "default: #D4D4D4", "light_plus": "default: #000000", @@ -1420,7 +1420,7 @@ }, { "c": "0", - "t": "source.java meta.class.java meta.class.body.java meta.method.java meta.method.body.java meta.definition.variable.java constant.numeric.decimal.java", + "t": "source.java meta.class.java meta.class.body.java meta.method.java meta.method.body.java constant.numeric.decimal.java", "r": { "dark_plus": "constant.numeric: #B5CEA8", "light_plus": "constant.numeric: #09885A", @@ -2047,7 +2047,7 @@ }, { "c": "=", - "t": "source.java meta.class.java meta.class.body.java meta.method.java meta.method.body.java meta.definition.variable.java keyword.operator.assignment.java", + "t": "source.java meta.class.java meta.class.body.java meta.method.java meta.method.body.java keyword.operator.assignment.java", "r": { "dark_plus": "keyword.operator: #D4D4D4", "light_plus": "keyword.operator: #000000", @@ -2058,7 +2058,7 @@ }, { "c": " ", - "t": "source.java meta.class.java meta.class.body.java meta.method.java meta.method.body.java meta.definition.variable.java", + "t": "source.java meta.class.java meta.class.body.java meta.method.java meta.method.body.java", "r": { "dark_plus": "default: #D4D4D4", "light_plus": "default: #000000", @@ -2069,7 +2069,7 @@ }, { "c": "0x5", - "t": "source.java meta.class.java meta.class.body.java meta.method.java meta.method.body.java meta.definition.variable.java constant.numeric.hex.java", + "t": "source.java meta.class.java meta.class.body.java meta.method.java meta.method.body.java constant.numeric.hex.java", "r": { "dark_plus": "constant.numeric: #B5CEA8", "light_plus": "constant.numeric: #09885A", @@ -2179,7 +2179,7 @@ }, { "c": "=", - "t": "source.java meta.class.java meta.class.body.java meta.method.java meta.method.body.java meta.definition.variable.java keyword.operator.assignment.java", + "t": "source.java meta.class.java meta.class.body.java meta.method.java meta.method.body.java keyword.operator.assignment.java", "r": { "dark_plus": "keyword.operator: #D4D4D4", "light_plus": "keyword.operator: #000000", @@ -2190,7 +2190,7 @@ }, { "c": " ", - "t": "source.java meta.class.java meta.class.body.java meta.method.java meta.method.body.java meta.definition.variable.java", + "t": "source.java meta.class.java meta.class.body.java meta.method.java meta.method.body.java", "r": { "dark_plus": "default: #D4D4D4", "light_plus": "default: #000000", @@ -2201,7 +2201,7 @@ }, { "c": "new", - "t": "source.java meta.class.java meta.class.body.java meta.method.java meta.method.body.java meta.definition.variable.java keyword.control.new.java", + "t": "source.java meta.class.java meta.class.body.java meta.method.java meta.method.body.java keyword.control.new.java", "r": { "dark_plus": "keyword.control: #C586C0", "light_plus": "keyword.control: #AF00DB", @@ -2212,7 +2212,7 @@ }, { "c": " ", - "t": "source.java meta.class.java meta.class.body.java meta.method.java meta.method.body.java meta.definition.variable.java", + "t": "source.java meta.class.java meta.class.body.java meta.method.java meta.method.body.java", "r": { "dark_plus": "default: #D4D4D4", "light_plus": "default: #000000", @@ -2223,7 +2223,7 @@ }, { "c": "Vector", - "t": "source.java meta.class.java meta.class.body.java meta.method.java meta.method.body.java meta.definition.variable.java meta.function-call.java entity.name.function.java", + "t": "source.java meta.class.java meta.class.body.java meta.method.java meta.method.body.java meta.function-call.java entity.name.function.java", "r": { "dark_plus": "entity.name.function: #DCDCAA", "light_plus": "entity.name.function: #795E26", @@ -2234,7 +2234,7 @@ }, { "c": "(", - "t": "source.java meta.class.java meta.class.body.java meta.method.java meta.method.body.java meta.definition.variable.java meta.function-call.java punctuation.definition.parameters.begin.bracket.round.java", + "t": "source.java meta.class.java meta.class.body.java meta.method.java meta.method.body.java meta.function-call.java punctuation.definition.parameters.begin.bracket.round.java", "r": { "dark_plus": "default: #D4D4D4", "light_plus": "default: #000000", @@ -2245,7 +2245,7 @@ }, { "c": ")", - "t": "source.java meta.class.java meta.class.body.java meta.method.java meta.method.body.java meta.definition.variable.java meta.function-call.java punctuation.definition.parameters.end.bracket.round.java", + "t": "source.java meta.class.java meta.class.body.java meta.method.java meta.method.body.java meta.function-call.java punctuation.definition.parameters.end.bracket.round.java", "r": { "dark_plus": "default: #D4D4D4", "light_plus": "default: #000000", diff --git a/extensions/lua/syntaxes/lua.tmLanguage.json b/extensions/lua/syntaxes/lua.tmLanguage.json index 8adc657f806..c2b31570531 100644 --- a/extensions/lua/syntaxes/lua.tmLanguage.json +++ b/extensions/lua/syntaxes/lua.tmLanguage.json @@ -4,23 +4,25 @@ "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/textmate/lua.tmbundle/commit/42da2c6ff5d86c068f72520f856190f413911a80", + "version": "https://github.com/textmate/lua.tmbundle/commit/8ae5641365b28f697121ba1133890e8d81f5b00e", "name": "Lua", "scopeName": "source.lua", - "comment": "Lua Syntax: version 0.8", "patterns": [ { - "begin": "\\b((local\\b)\\s+)?(function)\\s*(\\s+[a-zA-Z_][a-zA-Z0-9_]*(\\.[a-zA-Z_][a-zA-Z0-9_]*)*(:[a-zA-Z_][a-zA-Z0-9_]*)?\\s*)?(\\()", + "begin": "\\b(?:(local)\\s+)?(function)\\s*(?:\\s+([a-zA-Z_][a-zA-Z0-9_]*(?:([\\.:])[a-zA-Z_][a-zA-Z0-9_]*)?)\\s*)?(\\()", "beginCaptures": { "1": { "name": "storage.modifier.local.lua" }, - "3": { + "2": { "name": "keyword.control.lua" }, - "4": { + "3": { "name": "entity.name.function.lua" }, + "4": { + "name": "punctuation.separator.parameter.lua" + }, "5": { "name": "punctuation.definition.parameters.begin.lua" } @@ -36,6 +38,10 @@ { "match": "[a-zA-Z_][a-zA-Z0-9_]*", "name": "variable.parameter.function.lua" + }, + { + "match": ",", + "name": "punctuation.separator.arguments.lua" } ] }, diff --git a/extensions/lua/test/colorize-results/test_lua.json b/extensions/lua/test/colorize-results/test_lua.json index bc041f3ac30..c1495f2253e 100644 --- a/extensions/lua/test/colorize-results/test_lua.json +++ b/extensions/lua/test/colorize-results/test_lua.json @@ -55,7 +55,18 @@ } }, { - "c": " fact ", + "c": " ", + "t": "source.lua meta.function.lua", + "r": { + "dark_plus": "default: #D4D4D4", + "light_plus": "default: #000000", + "dark_vs": "default: #D4D4D4", + "light_vs": "default: #000000", + "hc_black": "default: #FFFFFF" + } + }, + { + "c": "fact", "t": "source.lua meta.function.lua entity.name.function.lua", "r": { "dark_plus": "entity.name.function: #DCDCAA", @@ -66,7 +77,7 @@ } }, { - "c": "(", + "c": " ", "t": "source.lua meta.function.lua", "r": { "dark_plus": "default: #D4D4D4", @@ -76,6 +87,17 @@ "hc_black": "default: #FFFFFF" } }, + { + "c": "(", + "t": "source.lua meta.function.lua punctuation.definition.parameters.begin.lua", + "r": { + "dark_plus": "default: #D4D4D4", + "light_plus": "default: #000000", + "dark_vs": "default: #D4D4D4", + "light_vs": "default: #000000", + "hc_black": "default: #FFFFFF" + } + }, { "c": "n", "t": "source.lua meta.function.lua variable.parameter.function.lua", diff --git a/extensions/markdown-language-features/src/extension.ts b/extensions/markdown-language-features/src/extension.ts index a9d95e36ce8..7786db20216 100644 --- a/extensions/markdown-language-features/src/extension.ts +++ b/extensions/markdown-language-features/src/extension.ts @@ -24,7 +24,7 @@ export function activate(context: vscode.ExtensionContext) { const telemetryReporter = loadDefaultTelemetryReporter(); context.subscriptions.push(telemetryReporter); - const contributions = getMarkdownExtensionContributions(); + const contributions = getMarkdownExtensionContributions(context); const cspArbiter = new ExtensionContentSecurityPolicyArbiter(context.globalState, context.workspaceState); const engine = new MarkdownEngine(contributions, githubSlugifier); diff --git a/extensions/markdown-language-features/src/features/preview.ts b/extensions/markdown-language-features/src/features/preview.ts index 2f4993fa13a..f15efe24098 100644 --- a/extensions/markdown-language-features/src/features/preview.ts +++ b/extensions/markdown-language-features/src/features/preview.ts @@ -271,6 +271,14 @@ export class MarkdownPreview { this.editor.title = MarkdownPreview.getPreviewTitle(this._resource, this._locked); } + private get iconPath() { + const root = path.join(this._contributions.extensionPath, 'media'); + return { + light: vscode.Uri.file(path.join(root, 'Preview.svg')), + dark: vscode.Uri.file(path.join(root, 'Preview_inverse.svg')) + }; + } + private isPreviewOf(resource: vscode.Uri): boolean { return this._resource.fsPath === resource.fsPath; } @@ -327,6 +335,7 @@ export class MarkdownPreview { const content = await this._contentProvider.provideTextDocumentContent(document, this._previewConfigurations, this.line, this.state); if (this._resource === resource) { this.editor.title = MarkdownPreview.getPreviewTitle(this._resource, this._locked); + this.editor.iconPath = this.iconPath; this.editor.webview.options = MarkdownPreview.getWebviewOptions(resource, this._contributions); this.editor.webview.html = content; } diff --git a/extensions/markdown-language-features/src/markdownExtensions.ts b/extensions/markdown-language-features/src/markdownExtensions.ts index a9ef207cf38..55c8d76e7a4 100644 --- a/extensions/markdown-language-features/src/markdownExtensions.ts +++ b/extensions/markdown-language-features/src/markdownExtensions.ts @@ -26,6 +26,7 @@ const resolveExtensionResources = (extension: vscode.Extension, resourcePat }; export interface MarkdownContributions { + readonly extensionPath: string; readonly previewScripts: vscode.Uri[]; readonly previewStyles: vscode.Uri[]; readonly markdownItPlugins: Thenable<(md: any) => any>[]; @@ -40,6 +41,10 @@ class MarkdownExtensionContributions implements MarkdownContributions { private _loaded = false; + public constructor( + public readonly extensionPath: string, + ) { } + public get previewScripts(): vscode.Uri[] { this.ensureLoaded(); return this._scripts; @@ -111,6 +116,6 @@ class MarkdownExtensionContributions implements MarkdownContributions { } } -export function getMarkdownExtensionContributions(): MarkdownContributions { - return new MarkdownExtensionContributions(); +export function getMarkdownExtensionContributions(context: vscode.ExtensionContext): MarkdownContributions { + return new MarkdownExtensionContributions(context.extensionPath); } \ No newline at end of file diff --git a/extensions/markdown-language-features/src/test/engine.ts b/extensions/markdown-language-features/src/test/engine.ts index 860bafad7cc..a1834e057a2 100644 --- a/extensions/markdown-language-features/src/test/engine.ts +++ b/extensions/markdown-language-features/src/test/engine.ts @@ -9,6 +9,7 @@ import { MarkdownContributions } from '../markdownExtensions'; import { githubSlugifier } from '../slugify'; const emptyContributions = new class implements MarkdownContributions { + readonly extensionPath = ''; readonly previewScripts: vscode.Uri[] = []; readonly previewStyles: vscode.Uri[] = []; readonly previewResourceRoots: vscode.Uri[] = []; diff --git a/extensions/npm/.vscode/tasks.json b/extensions/npm/.vscode/tasks.json index 0a411c1c867..b7c8a281635 100644 --- a/extensions/npm/.vscode/tasks.json +++ b/extensions/npm/.vscode/tasks.json @@ -1,8 +1,10 @@ { - "version": "0.1.0", + "version": "2.0.0", "command": "npm", - "isShellCommand": true, - "showOutput": "silent", + "type": "shell", + "presentation": { + "reveal": "silent", + }, "args": ["run", "compile"], "isBackground": true, "problemMatcher": "$tsc-watch" diff --git a/extensions/npm/README.md b/extensions/npm/README.md index c3dd9437203..6c8fa19625d 100644 --- a/extensions/npm/README.md +++ b/extensions/npm/README.md @@ -29,5 +29,5 @@ The extension provides code lense actions to run or debug a script from the edit - `npm.exclude` - Glob patterns for folders that should be excluded from automatic script detection. The pattern is matched against the **absolute path** of the package.json. For example, to exclude all test folders use '**/test/**'. - `npm.enableScriptExplorer` - Enable an explorer view for npm scripts. - `npm.scriptExplorerAction` - The default click action: `open` or `run`, the default is `open`. -- `npm.scriptCodeLens.enable` - Enable/disable the code lenses to run a script. +- `npm.scriptCodeLens.enable` - Enable/disable the code lenses to run a script, the default is `false`. diff --git a/extensions/npm/package.json b/extensions/npm/package.json index 7f4b794ee0c..434f7ea20b1 100644 --- a/extensions/npm/package.json +++ b/extensions/npm/package.json @@ -180,7 +180,7 @@ }, "npm.scriptCodeLens.enable": { "type": "boolean", - "default": true, + "default": false, "scope": "resource", "description": "%config.scriptCodeLens.enable%" }, diff --git a/extensions/package.json b/extensions/package.json index 7b4fd5a5bd0..1c3a19a4f02 100644 --- a/extensions/package.json +++ b/extensions/package.json @@ -3,7 +3,7 @@ "version": "0.0.1", "description": "Dependencies shared by all extensions", "dependencies": { - "typescript": "3.0.1-insiders.20180713" + "typescript": "3.0.1-insiders.20180723" }, "scripts": { "postinstall": "node ./postinstall" diff --git a/extensions/python/syntaxes/MagicPython.tmLanguage.json b/extensions/python/syntaxes/MagicPython.tmLanguage.json index 44a995bc046..fc32d74cec5 100644 --- a/extensions/python/syntaxes/MagicPython.tmLanguage.json +++ b/extensions/python/syntaxes/MagicPython.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/MagicStack/MagicPython/commit/b453f26ed856c9b16a053517c41207e3a72cc7d5", + "version": "https://github.com/MagicStack/MagicPython/commit/fb56c6a98d684e30bed1b0f9647e85741a48f914", "name": "MagicPython", "scopeName": "source.python", "patterns": [ @@ -97,7 +97,8 @@ }, "docstring-statement": { "begin": "^(?=\\s*[rR]?(\\'\\'\\'|\\\"\\\"\\\"|\\'|\\\"))", - "end": "(?<=\\'\\'\\'|\\\"\\\"\\\"|\\'|\\\")", + "comment": "the string either terminates correctly or by the beginning of a new line (this is for single line docstrings that aren't terminated) AND it's not followed by another docstring", + "end": "((?<=\\1)|^)(?!\\s*[rR]?(\\'\\'\\'|\\\"\\\"\\\"|\\'|\\\"))", "patterns": [ { "include": "#docstring" @@ -164,7 +165,7 @@ { "name": "string.quoted.docstring.single.python", "begin": "(\\'|\\\")", - "end": "(\\1)|((?=^]? [-+ ]? \\#?\n \\d* ,? (\\.\\d+)? [bcdeEfFgGnosxX%]? )?\n })\n )\n", + "name": "meta.format.brace.python", + "match": "(?x)\n (\n {{ | }}\n | (?:\n {\n \\w*? (\\.[[:alpha:]_]\\w*? | \\[[^\\]'\"]+\\])*?\n (![rsa])?\n ( : \\w? [<>=^]? [-+ ]? \\#?\n \\d* ,? (\\.\\d+)? [bcdeEfFgGnosxX%]? )?\n })\n )\n", "captures": { - "2": { - "name": "storage.type.format.python" + "1": { + "name": "constant.character.format.placeholder.other.python" }, "3": { "name": "storage.type.format.python" + }, + "4": { + "name": "storage.type.format.python" } } }, { - "name": "constant.character.format.placeholder.other.python", - "begin": "(?x)\n \\{\n \\w*? (\\.[[:alpha:]_]\\w*? | \\[[^\\]'\"]+\\])*?\n (![rsa])?\n (:)\n (?=[^'\"}\\n]*\\})\n", - "end": "\\}", - "beginCaptures": { - "2": { - "name": "storage.type.format.python" + "name": "meta.format.brace.python", + "match": "(?x)\n (\n {\n \\w*? (\\.[[:alpha:]_]\\w*? | \\[[^\\]'\"]+\\])*?\n (![rsa])?\n (:)\n (\n [^'\"{}\\n]+?\n |\n \\{ [^'\"}\\n]*? \\}\n )*\n }\n )\n", + "captures": { + "1": { + "name": "constant.character.format.placeholder.other.python" }, "3": { "name": "storage.type.format.python" + }, + "4": { + "name": "storage.type.format.python" } - }, - "patterns": [ - { - "match": "(?x) \\{ [^'\"}\\n]*? \\} (?=.*?\\})\n" - } - ] + } } ] }, @@ -4537,7 +4543,7 @@ }, "string-quoted-single-line": { "name": "string.quoted.single.python", - "begin": "(\\b[rR](?=[uU]))?([uU])?((['\"]))", + "begin": "(?:\\b([rR])(?=[uU]))?([uU])?((['\"]))", "end": "(\\3)|((?", + "name": "comment.block.xml" + } + }, + { + "begin": "", + "name": "comment.block.xml", + "patterns": [ + { + "begin": "--(?!>)", + "captures": { + "0": { + "name": "invalid.illegal.bad-comments-or-CDATA.xml" + } + } + } + ] } - }, - "end": "--%?>", - "name": "comment.block.xml" + ] } } } \ No newline at end of file diff --git a/extensions/yarn.lock b/extensions/yarn.lock index 6ed3a9d31c4..1d5962931ac 100644 --- a/extensions/yarn.lock +++ b/extensions/yarn.lock @@ -2,6 +2,6 @@ # yarn lockfile v1 -typescript@3.0.1-insiders.20180713: - version "3.0.1-insiders.20180713" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.0.1-insiders.20180713.tgz#02775b5197ab02b79ed5b84e7483c18ed164e55e" +typescript@3.0.1-insiders.20180723: + version "3.0.1-insiders.20180723" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.0.1-insiders.20180723.tgz#266fbafb349a6429777ab3525cda3bb0a2adc661" diff --git a/package.json b/package.json index a0af247bb1f..6968445d439 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "code-oss-dev", "version": "1.26.0", - "distro": "ba277984505f7010dbff765d57412a25891b4dea", + "distro": "4b5c6aa6ea6f222d62d08ca5653049b200be93a5", "author": { "name": "Microsoft Corporation" }, @@ -50,7 +50,8 @@ "vscode-nsfw": "1.0.17", "vscode-ripgrep": "^1.0.1", "vscode-textmate": "^4.0.1", - "vscode-xterm": "3.6.0-beta3", + "vscode-uri": "1.0.5", + "vscode-xterm": "3.6.0-beta5", "yauzl": "^2.9.1" }, "devDependencies": { @@ -138,4 +139,4 @@ "windows-mutex": "^0.2.0", "windows-process-tree": "0.2.2" } -} \ No newline at end of file +} diff --git a/src/typings/vscode-xterm.d.ts b/src/typings/vscode-xterm.d.ts index eb8c87e277a..b3a6c367c60 100644 --- a/src/typings/vscode-xterm.d.ts +++ b/src/typings/vscode-xterm.d.ts @@ -680,6 +680,8 @@ declare module 'vscode-xterm' { // Modifications to official .d.ts below declare module 'vscode-xterm' { interface TerminalCore { + debug: boolean; + buffer: { y: number; ybase: number; diff --git a/src/vs/base/browser/ui/inputbox/inputBox.ts b/src/vs/base/browser/ui/inputbox/inputBox.ts index 17b36ec3dea..1691821da48 100644 --- a/src/vs/base/browser/ui/inputbox/inputBox.ts +++ b/src/vs/base/browser/ui/inputbox/inputBox.ts @@ -535,6 +535,7 @@ export class HistoryInputBox extends InputBox implements IHistoryNavigationWidge if (next) { this.value = next; + aria.status(this.value); } } @@ -550,6 +551,7 @@ export class HistoryInputBox extends InputBox implements IHistoryNavigationWidge if (previous) { this.value = previous; + aria.status(this.value); } } diff --git a/src/vs/base/parts/ipc/common/ipc.ts b/src/vs/base/parts/ipc/common/ipc.ts index 37555c26b07..67376daaf3d 100644 --- a/src/vs/base/parts/ipc/common/ipc.ts +++ b/src/vs/base/parts/ipc/common/ipc.ts @@ -260,7 +260,8 @@ export class ChannelClient implements IChannelClient, IDisposable { let uninitializedPromise: TPromise | null = null; const emitter = new Emitter({ onFirstListenerAdd: () => { - uninitializedPromise = this.whenInitialized().then(() => { + uninitializedPromise = this.whenInitialized(); + uninitializedPromise.then(() => { uninitializedPromise = null; this.send(request.raw); }); diff --git a/src/vs/base/parts/ipc/node/ipc.cp.ts b/src/vs/base/parts/ipc/node/ipc.cp.ts index 38a8a96f813..3d863aa9e0b 100644 --- a/src/vs/base/parts/ipc/node/ipc.cp.ts +++ b/src/vs/base/parts/ipc/node/ipc.cp.ts @@ -150,6 +150,7 @@ export class Client implements IChannelClient, IDisposable { } this.activeRequests.splice(this.activeRequests.indexOf(listener), 1); + listener.dispose(); if (this.activeRequests.length === 0) { this.disposeDelayer.trigger(() => this.disposeClient()); diff --git a/src/vs/base/parts/quickopen/browser/quickOpenWidget.ts b/src/vs/base/parts/quickopen/browser/quickOpenWidget.ts index 2a3a7f0d15a..8341fd31256 100644 --- a/src/vs/base/parts/quickopen/browser/quickOpenWidget.ts +++ b/src/vs/base/parts/quickopen/browser/quickOpenWidget.ts @@ -152,6 +152,15 @@ export class QuickOpenWidget extends Disposable implements IModelProvider { DOM.EventHelper.stop(e, true); this.hide(HideReason.CANCELED); + } else if (keyboardEvent.keyCode === KeyCode.Tab && !keyboardEvent.altKey && !keyboardEvent.ctrlKey && !keyboardEvent.metaKey) { + const stops = e.currentTarget.querySelectorAll('input, .monaco-tree, .monaco-tree-row.focused .action-label.icon'); + if (keyboardEvent.shiftKey && keyboardEvent.target === stops[0]) { + DOM.EventHelper.stop(e, true); + stops[stops.length - 1].focus(); + } else if (!keyboardEvent.shiftKey && keyboardEvent.target === stops[stops.length - 1]) { + DOM.EventHelper.stop(e, true); + stops[0].focus(); + } } }) .on(DOM.EventType.CONTEXT_MENU, (e: Event) => DOM.EventHelper.stop(e, true)) // Do this to fix an issue on Mac where the menu goes into the way @@ -243,7 +252,7 @@ export class QuickOpenWidget extends Disposable implements IModelProvider { horizontalScrollMode: ScrollbarVisibility.Hidden, ariaLabel: nls.localize('treeAriaLabel', "Quick Picker"), keyboardSupport: this.options.keyboardSupport, - preventRootFocus: true + preventRootFocus: false })); this.treeElement = this.tree.getHTMLElement(); @@ -348,7 +357,7 @@ export class QuickOpenWidget extends Disposable implements IModelProvider { if (keyboardEvent.keyCode === KeyCode.DownArrow || keyboardEvent.keyCode === KeyCode.UpArrow || keyboardEvent.keyCode === KeyCode.PageDown || keyboardEvent.keyCode === KeyCode.PageUp) { DOM.EventHelper.stop(e, true); this.navigateInTree(keyboardEvent.keyCode, keyboardEvent.shiftKey); - this.inputBox.inputElement.focus(); + this.treeElement.focus(); } }); return this.builder.getHTMLElement(); diff --git a/src/vs/code/electron-main/windows.ts b/src/vs/code/electron-main/windows.ts index 4979ce9df99..482676324a4 100644 --- a/src/vs/code/electron-main/windows.ts +++ b/src/vs/code/electron-main/windows.ts @@ -851,7 +851,7 @@ export class WindowsManager implements IWindowsMainService { if (cli['folder-uri'] && cli['folder-uri'].length) { const arg = cli['folder-uri']; const folderUris: string[] = typeof arg === 'string' ? [arg] : arg; - pathsToOpen.push(...arrays.coalesce(folderUris.map(candidate => this.parseUri(URI.parse(candidate), { ignoreFileNotFound: true, gotoLineMode: cli.goto })))); + pathsToOpen.push(...arrays.coalesce(folderUris.map(candidate => this.parseUri(this.parseFolderUriArg(candidate), { ignoreFileNotFound: true, gotoLineMode: cli.goto })))); } // folder or file paths @@ -963,8 +963,16 @@ export class WindowsManager implements IWindowsMainService { return restoreWindows; } + private parseFolderUriArg(arg: string): URI { + // Do not support if user has passed folder path on Windows + if (isWindows && /^([a-z])\:(.*)$/i.test(arg)) { + return null; + } + return URI.parse(arg); + } + private parseUri(anyUri: URI, options?: { ignoreFileNotFound?: boolean, gotoLineMode?: boolean, forceOpenWorkspaceAsFile?: boolean; }): IPathToOpen { - if (!anyUri) { + if (!anyUri || !anyUri.scheme) { return null; } @@ -1110,7 +1118,7 @@ export class WindowsManager implements IWindowsMainService { if (openConfig.cli['folder-uri']) { const arg = openConfig.cli['folder-uri']; const folderUris: string[] = typeof arg === 'string' ? [arg] : arg; - if (folderUris.some(uri => !!findWindowOnWorkspaceOrFolderUri(WindowsManager.WINDOWS, URI.parse(uri)))) { + if (folderUris.some(uri => !!findWindowOnWorkspaceOrFolderUri(WindowsManager.WINDOWS, this.parseFolderUriArg(uri)))) { openConfig.cli['folder-uri'] = []; } } diff --git a/src/vs/editor/browser/controller/coreCommands.ts b/src/vs/editor/browser/controller/coreCommands.ts index 05c024d8d8c..083e0fd94a6 100644 --- a/src/vs/editor/browser/controller/coreCommands.ts +++ b/src/vs/editor/browser/controller/coreCommands.ts @@ -5,6 +5,7 @@ 'use strict'; +import * as nls from 'vs/nls'; import { Position } from 'vs/editor/common/core/position'; import { Range } from 'vs/editor/common/core/range'; import * as editorCommon from 'vs/editor/common/editorCommon'; @@ -16,7 +17,7 @@ import { registerEditorCommand, ICommandOptions, EditorCommand, Command } from ' import { IColumnSelectResult, ColumnSelection } from 'vs/editor/common/controller/cursorColumnSelection'; import { EditorContextKeys } from 'vs/editor/common/editorContextKeys'; import { KeyMod, KeyCode } from 'vs/base/common/keyCodes'; -import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry'; +import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; import H = editorCommon.Handler; import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService'; import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey'; @@ -26,8 +27,9 @@ import { TypeOperations } from 'vs/editor/common/controller/cursorTypeOperations import { DeleteOperations } from 'vs/editor/common/controller/cursorDeleteOperations'; import { VerticalRevealType } from 'vs/editor/common/view/viewEvents'; import { ICodeEditor } from 'vs/editor/browser/editorBrowser'; +import { MenuId } from 'vs/platform/actions/common/actions'; -const CORE_WEIGHT = KeybindingsRegistry.WEIGHT.editorCore(); +const CORE_WEIGHT = KeybindingWeight.EditorCore; export abstract class CoreEditorCommand extends EditorCommand { public runEditorCommand(accessor: ServicesAccessor, editor: ICodeEditor, args: any): void { @@ -1620,7 +1622,7 @@ function findFocusedEditor(accessor: ServicesAccessor): ICodeEditor { } function registerCommand(command: Command) { - KeybindingsRegistry.registerCommandAndKeybindingRule(command.toCommandAndKeybindingRule(CORE_WEIGHT)); + command.register(); } /** @@ -1721,6 +1723,12 @@ registerCommand(new EditorOrNativeTextInputCommand({ weight: CORE_WEIGHT, kbExpr: EditorContextKeys.textInputFocus, primary: KeyMod.CtrlCmd | KeyCode.KEY_Z + }, + menubarOpts: { + menuId: MenuId.MenubarEditMenu, + group: '1_do', + title: nls.localize({ key: 'miUndo', comment: ['&& denotes a mnemonic'] }, "&&Undo"), + order: 1 } })); registerCommand(new EditorHandlerCommand('default:' + H.Undo, H.Undo)); @@ -1736,6 +1744,12 @@ registerCommand(new EditorOrNativeTextInputCommand({ primary: KeyMod.CtrlCmd | KeyCode.KEY_Y, secondary: [KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_Z], mac: { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_Z } + }, + menubarOpts: { + menuId: MenuId.MenubarEditMenu, + group: '1_do', + title: nls.localize({ key: 'miRedo', comment: ['&& denotes a mnemonic'] }, "&&Redo"), + order: 2 } })); registerCommand(new EditorHandlerCommand('default:' + H.Redo, H.Redo)); diff --git a/src/vs/editor/browser/editorExtensions.ts b/src/vs/editor/browser/editorExtensions.ts index 6d9e1f04119..1d45a7e2999 100644 --- a/src/vs/editor/browser/editorExtensions.ts +++ b/src/vs/editor/browser/editorExtensions.ts @@ -9,13 +9,13 @@ import URI from 'vs/base/common/uri'; import { TPromise } from 'vs/base/common/winjs.base'; import { ServicesAccessor, IConstructorSignature1 } from 'vs/platform/instantiation/common/instantiation'; import { CommandsRegistry, ICommandHandlerDescription } from 'vs/platform/commands/common/commands'; -import { KeybindingsRegistry, ICommandAndKeybindingRule, IKeybindings } from 'vs/platform/keybinding/common/keybindingsRegistry'; +import { KeybindingsRegistry, IKeybindings } from 'vs/platform/keybinding/common/keybindingsRegistry'; import { Registry } from 'vs/platform/registry/common/platform'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { Position } from 'vs/editor/common/core/position'; import * as editorCommon from 'vs/editor/common/editorCommon'; import { IModelService } from 'vs/editor/common/services/modelService'; -import { MenuId, MenuRegistry, IMenuItem } from 'vs/platform/actions/common/actions'; +import { MenuId, MenuRegistry } from 'vs/platform/actions/common/actions'; import { IContextKeyService, ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey'; import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService'; import { ICodeEditor } from 'vs/editor/browser/editorBrowser'; @@ -29,53 +29,83 @@ export type IEditorContributionCtor = IConstructorSignature1 this.runCommand(accessor, args), - weight: weight, - when: kbWhen, - primary: kbOpts.primary, - secondary: kbOpts.secondary, - win: kbOpts.win, - linux: kbOpts.linux, - mac: kbOpts.mac, - description: this._description - }; + KeybindingsRegistry.registerCommandAndKeybindingRule({ + id: this.id, + handler: (accessor, args) => this.runCommand(accessor, args), + weight: this._kbOpts.weight, + when: kbWhen, + primary: this._kbOpts.primary, + secondary: this._kbOpts.secondary, + win: this._kbOpts.win, + linux: this._kbOpts.linux, + mac: this._kbOpts.mac, + description: this._description + }); + + } else { + + CommandsRegistry.registerCommand({ + id: this.id, + handler: (accessor, args) => this.runCommand(accessor, args), + description: this._description + }); + } } public abstract runCommand(accessor: ServicesAccessor, args: any): void | TPromise; @@ -144,8 +174,8 @@ export abstract class EditorCommand extends Command { //#region EditorAction export interface IEditorCommandMenuOptions { - group?: string; - order?: number; + group: string; + order: number; when?: ContextKeyExpr; } export interface IActionOptions extends ICommandOptions { @@ -166,20 +196,21 @@ export abstract class EditorAction extends EditorCommand { this.menuOpts = opts.menuOpts; } - public toMenuItem(): IMenuItem { - if (!this.menuOpts) { - return null; + public register(): void { + + if (this.menuOpts) { + MenuRegistry.appendMenuItem(MenuId.EditorContext, { + command: { + id: this.id, + title: this.label + }, + when: ContextKeyExpr.and(this.precondition, this.menuOpts.when), + group: this.menuOpts.group, + order: this.menuOpts.order + }); } - return { - command: { - id: this.id, - title: this.label - }, - when: ContextKeyExpr.and(this.precondition, this.menuOpts.when), - group: this.menuOpts.group, - order: this.menuOpts.order - }; + super.register(); } public runEditorCommand(accessor: ServicesAccessor, editor: ICodeEditor, args: any): void | TPromise { @@ -295,14 +326,7 @@ class EditorContributionRegistry { } public registerEditorAction(action: EditorAction) { - - let menuItem = action.toMenuItem(); - if (menuItem) { - MenuRegistry.appendMenuItem(MenuId.EditorContext, menuItem); - } - - KeybindingsRegistry.registerCommandAndKeybindingRule(action.toCommandAndKeybindingRule(KeybindingsRegistry.WEIGHT.editorContrib())); - + action.register(); this.editorActions.push(action); } @@ -315,7 +339,7 @@ class EditorContributionRegistry { } public registerEditorCommand(editorCommand: EditorCommand) { - KeybindingsRegistry.registerCommandAndKeybindingRule(editorCommand.toCommandAndKeybindingRule(KeybindingsRegistry.WEIGHT.editorContrib())); + editorCommand.register(); this.editorCommands[editorCommand.id] = editorCommand; } diff --git a/src/vs/editor/browser/widget/codeEditorWidget.ts b/src/vs/editor/browser/widget/codeEditorWidget.ts index fee65bb4dc3..3f20b8b4a2d 100644 --- a/src/vs/editor/browser/widget/codeEditorWidget.ts +++ b/src/vs/editor/browser/widget/codeEditorWidget.ts @@ -1550,6 +1550,8 @@ class EditorContextKeysManager extends Disposable { private _editorReadonly: IContextKey; private _hasMultipleSelections: IContextKey; private _hasNonEmptySelection: IContextKey; + private _canUndo: IContextKey; + private _canRedo: IContextKey; constructor( editor: CodeEditorWidget, @@ -1567,6 +1569,8 @@ class EditorContextKeysManager extends Disposable { this._editorReadonly = EditorContextKeys.readOnly.bindTo(contextKeyService); this._hasMultipleSelections = EditorContextKeys.hasMultipleSelections.bindTo(contextKeyService); this._hasNonEmptySelection = EditorContextKeys.hasNonEmptySelection.bindTo(contextKeyService); + this._canUndo = EditorContextKeys.canUndo.bindTo(contextKeyService); + this._canRedo = EditorContextKeys.canRedo.bindTo(contextKeyService); this._register(this._editor.onDidChangeConfiguration(() => this._updateFromConfig())); this._register(this._editor.onDidChangeCursorSelection(() => this._updateFromSelection())); @@ -1574,10 +1578,13 @@ class EditorContextKeysManager extends Disposable { this._register(this._editor.onDidBlurEditorWidget(() => this._updateFromFocus())); this._register(this._editor.onDidFocusEditorText(() => this._updateFromFocus())); this._register(this._editor.onDidBlurEditorText(() => this._updateFromFocus())); + this._register(this._editor.onDidChangeModel(() => this._updateFromModel())); + this._register(this._editor.onDidChangeConfiguration(() => this._updateFromModel())); this._updateFromConfig(); this._updateFromSelection(); this._updateFromFocus(); + this._updateFromModel(); } private _updateFromConfig(): void { @@ -1603,6 +1610,12 @@ class EditorContextKeysManager extends Disposable { this._editorTextFocus.set(this._editor.hasTextFocus() && !this._editor.isSimpleWidget); this._textInputFocus.set(this._editor.hasTextFocus()); } + + private _updateFromModel(): void { + const model = this._editor.getModel(); + this._canUndo.set(model && model.canUndo()); + this._canRedo.set(model && model.canRedo()); + } } export class EditorModeContext extends Disposable { diff --git a/src/vs/editor/browser/widget/diffReview.ts b/src/vs/editor/browser/widget/diffReview.ts index c06799df4c5..fe42bf6cc0d 100644 --- a/src/vs/editor/browser/widget/diffReview.ts +++ b/src/vs/editor/browser/widget/diffReview.ts @@ -30,6 +30,7 @@ import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService import { ICodeEditor } from 'vs/editor/browser/editorBrowser'; import { ITextModel, TextModelResolvedOptions } from 'vs/editor/common/model'; import { ViewLineRenderingData } from 'vs/editor/common/viewModel/viewModel'; +import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; const DIFF_LINES_PADDING = 3; @@ -810,7 +811,8 @@ class DiffReviewNext extends EditorAction { precondition: ContextKeyExpr.has('isInDiffEditor'), kbOpts: { kbExpr: null, - primary: KeyCode.F7 + primary: KeyCode.F7, + weight: KeybindingWeight.EditorContrib } }); } @@ -832,7 +834,8 @@ class DiffReviewPrev extends EditorAction { precondition: ContextKeyExpr.has('isInDiffEditor'), kbOpts: { kbExpr: null, - primary: KeyMod.Shift | KeyCode.F7 + primary: KeyMod.Shift | KeyCode.F7, + weight: KeybindingWeight.EditorContrib } }); } diff --git a/src/vs/editor/common/config/commonEditorConfig.ts b/src/vs/editor/common/config/commonEditorConfig.ts index deb7e9526c3..adaf242cb6f 100644 --- a/src/vs/editor/common/config/commonEditorConfig.ts +++ b/src/vs/editor/common/config/commonEditorConfig.ts @@ -276,7 +276,7 @@ const editorConfiguration: IConfigurationNode = { 'editor.wordSeparators': { 'type': 'string', 'default': EDITOR_DEFAULTS.wordSeparators, - 'description': nls.localize('wordSeparators', "Characters that will be used as word separators when doing word related navigations or operations") + 'description': nls.localize('wordSeparators', "Characters that will be used as word separators when doing word related navigations or operations.") }, 'editor.tabSize': { 'type': 'number', @@ -418,8 +418,14 @@ const editorConfiguration: IConfigurationNode = { 'editor.wrappingIndent': { 'type': 'string', 'enum': ['none', 'same', 'indent', 'deepIndent'], + enumDescriptions: [ + nls.localize('wrappingIndent.none', "No indentation. Wrapped lines begin at column 1."), + nls.localize('wrappingIndent.same', "Wrapped lines get the same indentation as the parent."), + nls.localize('wrappingIndent.indent', "Wrapped lines get +1 indentation toward the parent."), + nls.localize('wrappingIndent.deepIndent', "Wrapped lines get +2 indentation toward the parent."), + ], 'default': 'same', - 'description': nls.localize('wrappingIndent', "Controls the indentation of wrapped lines. Can be one of 'none', 'same', 'indent' or 'deepIndent'.") + 'description': nls.localize('wrappingIndent', "Controls the indentation of wrapped lines."), }, 'editor.mouseWheelScrollSensitivity': { 'type': 'number', @@ -510,13 +516,13 @@ const editorConfiguration: IConfigurationNode = { 'editor.suggestOnTriggerCharacters': { 'type': 'boolean', 'default': EDITOR_DEFAULTS.contribInfo.suggestOnTriggerCharacters, - 'description': nls.localize('suggestOnTriggerCharacters', "Controls if suggestions should automatically show up when typing trigger characters") + 'description': nls.localize('suggestOnTriggerCharacters', "Controls if suggestions should automatically show up when typing trigger characters.") }, 'editor.acceptSuggestionOnEnter': { 'type': 'string', 'enum': ['on', 'smart', 'off'], 'default': EDITOR_DEFAULTS.contribInfo.acceptSuggestionOnEnter, - 'description': nls.localize('acceptSuggestionOnEnter', "Controls if suggestions should be accepted on 'Enter' - in addition to 'Tab'. Helps to avoid ambiguity between inserting new lines or accepting suggestions. The value 'smart' means only accept a suggestion with Enter when it makes a textual change") + 'description': nls.localize('acceptSuggestionOnEnter', "Controls if suggestions should be accepted on 'Enter' - in addition to 'Tab'. Helps to avoid ambiguity between inserting new lines or accepting suggestions. The value 'smart' means only accept a suggestion with Enter when it makes a textual change.") }, 'editor.acceptSuggestionOnCommitCharacter': { 'type': 'boolean', @@ -560,13 +566,13 @@ const editorConfiguration: IConfigurationNode = { 'type': 'integer', 'default': 0, 'minimum': 0, - 'description': nls.localize('suggestFontSize', "Font size for the suggest widget") + 'description': nls.localize('suggestFontSize', "Font size for the suggest widget.") }, 'editor.suggestLineHeight': { 'type': 'integer', 'default': 0, 'minimum': 0, - 'description': nls.localize('suggestLineHeight', "Line height for the suggest widget") + 'description': nls.localize('suggestLineHeight', "Line height for the suggest widget.") }, 'editor.suggest.filterGraceful': { type: 'boolean', @@ -586,12 +592,12 @@ const editorConfiguration: IConfigurationNode = { 'editor.occurrencesHighlight': { 'type': 'boolean', 'default': EDITOR_DEFAULTS.contribInfo.occurrencesHighlight, - 'description': nls.localize('occurrencesHighlight', "Controls whether the editor should highlight semantic symbol occurrences") + 'description': nls.localize('occurrencesHighlight', "Controls whether the editor should highlight semantic symbol occurrences.") }, 'editor.overviewRulerLanes': { 'type': 'integer', 'default': 3, - 'description': nls.localize('overviewRulerLanes', "Controls the number of decorations that can show up at the same position in the overview ruler") + 'description': nls.localize('overviewRulerLanes', "Controls the number of decorations that can show up at the same position in the overview ruler.") }, 'editor.overviewRulerBorder': { 'type': 'boolean', @@ -607,7 +613,7 @@ const editorConfiguration: IConfigurationNode = { 'editor.mouseWheelZoom': { 'type': 'boolean', 'default': EDITOR_DEFAULTS.viewInfo.mouseWheelZoom, - 'description': nls.localize('mouseWheelZoom', "Zoom the font of the editor when using mouse wheel and holding Ctrl") + 'description': nls.localize('mouseWheelZoom', "Zoom the font of the editor when using mouse wheel and holding Ctrl.") }, 'editor.cursorStyle': { 'type': 'string', @@ -644,12 +650,12 @@ const editorConfiguration: IConfigurationNode = { 'editor.renderControlCharacters': { 'type': 'boolean', default: EDITOR_DEFAULTS.viewInfo.renderControlCharacters, - description: nls.localize('renderControlCharacters', "Controls whether the editor should render control characters") + description: nls.localize('renderControlCharacters', "Controls whether the editor should render control characters.") }, 'editor.renderIndentGuides': { 'type': 'boolean', default: EDITOR_DEFAULTS.viewInfo.renderIndentGuides, - description: nls.localize('renderIndentGuides', "Controls whether the editor should render indent guides") + description: nls.localize('renderIndentGuides', "Controls whether the editor should render indent guides.") }, 'editor.highlightActiveIndentGuide': { 'type': 'boolean', @@ -701,12 +707,12 @@ const editorConfiguration: IConfigurationNode = { 'editor.useTabStops': { 'type': 'boolean', 'default': EDITOR_DEFAULTS.useTabStops, - 'description': nls.localize('useTabStops', "Inserting and deleting whitespace follows tab stops") + 'description': nls.localize('useTabStops', "Inserting and deleting whitespace follows tab stops.") }, 'editor.trimAutoWhitespace': { 'type': 'boolean', 'default': EDITOR_MODEL_DEFAULTS.trimAutoWhitespace, - 'description': nls.localize('trimAutoWhitespace', "Remove trailing auto inserted whitespace") + 'description': nls.localize('trimAutoWhitespace', "Remove trailing auto inserted whitespace.") }, 'editor.stablePeek': { 'type': 'boolean', diff --git a/src/vs/editor/common/editorContextKeys.ts b/src/vs/editor/common/editorContextKeys.ts index e6cd1d9caf5..c306f76352c 100644 --- a/src/vs/editor/common/editorContextKeys.ts +++ b/src/vs/editor/common/editorContextKeys.ts @@ -30,6 +30,8 @@ export namespace EditorContextKeys { export const tabMovesFocus = new RawContextKey('editorTabMovesFocus', false); export const tabDoesNotMoveFocus: ContextKeyExpr = tabMovesFocus.toNegated(); export const isInEmbeddedEditor = new RawContextKey('isInEmbeddedEditor', undefined); + export const canUndo = new RawContextKey('canUndo', false); + export const canRedo = new RawContextKey('canRedo', false); // -- mode context keys export const languageId = new RawContextKey('editorLangId', undefined); diff --git a/src/vs/editor/common/model.ts b/src/vs/editor/common/model.ts index e4a6ba3feed..d37319c25b5 100644 --- a/src/vs/editor/common/model.ts +++ b/src/vs/editor/common/model.ts @@ -1030,6 +1030,12 @@ export interface ITextModel { */ undo(): Selection[]; + /** + * Is there anything in the undo stack? + * @internal + */ + canUndo(): boolean; + /** * Redo edit operations until the next stop point created by `pushStackElement`. * The inverse edit operations will be pushed on the undo stack. @@ -1037,6 +1043,12 @@ export interface ITextModel { */ redo(): Selection[]; + /** + * Is there anything in the redo stack? + * @internal + */ + canRedo(): boolean; + /** * @deprecated Please use `onDidChangeContent` instead. * An event emitted when the contents of the model have changed. diff --git a/src/vs/editor/common/model/editStack.ts b/src/vs/editor/common/model/editStack.ts index 13a955cf522..5f5e3066845 100644 --- a/src/vs/editor/common/model/editStack.ts +++ b/src/vs/editor/common/model/editStack.ts @@ -210,6 +210,10 @@ export class EditStack { return null; } + public canUndo(): boolean { + return (this.past.length > 0); + } + public redo(): IUndoRedoResult { if (this.future.length > 0) { @@ -233,4 +237,8 @@ export class EditStack { return null; } + + public canRedo(): boolean { + return (this.future.length > 0); + } } diff --git a/src/vs/editor/common/model/textModel.ts b/src/vs/editor/common/model/textModel.ts index 1a4005d6a1b..7bddfeb4441 100644 --- a/src/vs/editor/common/model/textModel.ts +++ b/src/vs/editor/common/model/textModel.ts @@ -1416,6 +1416,10 @@ export class TextModel extends Disposable implements model.ITextModel { } } + public canUndo(): boolean { + return this._commandManager.canUndo(); + } + private _redo(): Selection[] { this._isRedoing = true; let r = this._commandManager.redo(); @@ -1441,6 +1445,10 @@ export class TextModel extends Disposable implements model.ITextModel { } } + public canRedo(): boolean { + return this._commandManager.canRedo(); + } + //#endregion //#region Decorations diff --git a/src/vs/editor/contrib/bracketMatching/bracketMatching.ts b/src/vs/editor/contrib/bracketMatching/bracketMatching.ts index b2573d26fa0..5ed915fe01a 100644 --- a/src/vs/editor/contrib/bracketMatching/bracketMatching.ts +++ b/src/vs/editor/contrib/bracketMatching/bracketMatching.ts @@ -22,6 +22,7 @@ import { ModelDecorationOptions } from 'vs/editor/common/model/textModel'; import { ICodeEditor } from 'vs/editor/browser/editorBrowser'; import { registerColor } from 'vs/platform/theme/common/colorRegistry'; import { TrackedRangeStickiness, IModelDeltaDecoration, OverviewRulerLane } from 'vs/editor/common/model'; +import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; const overviewRulerBracketMatchForeground = registerColor('editorOverviewRuler.bracketMatchForeground', { dark: '#A0A0A0', light: '#A0A0A0', hc: '#A0A0A0' }, nls.localize('overviewRulerBracketMatchForeground', 'Overview ruler marker color for matching brackets.')); @@ -34,7 +35,8 @@ class JumpToBracketAction extends EditorAction { precondition: null, kbOpts: { kbExpr: EditorContextKeys.editorTextFocus, - primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.US_BACKSLASH + primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.US_BACKSLASH, + weight: KeybindingWeight.EditorContrib } }); } diff --git a/src/vs/editor/contrib/caretOperations/transpose.ts b/src/vs/editor/contrib/caretOperations/transpose.ts index 6523327b253..ee59ca9c28d 100644 --- a/src/vs/editor/contrib/caretOperations/transpose.ts +++ b/src/vs/editor/contrib/caretOperations/transpose.ts @@ -15,6 +15,7 @@ import { registerEditorAction, EditorAction, ServicesAccessor } from 'vs/editor/ import { ReplaceCommand } from 'vs/editor/common/commands/replaceCommand'; import { ICodeEditor } from 'vs/editor/browser/editorBrowser'; import { ITextModel } from 'vs/editor/common/model'; +import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; class TransposeLettersAction extends EditorAction { @@ -67,7 +68,8 @@ class TransposeLettersAction extends EditorAction { primary: 0, mac: { primary: KeyMod.WinCtrl | KeyCode.KEY_T - } + }, + weight: KeybindingWeight.EditorContrib } }); } diff --git a/src/vs/editor/contrib/clipboard/clipboard.ts b/src/vs/editor/contrib/clipboard/clipboard.ts index 97f62935e1f..4d0ec22210d 100644 --- a/src/vs/editor/contrib/clipboard/clipboard.ts +++ b/src/vs/editor/contrib/clipboard/clipboard.ts @@ -16,6 +16,8 @@ import { registerEditorAction, IActionOptions, EditorAction, ICommandKeybindings import { CopyOptions } from 'vs/editor/browser/controller/textAreaInput'; import { EditorContextKeys } from 'vs/editor/common/editorContextKeys'; import { ICodeEditor } from 'vs/editor/browser/editorBrowser'; +import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; +import { MenuId } from 'vs/platform/actions/common/actions'; const CLIPBOARD_CONTEXT_MENU_GROUP = '9_cutcopypaste'; @@ -62,7 +64,8 @@ class ExecCommandCutAction extends ExecCommandAction { let kbOpts: ICommandKeybindingsOptions = { kbExpr: EditorContextKeys.textInputFocus, primary: KeyMod.CtrlCmd | KeyCode.KEY_X, - win: { primary: KeyMod.CtrlCmd | KeyCode.KEY_X, secondary: [KeyMod.Shift | KeyCode.Delete] } + win: { primary: KeyMod.CtrlCmd | KeyCode.KEY_X, secondary: [KeyMod.Shift | KeyCode.Delete] }, + weight: KeybindingWeight.EditorContrib }; // Do not bind cut keybindings in the browser, // since browsers do that for us and it avoids security prompts @@ -78,6 +81,12 @@ class ExecCommandCutAction extends ExecCommandAction { menuOpts: { group: CLIPBOARD_CONTEXT_MENU_GROUP, order: 1 + }, + menubarOpts: { + menuId: MenuId.MenubarEditMenu, + group: '2_ccp', + title: nls.localize({ key: 'miCut', comment: ['&& denotes a mnemonic'] }, "Cu&&t"), + order: 1 } }); } @@ -99,7 +108,8 @@ class ExecCommandCopyAction extends ExecCommandAction { let kbOpts: ICommandKeybindingsOptions = { kbExpr: EditorContextKeys.textInputFocus, primary: KeyMod.CtrlCmd | KeyCode.KEY_C, - win: { primary: KeyMod.CtrlCmd | KeyCode.KEY_C, secondary: [KeyMod.CtrlCmd | KeyCode.Insert] } + win: { primary: KeyMod.CtrlCmd | KeyCode.KEY_C, secondary: [KeyMod.CtrlCmd | KeyCode.Insert] }, + weight: KeybindingWeight.EditorContrib }; // Do not bind copy keybindings in the browser, // since browsers do that for us and it avoids security prompts @@ -116,6 +126,12 @@ class ExecCommandCopyAction extends ExecCommandAction { menuOpts: { group: CLIPBOARD_CONTEXT_MENU_GROUP, order: 2 + }, + menubarOpts: { + menuId: MenuId.MenubarEditMenu, + group: '2_ccp', + title: nls.localize({ key: 'miCopy', comment: ['&& denotes a mnemonic'] }, "&&Copy"), + order: 2 } }); } @@ -137,7 +153,8 @@ class ExecCommandPasteAction extends ExecCommandAction { let kbOpts: ICommandKeybindingsOptions = { kbExpr: EditorContextKeys.textInputFocus, primary: KeyMod.CtrlCmd | KeyCode.KEY_V, - win: { primary: KeyMod.CtrlCmd | KeyCode.KEY_V, secondary: [KeyMod.Shift | KeyCode.Insert] } + win: { primary: KeyMod.CtrlCmd | KeyCode.KEY_V, secondary: [KeyMod.Shift | KeyCode.Insert] }, + weight: KeybindingWeight.EditorContrib }; // Do not bind paste keybindings in the browser, // since browsers do that for us and it avoids security prompts @@ -154,6 +171,12 @@ class ExecCommandPasteAction extends ExecCommandAction { menuOpts: { group: CLIPBOARD_CONTEXT_MENU_GROUP, order: 3 + }, + menubarOpts: { + menuId: MenuId.MenubarEditMenu, + group: '2_ccp', + title: nls.localize({ key: 'miPaste', comment: ['&& denotes a mnemonic'] }, "&&Paste"), + order: 3 } }); } @@ -169,7 +192,8 @@ class ExecCommandCopyWithSyntaxHighlightingAction extends ExecCommandAction { precondition: null, kbOpts: { kbExpr: EditorContextKeys.textInputFocus, - primary: null + primary: null, + weight: KeybindingWeight.EditorContrib } }); } diff --git a/src/vs/editor/contrib/codeAction/codeActionCommands.ts b/src/vs/editor/contrib/codeAction/codeActionCommands.ts index 53870292126..1f229bfbfbc 100644 --- a/src/vs/editor/contrib/codeAction/codeActionCommands.ts +++ b/src/vs/editor/contrib/codeAction/codeActionCommands.ts @@ -26,6 +26,7 @@ import { CodeActionModel, CodeActionsComputeEvent, SUPPORTED_CODE_ACTIONS } from import { CodeActionAutoApply, CodeActionFilter, CodeActionKind } from './codeActionTrigger'; import { CodeActionContextMenu } from './codeActionWidget'; import { LightBulbWidget } from './lightBulbWidget'; +import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; function contextKeyForSupportedActions(kind: CodeActionKind) { return ContextKeyExpr.regex( @@ -192,7 +193,8 @@ export class QuickFixAction extends EditorAction { precondition: ContextKeyExpr.and(EditorContextKeys.writable, EditorContextKeys.hasCodeActionsProvider), kbOpts: { kbExpr: EditorContextKeys.editorTextFocus, - primary: KeyMod.CtrlCmd | KeyCode.US_DOT + primary: KeyMod.CtrlCmd | KeyCode.US_DOT, + weight: KeybindingWeight.EditorContrib } }); } @@ -272,7 +274,8 @@ export class RefactorAction extends EditorAction { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_R, mac: { primary: KeyMod.WinCtrl | KeyMod.Shift | KeyCode.KEY_R - } + }, + weight: KeybindingWeight.EditorContrib }, menuOpts: { group: '1_modification', @@ -335,7 +338,8 @@ export class OrganizeImportsAction extends EditorAction { contextKeyForSupportedActions(CodeActionKind.SourceOrganizeImports)), kbOpts: { kbExpr: EditorContextKeys.editorTextFocus, - primary: KeyMod.Shift | KeyMod.Alt | KeyCode.KEY_O + primary: KeyMod.Shift | KeyMod.Alt | KeyCode.KEY_O, + weight: KeybindingWeight.EditorContrib } }); } diff --git a/src/vs/editor/contrib/comment/comment.ts b/src/vs/editor/contrib/comment/comment.ts index b570ff1f041..264e8527e52 100644 --- a/src/vs/editor/contrib/comment/comment.ts +++ b/src/vs/editor/contrib/comment/comment.ts @@ -12,6 +12,8 @@ import { registerEditorAction, IActionOptions, EditorAction, ServicesAccessor } import { BlockCommentCommand } from './blockCommentCommand'; import { LineCommentCommand, Type } from './lineCommentCommand'; import { ICodeEditor } from 'vs/editor/browser/editorBrowser'; +import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; +import { MenuId } from 'vs/platform/actions/common/actions'; abstract class CommentLineAction extends EditorAction { @@ -52,7 +54,14 @@ class ToggleCommentLineAction extends CommentLineAction { precondition: EditorContextKeys.writable, kbOpts: { kbExpr: EditorContextKeys.editorTextFocus, - primary: KeyMod.CtrlCmd | KeyCode.US_SLASH + primary: KeyMod.CtrlCmd | KeyCode.US_SLASH, + weight: KeybindingWeight.EditorContrib + }, + menubarOpts: { + menuId: MenuId.MenubarEditMenu, + group: '5_insert', + title: nls.localize({ key: 'miToggleLineComment', comment: ['&& denotes a mnemonic'] }, "&&Toggle Line Comment"), + order: 1 } }); } @@ -67,7 +76,8 @@ class AddLineCommentAction extends CommentLineAction { precondition: EditorContextKeys.writable, kbOpts: { kbExpr: EditorContextKeys.editorTextFocus, - primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_C) + primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_C), + weight: KeybindingWeight.EditorContrib } }); } @@ -82,7 +92,8 @@ class RemoveLineCommentAction extends CommentLineAction { precondition: EditorContextKeys.writable, kbOpts: { kbExpr: EditorContextKeys.editorTextFocus, - primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_U) + primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_U), + weight: KeybindingWeight.EditorContrib } }); } @@ -99,7 +110,14 @@ class BlockCommentAction extends EditorAction { kbOpts: { kbExpr: EditorContextKeys.editorTextFocus, primary: KeyMod.Shift | KeyMod.Alt | KeyCode.KEY_A, - linux: { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_A } + linux: { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_A }, + weight: KeybindingWeight.EditorContrib + }, + menubarOpts: { + menuId: MenuId.MenubarEditMenu, + group: '5_insert', + title: nls.localize({ key: 'miToggleBlockComment', comment: ['&& denotes a mnemonic'] }, "Toggle &&Block Comment"), + order: 2 } }); } diff --git a/src/vs/editor/contrib/contextmenu/contextmenu.ts b/src/vs/editor/contrib/contextmenu/contextmenu.ts index a3467f32a75..75de2e1c6d1 100644 --- a/src/vs/editor/contrib/contextmenu/contextmenu.ts +++ b/src/vs/editor/contrib/contextmenu/contextmenu.ts @@ -20,6 +20,7 @@ import { IEditorContribution, IScrollEvent, ScrollType } from 'vs/editor/common/ import { EditorContextKeys } from 'vs/editor/common/editorContextKeys'; import { registerEditorAction, registerEditorContribution, ServicesAccessor, EditorAction } from 'vs/editor/browser/editorExtensions'; import { ICodeEditor, IEditorMouseEvent, MouseTargetType } from 'vs/editor/browser/editorBrowser'; +import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; export interface IPosition { x: number; @@ -227,7 +228,8 @@ class ShowContextMenu extends EditorAction { precondition: null, kbOpts: { kbExpr: EditorContextKeys.textInputFocus, - primary: KeyMod.Shift | KeyCode.F10 + primary: KeyMod.Shift | KeyCode.F10, + weight: KeybindingWeight.EditorContrib } }); } diff --git a/src/vs/editor/contrib/cursorUndo/cursorUndo.ts b/src/vs/editor/contrib/cursorUndo/cursorUndo.ts index dec489e7d14..cd80e4025a1 100644 --- a/src/vs/editor/contrib/cursorUndo/cursorUndo.ts +++ b/src/vs/editor/contrib/cursorUndo/cursorUndo.ts @@ -12,6 +12,7 @@ import { Disposable } from 'vs/base/common/lifecycle'; import { IEditorContribution, ScrollType } from 'vs/editor/common/editorCommon'; import { EditorContextKeys } from 'vs/editor/common/editorContextKeys'; import { ICodeEditor } from 'vs/editor/browser/editorBrowser'; +import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; class CursorState { readonly selections: Selection[]; @@ -118,7 +119,8 @@ export class CursorUndo extends EditorAction { precondition: null, kbOpts: { kbExpr: EditorContextKeys.textInputFocus, - primary: KeyMod.CtrlCmd | KeyCode.KEY_U + primary: KeyMod.CtrlCmd | KeyCode.KEY_U, + weight: KeybindingWeight.EditorContrib } }); } diff --git a/src/vs/editor/contrib/documentSymbols/outlineModel.ts b/src/vs/editor/contrib/documentSymbols/outlineModel.ts index 28db38d0d47..38157732bfa 100644 --- a/src/vs/editor/contrib/documentSymbols/outlineModel.ts +++ b/src/vs/editor/contrib/documentSymbols/outlineModel.ts @@ -21,10 +21,14 @@ export abstract class TreeElement { abstract id: string; abstract children: { [id: string]: TreeElement }; - abstract parent: TreeElement | any; + abstract parent: TreeElement; abstract adopt(newParent: TreeElement): TreeElement; + remove(): void { + delete this.parent.children[this.id]; + } + static findId(candidate: DocumentSymbol | string, container: TreeElement): string { // complex id-computation which contains the origin/extension, // the parent path, and some dedupe logic when names collide @@ -73,6 +77,13 @@ export abstract class TreeElement { } return res; } + + static empty(element: TreeElement): boolean { + for (const _key in element.children) { + return false; + } + return true; + } } export class OutlineElement extends TreeElement { @@ -297,7 +308,11 @@ export class OutlineModel extends TreeElement { onUnexpectedExternalError(err); return group; }).then(group => { - result._groups[id] = group; + if (!TreeElement.empty(group)) { + result._groups[id] = group; + } else { + group.remove(); + } }); }); diff --git a/src/vs/editor/contrib/find/findController.ts b/src/vs/editor/contrib/find/findController.ts index 73bf698e3b8..5a43011b332 100644 --- a/src/vs/editor/contrib/find/findController.ts +++ b/src/vs/editor/contrib/find/findController.ts @@ -23,8 +23,9 @@ import { ICodeEditor } from 'vs/editor/browser/editorBrowser'; import { FindWidget, IFindController } from 'vs/editor/contrib/find/findWidget'; import { FindOptionsWidget } from 'vs/editor/contrib/find/findOptionsWidget'; import { IThemeService } from 'vs/platform/theme/common/themeService'; -import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry'; +import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; import { optional } from 'vs/platform/instantiation/common/instantiation'; +import { MenuId } from 'vs/platform/actions/common/actions'; export function getSelectionSearchString(editor: ICodeEditor): string { let selection = editor.getSelection(); @@ -386,7 +387,14 @@ export class StartFindAction extends EditorAction { precondition: null, kbOpts: { kbExpr: null, - primary: KeyMod.CtrlCmd | KeyCode.KEY_F + primary: KeyMod.CtrlCmd | KeyCode.KEY_F, + weight: KeybindingWeight.EditorContrib + }, + menubarOpts: { + menuId: MenuId.MenubarEditMenu, + group: '3_find', + title: nls.localize({ key: 'miFind', comment: ['&& denotes a mnemonic'] }, "&&Find"), + order: 1 } }); } @@ -418,7 +426,8 @@ export class StartFindWithSelectionAction extends EditorAction { primary: null, mac: { primary: KeyMod.CtrlCmd | KeyCode.KEY_E, - } + }, + weight: KeybindingWeight.EditorContrib } }); } @@ -467,7 +476,8 @@ export class NextMatchFindAction extends MatchFindAction { kbOpts: { kbExpr: EditorContextKeys.focus, primary: KeyCode.F3, - mac: { primary: KeyMod.CtrlCmd | KeyCode.KEY_G, secondary: [KeyCode.F3] } + mac: { primary: KeyMod.CtrlCmd | KeyCode.KEY_G, secondary: [KeyCode.F3] }, + weight: KeybindingWeight.EditorContrib } }); } @@ -488,7 +498,8 @@ export class PreviousMatchFindAction extends MatchFindAction { kbOpts: { kbExpr: EditorContextKeys.focus, primary: KeyMod.Shift | KeyCode.F3, - mac: { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_G, secondary: [KeyMod.Shift | KeyCode.F3] } + mac: { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_G, secondary: [KeyMod.Shift | KeyCode.F3] }, + weight: KeybindingWeight.EditorContrib } }); } @@ -533,7 +544,8 @@ export class NextSelectionMatchFindAction extends SelectionMatchFindAction { precondition: null, kbOpts: { kbExpr: EditorContextKeys.focus, - primary: KeyMod.CtrlCmd | KeyCode.F3 + primary: KeyMod.CtrlCmd | KeyCode.F3, + weight: KeybindingWeight.EditorContrib } }); } @@ -553,7 +565,8 @@ export class PreviousSelectionMatchFindAction extends SelectionMatchFindAction { precondition: null, kbOpts: { kbExpr: EditorContextKeys.focus, - primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.F3 + primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.F3, + weight: KeybindingWeight.EditorContrib } }); } @@ -574,7 +587,14 @@ export class StartFindReplaceAction extends EditorAction { kbOpts: { kbExpr: null, primary: KeyMod.CtrlCmd | KeyCode.KEY_H, - mac: { primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.KEY_F } + mac: { primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.KEY_F }, + weight: KeybindingWeight.EditorContrib + }, + menubarOpts: { + menuId: MenuId.MenubarEditMenu, + group: '3_find', + title: nls.localize({ key: 'miReplace', comment: ['&& denotes a mnemonic'] }, "&&Replace"), + order: 2 } }); } @@ -624,7 +644,7 @@ registerEditorCommand(new FindCommand({ precondition: CONTEXT_FIND_WIDGET_VISIBLE, handler: x => x.closeFindWidget(), kbOpts: { - weight: KeybindingsRegistry.WEIGHT.editorContrib(5), + weight: KeybindingWeight.EditorContrib + 5, kbExpr: EditorContextKeys.focus, primary: KeyCode.Escape, secondary: [KeyMod.Shift | KeyCode.Escape] @@ -636,7 +656,7 @@ registerEditorCommand(new FindCommand({ precondition: null, handler: x => x.toggleCaseSensitive(), kbOpts: { - weight: KeybindingsRegistry.WEIGHT.editorContrib(5), + weight: KeybindingWeight.EditorContrib + 5, kbExpr: EditorContextKeys.focus, primary: ToggleCaseSensitiveKeybinding.primary, mac: ToggleCaseSensitiveKeybinding.mac, @@ -650,7 +670,7 @@ registerEditorCommand(new FindCommand({ precondition: null, handler: x => x.toggleWholeWords(), kbOpts: { - weight: KeybindingsRegistry.WEIGHT.editorContrib(5), + weight: KeybindingWeight.EditorContrib + 5, kbExpr: EditorContextKeys.focus, primary: ToggleWholeWordKeybinding.primary, mac: ToggleWholeWordKeybinding.mac, @@ -664,7 +684,7 @@ registerEditorCommand(new FindCommand({ precondition: null, handler: x => x.toggleRegex(), kbOpts: { - weight: KeybindingsRegistry.WEIGHT.editorContrib(5), + weight: KeybindingWeight.EditorContrib + 5, kbExpr: EditorContextKeys.focus, primary: ToggleRegexKeybinding.primary, mac: ToggleRegexKeybinding.mac, @@ -678,7 +698,7 @@ registerEditorCommand(new FindCommand({ precondition: null, handler: x => x.toggleSearchScope(), kbOpts: { - weight: KeybindingsRegistry.WEIGHT.editorContrib(5), + weight: KeybindingWeight.EditorContrib + 5, kbExpr: EditorContextKeys.focus, primary: ToggleSearchScopeKeybinding.primary, mac: ToggleSearchScopeKeybinding.mac, @@ -692,7 +712,7 @@ registerEditorCommand(new FindCommand({ precondition: CONTEXT_FIND_WIDGET_VISIBLE, handler: x => x.replace(), kbOpts: { - weight: KeybindingsRegistry.WEIGHT.editorContrib(5), + weight: KeybindingWeight.EditorContrib + 5, kbExpr: EditorContextKeys.focus, primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_1 } @@ -703,7 +723,7 @@ registerEditorCommand(new FindCommand({ precondition: CONTEXT_FIND_WIDGET_VISIBLE, handler: x => x.replaceAll(), kbOpts: { - weight: KeybindingsRegistry.WEIGHT.editorContrib(5), + weight: KeybindingWeight.EditorContrib + 5, kbExpr: EditorContextKeys.focus, primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.Enter } @@ -714,7 +734,7 @@ registerEditorCommand(new FindCommand({ precondition: CONTEXT_FIND_WIDGET_VISIBLE, handler: x => x.selectAllMatches(), kbOpts: { - weight: KeybindingsRegistry.WEIGHT.editorContrib(5), + weight: KeybindingWeight.EditorContrib + 5, kbExpr: EditorContextKeys.focus, primary: KeyMod.Alt | KeyCode.Enter } diff --git a/src/vs/editor/contrib/folding/folding.ts b/src/vs/editor/contrib/folding/folding.ts index 43a305a49bc..a2a57574264 100644 --- a/src/vs/editor/contrib/folding/folding.ts +++ b/src/vs/editor/contrib/folding/folding.ts @@ -32,6 +32,7 @@ import { FoldingRangeProviderRegistry, FoldingRangeKind } from 'vs/editor/common import { SyntaxRangeProvider, ID_SYNTAX_PROVIDER } from './syntaxRangeProvider'; import { CancellationToken } from 'vs/base/common/cancellation'; import { InitializingRangeProvider, ID_INIT_PROVIDER } from 'vs/editor/contrib/folding/intializingRangeProvider'; +import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; export const ID = 'editor.contrib.folding'; @@ -486,7 +487,8 @@ class UnfoldAction extends FoldingAction { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.US_CLOSE_SQUARE_BRACKET, mac: { primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.US_CLOSE_SQUARE_BRACKET - } + }, + weight: KeybindingWeight.EditorContrib }, description: { description: 'Unfold the content in the editor', @@ -526,7 +528,8 @@ class UnFoldRecursivelyAction extends FoldingAction { precondition: null, kbOpts: { kbExpr: EditorContextKeys.editorTextFocus, - primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.US_CLOSE_SQUARE_BRACKET) + primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.US_CLOSE_SQUARE_BRACKET), + weight: KeybindingWeight.EditorContrib } }); } @@ -549,7 +552,8 @@ class FoldAction extends FoldingAction { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.US_OPEN_SQUARE_BRACKET, mac: { primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.US_OPEN_SQUARE_BRACKET - } + }, + weight: KeybindingWeight.EditorContrib }, description: { description: 'Fold the content in the editor', @@ -589,7 +593,8 @@ class FoldRecursivelyAction extends FoldingAction { precondition: null, kbOpts: { kbExpr: EditorContextKeys.editorTextFocus, - primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.US_OPEN_SQUARE_BRACKET) + primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.US_OPEN_SQUARE_BRACKET), + weight: KeybindingWeight.EditorContrib } }); } @@ -610,7 +615,8 @@ class FoldAllBlockCommentsAction extends FoldingAction { precondition: null, kbOpts: { kbExpr: EditorContextKeys.editorTextFocus, - primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.US_SLASH) + primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.US_SLASH), + weight: KeybindingWeight.EditorContrib } }); } @@ -638,7 +644,8 @@ class FoldAllRegionsAction extends FoldingAction { precondition: null, kbOpts: { kbExpr: EditorContextKeys.editorTextFocus, - primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_8) + primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_8), + weight: KeybindingWeight.EditorContrib } }); } @@ -666,7 +673,8 @@ class UnfoldAllRegionsAction extends FoldingAction { precondition: null, kbOpts: { kbExpr: EditorContextKeys.editorTextFocus, - primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_9) + primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_9), + weight: KeybindingWeight.EditorContrib } }); } @@ -694,7 +702,8 @@ class FoldAllAction extends FoldingAction { precondition: null, kbOpts: { kbExpr: EditorContextKeys.editorTextFocus, - primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_0) + primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_0), + weight: KeybindingWeight.EditorContrib } }); } @@ -714,7 +723,8 @@ class UnfoldAllAction extends FoldingAction { precondition: null, kbOpts: { kbExpr: EditorContextKeys.editorTextFocus, - primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_J) + primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_J), + weight: KeybindingWeight.EditorContrib } }); } @@ -757,7 +767,8 @@ for (let i = 1; i <= 7; i++) { precondition: null, kbOpts: { kbExpr: EditorContextKeys.editorTextFocus, - primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | (KeyCode.KEY_0 + i)) + primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | (KeyCode.KEY_0 + i)), + weight: KeybindingWeight.EditorContrib } }) ); diff --git a/src/vs/editor/contrib/format/formatActions.ts b/src/vs/editor/contrib/format/formatActions.ts index 985dd3e900e..25dee8a028a 100644 --- a/src/vs/editor/contrib/format/formatActions.ts +++ b/src/vs/editor/contrib/format/formatActions.ts @@ -26,6 +26,7 @@ import { EditorContextKeys } from 'vs/editor/common/editorContextKeys'; import { ICodeEditor } from 'vs/editor/browser/editorBrowser'; import { ISingleEditOperation } from 'vs/editor/common/model'; import { INotificationService } from 'vs/platform/notification/common/notification'; +import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; function alertFormattingEdits(edits: ISingleEditOperation[]): void { @@ -310,7 +311,8 @@ export class FormatDocumentAction extends AbstractFormatAction { kbExpr: EditorContextKeys.editorTextFocus, primary: KeyMod.Shift | KeyMod.Alt | KeyCode.KEY_F, // secondary: [KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_D)], - linux: { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_I } + linux: { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_I }, + weight: KeybindingWeight.EditorContrib }, menuOpts: { when: EditorContextKeys.hasDocumentFormattingProvider, @@ -341,7 +343,8 @@ export class FormatSelectionAction extends AbstractFormatAction { precondition: ContextKeyExpr.and(EditorContextKeys.writable, EditorContextKeys.hasNonEmptySelection), kbOpts: { kbExpr: EditorContextKeys.editorTextFocus, - primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_F) + primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_F), + weight: KeybindingWeight.EditorContrib }, menuOpts: { when: ContextKeyExpr.and(EditorContextKeys.hasDocumentSelectionFormattingProvider, EditorContextKeys.hasNonEmptySelection), diff --git a/src/vs/editor/contrib/goToDefinition/goToDefinitionCommands.ts b/src/vs/editor/contrib/goToDefinition/goToDefinitionCommands.ts index 981b9fc99dc..667e77dbf2d 100644 --- a/src/vs/editor/contrib/goToDefinition/goToDefinitionCommands.ts +++ b/src/vs/editor/contrib/goToDefinition/goToDefinitionCommands.ts @@ -25,6 +25,7 @@ import { ICodeEditor } from 'vs/editor/browser/editorBrowser'; import { ITextModel, IWordAtPosition } from 'vs/editor/common/model'; import { INotificationService } from 'vs/platform/notification/common/notification'; import { createCancelablePromise } from 'vs/base/common/async'; +import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; export class DefinitionActionConfig { @@ -191,7 +192,8 @@ export class GoToDefinitionAction extends DefinitionAction { EditorContextKeys.isInEmbeddedEditor.toNegated()), kbOpts: { kbExpr: EditorContextKeys.editorTextFocus, - primary: goToDeclarationKb + primary: goToDeclarationKb, + weight: KeybindingWeight.EditorContrib }, menuOpts: { group: 'navigation', @@ -215,7 +217,8 @@ export class OpenDefinitionToSideAction extends DefinitionAction { EditorContextKeys.isInEmbeddedEditor.toNegated()), kbOpts: { kbExpr: EditorContextKeys.editorTextFocus, - primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, goToDeclarationKb) + primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, goToDeclarationKb), + weight: KeybindingWeight.EditorContrib } }); } @@ -234,7 +237,8 @@ export class PeekDefinitionAction extends DefinitionAction { kbOpts: { kbExpr: EditorContextKeys.editorTextFocus, primary: KeyMod.Alt | KeyCode.F12, - linux: { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.F10 } + linux: { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.F10 }, + weight: KeybindingWeight.EditorContrib }, menuOpts: { group: 'navigation', @@ -274,7 +278,8 @@ export class GoToImplementationAction extends ImplementationAction { EditorContextKeys.isInEmbeddedEditor.toNegated()), kbOpts: { kbExpr: EditorContextKeys.editorTextFocus, - primary: KeyMod.CtrlCmd | KeyCode.F12 + primary: KeyMod.CtrlCmd | KeyCode.F12, + weight: KeybindingWeight.EditorContrib } }); } @@ -294,7 +299,8 @@ export class PeekImplementationAction extends ImplementationAction { EditorContextKeys.isInEmbeddedEditor.toNegated()), kbOpts: { kbExpr: EditorContextKeys.editorTextFocus, - primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.F12 + primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.F12, + weight: KeybindingWeight.EditorContrib } }); } @@ -330,7 +336,8 @@ export class GoToTypeDefinitionAction extends TypeDefinitionAction { EditorContextKeys.isInEmbeddedEditor.toNegated()), kbOpts: { kbExpr: EditorContextKeys.editorTextFocus, - primary: 0 + primary: 0, + weight: KeybindingWeight.EditorContrib }, menuOpts: { group: 'navigation', @@ -354,7 +361,8 @@ export class PeekTypeDefinitionAction extends TypeDefinitionAction { EditorContextKeys.isInEmbeddedEditor.toNegated()), kbOpts: { kbExpr: EditorContextKeys.editorTextFocus, - primary: 0 + primary: 0, + weight: KeybindingWeight.EditorContrib } }); } diff --git a/src/vs/editor/contrib/gotoError/gotoError.ts b/src/vs/editor/contrib/gotoError/gotoError.ts index 1c56024bc20..2ccee5cba7a 100644 --- a/src/vs/editor/contrib/gotoError/gotoError.ts +++ b/src/vs/editor/contrib/gotoError/gotoError.ts @@ -19,7 +19,7 @@ import { registerEditorAction, registerEditorContribution, ServicesAccessor, IAc import { ICodeEditor } from 'vs/editor/browser/editorBrowser'; import { IThemeService } from 'vs/platform/theme/common/themeService'; import { EditorContextKeys } from 'vs/editor/common/editorContextKeys'; -import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry'; +import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; import { MarkerNavigationWidget } from './gotoErrorWidget'; import { compare } from 'vs/base/common/strings'; import { binarySearch } from 'vs/base/common/arrays'; @@ -401,7 +401,8 @@ class NextMarkerInFilesAction extends MarkerNavigationAction { precondition: EditorContextKeys.writable, kbOpts: { kbExpr: EditorContextKeys.focus, - primary: KeyCode.F8 + primary: KeyCode.F8, + weight: KeybindingWeight.EditorContrib } }); } @@ -416,7 +417,8 @@ class PrevMarkerInFilesAction extends MarkerNavigationAction { precondition: EditorContextKeys.writable, kbOpts: { kbExpr: EditorContextKeys.focus, - primary: KeyMod.Shift | KeyCode.F8 + primary: KeyMod.Shift | KeyCode.F8, + weight: KeybindingWeight.EditorContrib } }); } @@ -437,7 +439,7 @@ registerEditorCommand(new MarkerCommand({ precondition: CONTEXT_MARKERS_NAVIGATION_VISIBLE, handler: x => x.closeMarkersNavigation(), kbOpts: { - weight: KeybindingsRegistry.WEIGHT.editorContrib(50), + weight: KeybindingWeight.EditorContrib + 50, kbExpr: EditorContextKeys.focus, primary: KeyCode.Escape, secondary: [KeyMod.Shift | KeyCode.Escape] diff --git a/src/vs/editor/contrib/hover/hover.ts b/src/vs/editor/contrib/hover/hover.ts index 45f39711585..cfef3c6c719 100644 --- a/src/vs/editor/contrib/hover/hover.ts +++ b/src/vs/editor/contrib/hover/hover.ts @@ -26,6 +26,7 @@ import { EditorContextKeys } from 'vs/editor/common/editorContextKeys'; import { MarkdownRenderer } from 'vs/editor/contrib/markdown/markdownRenderer'; import { IEmptyContentData } from 'vs/editor/browser/controller/mouseTarget'; import { HoverStartMode } from 'vs/editor/contrib/hover/hoverOperation'; +import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; export class ModesHoverController implements IEditorContribution { @@ -250,7 +251,8 @@ class ShowHoverAction extends EditorAction { precondition: null, kbOpts: { kbExpr: EditorContextKeys.editorTextFocus, - primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_I) + primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_I), + weight: KeybindingWeight.EditorContrib } }); } diff --git a/src/vs/editor/contrib/inPlaceReplace/inPlaceReplace.ts b/src/vs/editor/contrib/inPlaceReplace/inPlaceReplace.ts index 3127c005bfe..eba360f0676 100644 --- a/src/vs/editor/contrib/inPlaceReplace/inPlaceReplace.ts +++ b/src/vs/editor/contrib/inPlaceReplace/inPlaceReplace.ts @@ -22,6 +22,7 @@ import { ModelDecorationOptions } from 'vs/editor/common/model/textModel'; import { ICodeEditor } from 'vs/editor/browser/editorBrowser'; import { CancelablePromise, createCancelablePromise, timeout } from 'vs/base/common/async'; import { onUnexpectedError } from 'vs/base/common/errors'; +import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; class InPlaceReplaceController implements IEditorContribution { @@ -142,7 +143,8 @@ class InPlaceReplaceUp extends EditorAction { precondition: EditorContextKeys.writable, kbOpts: { kbExpr: EditorContextKeys.editorTextFocus, - primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.US_COMMA + primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.US_COMMA, + weight: KeybindingWeight.EditorContrib } }); } @@ -166,7 +168,8 @@ class InPlaceReplaceDown extends EditorAction { precondition: EditorContextKeys.writable, kbOpts: { kbExpr: EditorContextKeys.editorTextFocus, - primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.US_DOT + primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.US_DOT, + weight: KeybindingWeight.EditorContrib } }); } diff --git a/src/vs/editor/contrib/linesOperations/linesOperations.ts b/src/vs/editor/contrib/linesOperations/linesOperations.ts index 7f2c9fb66c4..4171729014e 100644 --- a/src/vs/editor/contrib/linesOperations/linesOperations.ts +++ b/src/vs/editor/contrib/linesOperations/linesOperations.ts @@ -23,6 +23,7 @@ import { MoveLinesCommand } from './moveLinesCommand'; import { TypeOperations } from 'vs/editor/common/controller/cursorTypeOperations'; import { CoreEditingCommands } from 'vs/editor/browser/controller/coreCommands'; import { ICodeEditor } from 'vs/editor/browser/editorBrowser'; +import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; // copy lines @@ -60,7 +61,8 @@ class CopyLinesUpAction extends AbstractCopyLinesAction { kbOpts: { kbExpr: EditorContextKeys.editorTextFocus, primary: KeyMod.Alt | KeyMod.Shift | KeyCode.UpArrow, - linux: { primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyMod.Shift | KeyCode.UpArrow } + linux: { primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyMod.Shift | KeyCode.UpArrow }, + weight: KeybindingWeight.EditorContrib } }); } @@ -76,7 +78,8 @@ class CopyLinesDownAction extends AbstractCopyLinesAction { kbOpts: { kbExpr: EditorContextKeys.editorTextFocus, primary: KeyMod.Alt | KeyMod.Shift | KeyCode.DownArrow, - linux: { primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyMod.Shift | KeyCode.DownArrow } + linux: { primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyMod.Shift | KeyCode.DownArrow }, + weight: KeybindingWeight.EditorContrib } }); } @@ -119,7 +122,8 @@ class MoveLinesUpAction extends AbstractMoveLinesAction { kbOpts: { kbExpr: EditorContextKeys.editorTextFocus, primary: KeyMod.Alt | KeyCode.UpArrow, - linux: { primary: KeyMod.Alt | KeyCode.UpArrow } + linux: { primary: KeyMod.Alt | KeyCode.UpArrow }, + weight: KeybindingWeight.EditorContrib } }); } @@ -135,7 +139,8 @@ class MoveLinesDownAction extends AbstractMoveLinesAction { kbOpts: { kbExpr: EditorContextKeys.editorTextFocus, primary: KeyMod.Alt | KeyCode.DownArrow, - linux: { primary: KeyMod.Alt | KeyCode.DownArrow } + linux: { primary: KeyMod.Alt | KeyCode.DownArrow }, + weight: KeybindingWeight.EditorContrib } }); } @@ -204,7 +209,8 @@ export class TrimTrailingWhitespaceAction extends EditorAction { precondition: EditorContextKeys.writable, kbOpts: { kbExpr: EditorContextKeys.editorTextFocus, - primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_X) + primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_X), + weight: KeybindingWeight.EditorContrib } }); } @@ -245,7 +251,8 @@ class DeleteLinesAction extends EditorAction { precondition: EditorContextKeys.writable, kbOpts: { kbExpr: EditorContextKeys.textInputFocus, - primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_K + primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_K, + weight: KeybindingWeight.EditorContrib } }); } @@ -314,7 +321,8 @@ export class IndentLinesAction extends EditorAction { precondition: EditorContextKeys.writable, kbOpts: { kbExpr: EditorContextKeys.editorTextFocus, - primary: KeyMod.CtrlCmd | KeyCode.US_CLOSE_SQUARE_BRACKET + primary: KeyMod.CtrlCmd | KeyCode.US_CLOSE_SQUARE_BRACKET, + weight: KeybindingWeight.EditorContrib } }); } @@ -335,7 +343,8 @@ class OutdentLinesAction extends EditorAction { precondition: EditorContextKeys.writable, kbOpts: { kbExpr: EditorContextKeys.editorTextFocus, - primary: KeyMod.CtrlCmd | KeyCode.US_OPEN_SQUARE_BRACKET + primary: KeyMod.CtrlCmd | KeyCode.US_OPEN_SQUARE_BRACKET, + weight: KeybindingWeight.EditorContrib } }); } @@ -354,7 +363,8 @@ export class InsertLineBeforeAction extends EditorAction { precondition: EditorContextKeys.writable, kbOpts: { kbExpr: EditorContextKeys.editorTextFocus, - primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.Enter + primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.Enter, + weight: KeybindingWeight.EditorContrib } }); } @@ -374,7 +384,8 @@ export class InsertLineAfterAction extends EditorAction { precondition: EditorContextKeys.writable, kbOpts: { kbExpr: EditorContextKeys.editorTextFocus, - primary: KeyMod.CtrlCmd | KeyCode.Enter + primary: KeyMod.CtrlCmd | KeyCode.Enter, + weight: KeybindingWeight.EditorContrib } }); } @@ -434,7 +445,8 @@ export class DeleteAllLeftAction extends AbstractDeleteAllToBoundaryAction { kbOpts: { kbExpr: EditorContextKeys.textInputFocus, primary: null, - mac: { primary: KeyMod.CtrlCmd | KeyCode.Backspace } + mac: { primary: KeyMod.CtrlCmd | KeyCode.Backspace }, + weight: KeybindingWeight.EditorContrib } }); } @@ -502,7 +514,8 @@ export class DeleteAllRightAction extends AbstractDeleteAllToBoundaryAction { kbOpts: { kbExpr: EditorContextKeys.textInputFocus, primary: null, - mac: { primary: KeyMod.WinCtrl | KeyCode.KEY_K, secondary: [KeyMod.CtrlCmd | KeyCode.Delete] } + mac: { primary: KeyMod.WinCtrl | KeyCode.KEY_K, secondary: [KeyMod.CtrlCmd | KeyCode.Delete] }, + weight: KeybindingWeight.EditorContrib } }); } @@ -559,7 +572,8 @@ export class JoinLinesAction extends EditorAction { kbOpts: { kbExpr: EditorContextKeys.editorTextFocus, primary: 0, - mac: { primary: KeyMod.WinCtrl | KeyCode.KEY_J } + mac: { primary: KeyMod.WinCtrl | KeyCode.KEY_J }, + weight: KeybindingWeight.EditorContrib } }); } diff --git a/src/vs/editor/contrib/message/messageController.ts b/src/vs/editor/contrib/message/messageController.ts index e80d0f6b90c..38ace15a614 100644 --- a/src/vs/editor/contrib/message/messageController.ts +++ b/src/vs/editor/contrib/message/messageController.ts @@ -19,7 +19,7 @@ import { IContextKeyService, RawContextKey, IContextKey } from 'vs/platform/cont import { IPosition } from 'vs/editor/common/core/position'; import { registerThemingParticipant, HIGH_CONTRAST } from 'vs/platform/theme/common/themeService'; import { inputValidationInfoBorder, inputValidationInfoBackground } from 'vs/platform/theme/common/colorRegistry'; -import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry'; +import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; export class MessageController extends Disposable implements editorCommon.IEditorContribution { @@ -114,7 +114,7 @@ registerEditorCommand(new MessageCommand({ precondition: MessageController.MESSAGE_VISIBLE, handler: c => c.closeMessage(), kbOpts: { - weight: KeybindingsRegistry.WEIGHT.editorContrib(30), + weight: KeybindingWeight.EditorContrib + 30, primary: KeyCode.Escape } })); diff --git a/src/vs/editor/contrib/multicursor/multicursor.ts b/src/vs/editor/contrib/multicursor/multicursor.ts index 0517d7061a5..ed677d9b80f 100644 --- a/src/vs/editor/contrib/multicursor/multicursor.ts +++ b/src/vs/editor/contrib/multicursor/multicursor.ts @@ -25,6 +25,7 @@ import { overviewRulerSelectionHighlightForeground } from 'vs/platform/theme/com import { themeColorFromId } from 'vs/platform/theme/common/themeService'; import { INewFindReplaceState, FindOptionOverride } from 'vs/editor/contrib/find/findState'; import { ICodeEditor } from 'vs/editor/browser/editorBrowser'; +import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; export class InsertCursorAbove extends EditorAction { @@ -40,7 +41,8 @@ export class InsertCursorAbove extends EditorAction { linux: { primary: KeyMod.Shift | KeyMod.Alt | KeyCode.UpArrow, secondary: [KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.UpArrow] - } + }, + weight: KeybindingWeight.EditorContrib } }); } @@ -78,7 +80,8 @@ export class InsertCursorBelow extends EditorAction { linux: { primary: KeyMod.Shift | KeyMod.Alt | KeyCode.DownArrow, secondary: [KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.DownArrow] - } + }, + weight: KeybindingWeight.EditorContrib } }); } @@ -112,7 +115,8 @@ class InsertCursorAtEndOfEachLineSelected extends EditorAction { precondition: null, kbOpts: { kbExpr: EditorContextKeys.editorTextFocus, - primary: KeyMod.Shift | KeyMod.Alt | KeyCode.KEY_I + primary: KeyMod.Shift | KeyMod.Alt | KeyCode.KEY_I, + weight: KeybindingWeight.EditorContrib } }); } @@ -522,7 +526,8 @@ export class AddSelectionToNextFindMatchAction extends MultiCursorSelectionContr precondition: null, kbOpts: { kbExpr: EditorContextKeys.focus, - primary: KeyMod.CtrlCmd | KeyCode.KEY_D + primary: KeyMod.CtrlCmd | KeyCode.KEY_D, + weight: KeybindingWeight.EditorContrib } }); } @@ -554,7 +559,8 @@ export class MoveSelectionToNextFindMatchAction extends MultiCursorSelectionCont precondition: null, kbOpts: { kbExpr: EditorContextKeys.focus, - primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_D) + primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_D), + weight: KeybindingWeight.EditorContrib } }); } @@ -586,7 +592,8 @@ export class SelectHighlightsAction extends MultiCursorSelectionControllerAction precondition: null, kbOpts: { kbExpr: EditorContextKeys.focus, - primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_L + primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_L, + weight: KeybindingWeight.EditorContrib } }); } @@ -604,7 +611,8 @@ export class CompatChangeAll extends MultiCursorSelectionControllerAction { precondition: EditorContextKeys.writable, kbOpts: { kbExpr: EditorContextKeys.editorTextFocus, - primary: KeyMod.CtrlCmd | KeyCode.F2 + primary: KeyMod.CtrlCmd | KeyCode.F2, + weight: KeybindingWeight.EditorContrib }, menuOpts: { group: '1_modification', diff --git a/src/vs/editor/contrib/parameterHints/parameterHints.ts b/src/vs/editor/contrib/parameterHints/parameterHints.ts index 92d7eb7a799..6ec4cda8857 100644 --- a/src/vs/editor/contrib/parameterHints/parameterHints.ts +++ b/src/vs/editor/contrib/parameterHints/parameterHints.ts @@ -15,7 +15,7 @@ import { registerEditorAction, registerEditorContribution, ServicesAccessor, Edi import { ICodeEditor } from 'vs/editor/browser/editorBrowser'; import { ParameterHintsWidget } from './parameterHintsWidget'; import { Context } from 'vs/editor/contrib/parameterHints/provideSignatureHelp'; -import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry'; +import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; class ParameterHintsController implements IEditorContribution { @@ -68,7 +68,8 @@ export class TriggerParameterHintsAction extends EditorAction { precondition: EditorContextKeys.hasSignatureHelpProvider, kbOpts: { kbExpr: EditorContextKeys.editorTextFocus, - primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.Space + primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.Space, + weight: KeybindingWeight.EditorContrib } }); } @@ -84,7 +85,7 @@ export class TriggerParameterHintsAction extends EditorAction { registerEditorContribution(ParameterHintsController); registerEditorAction(TriggerParameterHintsAction); -const weight = KeybindingsRegistry.WEIGHT.editorContrib(75); +const weight = KeybindingWeight.EditorContrib + 75; const ParameterHintsCommand = EditorCommand.bindToContribution(ParameterHintsController.get); diff --git a/src/vs/editor/contrib/referenceSearch/referenceSearch.ts b/src/vs/editor/contrib/referenceSearch/referenceSearch.ts index ff8515fdd1e..787b9d4760d 100644 --- a/src/vs/editor/contrib/referenceSearch/referenceSearch.ts +++ b/src/vs/editor/contrib/referenceSearch/referenceSearch.ts @@ -8,7 +8,7 @@ import * as nls from 'vs/nls'; import { KeyCode, KeyMod } from 'vs/base/common/keyCodes'; import { TPromise } from 'vs/base/common/winjs.base'; import { IContextKeyService, ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey'; -import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry'; +import { KeybindingsRegistry, KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; import { Position, IPosition } from 'vs/editor/common/core/position'; import * as editorCommon from 'vs/editor/common/editorCommon'; import { registerEditorAction, ServicesAccessor, EditorAction, registerEditorContribution, registerDefaultLanguageCommand } from 'vs/editor/browser/editorExtensions'; @@ -70,7 +70,8 @@ export class ReferenceAction extends EditorAction { EditorContextKeys.isInEmbeddedEditor.toNegated()), kbOpts: { kbExpr: EditorContextKeys.editorTextFocus, - primary: KeyMod.Shift | KeyCode.F12 + primary: KeyMod.Shift | KeyCode.F12, + weight: KeybindingWeight.EditorContrib }, menuOpts: { group: 'navigation', @@ -192,7 +193,7 @@ function withController(accessor: ServicesAccessor, fn: (controller: ReferencesC KeybindingsRegistry.registerCommandAndKeybindingRule({ id: 'goToNextReference', - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(50), + weight: KeybindingWeight.WorkbenchContrib + 50, primary: KeyCode.F4, when: ctxReferenceSearchVisible, handler(accessor) { @@ -204,7 +205,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({ KeybindingsRegistry.registerCommandAndKeybindingRule({ id: 'goToNextReferenceFromEmbeddedEditor', - weight: KeybindingsRegistry.WEIGHT.editorContrib(50), + weight: KeybindingWeight.EditorContrib + 50, primary: KeyCode.F4, when: PeekContext.inPeekEditor, handler(accessor) { @@ -216,7 +217,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({ KeybindingsRegistry.registerCommandAndKeybindingRule({ id: 'goToPreviousReference', - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(50), + weight: KeybindingWeight.WorkbenchContrib + 50, primary: KeyMod.Shift | KeyCode.F4, when: ctxReferenceSearchVisible, handler(accessor) { @@ -228,7 +229,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({ KeybindingsRegistry.registerCommandAndKeybindingRule({ id: 'goToPreviousReferenceFromEmbeddedEditor', - weight: KeybindingsRegistry.WEIGHT.editorContrib(50), + weight: KeybindingWeight.EditorContrib + 50, primary: KeyMod.Shift | KeyCode.F4, when: PeekContext.inPeekEditor, handler(accessor) { @@ -240,7 +241,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({ KeybindingsRegistry.registerCommandAndKeybindingRule({ id: 'closeReferenceSearch', - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(50), + weight: KeybindingWeight.WorkbenchContrib + 50, primary: KeyCode.Escape, secondary: [KeyMod.Shift | KeyCode.Escape], when: ContextKeyExpr.and(ctxReferenceSearchVisible, ContextKeyExpr.not('config.editor.stablePeek')), @@ -249,7 +250,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({ KeybindingsRegistry.registerCommandAndKeybindingRule({ id: 'closeReferenceSearchEditor', - weight: KeybindingsRegistry.WEIGHT.editorContrib(-101), + weight: KeybindingWeight.EditorContrib - 101, primary: KeyCode.Escape, secondary: [KeyMod.Shift | KeyCode.Escape], when: ContextKeyExpr.and(PeekContext.inPeekEditor, ContextKeyExpr.not('config.editor.stablePeek')), @@ -258,7 +259,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({ KeybindingsRegistry.registerCommandAndKeybindingRule({ id: 'openReferenceToSide', - weight: KeybindingsRegistry.WEIGHT.editorContrib(), + weight: KeybindingWeight.EditorContrib, primary: KeyMod.CtrlCmd | KeyCode.Enter, mac: { primary: KeyMod.WinCtrl | KeyCode.Enter diff --git a/src/vs/editor/contrib/rename/rename.ts b/src/vs/editor/contrib/rename/rename.ts index d83828e5695..c5eeedbb0e5 100644 --- a/src/vs/editor/contrib/rename/rename.ts +++ b/src/vs/editor/contrib/rename/rename.ts @@ -25,7 +25,7 @@ import { alert } from 'vs/base/browser/ui/aria/aria'; import { Range } from 'vs/editor/common/core/range'; import { MessageController } from 'vs/editor/contrib/message/messageController'; import { EditorState, CodeEditorStateFlag } from 'vs/editor/browser/core/editorState'; -import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry'; +import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; import { INotificationService } from 'vs/platform/notification/common/notification'; import { IBulkEditService } from 'vs/editor/browser/services/bulkEditService'; import URI from 'vs/base/common/uri'; @@ -224,7 +224,8 @@ export class RenameAction extends EditorAction { precondition: ContextKeyExpr.and(EditorContextKeys.writable, EditorContextKeys.hasRenameProvider), kbOpts: { kbExpr: EditorContextKeys.editorTextFocus, - primary: KeyCode.F2 + primary: KeyCode.F2, + weight: KeybindingWeight.EditorContrib }, menuOpts: { group: '1_modification', @@ -269,7 +270,7 @@ registerEditorCommand(new RenameCommand({ precondition: CONTEXT_RENAME_INPUT_VISIBLE, handler: x => x.acceptRenameInput(), kbOpts: { - weight: KeybindingsRegistry.WEIGHT.editorContrib(99), + weight: KeybindingWeight.EditorContrib + 99, kbExpr: EditorContextKeys.focus, primary: KeyCode.Enter } @@ -280,7 +281,7 @@ registerEditorCommand(new RenameCommand({ precondition: CONTEXT_RENAME_INPUT_VISIBLE, handler: x => x.cancelRenameInput(), kbOpts: { - weight: KeybindingsRegistry.WEIGHT.editorContrib(99), + weight: KeybindingWeight.EditorContrib + 99, kbExpr: EditorContextKeys.focus, primary: KeyCode.Escape, secondary: [KeyMod.Shift | KeyCode.Escape] diff --git a/src/vs/editor/contrib/smartSelect/smartSelect.ts b/src/vs/editor/contrib/smartSelect/smartSelect.ts index 7c25548d3c9..76b6057a039 100644 --- a/src/vs/editor/contrib/smartSelect/smartSelect.ts +++ b/src/vs/editor/contrib/smartSelect/smartSelect.ts @@ -16,6 +16,7 @@ import { registerEditorAction, ServicesAccessor, IActionOptions, EditorAction, r import { TokenSelectionSupport, ILogicalSelectionEntry } from './tokenSelectionSupport'; import { ICursorPositionChangedEvent } from 'vs/editor/common/controller/cursorEvents'; import { ICodeEditor } from 'vs/editor/browser/editorBrowser'; +import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; // --- selection state machine @@ -173,7 +174,8 @@ class GrowSelectionAction extends AbstractSmartSelect { kbOpts: { kbExpr: EditorContextKeys.editorTextFocus, primary: KeyMod.Shift | KeyMod.Alt | KeyCode.RightArrow, - mac: { primary: KeyMod.CtrlCmd | KeyMod.WinCtrl | KeyMod.Shift | KeyCode.RightArrow } + mac: { primary: KeyMod.CtrlCmd | KeyMod.WinCtrl | KeyMod.Shift | KeyCode.RightArrow }, + weight: KeybindingWeight.EditorContrib } }); } @@ -189,7 +191,8 @@ class ShrinkSelectionAction extends AbstractSmartSelect { kbOpts: { kbExpr: EditorContextKeys.editorTextFocus, primary: KeyMod.Shift | KeyMod.Alt | KeyCode.LeftArrow, - mac: { primary: KeyMod.CtrlCmd | KeyMod.WinCtrl | KeyMod.Shift | KeyCode.LeftArrow } + mac: { primary: KeyMod.CtrlCmd | KeyMod.WinCtrl | KeyMod.Shift | KeyCode.LeftArrow }, + weight: KeybindingWeight.EditorContrib } }); } diff --git a/src/vs/editor/contrib/snippet/snippetController2.ts b/src/vs/editor/contrib/snippet/snippetController2.ts index 3022a612e99..9a3a443b47a 100644 --- a/src/vs/editor/contrib/snippet/snippetController2.ts +++ b/src/vs/editor/contrib/snippet/snippetController2.ts @@ -18,7 +18,7 @@ import { Range } from 'vs/editor/common/core/range'; import { Choice } from 'vs/editor/contrib/snippet/snippetParser'; import { repeat } from 'vs/base/common/strings'; import { ICodeEditor } from 'vs/editor/browser/editorBrowser'; -import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry'; +import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; import { IEditorContribution } from 'vs/editor/common/editorCommon'; import { ILogService } from 'vs/platform/log/common/log'; @@ -227,7 +227,7 @@ registerEditorCommand(new CommandCtor({ precondition: ContextKeyExpr.and(SnippetController2.InSnippetMode, SnippetController2.HasNextTabstop), handler: ctrl => ctrl.next(), kbOpts: { - weight: KeybindingsRegistry.WEIGHT.editorContrib(30), + weight: KeybindingWeight.EditorContrib + 30, kbExpr: EditorContextKeys.editorTextFocus, primary: KeyCode.Tab } @@ -237,7 +237,7 @@ registerEditorCommand(new CommandCtor({ precondition: ContextKeyExpr.and(SnippetController2.InSnippetMode, SnippetController2.HasPrevTabstop), handler: ctrl => ctrl.prev(), kbOpts: { - weight: KeybindingsRegistry.WEIGHT.editorContrib(30), + weight: KeybindingWeight.EditorContrib + 30, kbExpr: EditorContextKeys.editorTextFocus, primary: KeyMod.Shift | KeyCode.Tab } @@ -247,7 +247,7 @@ registerEditorCommand(new CommandCtor({ precondition: SnippetController2.InSnippetMode, handler: ctrl => ctrl.cancel(), kbOpts: { - weight: KeybindingsRegistry.WEIGHT.editorContrib(30), + weight: KeybindingWeight.EditorContrib + 30, kbExpr: EditorContextKeys.editorTextFocus, primary: KeyCode.Escape, secondary: [KeyMod.Shift | KeyCode.Escape] @@ -259,7 +259,7 @@ registerEditorCommand(new CommandCtor({ precondition: SnippetController2.InSnippetMode, handler: ctrl => ctrl.finish(), // kbOpts: { - // weight: KeybindingsRegistry.WEIGHT.editorContrib(30), + // weight: KeybindingWeight.EditorContrib + 30, // kbExpr: EditorContextKeys.textFocus, // primary: KeyCode.Enter, // } diff --git a/src/vs/editor/contrib/suggest/suggestController.ts b/src/vs/editor/contrib/suggest/suggestController.ts index f92c3459f73..e281a671244 100644 --- a/src/vs/editor/contrib/suggest/suggestController.ts +++ b/src/vs/editor/contrib/suggest/suggestController.ts @@ -26,7 +26,7 @@ import { Context as SuggestContext } from './suggest'; import { SuggestModel, State } from './suggestModel'; import { ICompletionItem } from './completionModel'; import { SuggestWidget, ISelectedSuggestion } from './suggestWidget'; -import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry'; +import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; import { SuggestMemories } from 'vs/editor/contrib/suggest/suggestMemory'; class AcceptOnCharacterOracle { @@ -325,7 +325,8 @@ export class TriggerSuggestAction extends EditorAction { kbOpts: { kbExpr: EditorContextKeys.textInputFocus, primary: KeyMod.CtrlCmd | KeyCode.Space, - mac: { primary: KeyMod.WinCtrl | KeyCode.Space } + mac: { primary: KeyMod.WinCtrl | KeyCode.Space }, + weight: KeybindingWeight.EditorContrib } }); } @@ -344,7 +345,7 @@ export class TriggerSuggestAction extends EditorAction { registerEditorContribution(SuggestController); registerEditorAction(TriggerSuggestAction); -const weight = KeybindingsRegistry.WEIGHT.editorContrib(90); +const weight = KeybindingWeight.EditorContrib + 90; const SuggestCommand = EditorCommand.bindToContribution(SuggestController.get); diff --git a/src/vs/editor/contrib/toggleTabFocusMode/toggleTabFocusMode.ts b/src/vs/editor/contrib/toggleTabFocusMode/toggleTabFocusMode.ts index e3aa3349af1..87cb996bb1c 100644 --- a/src/vs/editor/contrib/toggleTabFocusMode/toggleTabFocusMode.ts +++ b/src/vs/editor/contrib/toggleTabFocusMode/toggleTabFocusMode.ts @@ -9,6 +9,7 @@ import { KeyCode, KeyMod } from 'vs/base/common/keyCodes'; import { registerEditorAction, ServicesAccessor, EditorAction } from 'vs/editor/browser/editorExtensions'; import { TabFocus } from 'vs/editor/common/config/commonEditorConfig'; import { ICodeEditor } from 'vs/editor/browser/editorBrowser'; +import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; export class ToggleTabFocusModeAction extends EditorAction { @@ -23,7 +24,8 @@ export class ToggleTabFocusModeAction extends EditorAction { kbOpts: { kbExpr: null, primary: KeyMod.CtrlCmd | KeyCode.KEY_M, - mac: { primary: KeyMod.WinCtrl | KeyMod.Shift | KeyCode.KEY_M } + mac: { primary: KeyMod.WinCtrl | KeyMod.Shift | KeyCode.KEY_M }, + weight: KeybindingWeight.EditorContrib } }); } diff --git a/src/vs/editor/contrib/wordHighlighter/wordHighlighter.ts b/src/vs/editor/contrib/wordHighlighter/wordHighlighter.ts index 7f21bc957a1..8c852574b12 100644 --- a/src/vs/editor/contrib/wordHighlighter/wordHighlighter.ts +++ b/src/vs/editor/contrib/wordHighlighter/wordHighlighter.ts @@ -25,6 +25,7 @@ import { firstIndex, isFalsyOrEmpty } from 'vs/base/common/arrays'; import { ICodeEditor } from 'vs/editor/browser/editorBrowser'; import { ITextModel, TrackedRangeStickiness, OverviewRulerLane, IModelDeltaDecoration } from 'vs/editor/common/model'; import { CancellationToken } from 'vs/base/common/cancellation'; +import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; export const editorWordHighlight = registerColor('editor.wordHighlightBackground', { dark: '#575757B8', light: '#57575740', hc: null }, nls.localize('wordHighlight', 'Background color of a symbol during read-access, like reading a variable. The color must not be opaque to not hide underlying decorations.'), true); export const editorWordHighlightStrong = registerColor('editor.wordHighlightStrongBackground', { dark: '#004972B8', light: '#0e639c40', hc: null }, nls.localize('wordHighlightStrong', 'Background color of a symbol during write-access, like writing to a variable. The color must not be opaque to not hide underlying decorations.'), true); @@ -459,7 +460,8 @@ class NextWordHighlightAction extends WordHighlightNavigationAction { precondition: ctxHasWordHighlights, kbOpts: { kbExpr: EditorContextKeys.editorTextFocus, - primary: KeyCode.F7 + primary: KeyCode.F7, + weight: KeybindingWeight.EditorContrib } }); } @@ -474,7 +476,8 @@ class PrevWordHighlightAction extends WordHighlightNavigationAction { precondition: ctxHasWordHighlights, kbOpts: { kbExpr: EditorContextKeys.editorTextFocus, - primary: KeyMod.Shift | KeyCode.F7 + primary: KeyMod.Shift | KeyCode.F7, + weight: KeybindingWeight.EditorContrib } }); } diff --git a/src/vs/editor/contrib/wordOperations/wordOperations.ts b/src/vs/editor/contrib/wordOperations/wordOperations.ts index 528303ab72c..237cc0bde06 100644 --- a/src/vs/editor/contrib/wordOperations/wordOperations.ts +++ b/src/vs/editor/contrib/wordOperations/wordOperations.ts @@ -19,6 +19,7 @@ import { getMapForWordSeparators, WordCharacterClassifier } from 'vs/editor/comm import { CursorState } from 'vs/editor/common/controller/cursorCommon'; import { CursorChangeReason } from 'vs/editor/common/controller/cursorEvents'; import { ICodeEditor } from 'vs/editor/browser/editorBrowser'; +import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; export interface MoveWordOptions extends ICommandOptions { inSelectionMode: boolean; @@ -100,7 +101,8 @@ export class CursorWordStartLeft extends WordLeftCommand { kbOpts: { kbExpr: EditorContextKeys.textInputFocus, primary: KeyMod.CtrlCmd | KeyCode.LeftArrow, - mac: { primary: KeyMod.Alt | KeyCode.LeftArrow } + mac: { primary: KeyMod.Alt | KeyCode.LeftArrow }, + weight: KeybindingWeight.EditorContrib } }); } @@ -138,7 +140,8 @@ export class CursorWordStartLeftSelect extends WordLeftCommand { kbOpts: { kbExpr: EditorContextKeys.textInputFocus, primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.LeftArrow, - mac: { primary: KeyMod.Alt | KeyMod.Shift | KeyCode.LeftArrow } + mac: { primary: KeyMod.Alt | KeyMod.Shift | KeyCode.LeftArrow }, + weight: KeybindingWeight.EditorContrib } }); } @@ -187,7 +190,8 @@ export class CursorWordEndRight extends WordRightCommand { kbOpts: { kbExpr: EditorContextKeys.textInputFocus, primary: KeyMod.CtrlCmd | KeyCode.RightArrow, - mac: { primary: KeyMod.Alt | KeyCode.RightArrow } + mac: { primary: KeyMod.Alt | KeyCode.RightArrow }, + weight: KeybindingWeight.EditorContrib } }); } @@ -225,7 +229,8 @@ export class CursorWordEndRightSelect extends WordRightCommand { kbOpts: { kbExpr: EditorContextKeys.textInputFocus, primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.RightArrow, - mac: { primary: KeyMod.Alt | KeyMod.Shift | KeyCode.RightArrow } + mac: { primary: KeyMod.Alt | KeyMod.Shift | KeyCode.RightArrow }, + weight: KeybindingWeight.EditorContrib } }); } @@ -330,7 +335,8 @@ export class DeleteWordLeft extends DeleteWordLeftCommand { kbOpts: { kbExpr: EditorContextKeys.textInputFocus, primary: KeyMod.CtrlCmd | KeyCode.Backspace, - mac: { primary: KeyMod.Alt | KeyCode.Backspace } + mac: { primary: KeyMod.Alt | KeyCode.Backspace }, + weight: KeybindingWeight.EditorContrib } }); } @@ -368,7 +374,8 @@ export class DeleteWordRight extends DeleteWordRightCommand { kbOpts: { kbExpr: EditorContextKeys.textInputFocus, primary: KeyMod.CtrlCmd | KeyCode.Delete, - mac: { primary: KeyMod.Alt | KeyCode.Delete } + mac: { primary: KeyMod.Alt | KeyCode.Delete }, + weight: KeybindingWeight.EditorContrib } }); } diff --git a/src/vs/editor/contrib/wordPartOperations/wordPartOperations.ts b/src/vs/editor/contrib/wordPartOperations/wordPartOperations.ts index 28829ba7b31..229dbedfc18 100644 --- a/src/vs/editor/contrib/wordPartOperations/wordPartOperations.ts +++ b/src/vs/editor/contrib/wordPartOperations/wordPartOperations.ts @@ -15,6 +15,7 @@ import { WordNavigationType, WordPartOperations } from 'vs/editor/common/control import { WordCharacterClassifier } from 'vs/editor/common/controller/wordCharacterClassifier'; import { DeleteWordCommand, MoveWordCommand } from '../wordOperations/wordOperations'; import { Position } from 'vs/editor/common/core/position'; +import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; export class DeleteWordPartLeft extends DeleteWordCommand { constructor() { @@ -26,7 +27,8 @@ export class DeleteWordPartLeft extends DeleteWordCommand { kbOpts: { kbExpr: EditorContextKeys.textInputFocus, primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.Backspace, - mac: { primary: KeyMod.WinCtrl | KeyMod.Alt | KeyCode.Backspace } + mac: { primary: KeyMod.WinCtrl | KeyMod.Alt | KeyCode.Backspace }, + weight: KeybindingWeight.EditorContrib } }); } @@ -50,7 +52,8 @@ export class DeleteWordPartRight extends DeleteWordCommand { kbOpts: { kbExpr: EditorContextKeys.textInputFocus, primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.Delete, - mac: { primary: KeyMod.WinCtrl | KeyMod.Alt | KeyCode.Delete } + mac: { primary: KeyMod.WinCtrl | KeyMod.Alt | KeyCode.Delete }, + weight: KeybindingWeight.EditorContrib } }); } @@ -81,7 +84,8 @@ export class CursorWordPartLeft extends WordPartLeftCommand { kbOpts: { kbExpr: EditorContextKeys.textInputFocus, primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.LeftArrow, - mac: { primary: KeyMod.WinCtrl | KeyMod.Alt | KeyCode.LeftArrow } + mac: { primary: KeyMod.WinCtrl | KeyMod.Alt | KeyCode.LeftArrow }, + weight: KeybindingWeight.EditorContrib } }); } @@ -96,7 +100,8 @@ export class CursorWordPartLeftSelect extends WordPartLeftCommand { kbOpts: { kbExpr: EditorContextKeys.textInputFocus, primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyMod.Shift | KeyCode.LeftArrow, - mac: { primary: KeyMod.WinCtrl | KeyMod.Alt | KeyMod.Shift | KeyCode.LeftArrow } + mac: { primary: KeyMod.WinCtrl | KeyMod.Alt | KeyMod.Shift | KeyCode.LeftArrow }, + weight: KeybindingWeight.EditorContrib } }); } @@ -117,7 +122,8 @@ export class CursorWordPartRight extends WordPartRightCommand { kbOpts: { kbExpr: EditorContextKeys.textInputFocus, primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.RightArrow, - mac: { primary: KeyMod.WinCtrl | KeyMod.Alt | KeyCode.RightArrow } + mac: { primary: KeyMod.WinCtrl | KeyMod.Alt | KeyCode.RightArrow }, + weight: KeybindingWeight.EditorContrib } }); } @@ -132,7 +138,8 @@ export class CursorWordPartRightSelect extends WordPartRightCommand { kbOpts: { kbExpr: EditorContextKeys.textInputFocus, primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyMod.Shift | KeyCode.RightArrow, - mac: { primary: KeyMod.WinCtrl | KeyMod.Alt | KeyMod.Shift | KeyCode.RightArrow } + mac: { primary: KeyMod.WinCtrl | KeyMod.Alt | KeyMod.Shift | KeyCode.RightArrow }, + weight: KeybindingWeight.EditorContrib } }); } diff --git a/src/vs/editor/standalone/browser/accessibilityHelp/accessibilityHelp.ts b/src/vs/editor/standalone/browser/accessibilityHelp/accessibilityHelp.ts index 7f6504e4607..b7b0b203953 100644 --- a/src/vs/editor/standalone/browser/accessibilityHelp/accessibilityHelp.ts +++ b/src/vs/editor/standalone/browser/accessibilityHelp/accessibilityHelp.ts @@ -30,7 +30,7 @@ import URI from 'vs/base/common/uri'; import { Selection } from 'vs/editor/common/core/selection'; import * as browser from 'vs/base/browser/browser'; import { IEditorConstructionOptions } from 'vs/editor/standalone/browser/standaloneCodeEditor'; -import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry'; +import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; const CONTEXT_ACCESSIBILITY_WIDGET_VISIBLE = new RawContextKey('accessibilityHelpWidgetVisible', false); @@ -342,7 +342,8 @@ class ShowAccessibilityHelpAction extends EditorAction { precondition: null, kbOpts: { kbExpr: EditorContextKeys.focus, - primary: (browser.isIE ? KeyMod.CtrlCmd | KeyCode.F1 : KeyMod.Alt | KeyCode.F1) + primary: (browser.isIE ? KeyMod.CtrlCmd | KeyCode.F1 : KeyMod.Alt | KeyCode.F1), + weight: KeybindingWeight.EditorContrib } }); } @@ -366,7 +367,7 @@ registerEditorCommand( precondition: CONTEXT_ACCESSIBILITY_WIDGET_VISIBLE, handler: x => x.hide(), kbOpts: { - weight: KeybindingsRegistry.WEIGHT.editorContrib(100), + weight: KeybindingWeight.EditorContrib + 100, kbExpr: EditorContextKeys.focus, primary: KeyCode.Escape, secondary: [KeyMod.Shift | KeyCode.Escape] diff --git a/src/vs/editor/standalone/browser/quickOpen/gotoLine.ts b/src/vs/editor/standalone/browser/quickOpen/gotoLine.ts index 9f83d8111c9..28bf35f5a56 100644 --- a/src/vs/editor/standalone/browser/quickOpen/gotoLine.ts +++ b/src/vs/editor/standalone/browser/quickOpen/gotoLine.ts @@ -18,6 +18,7 @@ import { KeyCode, KeyMod } from 'vs/base/common/keyCodes'; import { Position } from 'vs/editor/common/core/position'; import { Range } from 'vs/editor/common/core/range'; import { ITextModel } from 'vs/editor/common/model'; +import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; interface ParseResult { position: Position; @@ -153,7 +154,8 @@ export class GotoLineAction extends BaseEditorQuickOpenAction { kbOpts: { kbExpr: EditorContextKeys.focus, primary: KeyMod.CtrlCmd | KeyCode.KEY_G, - mac: { primary: KeyMod.WinCtrl | KeyCode.KEY_G } + mac: { primary: KeyMod.WinCtrl | KeyCode.KEY_G }, + weight: KeybindingWeight.EditorContrib } }); } diff --git a/src/vs/editor/standalone/browser/quickOpen/quickCommand.ts b/src/vs/editor/standalone/browser/quickOpen/quickCommand.ts index e44e14c0da8..7fe59dd0453 100644 --- a/src/vs/editor/standalone/browser/quickOpen/quickCommand.ts +++ b/src/vs/editor/standalone/browser/quickOpen/quickCommand.ts @@ -18,6 +18,7 @@ import { registerEditorAction, ServicesAccessor } from 'vs/editor/browser/editor import { KeyCode, KeyMod } from 'vs/base/common/keyCodes'; import * as browser from 'vs/base/browser/browser'; import { ICodeEditor } from 'vs/editor/browser/editorBrowser'; +import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; export class EditorActionCommandEntry extends QuickOpenEntryGroup { private key: string; @@ -79,9 +80,12 @@ export class QuickCommandAction extends BaseEditorQuickOpenAction { precondition: null, kbOpts: { kbExpr: EditorContextKeys.focus, - primary: (browser.isIE ? KeyMod.Alt | KeyCode.F1 : KeyCode.F1) + primary: (browser.isIE ? KeyMod.Alt | KeyCode.F1 : KeyCode.F1), + weight: KeybindingWeight.EditorContrib }, menuOpts: { + group: 'z_commands', + order: 1 } }); } diff --git a/src/vs/editor/standalone/browser/quickOpen/quickOutline.ts b/src/vs/editor/standalone/browser/quickOpen/quickOutline.ts index 19eeda1c9cc..ebc954e1b47 100644 --- a/src/vs/editor/standalone/browser/quickOpen/quickOutline.ts +++ b/src/vs/editor/standalone/browser/quickOpen/quickOutline.ts @@ -22,6 +22,7 @@ import { registerEditorAction, ServicesAccessor } from 'vs/editor/browser/editor import { KeyCode, KeyMod } from 'vs/base/common/keyCodes'; import { Range, IRange } from 'vs/editor/common/core/range'; import { ICodeEditor } from 'vs/editor/browser/editorBrowser'; +import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; let SCOPE_PREFIX = ':'; @@ -120,7 +121,8 @@ export class QuickOutlineAction extends BaseEditorQuickOpenAction { precondition: EditorContextKeys.hasDocumentSymbolProvider, kbOpts: { kbExpr: EditorContextKeys.focus, - primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_O + primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_O, + weight: KeybindingWeight.EditorContrib }, menuOpts: { group: 'navigation', diff --git a/src/vs/platform/extensionManagement/node/extensionManagementService.ts b/src/vs/platform/extensionManagement/node/extensionManagementService.ts index 5cc1c5b5bb7..84989938f78 100644 --- a/src/vs/platform/extensionManagement/node/extensionManagementService.ts +++ b/src/vs/platform/extensionManagement/node/extensionManagementService.ts @@ -250,7 +250,7 @@ export class ExtensionManagementService extends Disposable implements IExtension const existingExtension = installed.filter(i => areSameExtensions(i.galleryIdentifier, extension.identifier))[0]; operation = existingExtension ? InstallOperation.Update : InstallOperation.Install; return this.downloadInstallableExtension(extension, operation) - .then(installableExtension => this.installExtension(installableExtension)) + .then(installableExtension => this.installExtension(installableExtension).then(local => always(pfs.rimraf(installableExtension.zipPath), () => null).then(() => local))) .then(local => this.installDependenciesAndPackExtensions(local, existingExtension) .then(() => local, error => this.uninstall(local, true).then(() => TPromise.wrapError(error), () => TPromise.wrapError(error)))); }) @@ -331,7 +331,7 @@ export class ExtensionManagementService extends Disposable implements IExtension return this.galleryService.download(extension, operation) .then( zipPath => { - this.logService.info('Downloaded extension:', extension.name); + this.logService.info('Downloaded extension:', extension.name, zipPath); return validateLocalExtension(zipPath) .then( manifest => ({ zipPath, id: getLocalExtensionIdFromManifest(manifest), metadata }), diff --git a/src/vs/platform/keybinding/common/keybindingsRegistry.ts b/src/vs/platform/keybinding/common/keybindingsRegistry.ts index 39113558334..3d581b4e64f 100644 --- a/src/vs/platform/keybinding/common/keybindingsRegistry.ts +++ b/src/vs/platform/keybinding/common/keybindingsRegistry.ts @@ -57,6 +57,14 @@ export const enum KeybindingRuleSource { Extension = 1 } +export const enum KeybindingWeight { + EditorCore = 0, + EditorContrib = 100, + WorkbenchContrib = 200, + BuiltinExtension = 300, + ExternalExtension = 400 +} + export interface ICommandAndKeybindingRule extends IKeybindingRule { handler: ICommandHandler; description?: ICommandHandlerDescription; @@ -67,14 +75,6 @@ export interface IKeybindingsRegistry { registerKeybindingRule2(rule: IKeybindingRule2, source?: KeybindingRuleSource): void; registerCommandAndKeybindingRule(desc: ICommandAndKeybindingRule, source?: KeybindingRuleSource): void; getDefaultKeybindings(): IKeybindingItem[]; - - WEIGHT: { - editorCore(importance?: number): number; - editorContrib(importance?: number): number; - workbenchContrib(importance?: number): number; - builtinExtension(importance?: number): number; - externalExtension(importance?: number): number; - }; } class KeybindingsRegistryImpl implements IKeybindingsRegistry { @@ -82,24 +82,6 @@ class KeybindingsRegistryImpl implements IKeybindingsRegistry { private _keybindings: IKeybindingItem[]; private _keybindingsSorted: boolean; - public WEIGHT = { - editorCore: (importance: number = 0): number => { - return 0 + importance; - }, - editorContrib: (importance: number = 0): number => { - return 100 + importance; - }, - workbenchContrib: (importance: number = 0): number => { - return 200 + importance; - }, - builtinExtension: (importance: number = 0): number => { - return 300 + importance; - }, - externalExtension: (importance: number = 0): number => { - return 400 + importance; - } - }; - constructor() { this._keybindings = []; this._keybindingsSorted = true; diff --git a/src/vs/platform/request/node/request.ts b/src/vs/platform/request/node/request.ts index b8d501fa2b5..878a5c4a334 100644 --- a/src/vs/platform/request/node/request.ts +++ b/src/vs/platform/request/node/request.ts @@ -37,12 +37,12 @@ Registry.as(Extensions.Configuration) 'http.proxy': { type: 'string', pattern: '^https?://([^:]*(:[^@]*)?@)?([^:]+)(:\\d+)?/?$|^$', - description: localize('proxy', "The proxy setting to use. If not set will be taken from the http_proxy and https_proxy environment variables") + description: localize('proxy', "The proxy setting to use. If not set will be taken from the http_proxy and https_proxy environment variables.") }, 'http.proxyStrictSSL': { type: 'boolean', default: true, - description: localize('strictSSL', "Whether the proxy server certificate should be verified against the list of supplied CAs.") + description: localize('strictSSL', "Controls whether the proxy server certificate should be verified against the list of supplied CAs.") }, 'http.proxyAuthorization': { type: ['null', 'string'], diff --git a/src/vs/platform/search/common/search.ts b/src/vs/platform/search/common/search.ts index d2613c57504..7cacfe626a9 100644 --- a/src/vs/platform/search/common/search.ts +++ b/src/vs/platform/search/common/search.ts @@ -10,7 +10,7 @@ import { IDisposable } from 'vs/base/common/lifecycle'; import * as objects from 'vs/base/common/objects'; import * as paths from 'vs/base/common/paths'; import uri, { UriComponents } from 'vs/base/common/uri'; -import { PPromise, TPromise } from 'vs/base/common/winjs.base'; +import { TPromise } from 'vs/base/common/winjs.base'; import { IFilesConfiguration } from 'vs/platform/files/common/files'; import { createDecorator } from 'vs/platform/instantiation/common/instantiation'; @@ -46,7 +46,7 @@ export interface ISearchHistoryService { } export interface ISearchResultProvider { - search(query: ISearchQuery): PPromise; + search(query: ISearchQuery, onProgress?: (p: ISearchProgressItem) => void): TPromise; clearCache(cacheKey: string): TPromise; } diff --git a/src/vs/platform/telemetry/common/telemetryService.ts b/src/vs/platform/telemetry/common/telemetryService.ts index dba27cde4b1..0b8470198a3 100644 --- a/src/vs/platform/telemetry/common/telemetryService.ts +++ b/src/vs/platform/telemetry/common/telemetryService.ts @@ -21,7 +21,6 @@ export interface ITelemetryServiceConfig { appender: ITelemetryAppender; commonProperties?: TPromise<{ [name: string]: any }>; piiPaths?: string[]; - userOptIn?: boolean; } export class TelemetryService implements ITelemetryService { @@ -46,7 +45,7 @@ export class TelemetryService implements ITelemetryService { this._appender = config.appender; this._commonProperties = config.commonProperties || TPromise.as({}); this._piiPaths = config.piiPaths || []; - this._userOptIn = typeof config.userOptIn === 'undefined' ? true : config.userOptIn; + this._userOptIn = true; // static cleanup pattern for: `file:///DANGEROUS/PATH/resources/app/Useful/Information` this._cleanupPatterns = [/file:\/\/\/.*?\/resources\/app\//gi]; diff --git a/src/vs/platform/telemetry/test/electron-browser/telemetryService.test.ts b/src/vs/platform/telemetry/test/electron-browser/telemetryService.test.ts index 83ff1f5b7a8..8cd91f0803b 100644 --- a/src/vs/platform/telemetry/test/electron-browser/telemetryService.test.ts +++ b/src/vs/platform/telemetry/test/electron-browser/telemetryService.test.ts @@ -14,8 +14,6 @@ import * as Errors from 'vs/base/common/errors'; import * as sinon from 'sinon'; import { getConfigurationValue } from 'vs/platform/configuration/common/configuration'; -const optInStatusEventName: string = 'optInStatus'; - class TestTelemetryAppender implements ITelemetryAppender { public events: any[]; @@ -719,29 +717,9 @@ suite('TelemetryService', () => { } })); - test('Telemetry Service respects user opt-in settings', sinon.test(function () { + test('Telemetry Service sends events when enableTelemetry is on', sinon.test(function () { let testAppender = new TestTelemetryAppender(); - let service = new TelemetryService({ userOptIn: false, appender: testAppender }, undefined); - - return service.publicLog('testEvent').then(() => { - assert.equal(testAppender.getEventsCount(), 0); - service.dispose(); - }); - })); - - test('Telemetry Service does not sent optInStatus when user opted out', sinon.test(function () { - let testAppender = new TestTelemetryAppender(); - let service = new TelemetryService({ userOptIn: false, appender: testAppender }, undefined); - - return service.publicLog(optInStatusEventName, { optIn: false }).then(() => { - assert.equal(testAppender.getEventsCount(), 0); - service.dispose(); - }); - })); - - test('Telemetry Service sends events when enableTelemetry is on even user optin is on', sinon.test(function () { - let testAppender = new TestTelemetryAppender(); - let service = new TelemetryService({ userOptIn: true, appender: testAppender }, undefined); + let service = new TelemetryService({ appender: testAppender }, undefined); return service.publicLog('testEvent').then(() => { assert.equal(testAppender.getEventsCount(), 1); diff --git a/src/vs/platform/widget/browser/contextScopedHistoryWidget.ts b/src/vs/platform/widget/browser/contextScopedHistoryWidget.ts index c98eea4b962..013485d5e42 100644 --- a/src/vs/platform/widget/browser/contextScopedHistoryWidget.ts +++ b/src/vs/platform/widget/browser/contextScopedHistoryWidget.ts @@ -10,7 +10,7 @@ import { FindInput, IFindInputOptions } from 'vs/base/browser/ui/findinput/findI import { IContextViewProvider } from 'vs/base/browser/ui/contextview/contextview'; import { IContextScopedWidget, getContextScopedWidget, createWidgetScopedContextKeyService, bindContextScopedWidget } from 'vs/platform/widget/common/contextScopedWidget'; import { IHistoryNavigationWidget } from 'vs/base/browser/history'; -import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry'; +import { KeybindingsRegistry, KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; import { KeyCode, KeyMod } from 'vs/base/common/keyCodes'; export const HistoryNavigationWidgetContext = 'historyNavigationWidget'; @@ -53,7 +53,7 @@ export class ContextScopedFindInput extends FindInput { KeybindingsRegistry.registerCommandAndKeybindingRule({ id: 'history.showPrevious', - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: ContextKeyExpr.and(new ContextKeyDefinedExpr(HistoryNavigationWidgetContext), new ContextKeyEqualsExpr(HistoryNavigationEnablementContext, true)), primary: KeyCode.UpArrow, secondary: [KeyMod.Alt | KeyCode.UpArrow], @@ -65,7 +65,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({ KeybindingsRegistry.registerCommandAndKeybindingRule({ id: 'history.showNext', - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: new ContextKeyAndExpr([new ContextKeyDefinedExpr(HistoryNavigationWidgetContext), new ContextKeyEqualsExpr(HistoryNavigationEnablementContext, true)]), primary: KeyCode.DownArrow, secondary: [KeyMod.Alt | KeyCode.DownArrow], diff --git a/src/vs/platform/workspace/common/workspace.ts b/src/vs/platform/workspace/common/workspace.ts index 39a413b09e4..4d2a8cc88d5 100644 --- a/src/vs/platform/workspace/common/workspace.ts +++ b/src/vs/platform/workspace/common/workspace.ts @@ -77,6 +77,15 @@ export interface IWorkspaceContextService { isInsideWorkspace(resource: URI): boolean; } +export namespace IWorkspace { + export function isIWorkspace(thing: any): thing is IWorkspace { + return thing && typeof thing === 'object' + && typeof (thing as IWorkspace).id === 'string' + && typeof (thing as IWorkspace).name === 'string' + && Array.isArray((thing as IWorkspace).folders); + } +} + export interface IWorkspace { /** @@ -118,6 +127,15 @@ export interface IWorkspaceFolderData { readonly index: number; } +export namespace IWorkspaceFolder { + export function isIWorkspaceFolder(thing: any): thing is IWorkspaceFolder { + return thing && typeof thing === 'object' + && URI.isUri((thing as IWorkspaceFolder).uri) + && typeof (thing as IWorkspaceFolder).name === 'string' + && typeof (thing as IWorkspaceFolder).toResource === 'function'; + } +} + export interface IWorkspaceFolder extends IWorkspaceFolderData { /** diff --git a/src/vs/vscode.d.ts b/src/vs/vscode.d.ts index 607f418e181..ac726df3447 100644 --- a/src/vs/vscode.d.ts +++ b/src/vs/vscode.d.ts @@ -5500,6 +5500,11 @@ declare module 'vscode' { */ title: string; + /** + * Icon for the panel shown in UI. + */ + iconPath?: Uri | { light: Uri; dark: Uri }; + /** * Webview belonging to the panel. */ diff --git a/src/vs/workbench/api/electron-browser/mainThreadSearch.ts b/src/vs/workbench/api/electron-browser/mainThreadSearch.ts index 7e3224c1de2..caffd57767b 100644 --- a/src/vs/workbench/api/electron-browser/mainThreadSearch.ts +++ b/src/vs/workbench/api/electron-browser/mainThreadSearch.ts @@ -5,14 +5,14 @@ 'use strict'; import { isFalsyOrEmpty } from 'vs/base/common/arrays'; -import { IDisposable, dispose } from 'vs/base/common/lifecycle'; +import { dispose, IDisposable } from 'vs/base/common/lifecycle'; import { values } from 'vs/base/common/map'; import URI, { UriComponents } from 'vs/base/common/uri'; -import { PPromise, TPromise } from 'vs/base/common/winjs.base'; -import { IFileMatch, ISearchComplete, ISearchProgressItem, ISearchQuery, ISearchResultProvider, ISearchService, QueryType, IRawFileMatch2, ISearchCompleteStats } from 'vs/platform/search/common/search'; +import { TPromise } from 'vs/base/common/winjs.base'; +import { IFileMatch, IRawFileMatch2, ISearchComplete, ISearchCompleteStats, ISearchProgressItem, ISearchQuery, ISearchResultProvider, ISearchService, QueryType } from 'vs/platform/search/common/search'; +import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { extHostNamedCustomer } from 'vs/workbench/api/electron-browser/extHostCustomers'; import { ExtHostContext, ExtHostSearchShape, IExtHostContext, MainContext, MainThreadSearchShape } from '../node/extHost.protocol'; -import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; @extHostNamedCustomer(MainContext.MainThreadSearch) export class MainThreadSearch implements MainThreadSearchShape { @@ -97,10 +97,10 @@ class RemoteSearchProvider implements ISearchResultProvider, IDisposable { dispose(this._registrations); } - search(query: ISearchQuery): PPromise { + search(query: ISearchQuery, onProgress?: (p: ISearchProgressItem) => void): TPromise { if (isFalsyOrEmpty(query.folderQueries)) { - return PPromise.as(undefined); + return TPromise.as(undefined); } const folderQueriesForScheme = query.folderQueries.filter(fq => fq.folder.scheme === this._scheme); @@ -115,9 +115,9 @@ class RemoteSearchProvider implements ISearchResultProvider, IDisposable { let outer: TPromise; - return new PPromise((resolve, reject, report) => { + return new TPromise((resolve, reject) => { - const search = new SearchOperation(report); + const search = new SearchOperation(onProgress); this._searches.set(search.id, search); outer = query.type === QueryType.File diff --git a/src/vs/workbench/api/electron-browser/mainThreadTerminalService.ts b/src/vs/workbench/api/electron-browser/mainThreadTerminalService.ts index ccf129ce117..c25e31ae085 100644 --- a/src/vs/workbench/api/electron-browser/mainThreadTerminalService.ts +++ b/src/vs/workbench/api/electron-browser/mainThreadTerminalService.ts @@ -16,6 +16,8 @@ export class MainThreadTerminalService implements MainThreadTerminalServiceShape private _proxy: ExtHostTerminalServiceShape; private _toDispose: IDisposable[] = []; private _terminalProcesses: { [id: number]: ITerminalProcessExtHostProxy } = {}; + private _terminalOnDidWriteDataListeners: { [id: number]: IDisposable } = {}; + private _terminalOnDidAcceptInputListeners: { [id: number]: IDisposable } = {}; constructor( extHostContext: IExtHostContext, @@ -114,9 +116,18 @@ export class MainThreadTerminalService implements MainThreadTerminalServiceShape public $terminalRendererRegisterOnInputListener(terminalId: number): void { const terminalInstance = this.terminalService.getInstanceFromId(terminalId); - if (terminalInstance) { - terminalInstance.addDisposable(terminalInstance.onRendererInput(data => this._onTerminalRendererInput(terminalId, data))); + if (!terminalInstance) { + return; } + + // Listener already registered + if (this._terminalOnDidAcceptInputListeners.hasOwnProperty(terminalId)) { + return; + } + + // Register + this._terminalOnDidAcceptInputListeners[terminalId] = terminalInstance.onRendererInput(data => this._onTerminalRendererInput(terminalId, data)); + terminalInstance.addDisposable(this._terminalOnDidAcceptInputListeners[terminalId]); } public $sendText(terminalId: number, text: string, addNewLine: boolean): void { @@ -128,11 +139,20 @@ export class MainThreadTerminalService implements MainThreadTerminalServiceShape public $registerOnDataListener(terminalId: number): void { const terminalInstance = this.terminalService.getInstanceFromId(terminalId); - if (terminalInstance) { - terminalInstance.addDisposable(terminalInstance.onData(data => { - this._onTerminalData(terminalId, data); - })); + if (!terminalInstance) { + return; } + + // Listener already registered + if (this._terminalOnDidWriteDataListeners[terminalId]) { + return; + } + + // Register + this._terminalOnDidWriteDataListeners[terminalId] = terminalInstance.onData(data => { + this._onTerminalData(terminalId, data); + }); + terminalInstance.addDisposable(this._terminalOnDidWriteDataListeners[terminalId]); } private _onActiveTerminalChanged(terminalId: number | undefined): void { diff --git a/src/vs/workbench/api/electron-browser/mainThreadWebview.ts b/src/vs/workbench/api/electron-browser/mainThreadWebview.ts index 8def9ec323a..9e36bedbf59 100644 --- a/src/vs/workbench/api/electron-browser/mainThreadWebview.ts +++ b/src/vs/workbench/api/electron-browser/mainThreadWebview.ts @@ -2,23 +2,24 @@ * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { IDisposable, dispose } from 'vs/base/common/lifecycle'; +import * as dom from 'vs/base/browser/dom'; +import { dispose, IDisposable } from 'vs/base/common/lifecycle'; import * as map from 'vs/base/common/map'; import URI, { UriComponents } from 'vs/base/common/uri'; import { TPromise } from 'vs/base/common/winjs.base'; import { localize } from 'vs/nls'; -import { EditorViewColumn, viewColumnToEditorGroup, editorGroupToViewColumn } from 'vs/workbench/api/shared/editor'; import { ILifecycleService } from 'vs/platform/lifecycle/common/lifecycle'; import { IOpenerService } from 'vs/platform/opener/common/opener'; import { ExtHostContext, ExtHostWebviewsShape, IExtHostContext, MainContext, MainThreadWebviewsShape, WebviewPanelHandle } from 'vs/workbench/api/node/extHost.protocol'; +import { editorGroupToViewColumn, EditorViewColumn, viewColumnToEditorGroup } from 'vs/workbench/api/shared/editor'; import { WebviewEditor } from 'vs/workbench/parts/webview/electron-browser/webviewEditor'; import { WebviewEditorInput } from 'vs/workbench/parts/webview/electron-browser/webviewEditorInput'; -import { IWebviewEditorService, WebviewInputOptions, WebviewReviver, ICreateWebViewShowOptions } from 'vs/workbench/parts/webview/electron-browser/webviewEditorService'; +import { ICreateWebViewShowOptions, IWebviewEditorService, WebviewInputOptions, WebviewReviver } from 'vs/workbench/parts/webview/electron-browser/webviewEditorService'; import { IEditorService } from 'vs/workbench/services/editor/common/editorService'; import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions'; import { IEditorGroupsService } from 'vs/workbench/services/group/common/editorGroupsService'; -import { extHostNamedCustomer } from './extHostCustomers'; import * as vscode from 'vscode'; +import { extHostNamedCustomer } from './extHostCustomers'; @extHostNamedCustomer(MainContext.MainThreadWebviews) export class MainThreadWebviews implements MainThreadWebviewsShape, WebviewReviver { @@ -29,6 +30,39 @@ export class MainThreadWebviews implements MainThreadWebviewsShape, WebviewReviv private static revivalPool = 0; + private static _styleElement?: HTMLStyleElement; + + private static _icons = new Map(); + + private static updateStyleElement( + webview: WebviewEditorInput, + iconPath: { light: URI, dark: URI } | undefined + ) { + const id = webview.getId(); + if (!this._styleElement) { + this._styleElement = dom.createStyleSheet(); + this._styleElement.className = 'webview-icons'; + } + + if (!iconPath) { + this._icons.delete(id); + } else { + this._icons.set(id, iconPath); + } + + const cssRules: string[] = []; + this._icons.forEach((value, key) => { + const webviewSelector = `.show-file-icons .webview-${key}-name-file-icon::before`; + if (URI.isUri(value)) { + cssRules.push(`${webviewSelector} { content: ""; background-image: url(${value.toString()}); }`); + } else { + cssRules.push(`${webviewSelector} { content: ""; background-image: url(${value.light.toString()}); }`); + cssRules.push(`.vs-dark ${webviewSelector} { content: ""; background-image: url(${value.dark.toString()}); }`); + } + }); + this._styleElement.innerHTML = cssRules.join('\n'); + } + private _toDispose: IDisposable[] = []; private readonly _proxy: ExtHostWebviewsShape; @@ -96,6 +130,11 @@ export class MainThreadWebviews implements MainThreadWebviewsShape, WebviewReviv webview.setName(value); } + public $setIconPath(handle: WebviewPanelHandle, value: { light: UriComponents, dark: UriComponents } | undefined): void { + const webview = this.getWebview(handle); + MainThreadWebviews.updateStyleElement(webview, reviveWebviewIcon(value)); + } + public $setHtml(handle: WebviewPanelHandle, value: string): void { const webview = this.getWebview(handle); webview.html = value; @@ -185,9 +224,16 @@ export class MainThreadWebviews implements MainThreadWebviewsShape, WebviewReviv onDidClickLink: uri => this.onDidClickLink(handle, uri), onMessage: message => this._proxy.$onMessage(handle, message), onDispose: () => { + const cleanUp = () => { + const webview = this._webviews.get(handle); + if (webview) { + MainThreadWebviews.updateStyleElement(webview, undefined); + } + this._webviews.delete(handle); + }; this._proxy.$onDidDisposeWebviewPanel(handle).then( - () => this._webviews.delete(handle), - () => this._webviews.delete(handle)); + cleanUp, + cleanUp); } }; } @@ -297,3 +343,16 @@ function reviveWebviewOptions(options: WebviewInputOptions): WebviewInputOptions localResourceRoots: Array.isArray(options.localResourceRoots) ? options.localResourceRoots.map(URI.revive) : undefined }; } + +function reviveWebviewIcon( + value: { light: UriComponents, dark: UriComponents } | undefined +): { light: URI, dark: URI } | undefined { + if (!value) { + return undefined; + } + + return { + light: URI.revive(value.light), + dark: URI.revive(value.dark) + }; +} \ No newline at end of file diff --git a/src/vs/workbench/api/node/extHost.api.impl.ts b/src/vs/workbench/api/node/extHost.api.impl.ts index ed91294b6c5..4ca5751ecef 100644 --- a/src/vs/workbench/api/node/extHost.api.impl.ts +++ b/src/vs/workbench/api/node/extHost.api.impl.ts @@ -110,7 +110,7 @@ export function createApiFactory( const extHostDocumentSaveParticipant = rpcProtocol.set(ExtHostContext.ExtHostDocumentSaveParticipant, new ExtHostDocumentSaveParticipant(extHostLogService, extHostDocuments, rpcProtocol.getProxy(MainContext.MainThreadTextEditors))); const extHostEditors = rpcProtocol.set(ExtHostContext.ExtHostEditors, new ExtHostEditors(rpcProtocol, extHostDocumentsAndEditors)); const extHostCommands = rpcProtocol.set(ExtHostContext.ExtHostCommands, new ExtHostCommands(rpcProtocol, extHostHeapService, extHostLogService)); - const extHostTreeViews = rpcProtocol.set(ExtHostContext.ExtHostTreeViews, new ExtHostTreeViews(rpcProtocol.getProxy(MainContext.MainThreadTreeViews), extHostCommands)); + const extHostTreeViews = rpcProtocol.set(ExtHostContext.ExtHostTreeViews, new ExtHostTreeViews(rpcProtocol.getProxy(MainContext.MainThreadTreeViews), extHostCommands, extHostLogService)); rpcProtocol.set(ExtHostContext.ExtHostWorkspace, extHostWorkspace); rpcProtocol.set(ExtHostContext.ExtHostConfiguration, extHostConfiguration); const extHostDiagnostics = rpcProtocol.set(ExtHostContext.ExtHostDiagnostics, new ExtHostDiagnostics(rpcProtocol)); diff --git a/src/vs/workbench/api/node/extHost.protocol.ts b/src/vs/workbench/api/node/extHost.protocol.ts index 44947586fd5..dcccdfd0bf9 100644 --- a/src/vs/workbench/api/node/extHost.protocol.ts +++ b/src/vs/workbench/api/node/extHost.protocol.ts @@ -430,6 +430,7 @@ export interface MainThreadWebviewsShape extends IDisposable { $disposeWebview(handle: WebviewPanelHandle): void; $reveal(handle: WebviewPanelHandle, viewColumn: EditorViewColumn | null, preserveFocus: boolean): void; $setTitle(handle: WebviewPanelHandle, value: string): void; + $setIconPath(handle: WebviewPanelHandle, value: { light: UriComponents, dark: UriComponents } | undefined): void; $setHtml(handle: WebviewPanelHandle, value: string): void; $setOptions(handle: WebviewPanelHandle, options: vscode.WebviewOptions): void; $postMessage(handle: WebviewPanelHandle, value: any): Thenable; diff --git a/src/vs/workbench/api/node/extHostSearch.ts b/src/vs/workbench/api/node/extHostSearch.ts index 35f121e588c..e7bcb39550d 100644 --- a/src/vs/workbench/api/node/extHostSearch.ts +++ b/src/vs/workbench/api/node/extHostSearch.ts @@ -10,7 +10,7 @@ import { toErrorMessage } from 'vs/base/common/errorMessage'; import * as glob from 'vs/base/common/glob'; import * as resources from 'vs/base/common/resources'; import URI, { UriComponents } from 'vs/base/common/uri'; -import { PPromise, TPromise } from 'vs/base/common/winjs.base'; +import { TPromise } from 'vs/base/common/winjs.base'; import * as extfs from 'vs/base/node/extfs'; import { IFileMatch, IFolderQuery, IPatternInfo, IRawSearchQuery, ISearchCompleteStats, ISearchQuery } from 'vs/platform/search/common/search'; import * as vscode from 'vscode'; @@ -58,12 +58,9 @@ export class ExtHostSearch implements ExtHostSearchShape { } const query = reviveQuery(rawQuery); - return this._fileSearchManager.fileSearch(query, provider).then( - null, - null, - progress => { - this._proxy.$handleFileMatch(handle, session, progress.map(p => p.resource)); - }); + return this._fileSearchManager.fileSearch(query, provider, progress => { + this._proxy.$handleFileMatch(handle, session, progress.map(p => p.resource)); + }); } $clearCache(handle: number, cacheKey: string): TPromise { @@ -84,12 +81,7 @@ export class ExtHostSearch implements ExtHostSearchShape { const query = reviveQuery(rawQuery); const engine = new TextSearchEngine(pattern, query, provider, this._extfs); - return engine.search().then( - null, - null, - progress => { - this._proxy.$handleTextMatch(handle, session, progress); - }); + return engine.search(progress => this._proxy.$handleTextMatch(handle, session, progress)); } } @@ -380,11 +372,11 @@ class TextSearchEngine { this.activeCancellationTokens = new Set(); } - public search(): PPromise<{ limitHit: boolean }, IFileMatch[]> { + public search(onProgress: (matches: IFileMatch[]) => void): TPromise<{ limitHit: boolean }> { const folderQueries = this.config.folderQueries; - return new PPromise<{ limitHit: boolean }, IFileMatch[]>((resolve, reject, _onResult) => { - this.collector = new TextSearchResultsCollector(_onResult); + return new TPromise<{ limitHit: boolean }>((resolve, reject) => { + this.collector = new TextSearchResultsCollector(onProgress); const onResult = (match: vscode.TextSearchResult, folderIdx: number) => { if (this.isCanceled) { @@ -403,8 +395,8 @@ class TextSearchEngine { }; // For each root folder - PPromise.join(folderQueries.map((fq, i) => { - return this.searchInFolder(fq).then(null, null, r => onResult(r, i)); + TPromise.join(folderQueries.map((fq, i) => { + return this.searchInFolder(fq, r => onResult(r, i)); })).then(() => { this.collector.flush(); resolve({ limitHit: this.isLimitHit }); @@ -418,9 +410,9 @@ class TextSearchEngine { }); } - private searchInFolder(folderQuery: IFolderQuery): PPromise { + private searchInFolder(folderQuery: IFolderQuery, onResult: (result: vscode.TextSearchResult) => void): TPromise { let cancellation = new CancellationTokenSource(); - return new PPromise((resolve, reject, onResult) => { + return new TPromise((resolve, reject) => { const queryTester = new QueryGlobTester(this.config, folderQuery); const testingPs = []; @@ -532,10 +524,10 @@ class FileSearchEngine { this.activeCancellationTokens = new Set(); } - public search(): PPromise { + public search(_onResult: (match: IInternalFileMatch) => void): TPromise { const folderQueries = this.config.folderQueries; - return new PPromise((resolve, reject, _onResult) => { + return new TPromise((resolve, reject) => { const onResult = (match: IInternalFileMatch) => { this.resultCount++; _onResult(match); @@ -562,8 +554,8 @@ class FileSearchEngine { } // For each root folder - PPromise.join(folderQueries.map(fq => { - return this.searchInFolder(fq).then(null, null, onResult); + TPromise.join(folderQueries.map(fq => { + return this.searchInFolder(fq, onResult); })).then(cacheKeys => { resolve({ limitHit: this.isLimitHit, cacheKeys }); }, (errs: Error[]) => { @@ -576,9 +568,9 @@ class FileSearchEngine { }); } - private searchInFolder(fq: IFolderQuery): PPromise { + private searchInFolder(fq: IFolderQuery, onResult: (match: IInternalFileMatch) => void): TPromise { let cancellation = new CancellationTokenSource(); - return new PPromise((resolve, reject, onResult) => { + return new TPromise((resolve, reject) => { const options = this.getSearchOptionsForFolder(fq); const tree = this.initDirectoryTree(); @@ -748,12 +740,16 @@ class FileSearchManager { private readonly expandedCacheKeys = new Map(); - fileSearch(config: ISearchQuery, provider: vscode.SearchProvider): PPromise { - let searchP: PPromise; - return new PPromise((c, e, p) => { + fileSearch(config: ISearchQuery, provider: vscode.SearchProvider, onResult: (matches: IFileMatch[]) => void): TPromise { + let searchP: TPromise; + return new TPromise((c, e) => { const engine = new FileSearchEngine(config, provider); - searchP = this.doSearch(engine, FileSearchManager.BATCH_SIZE).then( + const onInternalResult = (progress: IInternalFileMatch[]) => { + onResult(progress.map(m => this.rawMatchToSearchItem(m))); + }; + + searchP = this.doSearch(engine, FileSearchManager.BATCH_SIZE, onInternalResult).then( result => { if (config.cacheKey) { this.expandedCacheKeys.set(config.cacheKey, result.cacheKeys); @@ -763,10 +759,7 @@ class FileSearchManager { limitHit: result.limitHit }); }, - e, - progress => { - p(progress.map(m => this.rawMatchToSearchItem(m))); - }); + e); }, () => { if (searchP) { searchP.cancel(); @@ -789,29 +782,31 @@ class FileSearchManager { }; } - private doSearch(engine: FileSearchEngine, batchSize: number): PPromise { - return new PPromise((c, e, p) => { + private doSearch(engine: FileSearchEngine, batchSize: number, onResultBatch: (matches: IInternalFileMatch[]) => void): TPromise { + return new TPromise((c, e) => { + const _onResult = match => { + if (match) { + batch.push(match); + if (batchSize > 0 && batch.length >= batchSize) { + onResultBatch(batch); + batch = []; + } + } + }; + let batch: IInternalFileMatch[] = []; - engine.search().then(result => { + engine.search(_onResult).then(result => { if (batch.length) { - p(batch); + onResultBatch(batch); } c(result); }, error => { if (batch.length) { - p(batch); + onResultBatch(batch); } e(error); - }, match => { - if (match) { - batch.push(match); - if (batchSize > 0 && batch.length >= batchSize) { - p(batch); - batch = []; - } - } }); }, () => { engine.cancel(); diff --git a/src/vs/workbench/api/node/extHostTreeViews.ts b/src/vs/workbench/api/node/extHostTreeViews.ts index a63e56f9972..811fc4b464b 100644 --- a/src/vs/workbench/api/node/extHostTreeViews.ts +++ b/src/vs/workbench/api/node/extHostTreeViews.ts @@ -18,6 +18,7 @@ import { asWinJsPromise } from 'vs/base/common/async'; import { TreeItemCollapsibleState, ThemeIcon } from 'vs/workbench/api/node/extHostTypes'; import { isUndefinedOrNull } from 'vs/base/common/types'; import { equals } from 'vs/base/common/arrays'; +import { ILogService } from 'vs/platform/log/common/log'; type TreeItemHandle = string; @@ -27,7 +28,8 @@ export class ExtHostTreeViews implements ExtHostTreeViewsShape { constructor( private _proxy: MainThreadTreeViewsShape, - private commands: ExtHostCommands + private commands: ExtHostCommands, + private logService: ILogService ) { commands.registerArgumentProcessor({ processArgument: arg => { @@ -99,7 +101,7 @@ export class ExtHostTreeViews implements ExtHostTreeViewsShape { } private createExtHostTreeViewer(id: string, dataProvider: vscode.TreeDataProvider): ExtHostTreeView { - const treeView = new ExtHostTreeView(id, dataProvider, this._proxy, this.commands.converter); + const treeView = new ExtHostTreeView(id, dataProvider, this._proxy, this.commands.converter, this.logService); this.treeViews.set(id, treeView); return treeView; } @@ -145,7 +147,7 @@ class ExtHostTreeView extends Disposable { private refreshPromise: TPromise = TPromise.as(null); - constructor(private viewId: string, private dataProvider: vscode.TreeDataProvider, private proxy: MainThreadTreeViewsShape, private commands: CommandsConverter) { + constructor(private viewId: string, private dataProvider: vscode.TreeDataProvider, private proxy: MainThreadTreeViewsShape, private commands: CommandsConverter, private logService: ILogService) { super(); this.proxy.$registerTreeViewDataProvider(viewId); if (this.dataProvider.onDidChangeTreeData) { @@ -192,7 +194,7 @@ class ExtHostTreeView extends Disposable { return this.refreshPromise .then(() => this.resolveUnknownParentChain(element)) .then(parentChain => this.resolveTreeNode(element, parentChain[parentChain.length - 1]) - .then(treeNode => this.proxy.$reveal(this.viewId, treeNode.item, parentChain.map(p => p.item), { select, focus }))); + .then(treeNode => this.proxy.$reveal(this.viewId, treeNode.item, parentChain.map(p => p.item), { select, focus })), error => this.logService.error(error)); } setExpanded(treeItemHandle: TreeItemHandle, expanded: boolean): void { diff --git a/src/vs/workbench/api/node/extHostWebview.ts b/src/vs/workbench/api/node/extHostWebview.ts index 0ad6b97fa30..78fb98240ea 100644 --- a/src/vs/workbench/api/node/extHostWebview.ts +++ b/src/vs/workbench/api/node/extHostWebview.ts @@ -3,14 +3,17 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { MainContext, MainThreadWebviewsShape, IMainContext, ExtHostWebviewsShape, WebviewPanelHandle, WebviewPanelViewState } from './extHost.protocol'; -import * as vscode from 'vscode'; -import { Event, Emitter } from 'vs/base/common/event'; +import { Emitter, Event } from 'vs/base/common/event'; +import URI from 'vs/base/common/uri'; +import { TPromise } from 'vs/base/common/winjs.base'; import * as typeConverters from 'vs/workbench/api/node/extHostTypeConverters'; import { EditorViewColumn } from 'vs/workbench/api/shared/editor'; -import { TPromise } from 'vs/base/common/winjs.base'; +import * as vscode from 'vscode'; +import { ExtHostWebviewsShape, IMainContext, MainContext, MainThreadWebviewsShape, WebviewPanelHandle, WebviewPanelViewState } from './extHost.protocol'; import { Disposable } from './extHostTypes'; -import URI from 'vs/base/common/uri'; + + +type IconPath = URI | { light: URI, dark: URI }; export class ExtHostWebview implements vscode.Webview { private readonly _handle: WebviewPanelHandle; @@ -78,6 +81,7 @@ export class ExtHostWebviewPanel implements vscode.WebviewPanel { private readonly _proxy: MainThreadWebviewsShape; private readonly _viewType: string; private _title: string; + private _iconPath: IconPath; private readonly _options: vscode.WebviewPanelOptions; private readonly _webview: ExtHostWebview; @@ -150,6 +154,20 @@ export class ExtHostWebviewPanel implements vscode.WebviewPanel { } } + get iconPath(): IconPath | undefined { + this.assertNotDisposed(); + return this._iconPath; + } + + set iconPath(value: IconPath | undefined) { + this.assertNotDisposed(); + if (this._iconPath !== value) { + this._iconPath = value; + + this._proxy.$setIconPath(this._handle, URI.isUri(value) ? { light: value, dark: value } : value); + } + } + get options() { return this._options; } diff --git a/src/vs/workbench/browser/labels.ts b/src/vs/workbench/browser/labels.ts index 35768b3f5fa..2de5aa211ec 100644 --- a/src/vs/workbench/browser/labels.ts +++ b/src/vs/workbench/browser/labels.ts @@ -183,6 +183,7 @@ export class ResourceLabel extends IconLabel { title: '', italic: this.options && this.options.italic, matches: this.options && this.options.matches, + extraClasses: [] }; const resource = this.label.resource; diff --git a/src/vs/workbench/browser/parts/editor/breadcrumbs.ts b/src/vs/workbench/browser/parts/editor/breadcrumbs.ts index ac7b2f27130..83f309f828b 100644 --- a/src/vs/workbench/browser/parts/editor/breadcrumbs.ts +++ b/src/vs/workbench/browser/parts/editor/breadcrumbs.ts @@ -136,7 +136,7 @@ Registry.as(Extensions.Configuration).registerConfigurat default: 'on', enum: ['on', 'off', 'last'], enumDescriptions: [ - localize('symbolpath.on', "Show all symbols the breadcrumbs view."), + localize('symbolpath.on', "Show all symbols in the breadcrumbs view."), localize('symbolpath.off', "Do not show symbols in the breadcrumbs view."), localize('symbolpath.last', "Only show the current symbol in the breadcrumbs view."), ] diff --git a/src/vs/workbench/browser/parts/editor/breadcrumbsControl.ts b/src/vs/workbench/browser/parts/editor/breadcrumbsControl.ts index c8a2110bfd2..14ab5ecc5b8 100644 --- a/src/vs/workbench/browser/parts/editor/breadcrumbsControl.ts +++ b/src/vs/workbench/browser/parts/editor/breadcrumbsControl.ts @@ -23,7 +23,7 @@ import { ContextKeyExpr, IContextKey, IContextKeyService, RawContextKey } from ' import { IContextViewService } from 'vs/platform/contextview/browser/contextView'; import { FileKind, IFileService } from 'vs/platform/files/common/files'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; -import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry'; +import { KeybindingsRegistry, KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; import { IQuickOpenService } from 'vs/platform/quickOpen/common/quickOpen'; import { attachBreadcrumbsStyler } from 'vs/platform/theme/common/styler'; import { IThemeService } from 'vs/platform/theme/common/themeService'; @@ -76,12 +76,12 @@ class Item extends BreadcrumbsItem { let label = this._instantiationService.createInstance(FileLabel, container, {}); label.setFile(this.element.uri, { hidePath: true, - fileKind: this.element.isFile ? FileKind.FILE : FileKind.FOLDER, - hideIcon: !this.element.isFile || !this.options.showFileIcons, - fileDecorations: { colors: this.options.showDecorationColors, badges: false } + hideIcon: this.element.kind === FileKind.FOLDER || !this.options.showFileIcons, + fileKind: this.element.kind, + fileDecorations: { colors: this.options.showDecorationColors, badges: false }, }); + dom.addClass(container, FileKind[this.element.kind].toLowerCase()); this._disposables.push(label); - dom.toggleClass(container, 'file', this.element.isFile); } else if (this.element instanceof OutlineModel) { // has outline element but not in one @@ -105,7 +105,7 @@ class Item extends BreadcrumbsItem { } let label = new IconLabel(container); let title = this.element.symbol.name.replace(/\r|\n|\r\n/g, '\u23CE'); - label.setValue(title, undefined, { title }); + label.setValue(title); this._disposables.push(label); } } @@ -323,7 +323,7 @@ export class BreadcrumbsControl { private _revealInEditor(event: IBreadcrumbsItemEvent, data: any): void { if (data instanceof FileElement) { - if (data.isFile) { + if (data.kind === FileKind.FILE) { // open file in editor this._editorService.openEditor({ resource: data.uri }); } else { @@ -373,7 +373,7 @@ CommandsRegistry.registerCommand('breadcrumbs.toggle', accessor => { KeybindingsRegistry.registerCommandAndKeybindingRule({ id: 'breadcrumbs.focus', - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.US_DOT, when: BreadcrumbsControl.CK_BreadcrumbsVisible, handler(accessor) { @@ -385,7 +385,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({ }); KeybindingsRegistry.registerCommandAndKeybindingRule({ id: 'breadcrumbs.focusNext', - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, primary: KeyCode.RightArrow, secondary: [KeyMod.Shift | KeyCode.RightArrow], when: ContextKeyExpr.and(BreadcrumbsControl.CK_BreadcrumbsVisible, BreadcrumbsControl.CK_BreadcrumbsActive), @@ -397,7 +397,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({ }); KeybindingsRegistry.registerCommandAndKeybindingRule({ id: 'breadcrumbs.focusPrevious', - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, primary: KeyCode.LeftArrow, secondary: [KeyMod.Shift | KeyCode.LeftArrow], when: ContextKeyExpr.and(BreadcrumbsControl.CK_BreadcrumbsVisible, BreadcrumbsControl.CK_BreadcrumbsActive), @@ -409,7 +409,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({ }); KeybindingsRegistry.registerCommandAndKeybindingRule({ id: 'breadcrumbs.selectFocused', - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, primary: KeyCode.Enter, secondary: [KeyCode.DownArrow], when: ContextKeyExpr.and(BreadcrumbsControl.CK_BreadcrumbsVisible, BreadcrumbsControl.CK_BreadcrumbsActive), @@ -422,7 +422,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({ }); KeybindingsRegistry.registerCommandAndKeybindingRule({ id: 'breadcrumbs.revealFocused', - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, primary: KeyMod.Shift | KeyCode.Enter, secondary: [KeyCode.Space], when: ContextKeyExpr.and(BreadcrumbsControl.CK_BreadcrumbsVisible, BreadcrumbsControl.CK_BreadcrumbsActive), @@ -435,7 +435,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({ }); KeybindingsRegistry.registerCommandAndKeybindingRule({ id: 'breadcrumbs.selectEditor', - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, primary: KeyCode.Escape, secondary: [KeyMod.Shift | KeyCode.Escape], when: ContextKeyExpr.and(BreadcrumbsControl.CK_BreadcrumbsVisible, BreadcrumbsControl.CK_BreadcrumbsActive), @@ -449,7 +449,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({ }); KeybindingsRegistry.registerCommandAndKeybindingRule({ id: 'breadcrumbs.pickFromTree', - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, primary: KeyCode.Tab, when: ContextKeyExpr.and(BreadcrumbsControl.CK_BreadcrumbsVisible, BreadcrumbsControl.CK_BreadcrumbsActive, WorkbenchListFocusContextKey), handler(accessor) { diff --git a/src/vs/workbench/browser/parts/editor/breadcrumbsModel.ts b/src/vs/workbench/browser/parts/editor/breadcrumbsModel.ts index f29efc47db1..40d9babb573 100644 --- a/src/vs/workbench/browser/parts/editor/breadcrumbsModel.ts +++ b/src/vs/workbench/browser/parts/editor/breadcrumbsModel.ts @@ -18,22 +18,23 @@ import URI from 'vs/base/common/uri'; import { ICodeEditor } from 'vs/editor/browser/editorBrowser'; import { IPosition } from 'vs/editor/common/core/position'; import { DocumentSymbolProviderRegistry } from 'vs/editor/common/modes'; -import { OutlineElement, OutlineGroup, OutlineModel } from 'vs/editor/contrib/documentSymbols/outlineModel'; +import { OutlineElement, OutlineGroup, OutlineModel, TreeElement } from 'vs/editor/contrib/documentSymbols/outlineModel'; import { IWorkspaceContextService, IWorkspaceFolder, WorkbenchState } from 'vs/platform/workspace/common/workspace'; import { Schemas } from 'vs/base/common/network'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { BreadcrumbsConfig } from 'vs/workbench/browser/parts/editor/breadcrumbs'; +import { FileKind } from 'vs/platform/files/common/files'; export class FileElement { constructor( readonly uri: URI, - readonly isFile: boolean + readonly kind: FileKind ) { } } export type BreadcrumbElement = FileElement | OutlineModel | OutlineGroup | OutlineElement; -type FileInfo = { path: FileElement[], folder: IWorkspaceFolder, showFolder: boolean }; +type FileInfo = { path: FileElement[], folder: IWorkspaceFolder }; export class EditorBreadcrumbsModel { @@ -101,14 +102,12 @@ export class EditorBreadcrumbsModel { if (uri.scheme === Schemas.untitled) { return { - showFolder: false, folder: undefined, path: [] }; } let info: FileInfo = { - showFolder: workspaceService.getWorkbenchState() === WorkbenchState.WORKSPACE, folder: workspaceService.getWorkspaceFolder(uri), path: [] }; @@ -117,9 +116,13 @@ export class EditorBreadcrumbsModel { if (info.folder && isEqual(info.folder.uri, uri)) { break; } - info.path.unshift(new FileElement(uri, info.path.length === 0)); + info.path.unshift(new FileElement(uri, info.path.length === 0 ? FileKind.FILE : FileKind.FOLDER)); uri = uri.with({ path: paths.dirname(uri.path) }); } + + if (info.folder && workspaceService.getWorkbenchState() === WorkbenchState.WORKSPACE) { + info.path.unshift(new FileElement(info.folder.uri, FileKind.ROOT_FOLDER)); + } return info; } @@ -163,18 +166,23 @@ export class EditorBreadcrumbsModel { }); OutlineModel.create(buffer, source.token).then(model => { + if (TreeElement.empty(model)) { + // empty -> no outline elements + this._updateOutlineElements([]); - // copy the model - model = model.adopt(); + } else { + // copy the model + model = model.adopt(); - this._updateOutlineElements(this._getOutlineElements(model, this._editor.getPosition())); - this._outlineDisposables.push(this._editor.onDidChangeCursorPosition(_ => { - timeout.cancelAndSet(() => { - if (!buffer.isDisposed() && versionIdThen === buffer.getVersionId()) { - this._updateOutlineElements(this._getOutlineElements(model, this._editor.getPosition())); - } - }, 150); - })); + this._updateOutlineElements(this._getOutlineElements(model, this._editor.getPosition())); + this._outlineDisposables.push(this._editor.onDidChangeCursorPosition(_ => { + timeout.cancelAndSet(() => { + if (!buffer.isDisposed() && versionIdThen === buffer.getVersionId()) { + this._updateOutlineElements(this._getOutlineElements(model, this._editor.getPosition())); + } + }, 150); + })); + } }).catch(err => { this._updateOutlineElements([]); onUnexpectedError(err); diff --git a/src/vs/workbench/browser/parts/editor/breadcrumbsPicker.ts b/src/vs/workbench/browser/parts/editor/breadcrumbsPicker.ts index 5a49481c2ec..c29f3e10307 100644 --- a/src/vs/workbench/browser/parts/editor/breadcrumbsPicker.ts +++ b/src/vs/workbench/browser/parts/editor/breadcrumbsPicker.ts @@ -26,6 +26,7 @@ import { BreadcrumbElement, FileElement } from 'vs/workbench/browser/parts/edito import { onUnexpectedError } from 'vs/base/common/errors'; import { breadcrumbsPickerBackground } from 'vs/platform/theme/common/colorRegistry'; import { FuzzyScore, createMatches, fuzzyScore } from 'vs/base/common/filters'; +import { IWorkspaceContextService, IWorkspace, IWorkspaceFolder } from 'vs/platform/workspace/common/workspace'; export function createBreadcrumbsPicker(instantiationService: IInstantiationService, parent: HTMLElement, element: BreadcrumbElement): BreadcrumbsPicker { let ctor: IConstructorSignature1 = element instanceof FileElement ? BreadcrumbsFilePicker : BreadcrumbsOutlinePicker; @@ -102,7 +103,7 @@ export abstract class BreadcrumbsPicker { this._tree.setInput(actualInput).then(() => { let selection = this._getInitialSelection(this._tree, input); if (selection) { - this._tree.reveal(selection).then(() => { + this._tree.reveal(selection, .5).then(() => { this._tree.setSelection([selection], this._tree); this._tree.setFocus(selection); this._tree.domFocus(); @@ -136,39 +137,61 @@ export abstract class BreadcrumbsPicker { export class FileDataSource implements IDataSource { - private readonly _parents = new WeakMap(); + private readonly _parents = new WeakMap(); constructor( @IFileService private readonly _fileService: IFileService, ) { } - getId(tree: ITree, element: IFileStat | URI): string { - return URI.isUri(element) ? element.toString() : element.resource.toString(); + getId(tree: ITree, element: IWorkspace | IWorkspaceFolder | IFileStat | URI): string { + if (URI.isUri(element)) { + return element.toString(); + } else if (IWorkspace.isIWorkspace(element)) { + return element.id; + } else if (IWorkspaceFolder.isIWorkspaceFolder(element)) { + return element.uri.toString(); + } else { + return element.resource.toString(); + } } - hasChildren(tree: ITree, element: IFileStat | URI): boolean { - return URI.isUri(element) || element.isDirectory; + hasChildren(tree: ITree, element: IWorkspace | IWorkspaceFolder | IFileStat | URI): boolean { + return URI.isUri(element) || IWorkspace.isIWorkspace(element) || IWorkspaceFolder.isIWorkspaceFolder(element) || element.isDirectory; } - getChildren(tree: ITree, element: IFileStat | URI): TPromise { - return this._fileService.resolveFile( - URI.isUri(element) ? element : element.resource - ).then(stat => { - for (const child of stat.children) { - this._parents.set(child, stat); + getChildren(tree: ITree, element: IWorkspace | IWorkspaceFolder | IFileStat | URI): TPromise { + if (IWorkspace.isIWorkspace(element)) { + return TPromise.as(element.folders).then(folders => { + for (let child of folders) { + this._parents.set(element, child); + } + return folders; + }); + } + let uri: URI; + if (IWorkspaceFolder.isIWorkspaceFolder(element)) { + uri = element.uri; + } else if (URI.isUri(element)) { + uri = element; + } else { + uri = element.resource; + } + return this._fileService.resolveFile(uri).then(stat => { + for (let child of stat.children) { + this._parents.set(stat, child); } return stat.children; }); } - getParent(tree: ITree, element: IFileStat | URI): TPromise { - return TPromise.as(URI.isUri(element) ? undefined : this._parents.get(element)); + getParent(tree: ITree, element: IWorkspace | URI | IWorkspaceFolder | IFileStat): TPromise { + return TPromise.as(this._parents.get(element)); } } export class FileRenderer implements IRenderer, IHighlightingRenderer { - private readonly _scores = new Map(); + private readonly _scores = new Map(); constructor( @IInstantiationService private readonly _instantiationService: IInstantiationService @@ -186,13 +209,22 @@ export class FileRenderer implements IRenderer, IHighlightingRenderer { return this._instantiationService.createInstance(FileLabel, container, { supportHighlights: true }); } - renderElement(tree: ITree, element: IFileStat, templateId: string, templateData: FileLabel): void { - templateData.setFile(element.resource, { - hidePath: true, - fileKind: element.isDirectory ? FileKind.FOLDER : FileKind.FILE, - fileDecorations: { colors: true, badges: true }, - matches: createMatches((this._scores.get(element.resource.toString()) || [, []])[1]) - }); + renderElement(tree: ITree, element: IFileStat | IWorkspaceFolder, templateId: string, templateData: FileLabel): void { + if (IWorkspaceFolder.isIWorkspaceFolder(element)) { + templateData.setFile(element.uri, { + hidePath: true, + fileKind: FileKind.ROOT_FOLDER, + fileDecorations: { colors: true, badges: true }, + matches: createMatches((this._scores.get(element) || [, []])[1]) + }); + } else { + templateData.setFile(element.resource, { + hidePath: true, + fileKind: element.isDirectory ? FileKind.FOLDER : FileKind.FILE, + fileDecorations: { colors: true, badges: true }, + matches: createMatches((this._scores.get(element) || [, []])[1]) + }); + } } disposeTemplate(tree: ITree, templateId: string, templateData: FileLabel): void { @@ -204,9 +236,9 @@ export class FileRenderer implements IRenderer, IHighlightingRenderer { let topScore: FuzzyScore; let topElement: any; while (nav.next()) { - let element = nav.current() as IFileStat; + let element = nav.current() as IFileStat | IWorkspaceFolder; let score = fuzzyScore(pattern, element.name, undefined, true); - this._scores.set(element.resource.toString(), score); + this._scores.set(element, score); if (!topScore || score && topScore[0] < score[0]) { topScore = score; topElement = element; @@ -217,31 +249,50 @@ export class FileRenderer implements IRenderer, IHighlightingRenderer { } export class FileSorter implements ISorter { - compare(tree: ITree, a: IFileStat, b: IFileStat): number { - if (a.isDirectory === b.isDirectory) { - // same type -> compare on names - return compareFileNames(a.name, b.name); - } else if (a.isDirectory) { - return -1; + compare(tree: ITree, a: IFileStat | IWorkspaceFolder, b: IFileStat | IWorkspaceFolder): number { + if (IWorkspaceFolder.isIWorkspaceFolder(a) && IWorkspaceFolder.isIWorkspaceFolder(b)) { + return a.index - b.index; } else { - return 1; + if ((a as IFileStat).isDirectory === (b as IFileStat).isDirectory) { + // same type -> compare on names + return compareFileNames(a.name, b.name); + } else if ((a as IFileStat).isDirectory) { + return -1; + } else { + return 1; + } } } } export class BreadcrumbsFilePicker extends BreadcrumbsPicker { + constructor( + parent: HTMLElement, + @IInstantiationService instantiationService: IInstantiationService, + @IThemeService themeService: IThemeService, + @IWorkspaceContextService private readonly _workspaceService: IWorkspaceContextService, + ) { + super(parent, instantiationService, themeService); + } + protected _getInput(input: BreadcrumbElement): any { - let { uri } = (input as FileElement); - return dirname(uri); + let { uri, kind } = (input as FileElement); + if (kind === FileKind.ROOT_FOLDER) { + return this._workspaceService.getWorkspace(); + } else { + return dirname(uri); + } } protected _getInitialSelection(tree: ITree, input: BreadcrumbElement): any { let { uri } = (input as FileElement); let nav = tree.getNavigator(); while (nav.next()) { - if (isEqual(uri, (nav.current() as IFileStat).resource)) { - return nav.current(); + let cur = nav.current(); + let candidate = IWorkspaceFolder.isIWorkspaceFolder(cur) ? cur.uri : (cur as IFileStat).resource; + if (isEqual(uri, candidate)) { + return cur; } } return undefined; @@ -257,9 +308,8 @@ export class BreadcrumbsFilePicker extends BreadcrumbsPicker { protected _onDidChangeSelection(e: ISelectionEvent): void { let [first] = e.selection; - let stat = first as IFileStat; - if (stat && !stat.isDirectory) { - this._onDidPickElement.fire(new FileElement(stat.resource, true)); + if (first && !IWorkspaceFolder.isIWorkspaceFolder(first) && !(first as IFileStat).isDirectory) { + this._onDidPickElement.fire(new FileElement((first as IFileStat).resource, FileKind.FILE)); } } } diff --git a/src/vs/workbench/browser/parts/editor/editor.contribution.ts b/src/vs/workbench/browser/parts/editor/editor.contribution.ts index bd435ff853f..f7865c8bb40 100644 --- a/src/vs/workbench/browser/parts/editor/editor.contribution.ts +++ b/src/vs/workbench/browser/parts/editor/editor.contribution.ts @@ -43,7 +43,7 @@ import { import * as editorCommands from 'vs/workbench/browser/parts/editor/editorCommands'; import { IEditorService } from 'vs/workbench/services/editor/common/editorService'; import { getQuickNavigateHandler, inQuickOpenContext } from 'vs/workbench/browser/parts/quickopen/quickopen'; -import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry'; +import { KeybindingsRegistry, KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey'; import { isMacintosh } from 'vs/base/common/platform'; import { AllEditorsPicker, ActiveEditorGroupPicker } from 'vs/workbench/browser/parts/editor/editorPicker'; @@ -380,7 +380,7 @@ registry.registerWorkbenchAction(new SyncActionDescriptor(OpenPreviousRecentlyUs const quickOpenNavigateNextInEditorPickerId = 'workbench.action.quickOpenNavigateNextInEditorPicker'; KeybindingsRegistry.registerCommandAndKeybindingRule({ id: quickOpenNavigateNextInEditorPickerId, - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(50), + weight: KeybindingWeight.WorkbenchContrib + 50, handler: getQuickNavigateHandler(quickOpenNavigateNextInEditorPickerId, true), when: editorPickerContext, primary: openNextEditorKeybinding.primary, @@ -390,7 +390,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({ const quickOpenNavigatePreviousInEditorPickerId = 'workbench.action.quickOpenNavigatePreviousInEditorPicker'; KeybindingsRegistry.registerCommandAndKeybindingRule({ id: quickOpenNavigatePreviousInEditorPickerId, - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(50), + weight: KeybindingWeight.WorkbenchContrib + 50, handler: getQuickNavigateHandler(quickOpenNavigatePreviousInEditorPickerId, false), when: editorPickerContext, primary: openPreviousEditorKeybinding.primary, diff --git a/src/vs/workbench/browser/parts/editor/editorCommands.ts b/src/vs/workbench/browser/parts/editor/editorCommands.ts index 97918df94dc..600ece0164f 100644 --- a/src/vs/workbench/browser/parts/editor/editorCommands.ts +++ b/src/vs/workbench/browser/parts/editor/editorCommands.ts @@ -6,7 +6,7 @@ import * as nls from 'vs/nls'; import * as types from 'vs/base/common/types'; import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation'; -import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry'; +import { KeybindingsRegistry, KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; import { TextCompareEditorVisibleContext, EditorInput, IEditorIdentifier, IEditorCommandsContext, ActiveEditorGroupEmptyContext, MultipleEditorGroupsContext, CloseDirection, IEditor, IEditorInput } from 'vs/workbench/common/editor'; import { IEditorService } from 'vs/workbench/services/editor/common/editorService'; import { EditorContextKeys } from 'vs/editor/common/editorContextKeys'; @@ -75,7 +75,7 @@ const isActiveEditorMoveArg = function (arg: ActiveEditorMoveArguments): boolean function registerActiveEditorMoveCommand(): void { KeybindingsRegistry.registerCommandAndKeybindingRule({ id: MOVE_ACTIVE_EDITOR_COMMAND_ID, - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: EditorContextKeys.editorTextFocus, primary: null, handler: (accessor, args: any) => moveActiveEditor(args, accessor), @@ -222,7 +222,7 @@ export function mergeAllGroups(editorGroupService: IEditorGroupsService): void { function registerDiffEditorCommands(): void { KeybindingsRegistry.registerCommandAndKeybindingRule({ id: 'workbench.action.compareEditor.nextChange', - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: TextCompareEditorVisibleContext, primary: null, handler: accessor => navigateInDiffEditor(accessor, true) @@ -230,7 +230,7 @@ function registerDiffEditorCommands(): void { KeybindingsRegistry.registerCommandAndKeybindingRule({ id: 'workbench.action.compareEditor.previousChange', - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: TextCompareEditorVisibleContext, primary: null, handler: accessor => navigateInDiffEditor(accessor, false) @@ -247,7 +247,7 @@ function registerDiffEditorCommands(): void { KeybindingsRegistry.registerCommandAndKeybindingRule({ id: TOGGLE_DIFF_INLINE_MODE, - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: void 0, primary: void 0, handler: (accessor, resourceOrContext: URI | IEditorCommandsContext, context?: IEditorCommandsContext) => { @@ -274,7 +274,7 @@ function registerOpenEditorAtIndexCommands(): void { KeybindingsRegistry.registerCommandAndKeybindingRule({ id: 'workbench.action.openEditorAtIndex' + visibleIndex, - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: void 0, primary: KeyMod.Alt | toKeyCode(visibleIndex), mac: { primary: KeyMod.WinCtrl | toKeyCode(visibleIndex) }, @@ -318,7 +318,7 @@ function registerFocusEditorGroupAtIndexCommands(): void { for (let groupIndex = 1; groupIndex < 8; groupIndex++) { KeybindingsRegistry.registerCommandAndKeybindingRule({ id: toCommandId(groupIndex), - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: void 0, primary: KeyMod.CtrlCmd | toKeyCode(groupIndex), handler: accessor => { @@ -422,7 +422,7 @@ function registerCloseEditorCommands() { KeybindingsRegistry.registerCommandAndKeybindingRule({ id: CLOSE_SAVED_EDITORS_COMMAND_ID, - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: void 0, primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyCode.KEY_U), handler: (accessor, resourceOrContext: URI | IEditorCommandsContext, context?: IEditorCommandsContext) => { @@ -442,7 +442,7 @@ function registerCloseEditorCommands() { KeybindingsRegistry.registerCommandAndKeybindingRule({ id: CLOSE_EDITORS_IN_GROUP_COMMAND_ID, - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: void 0, primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyCode.KEY_W), handler: (accessor, resourceOrContext: URI | IEditorCommandsContext, context?: IEditorCommandsContext) => { @@ -462,7 +462,7 @@ function registerCloseEditorCommands() { KeybindingsRegistry.registerCommandAndKeybindingRule({ id: CLOSE_EDITOR_COMMAND_ID, - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: void 0, primary: KeyMod.CtrlCmd | KeyCode.KEY_W, win: { primary: KeyMod.CtrlCmd | KeyCode.F4, secondary: [KeyMod.CtrlCmd | KeyCode.KEY_W] }, @@ -490,7 +490,7 @@ function registerCloseEditorCommands() { KeybindingsRegistry.registerCommandAndKeybindingRule({ id: CLOSE_EDITOR_GROUP_COMMAND_ID, - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: ContextKeyExpr.and(ActiveEditorGroupEmptyContext, MultipleEditorGroupsContext), primary: KeyMod.CtrlCmd | KeyCode.KEY_W, win: { primary: KeyMod.CtrlCmd | KeyCode.F4, secondary: [KeyMod.CtrlCmd | KeyCode.KEY_W] }, @@ -511,7 +511,7 @@ function registerCloseEditorCommands() { KeybindingsRegistry.registerCommandAndKeybindingRule({ id: CLOSE_OTHER_EDITORS_IN_GROUP_COMMAND_ID, - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: void 0, primary: void 0, mac: { primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.KEY_T }, @@ -540,7 +540,7 @@ function registerCloseEditorCommands() { KeybindingsRegistry.registerCommandAndKeybindingRule({ id: CLOSE_EDITORS_TO_THE_RIGHT_COMMAND_ID, - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: void 0, primary: void 0, handler: (accessor, resourceOrContext: URI | IEditorCommandsContext, context?: IEditorCommandsContext) => { @@ -557,7 +557,7 @@ function registerCloseEditorCommands() { KeybindingsRegistry.registerCommandAndKeybindingRule({ id: KEEP_EDITOR_COMMAND_ID, - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: void 0, primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyCode.Enter), handler: (accessor, resourceOrContext: URI | IEditorCommandsContext, context?: IEditorCommandsContext) => { @@ -574,7 +574,7 @@ function registerCloseEditorCommands() { KeybindingsRegistry.registerCommandAndKeybindingRule({ id: SHOW_EDITORS_IN_GROUP, - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: void 0, primary: void 0, handler: (accessor, resourceOrContext: URI | IEditorCommandsContext, context?: IEditorCommandsContext) => { diff --git a/src/vs/workbench/browser/parts/editor/media/notabstitlecontrol.css b/src/vs/workbench/browser/parts/editor/media/notabstitlecontrol.css index 6020090acfc..5c323a06753 100644 --- a/src/vs/workbench/browser/parts/editor/media/notabstitlecontrol.css +++ b/src/vs/workbench/browser/parts/editor/media/notabstitlecontrol.css @@ -57,11 +57,19 @@ content: '\\'; } -.monaco-workbench > .part.editor > .content .editor-group-container > .title .no-tabs-breadcrumbs.breadcrumbs-control.relative-path .monaco-breadcrumb-item:nth-child(2)::before { - /* relative path -> hide first seperator */ +.monaco-workbench > .part.editor > .content .editor-group-container > .title .no-tabs-breadcrumbs.breadcrumbs-control .monaco-breadcrumb-item.root_folder::before, +.monaco-workbench > .part.editor > .content .editor-group-container > .title .no-tabs-breadcrumbs.breadcrumbs-control .monaco-breadcrumb-item.root_folder + .monaco-breadcrumb-item::before, +.monaco-workbench > .part.editor > .content .editor-group-container > .title .no-tabs-breadcrumbs.breadcrumbs-control.relative-path .monaco-breadcrumb-item:nth-child(2)::before { + /* workspace folder, item following workspace folder, or relative path -> hide first seperator */ display: none; } +.monaco-workbench > .part.editor > .content .editor-group-container > .title .no-tabs-breadcrumbs.breadcrumbs-control .monaco-breadcrumb-item.root_folder::after { + /* use dot separator for workspace folder */ + content: '•'; + padding: 0 4px; +} + .monaco-workbench > .part.editor > .content .editor-group-container > .title .no-tabs-breadcrumbs.breadcrumbs-control .monaco-breadcrumb-item:last-child { padding-right: 4px; /* does not have trailing separator*/ } diff --git a/src/vs/workbench/browser/parts/menubar/media/menubarpart.css b/src/vs/workbench/browser/parts/menubar/media/menubarpart.css index 5b52a860a93..9b4ab103998 100644 --- a/src/vs/workbench/browser/parts/menubar/media/menubarpart.css +++ b/src/vs/workbench/browser/parts/menubar/media/menubarpart.css @@ -35,12 +35,15 @@ position: absolute; left: 0px; opacity: 1; + z-index: 2000; } .menubar-menu-items-holder.monaco-menu-container { - box-shadow: 0 2px 4px; + font-family: "Segoe WPC", "Segoe UI", ".SFNSDisplay-Light", "SFUIText-Light", "HelveticaNeue-Light", sans-serif, "Droid Sans Fallback"; + outline: 0; + border: none; } -.vs-dark .menubar-menu-items-holder.monaco-menu-container { - box-shadow: 0 2px 4px; +.menubar-menu-items-holder.monaco-menu-container :focus { + outline: 0; } \ No newline at end of file diff --git a/src/vs/workbench/browser/parts/menubar/menubar.contribution.ts b/src/vs/workbench/browser/parts/menubar/menubar.contribution.ts index 6c2e0b4adfc..83accf773bb 100644 --- a/src/vs/workbench/browser/parts/menubar/menubar.contribution.ts +++ b/src/vs/workbench/browser/parts/menubar/menubar.contribution.ts @@ -7,8 +7,6 @@ import * as nls from 'vs/nls'; import { MenuRegistry, MenuId } from 'vs/platform/actions/common/actions'; import { isMacintosh } from 'vs/base/common/platform'; -editMenuRegistration(); -selectionMenuRegistration(); goMenuRegistration(); if (isMacintosh) { @@ -19,256 +17,6 @@ helpMenuRegistration(); // Menu registration -function editMenuRegistration() { - MenuRegistry.appendMenuItem(MenuId.MenubarEditMenu, { - group: '1_do', - command: { - id: 'undo', - title: nls.localize({ key: 'miUndo', comment: ['&& denotes a mnemonic'] }, "&&Undo") - }, - order: 1 - }); - - MenuRegistry.appendMenuItem(MenuId.MenubarEditMenu, { - group: '1_do', - command: { - id: 'redo', - title: nls.localize({ key: 'miRedo', comment: ['&& denotes a mnemonic'] }, "&&Redo") - }, - order: 2 - }); - - MenuRegistry.appendMenuItem(MenuId.MenubarEditMenu, { - group: '2_ccp', - command: { - id: 'editor.action.clipboardCutAction', - title: nls.localize({ key: 'miCut', comment: ['&& denotes a mnemonic'] }, "Cu&&t") - }, - order: 1 - }); - - MenuRegistry.appendMenuItem(MenuId.MenubarEditMenu, { - group: '2_ccp', - command: { - id: 'editor.action.clipboardCopyAction', - title: nls.localize({ key: 'miCopy', comment: ['&& denotes a mnemonic'] }, "&&Copy") - }, - order: 2 - }); - - MenuRegistry.appendMenuItem(MenuId.MenubarEditMenu, { - group: '2_ccp', - command: { - id: 'editor.action.clipboardPasteAction', - title: nls.localize({ key: 'miPaste', comment: ['&& denotes a mnemonic'] }, "&&Paste") - }, - order: 3 - }); - - MenuRegistry.appendMenuItem(MenuId.MenubarEditMenu, { - group: '3_find', - command: { - id: 'actions.find', - title: nls.localize({ key: 'miFind', comment: ['&& denotes a mnemonic'] }, "&&Find") - }, - order: 1 - }); - - MenuRegistry.appendMenuItem(MenuId.MenubarEditMenu, { - group: '3_find', - command: { - id: 'editor.action.startFindReplaceAction', - title: nls.localize({ key: 'miReplace', comment: ['&& denotes a mnemonic'] }, "&&Replace") - }, - order: 2 - }); - - MenuRegistry.appendMenuItem(MenuId.MenubarEditMenu, { - group: '4_find_global', - command: { - id: 'workbench.action.findInFiles', - title: nls.localize({ key: 'miFindInFiles', comment: ['&& denotes a mnemonic'] }, "Find &&in Files") - }, - order: 1 - }); - - MenuRegistry.appendMenuItem(MenuId.MenubarEditMenu, { - group: '4_find_global', - command: { - - id: 'workbench.action.replaceInFiles', - title: nls.localize({ key: 'miReplaceInFiles', comment: ['&& denotes a mnemonic'] }, "Replace &&in Files") - }, - order: 2 - }); - - - MenuRegistry.appendMenuItem(MenuId.MenubarEditMenu, { - group: '5_insert', - command: { - id: 'editor.action.commentLine', - title: nls.localize({ key: 'miToggleLineComment', comment: ['&& denotes a mnemonic'] }, "&&Toggle Line Comment") - }, - order: 1 - }); - - MenuRegistry.appendMenuItem(MenuId.MenubarEditMenu, { - group: '5_insert', - command: { - id: 'editor.action.blockComment', - title: nls.localize({ key: 'miToggleBlockComment', comment: ['&& denotes a mnemonic'] }, "Toggle &&Block Comment") - }, - order: 2 - }); - - MenuRegistry.appendMenuItem(MenuId.MenubarEditMenu, { - group: '5_insert', - command: { - id: 'editor.emmet.action.expandAbbreviation', - title: nls.localize({ key: 'miEmmetExpandAbbreviation', comment: ['&& denotes a mnemonic'] }, "Emmet: E&&xpand Abbreviation") - }, - order: 1 - }); - - MenuRegistry.appendMenuItem(MenuId.MenubarEditMenu, { - group: '5_insert', - command: { - id: 'workbench.action.showEmmetCommands', - title: nls.localize({ key: 'miShowEmmetCommands', comment: ['&& denotes a mnemonic'] }, "E&&mmet...") - }, - order: 2 - }); -} - -function selectionMenuRegistration() { - MenuRegistry.appendMenuItem(MenuId.MenubarSelectionMenu, { - group: '1_basic', - command: { - id: 'editor.action.selectAll', - title: nls.localize({ key: 'miSelectAll', comment: ['&& denotes a mnemonic'] }, "&&Select All") - }, - order: 1 - }); - - MenuRegistry.appendMenuItem(MenuId.MenubarSelectionMenu, { - group: '1_basic', - command: { - id: 'editor.action.smartSelect.grow', - title: nls.localize({ key: 'miSmartSelectGrow', comment: ['&& denotes a mnemonic'] }, "&&Expand Selection") - }, - order: 2 - }); - - MenuRegistry.appendMenuItem(MenuId.MenubarSelectionMenu, { - group: '1_basic', - command: { - id: 'editor.action.smartSelect.shrink', - title: nls.localize({ key: 'miSmartSelectShrink', comment: ['&& denotes a mnemonic'] }, "&&Shrink Selection") - }, - order: 3 - }); - - MenuRegistry.appendMenuItem(MenuId.MenubarSelectionMenu, { - group: '2_line', - command: { - id: 'editor.action.copyLinesUpAction', - title: nls.localize({ key: 'miCopyLinesUp', comment: ['&& denotes a mnemonic'] }, "&&Copy Line Up") - }, - order: 1 - }); - - MenuRegistry.appendMenuItem(MenuId.MenubarSelectionMenu, { - group: '2_line', - command: { - id: 'editor.action.copyLinesDownAction', - title: nls.localize({ key: 'miCopyLinesDown', comment: ['&& denotes a mnemonic'] }, "Co&&py Line Down") - }, - order: 2 - }); - - MenuRegistry.appendMenuItem(MenuId.MenubarSelectionMenu, { - group: '2_line', - command: { - id: 'editor.action.moveLinesUpAction', - title: nls.localize({ key: 'miMoveLinesUp', comment: ['&& denotes a mnemonic'] }, "Mo&&ve Line Up") - }, - order: 3 - }); - - MenuRegistry.appendMenuItem(MenuId.MenubarSelectionMenu, { - group: '2_line', - command: { - id: 'editor.action.moveLinesDownAction', - title: nls.localize({ key: 'miMoveLinesDown', comment: ['&& denotes a mnemonic'] }, "Move &&Line Down") - }, - order: 4 - }); - - MenuRegistry.appendMenuItem(MenuId.MenubarSelectionMenu, { - group: '3_multi', - command: { - id: 'workbench.action.toggleMultiCursorModifier', - title: nls.localize('miMultiCursorAlt', "Switch to Alt+Click for Multi-Cursor") - }, - order: 1 - }); - - MenuRegistry.appendMenuItem(MenuId.MenubarSelectionMenu, { - group: '3_multi', - command: { - id: 'editor.action.insertCursorAbove', - title: nls.localize({ key: 'miInsertCursorAbove', comment: ['&& denotes a mnemonic'] }, "&&Add Cursor Above") - }, - order: 2 - }); - - MenuRegistry.appendMenuItem(MenuId.MenubarSelectionMenu, { - group: '3_multi', - command: { - id: 'editor.action.insertCursorBelow', - title: nls.localize({ key: 'miInsertCursorBelow', comment: ['&& denotes a mnemonic'] }, "A&&dd Cursor Below") - }, - order: 3 - }); - - MenuRegistry.appendMenuItem(MenuId.MenubarSelectionMenu, { - group: '3_multi', - command: { - id: 'editor.action.insertCursorAtEndOfEachLineSelected', - title: nls.localize({ key: 'miInsertCursorAtEndOfEachLineSelected', comment: ['&& denotes a mnemonic'] }, "Add C&&ursors to Line Ends") - }, - order: 4 - }); - - MenuRegistry.appendMenuItem(MenuId.MenubarSelectionMenu, { - group: '3_multi', - command: { - id: 'editor.action.addSelectionToNextFindMatch', - title: nls.localize({ key: 'miAddSelectionToNextFindMatch', comment: ['&& denotes a mnemonic'] }, "Add &&Next Occurrence") - }, - order: 5 - }); - - MenuRegistry.appendMenuItem(MenuId.MenubarSelectionMenu, { - group: '3_multi', - command: { - id: 'editor.action.addSelectionToPreviousFindMatch', - title: nls.localize({ key: 'miAddSelectionToPreviousFindMatch', comment: ['&& denotes a mnemonic'] }, "Add P&&revious Occurrence") - }, - order: 6 - }); - - MenuRegistry.appendMenuItem(MenuId.MenubarSelectionMenu, { - group: '3_multi', - command: { - id: 'editor.action.selectHighlights', - title: nls.localize({ key: 'miSelectHighlights', comment: ['&& denotes a mnemonic'] }, "Select All &&Occurrences") - }, - order: 7 - }); -} - - function goMenuRegistration() { // Forward/Back MenuRegistry.appendMenuItem(MenuId.MenubarGoMenu, { diff --git a/src/vs/workbench/browser/parts/menubar/menubarPart.ts b/src/vs/workbench/browser/parts/menubar/menubarPart.ts index 018fded98cd..7515a99f803 100644 --- a/src/vs/workbench/browser/parts/menubar/menubarPart.ts +++ b/src/vs/workbench/browser/parts/menubar/menubarPart.ts @@ -867,8 +867,6 @@ export class MenubarPart extends Part { let menuHolder = $(customMenu.buttonElement).div({ class: 'menubar-menu-items-holder' }); $(menuHolder.getHTMLElement().parentElement).addClass('open'); - - menuHolder.addClass('menubar-menu-items-holder-open context-view'); menuHolder.style({ 'zoom': `${1 / browser.getZoomFactor()}`, 'top': `${this.container.getClientArea().height * browser.getZoomFactor()}px` @@ -1166,6 +1164,9 @@ class ModifierKeyEmitter extends Emitter { this.fire(this._keyStatus); } })); + this._subscriptions.push(domEvent(document.body, 'mousedown')(e => { + this._keyStatus.lastKeyPressed = undefined; + })); this._subscriptions.push(domEvent(window, 'blur')(e => { this._keyStatus.lastKeyPressed = undefined; diff --git a/src/vs/workbench/browser/parts/notifications/notificationsCommands.ts b/src/vs/workbench/browser/parts/notifications/notificationsCommands.ts index 858f3bbe848..9519578fe60 100644 --- a/src/vs/workbench/browser/parts/notifications/notificationsCommands.ts +++ b/src/vs/workbench/browser/parts/notifications/notificationsCommands.ts @@ -7,7 +7,7 @@ import { CommandsRegistry } from 'vs/platform/commands/common/commands'; import { RawContextKey, ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey'; -import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry'; +import { KeybindingsRegistry, KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; import { KeyCode, KeyMod } from 'vs/base/common/keyCodes'; import { INotificationViewItem, isNotificationViewItem } from 'vs/workbench/common/notifications'; import { MenuRegistry, MenuId } from 'vs/platform/actions/common/actions'; @@ -88,7 +88,7 @@ export function registerNotificationCommands(center: INotificationsCenterControl // Hide Notifications Center KeybindingsRegistry.registerCommandAndKeybindingRule({ id: HIDE_NOTIFICATIONS_CENTER, - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(50), + weight: KeybindingWeight.WorkbenchContrib + 50, when: NotificationsCenterVisibleContext, primary: KeyCode.Escape, handler: accessor => center.hide() @@ -106,7 +106,7 @@ export function registerNotificationCommands(center: INotificationsCenterControl // Clear Notification KeybindingsRegistry.registerCommandAndKeybindingRule({ id: CLEAR_NOTIFICATION, - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: NotificationFocusedContext, primary: KeyCode.Delete, mac: { @@ -123,7 +123,7 @@ export function registerNotificationCommands(center: INotificationsCenterControl // Expand Notification KeybindingsRegistry.registerCommandAndKeybindingRule({ id: EXPAND_NOTIFICATION, - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: NotificationFocusedContext, primary: KeyCode.RightArrow, handler: (accessor, args?: any) => { @@ -137,7 +137,7 @@ export function registerNotificationCommands(center: INotificationsCenterControl // Collapse Notification KeybindingsRegistry.registerCommandAndKeybindingRule({ id: COLLAPSE_NOTIFICATION, - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: NotificationFocusedContext, primary: KeyCode.LeftArrow, handler: (accessor, args?: any) => { @@ -151,7 +151,7 @@ export function registerNotificationCommands(center: INotificationsCenterControl // Toggle Notification KeybindingsRegistry.registerCommandAndKeybindingRule({ id: TOGGLE_NOTIFICATION, - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: NotificationFocusedContext, primary: KeyCode.Space, secondary: [KeyCode.Enter], @@ -166,7 +166,7 @@ export function registerNotificationCommands(center: INotificationsCenterControl // Hide Toasts KeybindingsRegistry.registerCommandAndKeybindingRule({ id: HIDE_NOTIFICATION_TOAST, - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(50), + weight: KeybindingWeight.WorkbenchContrib + 50, when: NotificationsToastsVisibleContext, primary: KeyCode.Escape, handler: accessor => toasts.hide() @@ -178,7 +178,7 @@ export function registerNotificationCommands(center: INotificationsCenterControl // Focus Next Toast KeybindingsRegistry.registerCommandAndKeybindingRule({ id: FOCUS_NEXT_NOTIFICATION_TOAST, - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: ContextKeyExpr.and(NotificationFocusedContext, NotificationsToastsVisibleContext), primary: KeyCode.DownArrow, handler: (accessor) => { @@ -189,7 +189,7 @@ export function registerNotificationCommands(center: INotificationsCenterControl // Focus Previous Toast KeybindingsRegistry.registerCommandAndKeybindingRule({ id: FOCUS_PREVIOUS_NOTIFICATION_TOAST, - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: ContextKeyExpr.and(NotificationFocusedContext, NotificationsToastsVisibleContext), primary: KeyCode.UpArrow, handler: (accessor) => { @@ -200,7 +200,7 @@ export function registerNotificationCommands(center: INotificationsCenterControl // Focus First Toast KeybindingsRegistry.registerCommandAndKeybindingRule({ id: FOCUS_FIRST_NOTIFICATION_TOAST, - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: ContextKeyExpr.and(NotificationFocusedContext, NotificationsToastsVisibleContext), primary: KeyCode.PageUp, secondary: [KeyCode.Home], @@ -212,7 +212,7 @@ export function registerNotificationCommands(center: INotificationsCenterControl // Focus Last Toast KeybindingsRegistry.registerCommandAndKeybindingRule({ id: FOCUS_LAST_NOTIFICATION_TOAST, - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: ContextKeyExpr.and(NotificationFocusedContext, NotificationsToastsVisibleContext), primary: KeyCode.PageDown, secondary: [KeyCode.End], diff --git a/src/vs/workbench/browser/parts/panel/media/panelpart.css b/src/vs/workbench/browser/parts/panel/media/panelpart.css index 0c58440f0d4..cfd1137cf35 100644 --- a/src/vs/workbench/browser/parts/panel/media/panelpart.css +++ b/src/vs/workbench/browser/parts/panel/media/panelpart.css @@ -81,16 +81,19 @@ } .monaco-workbench > .part.panel > .title > .panel-switcher-container > .monaco-action-bar .badge { - margin-left: 4px; + margin-left: 8px; } .monaco-workbench > .part.panel > .title > .panel-switcher-container > .monaco-action-bar .badge .badge-content { - padding: 0.2em 0.5em; + padding: 0.3em 0.5em; border-radius: 1em; font-weight: normal; text-align: center; - display: inline; -} + display: inline-block; + min-width: 1.6em; + line-height: 1em; + box-sizing: border-box; + } /** Actions */ diff --git a/src/vs/workbench/browser/parts/quickinput/quickInput.contribution.ts b/src/vs/workbench/browser/parts/quickinput/quickInput.contribution.ts index cc7fb7c7577..7e5bc7f43a0 100644 --- a/src/vs/workbench/browser/parts/quickinput/quickInput.contribution.ts +++ b/src/vs/workbench/browser/parts/quickinput/quickInput.contribution.ts @@ -5,7 +5,7 @@ 'use strict'; import { QuickPickManyToggle, BackAction } from 'vs/workbench/browser/parts/quickinput/quickInput'; -import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry'; +import { KeybindingsRegistry, KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; import { Registry } from 'vs/platform/registry/common/platform'; import { IWorkbenchActionRegistry, Extensions as ActionExtensions } from 'vs/workbench/common/actions'; import { SyncActionDescriptor } from 'vs/platform/actions/common/actions'; @@ -15,4 +15,4 @@ import { inQuickOpenContext } from 'vs/workbench/browser/parts/quickopen/quickop KeybindingsRegistry.registerCommandAndKeybindingRule(QuickPickManyToggle); const registry = Registry.as(ActionExtensions.WorkbenchActions); -registry.registerWorkbenchAction(new SyncActionDescriptor(BackAction, BackAction.ID, BackAction.LABEL, { primary: null, win: { primary: KeyMod.Alt | KeyCode.LeftArrow }, mac: { primary: KeyMod.WinCtrl | KeyCode.US_MINUS }, linux: { primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.US_MINUS } }, inQuickOpenContext, KeybindingsRegistry.WEIGHT.workbenchContrib(50)), 'Back'); +registry.registerWorkbenchAction(new SyncActionDescriptor(BackAction, BackAction.ID, BackAction.LABEL, { primary: null, win: { primary: KeyMod.Alt | KeyCode.LeftArrow }, mac: { primary: KeyMod.WinCtrl | KeyCode.US_MINUS }, linux: { primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.US_MINUS } }, inQuickOpenContext, KeybindingWeight.WorkbenchContrib + 50), 'Back'); diff --git a/src/vs/workbench/browser/parts/quickinput/quickInput.ts b/src/vs/workbench/browser/parts/quickinput/quickInput.ts index b56ee969d43..b0b274f92e1 100644 --- a/src/vs/workbench/browser/parts/quickinput/quickInput.ts +++ b/src/vs/workbench/browser/parts/quickinput/quickInput.ts @@ -34,7 +34,7 @@ import { dispose, IDisposable } from 'vs/base/common/lifecycle'; import Severity from 'vs/base/common/severity'; import { IEditorGroupsService } from 'vs/workbench/services/group/common/editorGroupsService'; import { IContextKeyService, RawContextKey, IContextKey } from 'vs/platform/contextkey/common/contextkey'; -import { ICommandAndKeybindingRule, KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry'; +import { ICommandAndKeybindingRule, KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; import { inQuickOpenContext } from 'vs/workbench/browser/parts/quickopen/quickopen'; import { ActionBar, ActionItem } from 'vs/base/browser/ui/actionbar/actionbar'; import { Action } from 'vs/base/common/actions'; @@ -849,18 +849,22 @@ export class QuickInputService extends Component implements IQuickInputService { break; case KeyCode.Tab: if (!event.altKey && !event.ctrlKey && !event.metaKey) { - const inputs = [].slice.call(container.querySelectorAll('.action-label.icon')); + const selectors = ['.action-label.icon']; if (container.classList.contains('show-checkboxes')) { - inputs.push(...[].slice.call(container.querySelectorAll('input'))); + selectors.push('input'); } else { - inputs.push(...[].slice.call(container.querySelectorAll('input[type=text]'))); + selectors.push('input[type=text]'); } - if (event.shiftKey && event.target === inputs[0]) { + if (this.ui.list.isDisplayed()) { + selectors.push('.monaco-list'); + } + const stops = container.querySelectorAll(selectors.join(', ')); + if (event.shiftKey && event.target === stops[0]) { dom.EventHelper.stop(e, true); - inputs[inputs.length - 1].focus(); - } else if (!event.shiftKey && event.target === inputs[inputs.length - 1]) { + stops[stops.length - 1].focus(); + } else if (!event.shiftKey && event.target === stops[stops.length - 1]) { dom.EventHelper.stop(e, true); - inputs[0].focus(); + stops[0].focus(); } } break; @@ -1202,7 +1206,7 @@ function getIconClass(iconPath: { dark: URI; light?: URI; }) { export const QuickPickManyToggle: ICommandAndKeybindingRule = { id: 'workbench.action.quickPickManyToggle', - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: inQuickOpenContext, primary: undefined, handler: accessor => { diff --git a/src/vs/workbench/browser/parts/quickopen/quickopen.contribution.ts b/src/vs/workbench/browser/parts/quickopen/quickopen.contribution.ts index 3f4ad79d9b0..95a8a593377 100644 --- a/src/vs/workbench/browser/parts/quickopen/quickopen.contribution.ts +++ b/src/vs/workbench/browser/parts/quickopen/quickopen.contribution.ts @@ -9,14 +9,14 @@ import { IQuickOpenService } from 'vs/platform/quickOpen/common/quickOpen'; import { SyncActionDescriptor, MenuRegistry, MenuId } from 'vs/platform/actions/common/actions'; import { KeyMod, KeyCode } from 'vs/base/common/keyCodes'; import { IWorkbenchActionRegistry, Extensions as ActionExtensions } from 'vs/workbench/common/actions'; -import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry'; +import { KeybindingsRegistry, KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; import { RemoveFromEditorHistoryAction } from 'vs/workbench/browser/parts/quickopen/quickOpenController'; import { QuickOpenSelectNextAction, QuickOpenSelectPreviousAction, inQuickOpenContext, getQuickNavigateHandler, QuickOpenNavigateNextAction, QuickOpenNavigatePreviousAction, defaultQuickOpenContext, QUICKOPEN_ACTION_ID, QUICKOPEN_ACION_LABEL } from 'vs/workbench/browser/parts/quickopen/quickopen'; import { IQuickInputService } from 'vs/platform/quickinput/common/quickInput'; KeybindingsRegistry.registerCommandAndKeybindingRule({ id: 'workbench.action.closeQuickOpen', - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: inQuickOpenContext, primary: KeyCode.Escape, secondary: [KeyMod.Shift | KeyCode.Escape], handler: accessor => { @@ -29,7 +29,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({ KeybindingsRegistry.registerCommandAndKeybindingRule({ id: 'workbench.action.acceptSelectedQuickOpenItem', - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: inQuickOpenContext, primary: null, handler: accessor => { @@ -42,7 +42,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({ KeybindingsRegistry.registerCommandAndKeybindingRule({ id: 'workbench.action.focusQuickOpen', - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: inQuickOpenContext, primary: null, handler: accessor => { @@ -59,7 +59,7 @@ const globalQuickOpenKeybinding = { primary: KeyMod.CtrlCmd | KeyCode.KEY_P, sec KeybindingsRegistry.registerKeybindingRule({ id: QUICKOPEN_ACTION_ID, - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: undefined, primary: globalQuickOpenKeybinding.primary, secondary: globalQuickOpenKeybinding.secondary, @@ -70,8 +70,8 @@ MenuRegistry.appendMenuItem(MenuId.CommandPalette, { command: { id: QUICKOPEN_ACTION_ID, title: QUICKOPEN_ACION_LABEL } }); -registry.registerWorkbenchAction(new SyncActionDescriptor(QuickOpenSelectNextAction, QuickOpenSelectNextAction.ID, QuickOpenSelectNextAction.LABEL, { primary: null, mac: { primary: KeyMod.WinCtrl | KeyCode.KEY_N } }, inQuickOpenContext, KeybindingsRegistry.WEIGHT.workbenchContrib(50)), 'Select Next in Quick Open'); -registry.registerWorkbenchAction(new SyncActionDescriptor(QuickOpenSelectPreviousAction, QuickOpenSelectPreviousAction.ID, QuickOpenSelectPreviousAction.LABEL, { primary: null, mac: { primary: KeyMod.WinCtrl | KeyCode.KEY_P } }, inQuickOpenContext, KeybindingsRegistry.WEIGHT.workbenchContrib(50)), 'Select Previous in Quick Open'); +registry.registerWorkbenchAction(new SyncActionDescriptor(QuickOpenSelectNextAction, QuickOpenSelectNextAction.ID, QuickOpenSelectNextAction.LABEL, { primary: null, mac: { primary: KeyMod.WinCtrl | KeyCode.KEY_N } }, inQuickOpenContext, KeybindingWeight.WorkbenchContrib + 50), 'Select Next in Quick Open'); +registry.registerWorkbenchAction(new SyncActionDescriptor(QuickOpenSelectPreviousAction, QuickOpenSelectPreviousAction.ID, QuickOpenSelectPreviousAction.LABEL, { primary: null, mac: { primary: KeyMod.WinCtrl | KeyCode.KEY_P } }, inQuickOpenContext, KeybindingWeight.WorkbenchContrib + 50), 'Select Previous in Quick Open'); registry.registerWorkbenchAction(new SyncActionDescriptor(QuickOpenNavigateNextAction, QuickOpenNavigateNextAction.ID, QuickOpenNavigateNextAction.LABEL), 'Navigate Next in Quick Open'); registry.registerWorkbenchAction(new SyncActionDescriptor(QuickOpenNavigatePreviousAction, QuickOpenNavigatePreviousAction.ID, QuickOpenNavigatePreviousAction.LABEL), 'Navigate Previous in Quick Open'); registry.registerWorkbenchAction(new SyncActionDescriptor(RemoveFromEditorHistoryAction, RemoveFromEditorHistoryAction.ID, RemoveFromEditorHistoryAction.LABEL), 'Remove From History'); @@ -79,7 +79,7 @@ registry.registerWorkbenchAction(new SyncActionDescriptor(RemoveFromEditorHistor const quickOpenNavigateNextInFilePickerId = 'workbench.action.quickOpenNavigateNextInFilePicker'; KeybindingsRegistry.registerCommandAndKeybindingRule({ id: quickOpenNavigateNextInFilePickerId, - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(50), + weight: KeybindingWeight.WorkbenchContrib + 50, handler: getQuickNavigateHandler(quickOpenNavigateNextInFilePickerId, true), when: defaultQuickOpenContext, primary: globalQuickOpenKeybinding.primary, @@ -90,7 +90,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({ const quickOpenNavigatePreviousInFilePickerId = 'workbench.action.quickOpenNavigatePreviousInFilePicker'; KeybindingsRegistry.registerCommandAndKeybindingRule({ id: quickOpenNavigatePreviousInFilePickerId, - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(50), + weight: KeybindingWeight.WorkbenchContrib + 50, handler: getQuickNavigateHandler(quickOpenNavigatePreviousInFilePickerId, false), when: defaultQuickOpenContext, primary: globalQuickOpenKeybinding.primary | KeyMod.Shift, diff --git a/src/vs/workbench/browser/parts/views/customView.ts b/src/vs/workbench/browser/parts/views/customView.ts index 54306015001..bf04ef7a0c0 100644 --- a/src/vs/workbench/browser/parts/views/customView.ts +++ b/src/vs/workbench/browser/parts/views/customView.ts @@ -202,12 +202,18 @@ export class CustomTreeViewer extends Disposable implements ITreeViewer { @IExtensionService private extensionService: IExtensionService, @IWorkbenchThemeService private themeService: IWorkbenchThemeService, @IInstantiationService private instantiationService: IInstantiationService, - @ICommandService private commandService: ICommandService + @ICommandService private commandService: ICommandService, + @IConfigurationService private configurationService: IConfigurationService ) { super(); this.root = new Root(); this._register(this.themeService.onDidFileIconThemeChange(() => this.doRefresh([this.root]) /** soft refresh **/)); this._register(this.themeService.onThemeChange(() => this.doRefresh([this.root]) /** soft refresh **/)); + this._register(this.configurationService.onDidChangeConfiguration(e => { + if (e.affectsConfiguration('explorer.decorations')) { + this.doRefresh([this.root]); /** soft refresh **/ + } + })); } get dataProvider(): ITreeViewDataProvider { @@ -442,7 +448,6 @@ class TreeDataSource implements IDataSource { } interface ITreeExplorerTemplateData { - label: HTMLElement; resourceLabel: ResourceLabel; icon: HTMLElement; actionBar: ActionBar; @@ -459,7 +464,8 @@ class TreeRenderer implements IRenderer { private menus: TreeMenus, private actionItemProvider: IActionItemProvider, @IInstantiationService private instantiationService: IInstantiationService, - @IWorkbenchThemeService private themeService: IWorkbenchThemeService + @IWorkbenchThemeService private themeService: IWorkbenchThemeService, + @IConfigurationService private configurationService: IConfigurationService, ) { } @@ -475,37 +481,32 @@ class TreeRenderer implements IRenderer { DOM.addClass(container, 'custom-view-tree-node-item'); const icon = DOM.append(container, DOM.$('.custom-view-tree-node-item-icon')); - const label = DOM.append(container, DOM.$('.custom-view-tree-node-item-label')); const resourceLabel = this.instantiationService.createInstance(ResourceLabel, container, {}); - const actionsContainer = DOM.append(container, DOM.$('.actions')); + DOM.addClass(resourceLabel.element, 'custom-view-tree-node-item-resourceLabel'); + const actionsContainer = DOM.append(resourceLabel.element, DOM.$('.actions')); const actionBar = new ActionBar(actionsContainer, { actionItemProvider: this.actionItemProvider, actionRunner: new MultipleSelectionActionRunner(() => tree.getSelection()) }); - return { label, resourceLabel, icon, actionBar, aligner: new Aligner(container, tree, this.themeService) }; + return { resourceLabel, icon, actionBar, aligner: new Aligner(container, tree, this.themeService) }; } renderElement(tree: ITree, node: ITreeItem, templateId: string, templateData: ITreeExplorerTemplateData): void { const resource = node.resourceUri ? URI.revive(node.resourceUri) : null; const label = node.label ? node.label : resource ? basename(resource.path) : ''; const icon = this.themeService.getTheme().type === LIGHT ? node.icon : node.iconDark; + const title = node.tooltip ? node.tooltip : resource ? void 0 : label; // reset templateData.resourceLabel.clear(); templateData.actionBar.clear(); - templateData.label.textContent = ''; - DOM.removeClass(templateData.label, 'custom-view-tree-node-item-label'); - DOM.removeClass(templateData.resourceLabel.element, 'custom-view-tree-node-item-resourceLabel'); if ((resource || node.themeIcon) && !icon) { - const title = node.tooltip ? node.tooltip : resource ? void 0 : label; - templateData.resourceLabel.setLabel({ name: label, resource: resource ? resource : URI.parse('_icon_resource') }, { fileKind: this.getFileKind(node), title }); - DOM.addClass(templateData.resourceLabel.element, 'custom-view-tree-node-item-resourceLabel'); + const fileDecorations = this.configurationService.getValue<{ colors: boolean, badges: boolean }>('explorer.decorations'); + templateData.resourceLabel.setLabel({ name: label, resource: resource ? resource : URI.parse('_icon_resource') }, { fileKind: this.getFileKind(node), title, fileDecorations: fileDecorations, extraClasses: ['custom-view-tree-node-item-resourceLabel'] }); } else { - templateData.label.textContent = label; - DOM.addClass(templateData.label, 'custom-view-tree-node-item-label'); - templateData.label.title = typeof node.tooltip === 'string' ? node.tooltip : label; + templateData.resourceLabel.setLabel({ name: label }, { title, hideIcon: true, extraClasses: ['custom-view-tree-node-item-resourceLabel'] }); } templateData.icon.style.backgroundImage = icon ? `url('${icon}')` : ''; diff --git a/src/vs/workbench/browser/parts/views/media/views.css b/src/vs/workbench/browser/parts/views/media/views.css index 7d9c1184814..597a1fcc597 100644 --- a/src/vs/workbench/browser/parts/views/media/views.css +++ b/src/vs/workbench/browser/parts/views/media/views.css @@ -58,6 +58,10 @@ display: inline-block; } +.tree-explorer-viewlet-tree-view .monaco-tree .monaco-tree-row { + padding-right: 12px; +} + .tree-explorer-viewlet-tree-view .monaco-tree .monaco-tree-row .custom-view-tree-node-item { display: flex; height: 22px; @@ -68,8 +72,7 @@ flex-wrap: nowrap } -.tree-explorer-viewlet-tree-view .monaco-tree .monaco-tree-row .custom-view-tree-node-item .custom-view-tree-node-item-resourceLabel, -.tree-explorer-viewlet-tree-view .monaco-tree .monaco-tree-row .custom-view-tree-node-item > .custom-view-tree-node-item-label { +.tree-explorer-viewlet-tree-view .monaco-tree .monaco-tree-row .custom-view-tree-node-item .custom-view-tree-node-item-resourceLabel { flex: 1; text-overflow: ellipsis; overflow: hidden; @@ -85,18 +88,22 @@ -webkit-font-smoothing: antialiased; } -.tree-explorer-viewlet-tree-view .monaco-tree .monaco-tree-row .custom-view-tree-node-item > .actions { - display: none; - padding-right: 6px; +.tree-explorer-viewlet-tree-view .monaco-tree .monaco-tree-row .custom-view-tree-node-item > .custom-view-tree-node-item-resourceLabel::after { + padding-right: 0px; } -.tree-explorer-viewlet-tree-view .monaco-tree .monaco-tree-row:hover .custom-view-tree-node-item > .actions, -.tree-explorer-viewlet-tree-view .monaco-tree .monaco-tree-row.selected .custom-view-tree-node-item > .actions, -.tree-explorer-viewlet-tree-view .monaco-tree .monaco-tree-row.focused .custom-view-tree-node-item > .actions { +.tree-explorer-viewlet-tree-view .monaco-tree .monaco-tree-row .custom-view-tree-node-item > .custom-view-tree-node-item-resourceLabel > .actions { + display: none; + flex-grow: 100; +} + +.tree-explorer-viewlet-tree-view .monaco-tree .monaco-tree-row:hover .custom-view-tree-node-item > .custom-view-tree-node-item-resourceLabel > .actions, +.tree-explorer-viewlet-tree-view .monaco-tree .monaco-tree-row.selected .custom-view-tree-node-item > .custom-view-tree-node-item-resourceLabel > .actions, +.tree-explorer-viewlet-tree-view .monaco-tree .monaco-tree-row.focused .custom-view-tree-node-item > .custom-view-tree-node-item-resourceLabel > .actions { display: block; } -.tree-explorer-viewlet-tree-view .monaco-tree .custom-view-tree-node-item > .actions .action-label { +.tree-explorer-viewlet-tree-view .monaco-tree .custom-view-tree-node-item > .custom-view-tree-node-item-resourceLabel > .actions .action-label { width: 16px; height: 100%; background-position: 50% 50%; diff --git a/src/vs/workbench/common/actions.ts b/src/vs/workbench/common/actions.ts index a2533c808d4..c8bd1928dfd 100644 --- a/src/vs/workbench/common/actions.ts +++ b/src/vs/workbench/common/actions.ts @@ -6,7 +6,7 @@ import { TPromise } from 'vs/base/common/winjs.base'; import { Registry } from 'vs/platform/registry/common/platform'; -import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry'; +import { KeybindingsRegistry, KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; import { ICommandHandler, CommandsRegistry } from 'vs/platform/commands/common/commands'; import { SyncActionDescriptor, MenuRegistry, MenuId } from 'vs/platform/actions/common/actions'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; @@ -41,7 +41,7 @@ Registry.add(Extensions.WorkbenchActions, new class implements IWorkbenchActionR // keybinding const when = descriptor.keybindingContext; - const weight = (typeof descriptor.keybindingWeight === 'undefined' ? KeybindingsRegistry.WEIGHT.workbenchContrib() : descriptor.keybindingWeight); + const weight = (typeof descriptor.keybindingWeight === 'undefined' ? KeybindingWeight.WorkbenchContrib : descriptor.keybindingWeight); const keybindings = descriptor.keybindings; KeybindingsRegistry.registerKeybindingRule({ id: descriptor.id, diff --git a/src/vs/workbench/common/views.ts b/src/vs/workbench/common/views.ts index ba637549b16..b1049fab080 100644 --- a/src/vs/workbench/common/views.ts +++ b/src/vs/workbench/common/views.ts @@ -288,7 +288,6 @@ export interface ITreeItem { command?: Command; children?: ITreeItem[]; - } export interface ITreeViewDataProvider { diff --git a/src/vs/workbench/electron-browser/bootstrap/index.js b/src/vs/workbench/electron-browser/bootstrap/index.js index 692122631e7..51700d6f0b3 100644 --- a/src/vs/workbench/electron-browser/bootstrap/index.js +++ b/src/vs/workbench/electron-browser/bootstrap/index.js @@ -70,8 +70,8 @@ function uriFromPath(_path) { } function readFile(file) { - return new Promise(function(resolve, reject) { - fs.readFile(file, 'utf8', function(err, data) { + return new Promise(function (resolve, reject) { + fs.readFile(file, 'utf8', function (err, data) { if (err) { reject(err); return; @@ -81,6 +81,37 @@ function readFile(file) { }); } +function showPartsSplash(configuration) { + + let key; + let keep = false; + // this is the logic of StorageService#getWorkspaceKey and StorageService#toStorageKey + if (configuration.folderUri) { + let workspaceKey = require('vscode-uri').default.revive(configuration.folderUri).toString().replace('file:///', '').replace(/^\//, ''); + key = `storage://workspace/${workspaceKey}/parts-splash`; + } else if (configuration.workspace) { + key = `storage://workspace/root:${configuration.workspace.id}/parts-splash`; + } else { + key = `storage://global/parts-splash`; + keep = true; + } + + // TODO@Ben remove me after a while + perf.mark('willAccessLocalStorage'); + let storage = window.localStorage; + perf.mark('didAccessLocalStorage'); + + let structure = storage.getItem(key); + if (structure) { + let splash = document.createElement('div'); + splash.innerHTML = structure; + document.body.appendChild(splash); + } + if (!keep) { + storage.removeItem(key); + } +} + const writeFile = (file, content) => new Promise((c, e) => fs.writeFile(file, content, 'utf8', err => err ? e(err) : c())); function registerListeners(enableDeveloperTools) { @@ -159,6 +190,8 @@ function main() { assign(process.env, configuration.userEnv); perf.importEntries(configuration.perfEntries); + showPartsSplash(configuration); + // Get the nls configuration into the process.env as early as possible. var nlsConfig = { availableLanguages: {} }; const config = process.env['VSCODE_NLS_CONFIG']; @@ -171,7 +204,7 @@ function main() { if (nlsConfig._resolvedLanguagePackCoreLocation) { let bundles = Object.create(null); - nlsConfig.loadBundle = function(bundle, language, cb) { + nlsConfig.loadBundle = function (bundle, language, cb) { let result = bundles[bundle]; if (result) { cb(undefined, result); diff --git a/src/vs/workbench/electron-browser/commands.ts b/src/vs/workbench/electron-browser/commands.ts index 0c1ea832e8e..3853ebdfab4 100644 --- a/src/vs/workbench/electron-browser/commands.ts +++ b/src/vs/workbench/electron-browser/commands.ts @@ -7,7 +7,7 @@ import { KeyMod, KeyChord, KeyCode } from 'vs/base/common/keyCodes'; import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation'; -import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry'; +import { KeybindingsRegistry, KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; import { IPartService } from 'vs/workbench/services/part/common/partService'; import { IWindowsService, IWindowService } from 'vs/platform/windows/common/windows'; import { List } from 'vs/base/browser/ui/list/listWidget'; @@ -65,7 +65,7 @@ export function registerCommands(): void { KeybindingsRegistry.registerCommandAndKeybindingRule({ id: 'list.focusDown', - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: WorkbenchListFocusContextKey, primary: KeyCode.DownArrow, mac: { @@ -106,7 +106,7 @@ export function registerCommands(): void { KeybindingsRegistry.registerCommandAndKeybindingRule({ id: 'list.expandSelectionDown', - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: ContextKeyExpr.and(WorkbenchListFocusContextKey, WorkbenchListSupportsMultiSelectContextKey), primary: KeyMod.Shift | KeyCode.DownArrow, handler: (accessor, arg2) => { @@ -167,7 +167,7 @@ export function registerCommands(): void { KeybindingsRegistry.registerCommandAndKeybindingRule({ id: 'list.focusUp', - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: WorkbenchListFocusContextKey, primary: KeyCode.UpArrow, mac: { @@ -179,7 +179,7 @@ export function registerCommands(): void { KeybindingsRegistry.registerCommandAndKeybindingRule({ id: 'list.expandSelectionUp', - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: ContextKeyExpr.and(WorkbenchListFocusContextKey, WorkbenchListSupportsMultiSelectContextKey), primary: KeyMod.Shift | KeyCode.UpArrow, handler: (accessor, arg2) => { @@ -213,7 +213,7 @@ export function registerCommands(): void { KeybindingsRegistry.registerCommandAndKeybindingRule({ id: 'list.collapse', - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: WorkbenchListFocusContextKey, primary: KeyCode.LeftArrow, mac: { @@ -243,7 +243,7 @@ export function registerCommands(): void { KeybindingsRegistry.registerCommandAndKeybindingRule({ id: 'list.expand', - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: WorkbenchListFocusContextKey, primary: KeyCode.RightArrow, handler: (accessor) => { @@ -269,7 +269,7 @@ export function registerCommands(): void { KeybindingsRegistry.registerCommandAndKeybindingRule({ id: 'list.focusPageUp', - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: WorkbenchListFocusContextKey, primary: KeyCode.PageUp, handler: (accessor) => { @@ -298,7 +298,7 @@ export function registerCommands(): void { KeybindingsRegistry.registerCommandAndKeybindingRule({ id: 'list.focusPageDown', - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: WorkbenchListFocusContextKey, primary: KeyCode.PageDown, handler: (accessor) => { @@ -327,7 +327,7 @@ export function registerCommands(): void { KeybindingsRegistry.registerCommandAndKeybindingRule({ id: 'list.focusFirst', - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: WorkbenchListFocusContextKey, primary: KeyCode.Home, handler: accessor => listFocusFirst(accessor) @@ -335,7 +335,7 @@ export function registerCommands(): void { KeybindingsRegistry.registerCommandAndKeybindingRule({ id: 'list.focusFirstChild', - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: WorkbenchListFocusContextKey, primary: null, handler: accessor => listFocusFirst(accessor, { fromFocused: true }) @@ -366,7 +366,7 @@ export function registerCommands(): void { KeybindingsRegistry.registerCommandAndKeybindingRule({ id: 'list.focusLast', - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: WorkbenchListFocusContextKey, primary: KeyCode.End, handler: accessor => listFocusLast(accessor) @@ -374,7 +374,7 @@ export function registerCommands(): void { KeybindingsRegistry.registerCommandAndKeybindingRule({ id: 'list.focusLastChild', - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: WorkbenchListFocusContextKey, primary: null, handler: accessor => listFocusLast(accessor, { fromFocused: true }) @@ -405,7 +405,7 @@ export function registerCommands(): void { KeybindingsRegistry.registerCommandAndKeybindingRule({ id: 'list.select', - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: WorkbenchListFocusContextKey, primary: KeyCode.Enter, mac: { @@ -436,7 +436,7 @@ export function registerCommands(): void { KeybindingsRegistry.registerCommandAndKeybindingRule({ id: 'list.selectAll', - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: ContextKeyExpr.and(WorkbenchListFocusContextKey, WorkbenchListSupportsMultiSelectContextKey), primary: KeyMod.CtrlCmd | KeyCode.KEY_A, handler: (accessor) => { @@ -452,7 +452,7 @@ export function registerCommands(): void { KeybindingsRegistry.registerCommandAndKeybindingRule({ id: 'list.toggleExpand', - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: WorkbenchListFocusContextKey, primary: KeyCode.Space, handler: (accessor) => { @@ -472,7 +472,7 @@ export function registerCommands(): void { KeybindingsRegistry.registerCommandAndKeybindingRule({ id: 'list.clear', - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: ContextKeyExpr.and(WorkbenchListFocusContextKey, WorkbenchListHasSelectionOrFocus), primary: KeyCode.Escape, handler: (accessor) => { @@ -518,7 +518,7 @@ export function registerCommands(): void { KeybindingsRegistry.registerCommandAndKeybindingRule({ id: 'workbench.action.closeWindow', // close the window when the last editor is closed by reusing the same keybinding - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: ContextKeyExpr.and(NoEditorsVisibleContext, SingleEditorGroupsContext), primary: KeyMod.CtrlCmd | KeyCode.KEY_W, handler: accessor => { @@ -529,7 +529,7 @@ export function registerCommands(): void { KeybindingsRegistry.registerCommandAndKeybindingRule({ id: 'workbench.action.exitZenMode', - weight: KeybindingsRegistry.WEIGHT.editorContrib(-1000), + weight: KeybindingWeight.EditorContrib - 1000, handler(accessor: ServicesAccessor, configurationOrName: any) { const partService = accessor.get(IPartService); partService.toggleZenMode(); @@ -540,7 +540,7 @@ export function registerCommands(): void { KeybindingsRegistry.registerCommandAndKeybindingRule({ id: QUIT_ID, - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, handler(accessor: ServicesAccessor) { const windowsService = accessor.get(IWindowsService); windowsService.quit(); diff --git a/src/vs/workbench/electron-browser/main.contribution.ts b/src/vs/workbench/electron-browser/main.contribution.ts index 847b5e6972f..e408207987d 100644 --- a/src/vs/workbench/electron-browser/main.contribution.ts +++ b/src/vs/workbench/electron-browser/main.contribution.ts @@ -19,7 +19,7 @@ import { registerCommands, QUIT_ID } from 'vs/workbench/electron-browser/command import { AddRootFolderAction, GlobalRemoveRootFolderAction, OpenWorkspaceAction, SaveWorkspaceAsAction, OpenWorkspaceConfigFileAction, DuplicateWorkspaceInNewWindowAction, OpenFileFolderAction, OpenFileAction, OpenFolderAction } from 'vs/workbench/browser/actions/workspaceActions'; import { ContextKeyExpr, RawContextKey } from 'vs/platform/contextkey/common/contextkey'; import { inQuickOpenContext, getQuickNavigateHandler } from 'vs/workbench/browser/parts/quickopen/quickopen'; -import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry'; +import { KeybindingsRegistry, KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; import { CommandsRegistry } from 'vs/platform/commands/common/commands'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; @@ -135,7 +135,7 @@ const recentFilesPickerContext = ContextKeyExpr.and(inQuickOpenContext, ContextK const quickOpenNavigateNextInRecentFilesPickerId = 'workbench.action.quickOpenNavigateNextInRecentFilesPicker'; KeybindingsRegistry.registerCommandAndKeybindingRule({ id: quickOpenNavigateNextInRecentFilesPickerId, - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(50), + weight: KeybindingWeight.WorkbenchContrib + 50, handler: getQuickNavigateHandler(quickOpenNavigateNextInRecentFilesPickerId, true), when: recentFilesPickerContext, primary: KeyMod.CtrlCmd | KeyCode.KEY_R, @@ -145,7 +145,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({ const quickOpenNavigatePreviousInRecentFilesPicker = 'workbench.action.quickOpenNavigatePreviousInRecentFilesPicker'; KeybindingsRegistry.registerCommandAndKeybindingRule({ id: quickOpenNavigatePreviousInRecentFilesPicker, - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(50), + weight: KeybindingWeight.WorkbenchContrib + 50, handler: getQuickNavigateHandler(quickOpenNavigatePreviousInRecentFilesPicker, false), when: recentFilesPickerContext, primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_R, @@ -425,6 +425,11 @@ configurationRegistry.registerConfiguration({ 'description': nls.localize('openDefaultSettings', "Controls if opening settings also opens an editor showing all default settings."), 'default': true }, + 'workbench.settings.openDefaultKeybindings': { + 'type': 'boolean', + 'description': nls.localize('openDefaultKeybindings', "Controls if opening keybinding settings also opens an editor showing all default keybindings."), + 'default': true + }, 'workbench.sideBar.location': { 'type': 'string', 'enum': ['left', 'right'], diff --git a/src/vs/workbench/electron-browser/main.ts b/src/vs/workbench/electron-browser/main.ts index 96bcb26b2a0..05c7a8a054e 100644 --- a/src/vs/workbench/electron-browser/main.ts +++ b/src/vs/workbench/electron-browser/main.ts @@ -195,10 +195,7 @@ function createStorageService(workspaceService: IWorkspaceContextService, enviro if (disableStorage) { storage = inMemoryLocalStorageInstance; } else { - // TODO@Ben remove me after a while - perf.mark('willAccessLocalStorage'); storage = window.localStorage; - perf.mark('didAccessLocalStorage'); } return new StorageService(storage, storage, workspaceId, secondaryWorkspaceId); diff --git a/src/vs/workbench/electron-browser/shell.ts b/src/vs/workbench/electron-browser/shell.ts index 73dde75f2bb..24e8b1f7cc7 100644 --- a/src/vs/workbench/electron-browser/shell.ts +++ b/src/vs/workbench/electron-browser/shell.ts @@ -41,7 +41,7 @@ import { IIntegrityService } from 'vs/platform/integrity/common/integrity'; import { EditorWorkerServiceImpl } from 'vs/editor/common/services/editorWorkerServiceImpl'; import { IEditorWorkerService } from 'vs/editor/common/services/editorWorkerService'; import { ExtensionService } from 'vs/workbench/services/extensions/electron-browser/extensionService'; -import { IStorageService } from 'vs/platform/storage/common/storage'; +import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection'; import { InstantiationService } from 'vs/platform/instantiation/common/instantiationService'; @@ -91,12 +91,13 @@ import { NotificationService } from 'vs/workbench/services/notification/common/n import { IDialogService } from 'vs/platform/dialogs/common/dialogs'; import { DialogService } from 'vs/workbench/services/dialogs/electron-browser/dialogService'; import { DialogChannel } from 'vs/platform/dialogs/common/dialogIpc'; -import { EventType, addDisposableListener, addClass } from 'vs/base/browser/dom'; +import { EventType, addDisposableListener, addClass, getTotalHeight, getTotalWidth } from 'vs/base/browser/dom'; import { IOpenerService } from 'vs/platform/opener/common/opener'; import { OpenerService } from 'vs/editor/browser/services/openerService'; import { SearchHistoryService } from 'vs/workbench/services/search/node/searchHistoryService'; import { MulitExtensionManagementService } from 'vs/platform/extensionManagement/common/multiExtensionManagement'; import { ExtensionManagementServerService } from 'vs/workbench/services/extensions/node/extensionManagementServerService'; +import { Parts, Position } from 'vs/workbench/services/part/common/partService'; /** * Services that we require for the Shell @@ -188,6 +189,9 @@ export class WorkbenchShell extends Disposable { // Startup Workbench workbench.startup().done(startupInfos => { + // Remove splash screen + this._removePartsSplash(); + // Set lifecycle phase to `Runnning` so that other contributions can now do something this.lifecycleService.phase = LifecyclePhase.Running; @@ -508,13 +512,74 @@ export class WorkbenchShell extends Disposable { // Keep font info for next startup around saveFontInfo(this.storageService); + this._savePartsSplash(); + // Dispose Workbench if (this.workbench) { this.workbench.dispose(reason); } } + + private static readonly PARTS_SPLASH_ID = 'monaco-parts-splash'; + + private _savePartsSplash() { + + // capture html-structure + let state = this.contextService.getWorkbenchState(); + let html = `
`; + + // title part + let titleHeight: number; + { + let part = this.workbench.getContainer(Parts.TITLEBAR_PART); + let height = getTotalHeight(part); + let bg = part.style.backgroundColor || 'inhert'; + html += `
`; + titleHeight = height; + } + + // activitybar-part + let left = this.workbench.getSideBarPosition() === Position.LEFT; + let activityPartWidth: number; + { + let part = this.workbench.getContainer(Parts.ACTIVITYBAR_PART); + let width = getTotalWidth(part); + let bg = part.style.backgroundColor || 'inhert'; + html += `
`; + activityPartWidth = width; + } + + // sidebar-part (only for folder/workspace cases) + if (state !== WorkbenchState.EMPTY) { + let part = this.workbench.getContainer(Parts.SIDEBAR_PART); + let width = getTotalWidth(part); + let bg = part.style.backgroundColor || 'inhert'; + html += `
`; + } + + // statusbar-part + { + let part = this.workbench.getContainer(Parts.STATUSBAR_PART); + let height = getTotalHeight(part); + let bg = part.style.backgroundColor || 'inhert'; + html += `
`; + } + + html += '\n
'; + + // store per workspace or globally + this.storageService.store('parts-splash', html, state === WorkbenchState.EMPTY ? StorageScope.GLOBAL : StorageScope.WORKSPACE); + } + + private _removePartsSplash(): void { + let element = document.getElementById(WorkbenchShell.PARTS_SPLASH_ID); + if (element) { + element.remove(); + } + } } + registerThemingParticipant((theme: ITheme, collector: ICssStyleCollector) => { // Foreground diff --git a/src/vs/workbench/parts/codeEditor/codeEditor.contribution.ts b/src/vs/workbench/parts/codeEditor/codeEditor.contribution.ts index cc4c07f981a..a4085223ade 100644 --- a/src/vs/workbench/parts/codeEditor/codeEditor.contribution.ts +++ b/src/vs/workbench/parts/codeEditor/codeEditor.contribution.ts @@ -6,6 +6,7 @@ import './electron-browser/accessibility'; import './electron-browser/inspectKeybindings'; import './electron-browser/largeFileOptimizations'; +import './electron-browser/menubarRegistrations'; import './electron-browser/menuPreventer'; import './electron-browser/selectionClipboard'; import './electron-browser/textMate/inspectTMScopes'; diff --git a/src/vs/workbench/parts/codeEditor/electron-browser/accessibility.ts b/src/vs/workbench/parts/codeEditor/electron-browser/accessibility.ts index a9e4ec6741e..c7242e8ecdc 100644 --- a/src/vs/workbench/parts/codeEditor/electron-browser/accessibility.ts +++ b/src/vs/workbench/parts/codeEditor/electron-browser/accessibility.ts @@ -30,7 +30,7 @@ import * as platform from 'vs/base/common/platform'; import { alert } from 'vs/base/browser/ui/aria/aria'; import { IOpenerService } from 'vs/platform/opener/common/opener'; import URI from 'vs/base/common/uri'; -import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry'; +import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; const CONTEXT_ACCESSIBILITY_WIDGET_VISIBLE = new RawContextKey('accessibilityHelpWidgetVisible', false); @@ -286,7 +286,8 @@ class ShowAccessibilityHelpAction extends EditorAction { precondition: null, kbOpts: { kbExpr: EditorContextKeys.focus, - primary: KeyMod.Alt | KeyCode.F1 + primary: KeyMod.Alt | KeyCode.F1, + weight: KeybindingWeight.EditorContrib } }); } @@ -309,7 +310,7 @@ registerEditorCommand(new AccessibilityHelpCommand({ precondition: CONTEXT_ACCESSIBILITY_WIDGET_VISIBLE, handler: x => x.hide(), kbOpts: { - weight: KeybindingsRegistry.WEIGHT.editorContrib(100), + weight: KeybindingWeight.EditorContrib + 100, kbExpr: EditorContextKeys.focus, primary: KeyCode.Escape, secondary: [KeyMod.Shift | KeyCode.Escape] } diff --git a/src/vs/workbench/parts/codeEditor/electron-browser/menubarRegistrations.ts b/src/vs/workbench/parts/codeEditor/electron-browser/menubarRegistrations.ts new file mode 100644 index 00000000000..02d2ee2f366 --- /dev/null +++ b/src/vs/workbench/parts/codeEditor/electron-browser/menubarRegistrations.ts @@ -0,0 +1,138 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +'use strict'; + +import * as nls from 'vs/nls'; +import { MenuRegistry, MenuId } from 'vs/platform/actions/common/actions'; + +selectionMenuRegistration(); + +function selectionMenuRegistration() { + MenuRegistry.appendMenuItem(MenuId.MenubarSelectionMenu, { + group: '1_basic', + command: { + id: 'editor.action.selectAll', + title: nls.localize({ key: 'miSelectAll', comment: ['&& denotes a mnemonic'] }, "&&Select All") + }, + order: 1 + }); + + MenuRegistry.appendMenuItem(MenuId.MenubarSelectionMenu, { + group: '1_basic', + command: { + id: 'editor.action.smartSelect.grow', + title: nls.localize({ key: 'miSmartSelectGrow', comment: ['&& denotes a mnemonic'] }, "&&Expand Selection") + }, + order: 2 + }); + + MenuRegistry.appendMenuItem(MenuId.MenubarSelectionMenu, { + group: '1_basic', + command: { + id: 'editor.action.smartSelect.shrink', + title: nls.localize({ key: 'miSmartSelectShrink', comment: ['&& denotes a mnemonic'] }, "&&Shrink Selection") + }, + order: 3 + }); + + MenuRegistry.appendMenuItem(MenuId.MenubarSelectionMenu, { + group: '2_line', + command: { + id: 'editor.action.copyLinesUpAction', + title: nls.localize({ key: 'miCopyLinesUp', comment: ['&& denotes a mnemonic'] }, "&&Copy Line Up") + }, + order: 1 + }); + + MenuRegistry.appendMenuItem(MenuId.MenubarSelectionMenu, { + group: '2_line', + command: { + id: 'editor.action.copyLinesDownAction', + title: nls.localize({ key: 'miCopyLinesDown', comment: ['&& denotes a mnemonic'] }, "Co&&py Line Down") + }, + order: 2 + }); + + MenuRegistry.appendMenuItem(MenuId.MenubarSelectionMenu, { + group: '2_line', + command: { + id: 'editor.action.moveLinesUpAction', + title: nls.localize({ key: 'miMoveLinesUp', comment: ['&& denotes a mnemonic'] }, "Mo&&ve Line Up") + }, + order: 3 + }); + + MenuRegistry.appendMenuItem(MenuId.MenubarSelectionMenu, { + group: '2_line', + command: { + id: 'editor.action.moveLinesDownAction', + title: nls.localize({ key: 'miMoveLinesDown', comment: ['&& denotes a mnemonic'] }, "Move &&Line Down") + }, + order: 4 + }); + + MenuRegistry.appendMenuItem(MenuId.MenubarSelectionMenu, { + group: '3_multi', + command: { + id: 'workbench.action.toggleMultiCursorModifier', + title: nls.localize('miMultiCursorAlt', "Switch to Alt+Click for Multi-Cursor") + }, + order: 1 + }); + + MenuRegistry.appendMenuItem(MenuId.MenubarSelectionMenu, { + group: '3_multi', + command: { + id: 'editor.action.insertCursorAbove', + title: nls.localize({ key: 'miInsertCursorAbove', comment: ['&& denotes a mnemonic'] }, "&&Add Cursor Above") + }, + order: 2 + }); + + MenuRegistry.appendMenuItem(MenuId.MenubarSelectionMenu, { + group: '3_multi', + command: { + id: 'editor.action.insertCursorBelow', + title: nls.localize({ key: 'miInsertCursorBelow', comment: ['&& denotes a mnemonic'] }, "A&&dd Cursor Below") + }, + order: 3 + }); + + MenuRegistry.appendMenuItem(MenuId.MenubarSelectionMenu, { + group: '3_multi', + command: { + id: 'editor.action.insertCursorAtEndOfEachLineSelected', + title: nls.localize({ key: 'miInsertCursorAtEndOfEachLineSelected', comment: ['&& denotes a mnemonic'] }, "Add C&&ursors to Line Ends") + }, + order: 4 + }); + + MenuRegistry.appendMenuItem(MenuId.MenubarSelectionMenu, { + group: '3_multi', + command: { + id: 'editor.action.addSelectionToNextFindMatch', + title: nls.localize({ key: 'miAddSelectionToNextFindMatch', comment: ['&& denotes a mnemonic'] }, "Add &&Next Occurrence") + }, + order: 5 + }); + + MenuRegistry.appendMenuItem(MenuId.MenubarSelectionMenu, { + group: '3_multi', + command: { + id: 'editor.action.addSelectionToPreviousFindMatch', + title: nls.localize({ key: 'miAddSelectionToPreviousFindMatch', comment: ['&& denotes a mnemonic'] }, "Add P&&revious Occurrence") + }, + order: 6 + }); + + MenuRegistry.appendMenuItem(MenuId.MenubarSelectionMenu, { + group: '3_multi', + command: { + id: 'editor.action.selectHighlights', + title: nls.localize({ key: 'miSelectHighlights', comment: ['&& denotes a mnemonic'] }, "Select All &&Occurrences") + }, + order: 7 + }); +} diff --git a/src/vs/workbench/parts/codeEditor/electron-browser/toggleWordWrap.ts b/src/vs/workbench/parts/codeEditor/electron-browser/toggleWordWrap.ts index 882cd01e68b..947ec9d0f42 100644 --- a/src/vs/workbench/parts/codeEditor/electron-browser/toggleWordWrap.ts +++ b/src/vs/workbench/parts/codeEditor/electron-browser/toggleWordWrap.ts @@ -18,6 +18,7 @@ import { InternalEditorOptions, EDITOR_DEFAULTS } from 'vs/editor/common/config/ import { ITextResourceConfigurationService } from 'vs/editor/common/services/resourceConfiguration'; import { ICodeEditor } from 'vs/editor/browser/editorBrowser'; import { INotificationService } from 'vs/platform/notification/common/notification'; +import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; const transientWordWrapState = 'transientWordWrapState'; const isWordWrapMinifiedKey = 'isWordWrapMinified'; @@ -141,7 +142,8 @@ class ToggleWordWrapAction extends EditorAction { precondition: null, kbOpts: { kbExpr: null, - primary: KeyMod.Alt | KeyCode.KEY_Z + primary: KeyMod.Alt | KeyCode.KEY_Z, + weight: KeybindingWeight.EditorContrib } }); } diff --git a/src/vs/workbench/parts/comments/electron-browser/commentsEditorContribution.ts b/src/vs/workbench/parts/comments/electron-browser/commentsEditorContribution.ts index 1c35b032439..619170cb23a 100644 --- a/src/vs/workbench/parts/comments/electron-browser/commentsEditorContribution.ts +++ b/src/vs/workbench/parts/comments/electron-browser/commentsEditorContribution.ts @@ -19,7 +19,7 @@ import * as modes from 'vs/editor/common/modes'; import { peekViewEditorBackground, peekViewResultsBackground, peekViewResultsSelectionBackground } from 'vs/editor/contrib/referenceSearch/referencesWidget'; import { IContextKey, IContextKeyService, RawContextKey } from 'vs/platform/contextkey/common/contextkey'; import { ServicesAccessor, IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; -import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry'; +import { KeybindingsRegistry, KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; import { INotificationService } from 'vs/platform/notification/common/notification'; import { editorForeground } from 'vs/platform/theme/common/colorRegistry'; import { IThemeService, registerThemingParticipant } from 'vs/platform/theme/common/themeService'; @@ -447,7 +447,7 @@ registerEditorAction(NextCommentThreadAction); KeybindingsRegistry.registerCommandAndKeybindingRule({ id: 'closeReviewPanel', - weight: KeybindingsRegistry.WEIGHT.editorContrib(), + weight: KeybindingWeight.EditorContrib, primary: KeyCode.Escape, secondary: [KeyMod.Shift | KeyCode.Escape], when: ctxReviewPanelVisible, diff --git a/src/vs/workbench/parts/debug/browser/breakpointsView.ts b/src/vs/workbench/parts/debug/browser/breakpointsView.ts index edf399c0e2a..ef55c3cdac8 100644 --- a/src/vs/workbench/parts/debug/browser/breakpointsView.ts +++ b/src/vs/workbench/parts/debug/browser/breakpointsView.ts @@ -39,6 +39,14 @@ import { ViewletPanel, IViewletPanelOptions } from 'vs/workbench/browser/parts/v const $ = dom.$; +function createCheckbox(): HTMLInputElement { + const checkbox = $('input'); + checkbox.type = 'checkbox'; + checkbox.tabIndex = -1; + + return checkbox; +} + export class BreakpointsView extends ViewletPanel { private static readonly MAX_VISIBLE_FILES = 9; @@ -297,8 +305,7 @@ class BreakpointsRenderer implements IRenderer$('input'); - data.checkbox.type = 'checkbox'; + data.checkbox = createCheckbox(); data.toDispose = []; data.toDispose.push(dom.addStandardDisposableListener(data.checkbox, 'change', (e) => { this.debugService.enableOrDisableBreakpoints(!data.context.enabled, data.context); @@ -365,8 +372,7 @@ class ExceptionBreakpointsRenderer implements IRenderer$('input'); - data.checkbox.type = 'checkbox'; + data.checkbox = createCheckbox(); data.toDispose = []; data.toDispose.push(dom.addStandardDisposableListener(data.checkbox, 'change', (e) => { this.debugService.enableOrDisableBreakpoints(!data.context.enabled, data.context); @@ -416,8 +422,7 @@ class FunctionBreakpointsRenderer implements IRenderer$('input'); - data.checkbox.type = 'checkbox'; + data.checkbox = createCheckbox(); data.toDispose = []; data.toDispose.push(dom.addStandardDisposableListener(data.checkbox, 'change', (e) => { this.debugService.enableOrDisableBreakpoints(!data.context.enabled, data.context); diff --git a/src/vs/workbench/parts/debug/browser/debugActions.ts b/src/vs/workbench/parts/debug/browser/debugActions.ts index 26931ec59c2..04fd4058642 100644 --- a/src/vs/workbench/parts/debug/browser/debugActions.ts +++ b/src/vs/workbench/parts/debug/browser/debugActions.ts @@ -9,6 +9,7 @@ import * as lifecycle from 'vs/base/common/lifecycle'; import { TPromise } from 'vs/base/common/winjs.base'; import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding'; import { ICommandService } from 'vs/platform/commands/common/commands'; +import * as aria from 'vs/base/browser/ui/aria/aria'; import { IWorkspaceContextService, WorkbenchState } from 'vs/platform/workspace/common/workspace'; import { IFileService } from 'vs/platform/files/common/files'; import { IDebugService, State, ISession, IThread, IEnablement, IBreakpoint, IStackFrame, REPL_ID, SessionState } @@ -691,6 +692,7 @@ export class ClearReplAction extends AbstractDebugAction { public run(): TPromise { this.debugService.removeReplExpressions(); + aria.status(nls.localize('debugConsoleCleared', "Debug console was cleared")); // focus back to repl return this.panelService.openPanel(REPL_ID, true); diff --git a/src/vs/workbench/parts/debug/browser/debugCommands.ts b/src/vs/workbench/parts/debug/browser/debugCommands.ts index bc62db248c5..7c09e489c3a 100644 --- a/src/vs/workbench/parts/debug/browser/debugCommands.ts +++ b/src/vs/workbench/parts/debug/browser/debugCommands.ts @@ -8,7 +8,7 @@ import { KeyCode, KeyMod } from 'vs/base/common/keyCodes'; import { TPromise } from 'vs/base/common/winjs.base'; import { List } from 'vs/base/browser/ui/list/listWidget'; import * as errors from 'vs/base/common/errors'; -import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry'; +import { KeybindingsRegistry, KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; import { IListService } from 'vs/platform/list/browser/listService'; import { IWorkspaceContextService, WorkbenchState } from 'vs/platform/workspace/common/workspace'; import { IDebugService, IEnablement, CONTEXT_BREAKPOINTS_FOCUSED, CONTEXT_WATCH_EXPRESSIONS_FOCUSED, CONTEXT_VARIABLES_FOCUSED, EDITOR_CONTRIBUTION_ID, IDebugEditorContribution, CONTEXT_IN_DEBUG_MODE, CONTEXT_EXPRESSION_SELECTED, CONTEXT_BREAKPOINT_SELECTED } from 'vs/workbench/parts/debug/common/debug'; @@ -32,7 +32,7 @@ export function registerCommands(): void { KeybindingsRegistry.registerCommandAndKeybindingRule({ id: 'debug.toggleBreakpoint', - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(5), + weight: KeybindingWeight.WorkbenchContrib + 5, when: ContextKeyExpr.and(CONTEXT_BREAKPOINTS_FOCUSED, InputFocusedContext.toNegated()), primary: KeyCode.Space, handler: (accessor) => { @@ -50,7 +50,7 @@ export function registerCommands(): void { KeybindingsRegistry.registerCommandAndKeybindingRule({ id: 'debug.enableOrDisableBreakpoint', - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, primary: undefined, when: EditorContextKeys.editorTextFocus, handler: (accessor) => { @@ -72,7 +72,7 @@ export function registerCommands(): void { KeybindingsRegistry.registerCommandAndKeybindingRule({ id: 'debug.renameWatchExpression', - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(5), + weight: KeybindingWeight.WorkbenchContrib + 5, when: CONTEXT_WATCH_EXPRESSIONS_FOCUSED, primary: KeyCode.F2, mac: { primary: KeyCode.Enter }, @@ -93,7 +93,7 @@ export function registerCommands(): void { KeybindingsRegistry.registerCommandAndKeybindingRule({ id: 'debug.setVariable', - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(5), + weight: KeybindingWeight.WorkbenchContrib + 5, when: CONTEXT_VARIABLES_FOCUSED, primary: KeyCode.F2, mac: { primary: KeyCode.Enter }, @@ -114,7 +114,7 @@ export function registerCommands(): void { KeybindingsRegistry.registerCommandAndKeybindingRule({ id: 'debug.removeWatchExpression', - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: ContextKeyExpr.and(CONTEXT_WATCH_EXPRESSIONS_FOCUSED, CONTEXT_EXPRESSION_SELECTED.toNegated()), primary: KeyCode.Delete, mac: { primary: KeyMod.CtrlCmd | KeyCode.Backspace }, @@ -135,7 +135,7 @@ export function registerCommands(): void { KeybindingsRegistry.registerCommandAndKeybindingRule({ id: 'debug.removeBreakpoint', - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: ContextKeyExpr.and(CONTEXT_BREAKPOINTS_FOCUSED, CONTEXT_BREAKPOINT_SELECTED.toNegated()), primary: KeyCode.Delete, mac: { primary: KeyMod.CtrlCmd | KeyCode.Backspace }, @@ -159,7 +159,7 @@ export function registerCommands(): void { KeybindingsRegistry.registerCommandAndKeybindingRule({ id: 'debug.installAdditionalDebuggers', - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: undefined, primary: undefined, handler: (accessor) => { @@ -175,7 +175,7 @@ export function registerCommands(): void { KeybindingsRegistry.registerCommandAndKeybindingRule({ id: ADD_CONFIGURATION_ID, - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: undefined, primary: undefined, handler: (accessor, launchUri: string) => { @@ -220,7 +220,7 @@ export function registerCommands(): void { return TPromise.as(null); }; KeybindingsRegistry.registerCommandAndKeybindingRule({ - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, primary: KeyMod.Shift | KeyCode.F9, when: EditorContextKeys.editorTextFocus, id: TOGGLE_INLINE_BREAKPOINT_ID, @@ -246,7 +246,7 @@ export function registerCommands(): void { KeybindingsRegistry.registerCommandAndKeybindingRule({ id: 'debug.openBreakpointToSide', - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: CONTEXT_BREAKPOINTS_FOCUSED, primary: KeyMod.CtrlCmd | KeyCode.Enter, secondary: [KeyMod.Alt | KeyCode.Enter], diff --git a/src/vs/workbench/parts/debug/browser/debugEditorActions.ts b/src/vs/workbench/parts/debug/browser/debugEditorActions.ts index a8e56c2bc4c..d6332e2f2ca 100644 --- a/src/vs/workbench/parts/debug/browser/debugEditorActions.ts +++ b/src/vs/workbench/parts/debug/browser/debugEditorActions.ts @@ -16,6 +16,7 @@ import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet'; import { ICodeEditor } from 'vs/editor/browser/editorBrowser'; import { IEditorService } from 'vs/workbench/services/editor/common/editorService'; import { openBreakpointSource } from 'vs/workbench/parts/debug/browser/breakpointsView'; +import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; export const TOGGLE_BREAKPOINT_ID = 'editor.debug.action.toggleBreakpoint'; class ToggleBreakpointAction extends EditorAction { @@ -27,7 +28,8 @@ class ToggleBreakpointAction extends EditorAction { precondition: null, kbOpts: { kbExpr: EditorContextKeys.editorTextFocus, - primary: KeyCode.F9 + primary: KeyCode.F9, + weight: KeybindingWeight.EditorContrib } }); } @@ -197,7 +199,8 @@ class ShowDebugHoverAction extends EditorAction { precondition: CONTEXT_IN_DEBUG_MODE, kbOpts: { kbExpr: EditorContextKeys.editorTextFocus, - primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_I) + primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_I), + weight: KeybindingWeight.EditorContrib } }); } diff --git a/src/vs/workbench/parts/debug/electron-browser/breakpointWidget.ts b/src/vs/workbench/parts/debug/electron-browser/breakpointWidget.ts index b6781653be4..c3f164601c0 100644 --- a/src/vs/workbench/parts/debug/electron-browser/breakpointWidget.ts +++ b/src/vs/workbench/parts/debug/electron-browser/breakpointWidget.ts @@ -33,6 +33,7 @@ import { transparent, editorForeground } from 'vs/platform/theme/common/colorReg import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection'; import { IDecorationOptions } from 'vs/editor/common/editorCommon'; import { CodeEditorWidget } from 'vs/editor/browser/widget/codeEditorWidget'; +import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; const $ = dom.$; const IPrivateBreakpointWidgetService = createDecorator('privateBreakopintWidgetService'); @@ -296,7 +297,8 @@ class AcceptBreakpointWidgetInputAction extends EditorCommand { precondition: CONTEXT_BREAKPOINT_WIDGET_VISIBLE, kbOpts: { kbExpr: CONTEXT_IN_BREAKPOINT_WIDGET, - primary: KeyCode.Enter + primary: KeyCode.Enter, + weight: KeybindingWeight.EditorContrib } }); } @@ -315,7 +317,8 @@ class CloseBreakpointWidgetCommand extends EditorCommand { kbOpts: { kbExpr: EditorContextKeys.textInputFocus, primary: KeyCode.Escape, - secondary: [KeyMod.Shift | KeyCode.Escape] + secondary: [KeyMod.Shift | KeyCode.Escape], + weight: KeybindingWeight.EditorContrib } }); } diff --git a/src/vs/workbench/parts/debug/electron-browser/debug.contribution.ts b/src/vs/workbench/parts/debug/electron-browser/debug.contribution.ts index a9b45955e1f..816bea9c85c 100644 --- a/src/vs/workbench/parts/debug/electron-browser/debug.contribution.ts +++ b/src/vs/workbench/parts/debug/electron-browser/debug.contribution.ts @@ -10,7 +10,7 @@ import { KeyMod, KeyCode } from 'vs/base/common/keyCodes'; import { SyncActionDescriptor, MenuRegistry, MenuId } from 'vs/platform/actions/common/actions'; import { Registry } from 'vs/platform/registry/common/platform'; import { registerSingleton } from 'vs/platform/instantiation/common/extensions'; -import { KeybindingsRegistry, IKeybindings } from 'vs/platform/keybinding/common/keybindingsRegistry'; +import { KeybindingWeight, IKeybindings } from 'vs/platform/keybinding/common/keybindingsRegistry'; import { IConfigurationRegistry, Extensions as ConfigurationExtensions } from 'vs/platform/configuration/common/configurationRegistry'; import { IWorkbenchActionRegistry, Extensions as WorkbenchActionRegistryExtensions } from 'vs/workbench/common/actions'; import { ToggleViewletAction, Extensions as ViewletExtensions, ViewletRegistry, ViewletDescriptor } from 'vs/workbench/browser/viewlet'; @@ -130,7 +130,7 @@ const debugCategory = nls.localize('debugCategory', "Debug"); registry.registerWorkbenchAction(new SyncActionDescriptor( StartAction, StartAction.ID, StartAction.LABEL, { primary: KeyCode.F5 }, CONTEXT_NOT_IN_DEBUG_MODE), 'Debug: Start Debugging', debugCategory); registry.registerWorkbenchAction(new SyncActionDescriptor(StepOverAction, StepOverAction.ID, StepOverAction.LABEL, { primary: KeyCode.F10 }, CONTEXT_IN_DEBUG_MODE), 'Debug: Step Over', debugCategory); -registry.registerWorkbenchAction(new SyncActionDescriptor(StepIntoAction, StepIntoAction.ID, StepIntoAction.LABEL, { primary: KeyCode.F11 }, CONTEXT_IN_DEBUG_MODE, KeybindingsRegistry.WEIGHT.workbenchContrib(1)), 'Debug: Step Into', debugCategory); +registry.registerWorkbenchAction(new SyncActionDescriptor(StepIntoAction, StepIntoAction.ID, StepIntoAction.LABEL, { primary: KeyCode.F11 }, CONTEXT_IN_DEBUG_MODE, KeybindingWeight.WorkbenchContrib + 1), 'Debug: Step Into', debugCategory); registry.registerWorkbenchAction(new SyncActionDescriptor(StepOutAction, StepOutAction.ID, StepOutAction.LABEL, { primary: KeyMod.Shift | KeyCode.F11 }, CONTEXT_IN_DEBUG_MODE), 'Debug: Step Out', debugCategory); registry.registerWorkbenchAction(new SyncActionDescriptor(RestartAction, RestartAction.ID, RestartAction.LABEL, { primary: KeyMod.Shift | KeyMod.CtrlCmd | KeyCode.F5 }, CONTEXT_IN_DEBUG_MODE), 'Debug: Restart', debugCategory); registry.registerWorkbenchAction(new SyncActionDescriptor(StopAction, StopAction.ID, StopAction.LABEL, { primary: KeyMod.Shift | KeyCode.F5 }, CONTEXT_IN_DEBUG_MODE), 'Debug: Stop', debugCategory); diff --git a/src/vs/workbench/parts/debug/electron-browser/repl.ts b/src/vs/workbench/parts/debug/electron-browser/repl.ts index 35b974a511b..10bbf3327fa 100644 --- a/src/vs/workbench/parts/debug/electron-browser/repl.ts +++ b/src/vs/workbench/parts/debug/electron-browser/repl.ts @@ -11,6 +11,7 @@ import { TPromise } from 'vs/base/common/winjs.base'; import * as errors from 'vs/base/common/errors'; import { IAction } from 'vs/base/common/actions'; import * as dom from 'vs/base/browser/dom'; +import * as aria from 'vs/base/browser/ui/aria/aria'; import { isMacintosh } from 'vs/base/common/platform'; import { CancellationToken } from 'vs/base/common/cancellation'; import { KeyCode } from 'vs/base/common/keyCodes'; @@ -46,6 +47,7 @@ import { IDebugService, REPL_ID, DEBUG_SCHEME, CONTEXT_IN_DEBUG_REPL } from 'vs/ import { HistoryNavigator } from 'vs/base/common/history'; import { IHistoryNavigationWidget } from 'vs/base/browser/history'; import { createAndBindHistoryNavigationWidgetScopedContextKeyService } from 'vs/platform/widget/browser/contextScopedHistoryWidget'; +import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; const $ = dom.$; @@ -210,6 +212,7 @@ export class Repl extends Panel implements IPrivateReplService, IHistoryNavigati const historyInput = previous ? this.history.previous() : this.history.next(); if (historyInput) { this.replInput.setValue(historyInput); + aria.status(historyInput); // always leave cursor at the end. this.replInput.setPosition({ lineNumber: 1, column: historyInput.length + 1 }); this.historyNavigationEnablement.set(true); @@ -313,7 +316,8 @@ class AcceptReplInputAction extends EditorAction { precondition: CONTEXT_IN_DEBUG_REPL, kbOpts: { kbExpr: EditorContextKeys.textInputFocus, - primary: KeyCode.Enter + primary: KeyCode.Enter, + weight: KeybindingWeight.EditorContrib } }); } diff --git a/src/vs/workbench/parts/debug/electron-browser/watchExpressionsView.ts b/src/vs/workbench/parts/debug/electron-browser/watchExpressionsView.ts index 3ff99dc0765..0963de50db7 100644 --- a/src/vs/workbench/parts/debug/electron-browser/watchExpressionsView.ts +++ b/src/vs/workbench/parts/debug/electron-browser/watchExpressionsView.ts @@ -177,7 +177,7 @@ class WatchExpressionsActionProvider implements IActionProvider { if (element instanceof Variable) { const variable = element; if (!variable.hasChildren) { - actions.push(new CopyValueAction(CopyValueAction.ID, CopyValueAction.LABEL, variable.value, this.debugService)); + actions.push(new CopyValueAction(CopyValueAction.ID, CopyValueAction.LABEL, variable, this.debugService)); } actions.push(new Separator()); } diff --git a/src/vs/workbench/parts/emmet/browser/actions/showEmmetCommands.ts b/src/vs/workbench/parts/emmet/browser/actions/showEmmetCommands.ts index ea18fc77506..c144579d4aa 100644 --- a/src/vs/workbench/parts/emmet/browser/actions/showEmmetCommands.ts +++ b/src/vs/workbench/parts/emmet/browser/actions/showEmmetCommands.ts @@ -12,6 +12,7 @@ import { registerEditorAction, EditorAction, ServicesAccessor } from 'vs/editor/ import { IQuickOpenService } from 'vs/platform/quickOpen/common/quickOpen'; import { EditorContextKeys } from 'vs/editor/common/editorContextKeys'; import { ICodeEditor } from 'vs/editor/browser/editorBrowser'; +import { MenuId } from 'vs/platform/actions/common/actions'; const EMMET_COMMANDS_PREFIX = '>Emmet: '; @@ -23,6 +24,12 @@ class ShowEmmetCommandsAction extends EditorAction { label: nls.localize('showEmmetCommands', "Show Emmet Commands"), alias: 'Show Emmet Commands', precondition: EditorContextKeys.writable, + menubarOpts: { + menuId: MenuId.MenubarEditMenu, + group: '5_insert', + title: nls.localize({ key: 'miShowEmmetCommands', comment: ['&& denotes a mnemonic'] }, "E&&mmet..."), + order: 4 + } }); } diff --git a/src/vs/workbench/parts/emmet/electron-browser/actions/expandAbbreviation.ts b/src/vs/workbench/parts/emmet/electron-browser/actions/expandAbbreviation.ts index 5a9512f8999..42968c4b846 100644 --- a/src/vs/workbench/parts/emmet/electron-browser/actions/expandAbbreviation.ts +++ b/src/vs/workbench/parts/emmet/electron-browser/actions/expandAbbreviation.ts @@ -10,6 +10,8 @@ import { registerEditorAction } from 'vs/editor/browser/editorExtensions'; import { EditorContextKeys } from 'vs/editor/common/editorContextKeys'; import { KeyCode } from 'vs/base/common/keyCodes'; import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey'; +import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; +import { MenuId } from 'vs/platform/actions/common/actions'; class ExpandAbbreviationAction extends EmmetEditorAction { @@ -26,7 +28,14 @@ class ExpandAbbreviationAction extends EmmetEditorAction { EditorContextKeys.editorTextFocus, EditorContextKeys.tabDoesNotMoveFocus, ContextKeyExpr.has('config.emmet.triggerExpansionOnTab') - ) + ), + weight: KeybindingWeight.EditorContrib + }, + menubarOpts: { + menuId: MenuId.MenubarEditMenu, + group: '5_insert', + title: nls.localize({ key: 'miEmmetExpandAbbreviation', comment: ['&& denotes a mnemonic'] }, "Emmet: E&&xpand Abbreviation"), + order: 3 } }); diff --git a/src/vs/workbench/parts/execution/electron-browser/execution.contribution.ts b/src/vs/workbench/parts/execution/electron-browser/execution.contribution.ts index c7b217c4413..8687e81f62d 100644 --- a/src/vs/workbench/parts/execution/electron-browser/execution.contribution.ts +++ b/src/vs/workbench/parts/execution/electron-browser/execution.contribution.ts @@ -20,7 +20,7 @@ import { getDefaultTerminalWindows, getDefaultTerminalLinuxReady, DEFAULT_TERMIN import { WinTerminalService, MacTerminalService, LinuxTerminalService } from 'vs/workbench/parts/execution/electron-browser/terminalService'; import { IHistoryService } from 'vs/workbench/services/history/common/history'; import { ResourceContextKey } from 'vs/workbench/common/resources'; -import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry'; +import { KeybindingsRegistry, KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; import { IFileService } from 'vs/platform/files/common/files'; import { IListService } from 'vs/platform/list/browser/listService'; import { getMultiSelectedResources } from 'vs/workbench/parts/files/browser/files'; @@ -113,7 +113,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({ id: OPEN_NATIVE_CONSOLE_COMMAND_ID, primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_C, when: KEYBINDING_CONTEXT_TERMINAL_NOT_FOCUSED, - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, handler: (accessor) => { const historyService = accessor.get(IHistoryService); const terminalService = accessor.get(ITerminalService); diff --git a/src/vs/workbench/parts/extensions/electron-browser/extensionEditor.ts b/src/vs/workbench/parts/extensions/electron-browser/extensionEditor.ts index d7f89ad8915..4f850fe16ea 100644 --- a/src/vs/workbench/parts/extensions/electron-browser/extensionEditor.ts +++ b/src/vs/workbench/parts/extensions/electron-browser/extensionEditor.ts @@ -43,7 +43,7 @@ import { KeybindingLabel } from 'vs/base/browser/ui/keybindingLabel/keybindingLa import { IContextKeyService, RawContextKey, IContextKey } from 'vs/platform/contextkey/common/contextkey'; import { Command } from 'vs/editor/browser/editorExtensions'; import { IEditorService } from 'vs/workbench/services/editor/common/editorService'; -import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry'; +import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; import { Color } from 'vs/base/common/color'; import { assign } from 'vs/base/common/objects'; import { INotificationService } from 'vs/platform/notification/common/notification'; @@ -1121,7 +1121,8 @@ const showCommand = new ShowExtensionEditorFindCommand({ id: 'editor.action.extensioneditor.showfind', precondition: KEYBINDING_CONTEXT_EXTENSIONEDITOR_WEBVIEW_FOCUS, kbOpts: { - primary: KeyMod.CtrlCmd | KeyCode.KEY_F + primary: KeyMod.CtrlCmd | KeyCode.KEY_F, + weight: KeybindingWeight.EditorContrib } }); -KeybindingsRegistry.registerCommandAndKeybindingRule(showCommand.toCommandAndKeybindingRule(KeybindingsRegistry.WEIGHT.editorContrib())); +showCommand.register(); diff --git a/src/vs/workbench/parts/extensions/electron-browser/extensionTipsService.ts b/src/vs/workbench/parts/extensions/electron-browser/extensionTipsService.ts index 728d2b9e9b3..ab53ea18d8b 100644 --- a/src/vs/workbench/parts/extensions/electron-browser/extensionTipsService.ts +++ b/src/vs/workbench/parts/extensions/electron-browser/extensionTipsService.ts @@ -43,7 +43,6 @@ import { assign } from 'vs/base/common/objects'; import URI from 'vs/base/common/uri'; import { areSameExtensions, getGalleryExtensionIdFromLocal } from 'vs/platform/extensionManagement/common/extensionManagementUtil'; import { IExperimentService, ExperimentActionType, ExperimentState } from 'vs/workbench/parts/experiments/node/experimentService'; -import { Schemas } from 'vs/base/common/network'; const milliSecondsInADay = 1000 * 60 * 60 * 24; const choiceNever = localize('neverShowAgain', "Don't Show Again"); @@ -500,7 +499,7 @@ export class ExtensionTipsService extends Disposable implements IExtensionTipsSe let hasSuggestion = false; const uri = model.uri; - if (!uri || uri.scheme !== Schemas.file) { + if (!uri || !this.fileService.canHandleResource(uri)) { return; } @@ -892,7 +891,7 @@ export class ExtensionTipsService extends Disposable implements IExtensionTipsSe private fetchDynamicWorkspaceRecommendations(): TPromise { if (this.contextService.getWorkbenchState() !== WorkbenchState.FOLDER - || this.contextService.getWorkspace().folders[0].uri.scheme !== Schemas.file // #54483: check with @Ramya + || !this.fileService.canHandleResource(this.contextService.getWorkspace().folders[0].uri) || this._dynamicWorkspaceRecommendations.length || !this._extensionsRecommendationsUrl) { return TPromise.as(null); diff --git a/src/vs/workbench/parts/files/electron-browser/fileActions.contribution.ts b/src/vs/workbench/parts/files/electron-browser/fileActions.contribution.ts index 36e761a3e9b..dbca8fb34ef 100644 --- a/src/vs/workbench/parts/files/electron-browser/fileActions.contribution.ts +++ b/src/vs/workbench/parts/files/electron-browser/fileActions.contribution.ts @@ -14,7 +14,7 @@ import { KeyMod, KeyChord, KeyCode } from 'vs/base/common/keyCodes'; import { openWindowCommand, REVEAL_IN_OS_COMMAND_ID, COPY_PATH_COMMAND_ID, REVEAL_IN_EXPLORER_COMMAND_ID, OPEN_TO_SIDE_COMMAND_ID, REVERT_FILE_COMMAND_ID, SAVE_FILE_COMMAND_ID, SAVE_FILE_LABEL, SAVE_FILE_AS_COMMAND_ID, SAVE_FILE_AS_LABEL, SAVE_ALL_IN_GROUP_COMMAND_ID, OpenEditorsGroupContext, COMPARE_WITH_SAVED_COMMAND_ID, COMPARE_RESOURCE_COMMAND_ID, SELECT_FOR_COMPARE_COMMAND_ID, ResourceSelectedForCompareContext, REVEAL_IN_OS_LABEL, DirtyEditorContext, COMPARE_SELECTED_COMMAND_ID, REMOVE_ROOT_FOLDER_COMMAND_ID, REMOVE_ROOT_FOLDER_LABEL, SAVE_FILES_COMMAND_ID, COPY_RELATIVE_PATH_COMMAND_ID } from 'vs/workbench/parts/files/electron-browser/fileCommands'; import { CommandsRegistry, ICommandHandler } from 'vs/platform/commands/common/commands'; import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey'; -import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry'; +import { KeybindingsRegistry, KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; import { isWindows, isMacintosh } from 'vs/base/common/platform'; import { FilesExplorerFocusCondition, ExplorerRootContext, ExplorerFolderContext, ExplorerResourceNotReadonlyContext } from 'vs/workbench/parts/files/common/files'; import { ADD_ROOT_FOLDER_COMMAND_ID, ADD_ROOT_FOLDER_LABEL } from 'vs/workbench/browser/actions/workspaceCommands'; @@ -50,7 +50,7 @@ const explorerCommandsWeightBonus = 10; // give our commands a little bit more w const RENAME_ID = 'renameFile'; KeybindingsRegistry.registerCommandAndKeybindingRule({ id: RENAME_ID, - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(explorerCommandsWeightBonus), + weight: KeybindingWeight.WorkbenchContrib + explorerCommandsWeightBonus, when: ContextKeyExpr.and(FilesExplorerFocusCondition, ExplorerRootContext.toNegated(), ExplorerResourceNotReadonlyContext), primary: KeyCode.F2, mac: { @@ -62,7 +62,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({ const MOVE_FILE_TO_TRASH_ID = 'moveFileToTrash'; KeybindingsRegistry.registerCommandAndKeybindingRule({ id: MOVE_FILE_TO_TRASH_ID, - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(explorerCommandsWeightBonus), + weight: KeybindingWeight.WorkbenchContrib + explorerCommandsWeightBonus, when: ContextKeyExpr.and(FilesExplorerFocusCondition, ExplorerRootContext.toNegated(), ExplorerResourceNotReadonlyContext), primary: KeyCode.Delete, mac: { @@ -74,7 +74,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({ const DELETE_FILE_ID = 'deleteFile'; KeybindingsRegistry.registerCommandAndKeybindingRule({ id: DELETE_FILE_ID, - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(explorerCommandsWeightBonus), + weight: KeybindingWeight.WorkbenchContrib + explorerCommandsWeightBonus, when: ContextKeyExpr.and(FilesExplorerFocusCondition, ExplorerRootContext.toNegated(), ExplorerResourceNotReadonlyContext), primary: KeyMod.Shift | KeyCode.Delete, mac: { @@ -86,7 +86,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({ const COPY_FILE_ID = 'filesExplorer.copy'; KeybindingsRegistry.registerCommandAndKeybindingRule({ id: COPY_FILE_ID, - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(explorerCommandsWeightBonus), + weight: KeybindingWeight.WorkbenchContrib + explorerCommandsWeightBonus, when: ContextKeyExpr.and(FilesExplorerFocusCondition, ExplorerRootContext.toNegated()), primary: KeyMod.CtrlCmd | KeyCode.KEY_C, handler: copyFileHandler, @@ -96,7 +96,7 @@ const PASTE_FILE_ID = 'filesExplorer.paste'; KeybindingsRegistry.registerCommandAndKeybindingRule({ id: PASTE_FILE_ID, - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(explorerCommandsWeightBonus), + weight: KeybindingWeight.WorkbenchContrib + explorerCommandsWeightBonus, when: ContextKeyExpr.and(FilesExplorerFocusCondition, ExplorerResourceNotReadonlyContext), primary: KeyMod.CtrlCmd | KeyCode.KEY_V, handler: pasteFileHandler diff --git a/src/vs/workbench/parts/files/electron-browser/fileCommands.ts b/src/vs/workbench/parts/files/electron-browser/fileCommands.ts index 1bbf1bcaec2..5be4ed15f03 100644 --- a/src/vs/workbench/parts/files/electron-browser/fileCommands.ts +++ b/src/vs/workbench/parts/files/electron-browser/fileCommands.ts @@ -29,7 +29,7 @@ import { IFileService } from 'vs/platform/files/common/files'; import { IUntitledEditorService } from 'vs/workbench/services/untitled/common/untitledEditorService'; import { IEditorViewState } from 'vs/editor/common/editorCommon'; import { getCodeEditor } from 'vs/editor/browser/editorBrowser'; -import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry'; +import { KeybindingsRegistry, KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; import { KeyMod, KeyCode, KeyChord } from 'vs/base/common/keyCodes'; import { isWindows, isMacintosh, isLinux } from 'vs/base/common/platform'; import { ITextModelService } from 'vs/editor/common/services/resolverService'; @@ -234,7 +234,7 @@ CommandsRegistry.registerCommand({ }); KeybindingsRegistry.registerCommandAndKeybindingRule({ - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: ExplorerFocusCondition, primary: KeyMod.CtrlCmd | KeyCode.Enter, mac: { @@ -272,7 +272,7 @@ let provider: FileOnDiskContentProvider; KeybindingsRegistry.registerCommandAndKeybindingRule({ id: COMPARE_WITH_SAVED_COMMAND_ID, when: undefined, - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyCode.KEY_D), handler: (accessor, resource: URI | object) => { if (!provider) { @@ -365,7 +365,7 @@ function revealResourcesInOS(resources: URI[], windowsService: IWindowsService, KeybindingsRegistry.registerCommandAndKeybindingRule({ id: REVEAL_IN_OS_COMMAND_ID, - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: EditorContextKeys.focus.toNegated(), primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.KEY_R, win: { @@ -378,7 +378,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({ }); KeybindingsRegistry.registerCommandAndKeybindingRule({ - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: undefined, primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyCode.KEY_R), id: 'workbench.action.files.revealActiveFileInWindows', @@ -419,7 +419,7 @@ function resourcesToClipboard(resources: URI[], clipboardService: IClipboardServ } KeybindingsRegistry.registerCommandAndKeybindingRule({ - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: EditorContextKeys.focus.toNegated(), primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.KEY_C, win: { @@ -433,7 +433,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({ }); KeybindingsRegistry.registerCommandAndKeybindingRule({ - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: EditorContextKeys.focus.toNegated(), primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyMod.Alt | KeyCode.KEY_C, win: { @@ -447,7 +447,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({ }); KeybindingsRegistry.registerCommandAndKeybindingRule({ - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: undefined, primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyCode.KEY_P), id: 'workbench.action.files.copyPathOfActiveFile', @@ -486,7 +486,7 @@ CommandsRegistry.registerCommand({ KeybindingsRegistry.registerCommandAndKeybindingRule({ id: SAVE_FILE_AS_COMMAND_ID, - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: undefined, primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_S, handler: (accessor, resourceOrObject: URI | object | { from: string }) => { @@ -504,7 +504,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({ KeybindingsRegistry.registerCommandAndKeybindingRule({ when: undefined, - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, primary: KeyMod.CtrlCmd | KeyCode.KEY_S, id: SAVE_FILE_COMMAND_ID, handler: (accessor, resource: URI | object) => { diff --git a/src/vs/workbench/parts/localizations/electron-browser/localizations.contribution.ts b/src/vs/workbench/parts/localizations/electron-browser/localizations.contribution.ts index 340f821e0f4..ef0e09b3c44 100644 --- a/src/vs/workbench/parts/localizations/electron-browser/localizations.contribution.ts +++ b/src/vs/workbench/parts/localizations/electron-browser/localizations.contribution.ts @@ -141,19 +141,15 @@ export class LocalizationWorkbenchContribution extends Disposable implements IWo return; } - const extensionIdPostfix = this.getPossibleChineseMapping(locale); - const ceintlExtensionSearch = this.galleryService.query({ names: [`MS-CEINTL.vscode-language-pack-${extensionIdPostfix}`], pageSize: 1 }); - const tagSearch = this.galleryService.query({ text: `tag:lp-${locale}`, pageSize: 1 }); - - TPromise.join([ceintlExtensionSearch, tagSearch]).then(([ceintlResult, tagResult]) => { - if (ceintlResult.total === 0 && tagResult.total === 0) { + this.galleryService.query({ text: `tag:lp-${locale}` }).then(tagResult => { + if (tagResult.total === 0) { return; } - const extensionToInstall = ceintlResult.total === 1 ? ceintlResult.firstPage[0] : tagResult.total === 1 ? tagResult.firstPage[0] : null; - const extensionToFetchTranslationsFrom = extensionToInstall || (tagResult.total > 0 ? tagResult.firstPage[0] : null); + const extensionToInstall = tagResult.total === 1 ? tagResult.firstPage[0] : tagResult.firstPage.filter(e => e.publisher === 'MS-CEINTL' && e.name.indexOf('vscode-language-pack') === 0)[0]; + const extensionToFetchTranslationsFrom = extensionToInstall || tagResult.firstPage[0]; - if (!extensionToFetchTranslationsFrom || !extensionToFetchTranslationsFrom.assets.manifest) { + if (!extensionToFetchTranslationsFrom.assets.manifest) { return; } @@ -236,11 +232,6 @@ export class LocalizationWorkbenchContribution extends Disposable implements IWo } - private getPossibleChineseMapping(locale: string): string { - locale = locale.toLowerCase(); - return locale === 'zh-cn' ? 'zh-hans' : locale === 'zh-tw' ? 'zh-hant' : locale; - } - private getLanguagePackExtension(language: string): TPromise { return this.localizationService.getLanguageIds(LanguageType.Core) .then(coreLanguages => { diff --git a/src/vs/workbench/parts/markers/electron-browser/markers.contribution.ts b/src/vs/workbench/parts/markers/electron-browser/markers.contribution.ts index b9ba41a1e7a..8ed5e8f4b35 100644 --- a/src/vs/workbench/parts/markers/electron-browser/markers.contribution.ts +++ b/src/vs/workbench/parts/markers/electron-browser/markers.contribution.ts @@ -10,7 +10,7 @@ import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey'; import { Extensions, IConfigurationRegistry } from 'vs/platform/configuration/common/configurationRegistry'; import { IPanelService } from 'vs/workbench/services/panel/common/panelService'; import { IWorkbenchActionRegistry, Extensions as ActionExtensions } from 'vs/workbench/common/actions'; -import { KeybindingsRegistry, IKeybindings } from 'vs/platform/keybinding/common/keybindingsRegistry'; +import { KeybindingsRegistry, KeybindingWeight, IKeybindings } from 'vs/platform/keybinding/common/keybindingsRegistry'; import { KeyCode, KeyMod } from 'vs/base/common/keyCodes'; import { localize } from 'vs/nls'; import { Marker, RelatedInformation } from 'vs/workbench/parts/markers/electron-browser/markersModel'; @@ -27,7 +27,7 @@ import './markersFileDecorations'; KeybindingsRegistry.registerCommandAndKeybindingRule({ id: Constants.MARKER_OPEN_SIDE_ACTION_ID, - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: ContextKeyExpr.and(Constants.MarkerFocusContextKey), primary: KeyMod.CtrlCmd | KeyCode.Enter, mac: { @@ -41,7 +41,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({ KeybindingsRegistry.registerCommandAndKeybindingRule({ id: Constants.MARKER_SHOW_PANEL_ID, - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: undefined, primary: undefined, handler: (accessor, args: any) => { diff --git a/src/vs/workbench/parts/outline/electron-browser/outlinePanel.ts b/src/vs/workbench/parts/outline/electron-browser/outlinePanel.ts index 3634c35da04..c61097b03d3 100644 --- a/src/vs/workbench/parts/outline/electron-browser/outlinePanel.ts +++ b/src/vs/workbench/parts/outline/electron-browser/outlinePanel.ts @@ -39,7 +39,7 @@ import { ContextKeyExpr, IContextKey, IContextKeyService } from 'vs/platform/con import { IContextMenuService } from 'vs/platform/contextview/browser/contextView'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding'; -import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry'; +import { KeybindingsRegistry, KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; import { WorkbenchTree } from 'vs/platform/list/browser/listService'; import { IMarkerService, MarkerSeverity } from 'vs/platform/markers/common/markers'; import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage'; @@ -489,6 +489,10 @@ export class OutlinePanel extends ViewletPanel { return; } + if (TreeElement.empty(model)) { + return this._showMessage(localize('no-symbols', "No symbols found in document '{0}'", posix.basename(textModel.uri.path))); + } + let newSize = TreeElement.size(model); if (newSize > 7500) { // this is a workaround for performance issues with the tree: https://github.com/Microsoft/vscode/issues/18180 @@ -717,7 +721,7 @@ async function goUpOrDownToHighligthedElement(accessor: ServicesAccessor, prev: KeybindingsRegistry.registerCommandAndKeybindingRule({ id: 'outline.focusDownHighlighted', - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, primary: KeyCode.DownArrow, when: ContextKeyExpr.and(OutlineViewFiltered, OutlineViewFocused), handler: accessor => goUpOrDownToHighligthedElement(accessor, false) @@ -725,7 +729,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({ KeybindingsRegistry.registerCommandAndKeybindingRule({ id: 'outline.focusUpHighlighted', - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, primary: KeyCode.UpArrow, when: ContextKeyExpr.and(OutlineViewFiltered, OutlineViewFocused), handler: accessor => goUpOrDownToHighligthedElement(accessor, true) diff --git a/src/vs/workbench/parts/output/browser/outputActions.ts b/src/vs/workbench/parts/output/browser/outputActions.ts index 8543c9bb2b0..4334f2886d6 100644 --- a/src/vs/workbench/parts/output/browser/outputActions.ts +++ b/src/vs/workbench/parts/output/browser/outputActions.ts @@ -6,6 +6,7 @@ import { TPromise } from 'vs/base/common/winjs.base'; import * as nls from 'vs/nls'; +import * as aria from 'vs/base/browser/ui/aria/aria'; import { IAction, Action } from 'vs/base/common/actions'; import { IOutputService, OUTPUT_PANEL_ID, IOutputChannelRegistry, Extensions as OutputExt, IOutputChannelIdentifier, COMMAND_OPEN_LOG_VIEWER } from 'vs/workbench/parts/output/common/output'; import { SelectActionItem } from 'vs/base/browser/ui/actionbar/actionbar'; @@ -49,6 +50,7 @@ export class ClearOutputAction extends Action { public run(): TPromise { this.outputService.getActiveChannel().clear(); + aria.status(nls.localize('outputCleared', "Output was cleared")); return TPromise.as(true); } diff --git a/src/vs/workbench/parts/preferences/browser/keybindingsEditorContribution.ts b/src/vs/workbench/parts/preferences/browser/keybindingsEditorContribution.ts index 2a3fab73b51..c72f997106d 100644 --- a/src/vs/workbench/parts/preferences/browser/keybindingsEditorContribution.ts +++ b/src/vs/workbench/parts/preferences/browser/keybindingsEditorContribution.ts @@ -29,6 +29,7 @@ import { WindowsNativeResolvedKeybinding } from 'vs/workbench/services/keybindin import { themeColorFromId, ThemeColor } from 'vs/platform/theme/common/themeService'; import { overviewRulerInfo, overviewRulerError } from 'vs/editor/common/view/editorColorRegistry'; import { IModelDeltaDecoration, ITextModel, TrackedRangeStickiness, OverviewRulerLane } from 'vs/editor/common/model'; +import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; const NLS_LAUNCH_MESSAGE = nls.localize('defineKeybinding.start', "Define Keybinding"); const NLS_KB_LAYOUT_ERROR_MESSAGE = nls.localize('defineKeybinding.kbLayoutErrorMessage', "You won't be able to produce this key combination under your current keyboard layout."); @@ -365,7 +366,8 @@ class DefineKeybindingCommand extends EditorCommand { precondition: ContextKeyExpr.and(EditorContextKeys.writable, EditorContextKeys.languageId.isEqualTo('jsonc')), kbOpts: { kbExpr: EditorContextKeys.editorTextFocus, - primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_K) + primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_K), + weight: KeybindingWeight.EditorContrib } }); } diff --git a/src/vs/workbench/parts/preferences/browser/media/configure-inverse.svg b/src/vs/workbench/parts/preferences/browser/media/configure-inverse.svg new file mode 100644 index 00000000000..61baaea2b8b --- /dev/null +++ b/src/vs/workbench/parts/preferences/browser/media/configure-inverse.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/vs/workbench/parts/preferences/browser/media/configure.svg b/src/vs/workbench/parts/preferences/browser/media/configure.svg new file mode 100644 index 00000000000..3dec2ba50fd --- /dev/null +++ b/src/vs/workbench/parts/preferences/browser/media/configure.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/vs/workbench/parts/preferences/browser/media/settingsEditor2.css b/src/vs/workbench/parts/preferences/browser/media/settingsEditor2.css index 5b926a5fcd5..4301d35c32f 100644 --- a/src/vs/workbench/parts/preferences/browser/media/settingsEditor2.css +++ b/src/vs/workbench/parts/preferences/browser/media/settingsEditor2.css @@ -8,16 +8,14 @@ } .settings-editor { - padding-top: 11px; - padding-left: 5px; - max-width: 1100px; + padding: 11px 0px 24px 0px; + max-width: 1000px; margin: auto; } /* header styling */ .settings-editor > .settings-header { - padding-left: 17px; - padding-right: 11px; + padding-right: 24px; box-sizing: border-box; margin: auto; } @@ -30,19 +28,6 @@ opacity: .7; } -.settings-editor > .settings-header > .settings-advanced-customization .open-settings-button, -.settings-editor > .settings-header > .settings-advanced-customization .open-settings-button:hover, -.settings-editor > .settings-header > .settings-advanced-customization .open-settings-button:active { - padding: 0; - text-decoration: underline; - display: inline; -} - -.settings-editor > .settings-header > .settings-advanced-customization { - opacity: .7; - margin-top: 8px; -} - .settings-editor > .settings-header > .settings-preview-header > .settings-preview-warning { text-align: right; text-transform: uppercase; @@ -68,17 +53,25 @@ .settings-editor > .settings-header .search-container > .settings-search-input > .monaco-inputbox .input { font-size: 14px; - padding-left: 10px; + padding-left: 9px; } .settings-editor > .settings-header > .settings-header-controls { - margin-top: 8px; - height: 30px; + height: 29px; display: flex; + border-bottom: solid 1px; } -.settings-editor > .settings-header .settings-tabs-widget > .monaco-action-bar .action-item:not(:first-child) .action-label { - margin-left: 14px; +.vs .settings-editor > .settings-header > .settings-header-controls { + color: #6c6c6c; +} + +.vs-dark .settings-editor > .settings-header > .settings-header-controls { + color: #3c3c3c; +} + +.settings-editor > .settings-header .settings-tabs-widget > .monaco-action-bar .action-item .action-label { + margin-right: 0px; } .settings-editor > .settings-header .settings-tabs-widget .monaco-action-bar .action-item .dropdown-icon { @@ -88,25 +81,63 @@ .settings-editor > .settings-header > .settings-header-controls .settings-header-controls-right { margin-left: auto; - padding-top: 3px; + padding-top: 4px; display: flex; } -.settings-editor > .settings-header > .settings-header-controls .settings-header-controls-right #configured-only-checkbox { - flex-shrink: 0; +.settings-editor > .settings-header > .settings-header-controls .settings-header-controls-right .toolbar-toggle-more { + display: block; + width: 22px; + height: 22px; + background-position: center; + background-repeat: no-repeat; } -.settings-editor > .settings-header > .settings-header-controls .settings-header-controls-right .configured-only-label { - white-space: nowrap; - margin-right: 10px; - margin-left: 2px; - opacity: 0.7; +.vs .settings-editor > .settings-header > .settings-header-controls .settings-header-controls-right .toolbar-toggle-more { + background-image: url('configure.svg'); +} + +.vs-dark .settings-editor > .settings-header > .settings-header-controls .settings-header-controls-right .toolbar-toggle-more { + background-image: url('configure-inverse.svg'); +} + +.vs .settings-editor.showing-modified-only > .settings-header > .settings-header-controls .settings-header-controls-right .toolbar-toggle-more::before { + border-color : #fff; +} + +.vs-dark .settings-editor.showing-modified-only > .settings-header > .settings-header-controls .settings-header-controls-right .toolbar-toggle-more::before { + border-color : #000; +} + +.settings-editor.showing-modified-only > .settings-header > .settings-header-controls .settings-header-controls-right .toolbar-toggle-more::before { + content: ""; + width: 6px; + height: 6px; + position: absolute; + top: 3px; + right: 3px; + border-radius: 10px; + border: 1px solid; +} + +.settings-editor > .settings-header > .settings-header-controls .settings-tabs-widget > .monaco-action-bar .action-item { + padding: 0px; /* padding must be on action-label because it has the bottom-border, because that's where the .checked class is */ +} + +.settings-editor > .settings-header > .settings-header-controls .settings-tabs-widget > .monaco-action-bar .action-item .action-label { + text-transform: none; + font-size: 13px; + + padding-bottom: 4px; + padding-top: 7px; + padding-left: 9px; + padding-right: 9px; } .settings-editor > .settings-body { display: flex; margin: auto; - max-width: 1100px; + max-width: 1000px; justify-content: space-between; } @@ -116,14 +147,15 @@ .settings-editor > .settings-body .settings-tree-container .monaco-tree-wrapper, .settings-editor > .settings-body > .settings-tree-container .setting-measure-container { - /** Allocate space for the scrollbar */ - width: calc(100% - 11px) + /** Match header padding, leave room for scrollbar on the outside */ + width: calc(100% - 24px) } .settings-editor > .settings-body .settings-toc-container { - width: 175px; - margin-right: 5px; + width: 160px; + padding-top: 8px; + box-sizing: border-box; } .settings-editor > .settings-body .settings-toc-container.hidden { @@ -142,20 +174,40 @@ display: none; } +.settings-editor > .settings-body .settings-toc-container .monaco-scrollable-element > .shadow { + display: none; +} + .settings-editor > .settings-body .settings-toc-container .monaco-tree-row .settings-toc-entry { overflow: hidden; text-overflow: ellipsis; line-height: 22px; + opacity: 0.7; +} + +.settings-editor > .settings-body .settings-toc-container .monaco-tree-row.has-children > .content:before { + opacity: 0.7; +} + +.settings-editor > .settings-body .settings-toc-container .monaco-tree-row.has-children.selected > .content:before { + opacity: 1; } .settings-editor > .settings-body .settings-toc-container .monaco-tree-row .settings-toc-entry.no-results { opacity: 0.5; } +.settings-editor > .settings-body .settings-toc-container .monaco-tree-row.selected .settings-toc-entry { + font-weight: bold; + opacity: 1; +} + .settings-editor > .settings-body .settings-tree-container { flex: 1; - max-width: 875px; + max-width: 792px; margin-right: 1px; /* So the item doesn't blend into the edge of the view container */ + padding-top: 8px; + box-sizing: border-box; border-spacing: 0; border-collapse: separate; position: relative; @@ -309,7 +361,7 @@ } .settings-editor > .settings-body > .settings-tree-container .settings-group-level-1.settings-group-first { - padding-top: 4px; + padding-top: 7px; } .settings-editor > .settings-body .settings-feedback-button { diff --git a/src/vs/workbench/parts/preferences/browser/preferencesActions.ts b/src/vs/workbench/parts/preferences/browser/preferencesActions.ts index 4c19890f0f3..70beb50fe4f 100644 --- a/src/vs/workbench/parts/preferences/browser/preferencesActions.ts +++ b/src/vs/workbench/parts/preferences/browser/preferencesActions.ts @@ -125,6 +125,24 @@ export class OpenGlobalKeybindingsFileAction extends Action { } } +export class OpenDefaultKeybindingsFileAction extends Action { + + public static readonly ID = 'workbench.action.openDefaultKeybindingsFile'; + public static readonly LABEL = nls.localize('openDefaultKeybindingsFile', "Open Default Keyboard Shortcuts File"); + + constructor( + id: string, + label: string, + @IPreferencesService private preferencesService: IPreferencesService + ) { + super(id, label); + } + + public run(event?: any): TPromise { + return this.preferencesService.openDefaultKeybindingsFile(); + } +} + export class OpenWorkspaceSettingsAction extends Action { public static readonly ID = 'workbench.action.openWorkspaceSettings'; diff --git a/src/vs/workbench/parts/preferences/browser/settingsEditor2.ts b/src/vs/workbench/parts/preferences/browser/settingsEditor2.ts index 8b6d31130d0..161504cd879 100644 --- a/src/vs/workbench/parts/preferences/browser/settingsEditor2.ts +++ b/src/vs/workbench/parts/preferences/browser/settingsEditor2.ts @@ -5,47 +5,43 @@ import * as DOM from 'vs/base/browser/dom'; import { Button } from 'vs/base/browser/ui/button/button'; +import { ToolBar } from 'vs/base/browser/ui/toolbar/toolbar'; +import { Action } from 'vs/base/common/actions'; import * as arrays from 'vs/base/common/arrays'; import { Delayer, ThrottledDelayer } from 'vs/base/common/async'; import { CancellationToken } from 'vs/base/common/cancellation'; import * as collections from 'vs/base/common/collections'; -import { Color, RGBA } from 'vs/base/common/color'; import { getErrorMessage, isPromiseCanceledError } from 'vs/base/common/errors'; import URI from 'vs/base/common/uri'; import { TPromise } from 'vs/base/common/winjs.base'; import { ITree, ITreeConfiguration } from 'vs/base/parts/tree/browser/tree'; -import { DefaultTreestyler, OpenMode } from 'vs/base/parts/tree/browser/treeDefaults'; +import { OpenMode, DefaultTreestyler } from 'vs/base/parts/tree/browser/treeDefaults'; import 'vs/css!./media/settingsEditor2'; import { localize } from 'vs/nls'; import { ConfigurationTarget, IConfigurationOverrides, IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; +import { IContextMenuService } from 'vs/platform/contextview/browser/contextView'; import { IEnvironmentService } from 'vs/platform/environment/common/environment'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { WorkbenchTree, WorkbenchTreeController } from 'vs/platform/list/browser/listService'; import { ILogService } from 'vs/platform/log/common/log'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; -import { editorBackground, focusBorder, foreground, registerColor } from 'vs/platform/theme/common/colorRegistry'; import { attachButtonStyler, attachStyler } from 'vs/platform/theme/common/styler'; -import { ICssStyleCollector, ITheme, IThemeService, registerThemingParticipant } from 'vs/platform/theme/common/themeService'; +import { IThemeService } from 'vs/platform/theme/common/themeService'; import { BaseEditor } from 'vs/workbench/browser/parts/editor/baseEditor'; import { EditorOptions, IEditor } from 'vs/workbench/common/editor'; import { SearchWidget, SettingsTarget, SettingsTargetsWidget } from 'vs/workbench/parts/preferences/browser/preferencesWidgets'; import { commonlyUsedData, tocData } from 'vs/workbench/parts/preferences/browser/settingsLayout'; -import { ISettingsEditorViewState, NonExpandableTree, resolveExtensionsSettings, resolveSettingsTree, SearchResultIdx, SearchResultModel, SettingsAccessibilityProvider, SettingsDataSource, SettingsRenderer, SettingsTreeController, SettingsTreeElement, SettingsTreeFilter, SettingsTreeGroupElement, SettingsTreeModel, SettingsTreeSettingElement } from 'vs/workbench/parts/preferences/browser/settingsTree'; +import { ISettingsEditorViewState, resolveExtensionsSettings, resolveSettingsTree, SearchResultIdx, SearchResultModel, SettingsRenderer, SettingsTree, SettingsTreeElement, SettingsTreeFilter, SettingsTreeGroupElement, SettingsTreeModel, SettingsTreeSettingElement, settingsHeaderForeground } from 'vs/workbench/parts/preferences/browser/settingsTree'; import { TOCDataSource, TOCRenderer, TOCTreeModel } from 'vs/workbench/parts/preferences/browser/tocTree'; import { CONTEXT_SETTINGS_EDITOR, CONTEXT_SETTINGS_FIRST_ROW_FOCUS, CONTEXT_SETTINGS_ROW_FOCUS, CONTEXT_SETTINGS_SEARCH_FOCUS, CONTEXT_TOC_ROW_FOCUS, IPreferencesSearchService, ISearchProvider } from 'vs/workbench/parts/preferences/common/preferences'; import { IPreferencesService, ISearchResult, ISettingsEditorModel } from 'vs/workbench/services/preferences/common/preferences'; import { SettingsEditor2Input } from 'vs/workbench/services/preferences/common/preferencesEditorInput'; import { DefaultSettingsEditorModel } from 'vs/workbench/services/preferences/common/preferencesModels'; +import { editorBackground, foreground } from 'vs/platform/theme/common/colorRegistry'; const $ = DOM.$; -export const settingItemInactiveSelectionBorder = registerColor('settings.inactiveSelectedItemBorder', { - dark: '#3F3F46', - light: '#CCCEDB', - hc: null -}, localize('settingItemInactiveSelectionBorder', "The color of the selected setting row border, when the settings list does not have focus.")); - export class SettingsEditor2 extends BaseEditor { public static readonly ID: string = 'workbench.editor.settings2'; @@ -56,12 +52,10 @@ export class SettingsEditor2 extends BaseEditor { private headerContainer: HTMLElement; private searchWidget: SearchWidget; private settingsTargetsWidget: SettingsTargetsWidget; - - private showConfiguredSettingsOnlyCheckbox: HTMLInputElement; + private toolbar: ToolBar; private settingsTreeContainer: HTMLElement; private settingsTree: WorkbenchTree; - private treeDataSource: SettingsDataSource; private tocTreeModel: TOCTreeModel; private settingsTreeModel: SettingsTreeModel; @@ -99,7 +93,8 @@ export class SettingsEditor2 extends BaseEditor { @IPreferencesSearchService private preferencesSearchService: IPreferencesSearchService, @ILogService private logService: ILogService, @IEnvironmentService private environmentService: IEnvironmentService, - @IContextKeyService contextKeyService: IContextKeyService + @IContextKeyService contextKeyService: IContextKeyService, + @IContextMenuService private contextMenuService: IContextMenuService ) { super(SettingsEditor2.ID, telemetryService, themeService); this.delayedFilterLogging = new Delayer(1000); @@ -203,26 +198,13 @@ export class SettingsEditor2 extends BaseEditor { })); this._register(this.searchWidget.onDidChange(() => this.onSearchInputChanged())); - const advancedCustomization = DOM.append(this.headerContainer, $('.settings-advanced-customization')); - const advancedCustomizationLabel = DOM.append(advancedCustomization, $('span.settings-advanced-customization-label')); - advancedCustomizationLabel.textContent = localize('advancedCustomizationLabel', "For advanced customizations open and edit") + ' '; - const openSettingsButton = this._register(new Button(advancedCustomization, { title: true, buttonBackground: null, buttonHoverBackground: null })); - this._register(attachButtonStyler(openSettingsButton, this.themeService, { - buttonBackground: Color.transparent.toString(), - buttonHoverBackground: Color.transparent.toString(), - buttonForeground: foreground - })); - openSettingsButton.label = localize('openSettingsLabel', "settings.json"); - openSettingsButton.element.classList.add('open-settings-button'); - - this._register(openSettingsButton.onDidClick(() => this.openSettingsFile())); - const headerControlsContainer = DOM.append(this.headerContainer, $('.settings-header-controls')); const targetWidgetContainer = DOM.append(headerControlsContainer, $('.settings-target-container')); this.settingsTargetsWidget = this._register(this.instantiationService.createInstance(SettingsTargetsWidget, targetWidgetContainer)); this.settingsTargetsWidget.settingsTarget = ConfigurationTarget.USER; this.settingsTargetsWidget.onDidTargetChange(() => { this.viewState.settingsTarget = this.settingsTargetsWidget.settingsTarget; + this.toolbar.context = this.settingsTargetsWidget.settingsTarget; this.settingsTreeModel.update(); this.refreshTreeAndMaintainFocus(); @@ -234,13 +216,17 @@ export class SettingsEditor2 extends BaseEditor { private createHeaderControls(parent: HTMLElement): void { const headerControlsContainerRight = DOM.append(parent, $('.settings-header-controls-right')); - this.showConfiguredSettingsOnlyCheckbox = DOM.append(headerControlsContainerRight, $('input#configured-only-checkbox')); - this.showConfiguredSettingsOnlyCheckbox.type = 'checkbox'; - const showConfiguredSettingsOnlyLabel = DOM.append(headerControlsContainerRight, $('label.configured-only-label')); - showConfiguredSettingsOnlyLabel.textContent = localize('showOverriddenOnly', "Show modified only"); - showConfiguredSettingsOnlyLabel.htmlFor = 'configured-only-checkbox'; + this.toolbar = new ToolBar(headerControlsContainerRight, this.contextMenuService, { + ariaLabel: localize('settingsToolbarLabel', "Settings Editor Actions"), + actionRunner: this.actionRunner + }); - this._register(DOM.addDisposableListener(this.showConfiguredSettingsOnlyCheckbox, 'change', e => this.onShowConfiguredOnlyClicked())); + const actions = [ + this.instantiationService.createInstance(ToggleShowModifiedOnlyAction, this, this.viewState), + this.instantiationService.createInstance(OpenSettingsAction) + ]; + this.toolbar.setActions([], actions)(); + this.toolbar.context = this.settingsTargetsWidget.settingsTarget; } private revealSetting(settingName: string): void { @@ -288,12 +274,29 @@ export class SettingsEditor2 extends BaseEditor { dataSource: tocDataSource, renderer: tocRenderer, controller: this.instantiationService.createInstance(WorkbenchTreeController, { openMode: OpenMode.DOUBLE_CLICK }), - filter: this.instantiationService.createInstance(SettingsTreeFilter, this.viewState) + filter: this.instantiationService.createInstance(SettingsTreeFilter, this.viewState), + styler: new DefaultTreestyler(DOM.createStyleSheet(), 'settings-toc-tree'), }, { showLoading: false, twistiePixels: 15 }); + this.tocTree.getHTMLElement().classList.add('settings-toc-tree'); + + this._register(attachStyler(this.themeService, { + listActiveSelectionBackground: editorBackground, + listActiveSelectionForeground: settingsHeaderForeground, + listFocusAndSelectionBackground: editorBackground, + listFocusAndSelectionForeground: settingsHeaderForeground, + listFocusBackground: editorBackground, + listFocusForeground: settingsHeaderForeground, + listHoverForeground: foreground, + listHoverBackground: editorBackground, + listInactiveSelectionBackground: editorBackground, + listInactiveSelectionForeground: settingsHeaderForeground, + }, colors => { + this.tocTree.style(colors); + })); this._register(this.tocTree.onDidChangeFocus(e => { const element = e.focus; @@ -307,7 +310,6 @@ export class SettingsEditor2 extends BaseEditor { this.settingsTree.setFocus(element); } } - })); this._register(this.tocTree.onDidFocus(() => { @@ -329,66 +331,18 @@ export class SettingsEditor2 extends BaseEditor { private createSettingsTree(parent: HTMLElement): void { this.settingsTreeContainer = DOM.append(parent, $('.settings-tree-container')); - this.treeDataSource = this.instantiationService.createInstance(SettingsDataSource, this.viewState); const renderer = this.instantiationService.createInstance(SettingsRenderer, this.settingsTreeContainer); this._register(renderer.onDidChangeSetting(e => this.onDidChangeSetting(e.key, e.value))); this._register(renderer.onDidOpenSettings(() => this.openSettingsFile())); this._register(renderer.onDidClickSettingLink(settingName => this.revealSetting(settingName))); - const treeClass = 'settings-editor-tree'; - this.settingsTree = this.instantiationService.createInstance(NonExpandableTree, this.settingsTreeContainer, - { - dataSource: this.treeDataSource, - renderer, - controller: this.instantiationService.createInstance(SettingsTreeController), - accessibilityProvider: this.instantiationService.createInstance(SettingsAccessibilityProvider), - filter: this.instantiationService.createInstance(SettingsTreeFilter, this.viewState), - styler: new DefaultTreestyler(DOM.createStyleSheet(), treeClass) - }, + this.settingsTree = this.instantiationService.createInstance(SettingsTree, + this.settingsTreeContainer, + this.viewState, { - ariaLabel: localize('treeAriaLabel', "Settings"), - showLoading: false, - indentPixels: 0, - twistiePixels: 0, + renderer }); - this._register(registerThemingParticipant((theme: ITheme, collector: ICssStyleCollector) => { - const activeBorderColor = theme.getColor(focusBorder); - if (activeBorderColor) { - collector.addRule(`.settings-editor > .settings-body > .settings-tree-container .monaco-tree:focus .monaco-tree-row.focused {outline: solid 1px ${activeBorderColor}; outline-offset: -1px; }`); - } - - const inactiveBorderColor = theme.getColor(settingItemInactiveSelectionBorder); - if (inactiveBorderColor) { - collector.addRule(`.settings-editor > .settings-body > .settings-tree-container .monaco-tree .monaco-tree-row.focused {outline: solid 1px ${inactiveBorderColor}; outline-offset: -1px; }`); - } - - const foregroundColor = theme.getColor(foreground); - if (foregroundColor) { - // Links appear inside other elements in markdown. CSS opacity acts like a mask. So we have to dynamically compute the description color to avoid - // applying an opacity to the link color. - const fgWithOpacity = new Color(new RGBA(foregroundColor.rgba.r, foregroundColor.rgba.g, foregroundColor.rgba.b, .7)); - collector.addRule(`.settings-editor > .settings-body > .settings-tree-container .setting-item .setting-item-description { color: ${fgWithOpacity}; }`); - } - })); - - this.settingsTree.getHTMLElement().classList.add(treeClass); - - this._register(attachStyler(this.themeService, { - listActiveSelectionBackground: editorBackground, - listActiveSelectionForeground: foreground, - listFocusAndSelectionBackground: editorBackground, - listFocusAndSelectionForeground: foreground, - listFocusBackground: editorBackground, - listFocusForeground: foreground, - listHoverForeground: foreground, - listHoverBackground: editorBackground, - listInactiveSelectionBackground: editorBackground, - listInactiveSelectionForeground: foreground - }, colors => { - this.settingsTree.style(colors); - })); - this._register(this.settingsTree.onDidChangeFocus(e => { this.settingsTree.setSelection([e.focus]); if (this.selectedElement) { @@ -444,12 +398,13 @@ export class SettingsEditor2 extends BaseEditor { })); } - private onShowConfiguredOnlyClicked(): void { - this.viewState.showConfiguredOnly = this.showConfiguredSettingsOnlyCheckbox.checked; - this.refreshTreeAndMaintainFocus(); - this.tocTree.refresh(); - this.settingsTree.setScrollPosition(0); - this.expandAll(this.settingsTree); + toggleShowModifiedOnly(): TPromise { + this.viewState.showConfiguredOnly = !this.viewState.showConfiguredOnly; + DOM.toggleClass(this.rootElement, 'showing-modified-only', this.viewState.showConfiguredOnly); + return this.refreshTreeAndMaintainFocus().then(() => { + this.settingsTree.setScrollPosition(0); + this.expandAll(this.settingsTree); + }); } private onDidChangeSetting(key: string, value: any): void { @@ -828,7 +783,7 @@ export class SettingsEditor2 extends BaseEditor { } private layoutTrees(dimension: DOM.Dimension): void { - const listHeight = dimension.height - (DOM.getDomNodePagePosition(this.headerContainer).height + 12 /*padding*/); + const listHeight = dimension.height - (DOM.getDomNodePagePosition(this.headerContainer).height + 11 /*padding*/); this.settingsTreeContainer.style.height = `${listHeight}px`; this.settingsTree.layout(listHeight, 800); @@ -837,8 +792,56 @@ export class SettingsEditor2 extends BaseEditor { this.settingsTree.refresh(selectedSetting); } - const tocHeight = listHeight - 5; // padding - this.tocTreeContainer.style.height = `${tocHeight}px`; - this.tocTree.layout(tocHeight, 175); + this.tocTreeContainer.style.height = `${listHeight}px`; + this.tocTree.layout(listHeight, 175); + } +} + +class OpenSettingsAction extends Action { + static readonly ID = 'settings.openSettingsJson'; + static readonly LABEL = localize('openSettingsJsonLabel', "Open settings.json for advanced customizations"); + + constructor( + @IPreferencesService private readonly preferencesService: IPreferencesService, + ) { + super(OpenSettingsAction.ID, OpenSettingsAction.LABEL, 'open-settings-json'); + } + + + run(context?: SettingsTarget): TPromise { + return this._run(context) + .then(() => { }); + } + + private _run(context?: SettingsTarget): TPromise { + if (context === ConfigurationTarget.USER) { + return this.preferencesService.openGlobalSettings(); + } else if (context === ConfigurationTarget.WORKSPACE) { + return this.preferencesService.openWorkspaceSettings(); + } else if (URI.isUri(context)) { + return this.preferencesService.openFolderSettings(context); + } + + return TPromise.wrap(null); + } +} + +class ToggleShowModifiedOnlyAction extends Action { + static readonly ID = 'settings.toggleShowModifiedOnly'; + static readonly LABEL = localize('showModifiedOnlyLabel', "Show modified settings only"); + + get checked(): boolean { + return this.viewState.showConfiguredOnly; + } + + constructor( + private settingsEditor: SettingsEditor2, + private viewState: ISettingsEditorViewState + ) { + super(ToggleShowModifiedOnlyAction.ID, ToggleShowModifiedOnlyAction.LABEL, 'show-modified-only'); + } + + run(): TPromise { + return this.settingsEditor.toggleShowModifiedOnly(); } } diff --git a/src/vs/workbench/parts/preferences/browser/settingsTree.ts b/src/vs/workbench/parts/preferences/browser/settingsTree.ts index 6d76e106d55..195b722de7d 100644 --- a/src/vs/workbench/parts/preferences/browser/settingsTree.ts +++ b/src/vs/workbench/parts/preferences/browser/settingsTree.ts @@ -12,6 +12,7 @@ import { Checkbox } from 'vs/base/browser/ui/checkbox/checkbox'; import { InputBox } from 'vs/base/browser/ui/inputbox/inputBox'; import { SelectBox } from 'vs/base/browser/ui/selectBox/selectBox'; import * as arrays from 'vs/base/common/arrays'; +import { Color, RGBA } from 'vs/base/common/color'; import { onUnexpectedError } from 'vs/base/common/errors'; import { Emitter, Event } from 'vs/base/common/event'; import { KeyCode } from 'vs/base/common/keyCodes'; @@ -20,52 +21,53 @@ import * as objects from 'vs/base/common/objects'; import { escapeRegExpCharacters, startsWith } from 'vs/base/common/strings'; import URI from 'vs/base/common/uri'; import { TPromise } from 'vs/base/common/winjs.base'; -import { IAccessibilityProvider, IDataSource, IFilter, ITree, IRenderer } from 'vs/base/parts/tree/browser/tree'; +import { IAccessibilityProvider, IDataSource, IFilter, IRenderer, ITree, ITreeConfiguration } from 'vs/base/parts/tree/browser/tree'; +import { DefaultTreestyler } from 'vs/base/parts/tree/browser/treeDefaults'; import { localize } from 'vs/nls'; import { ConfigurationTarget, IConfigurationService } from 'vs/platform/configuration/common/configuration'; +import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; import { IContextViewService } from 'vs/platform/contextview/browser/contextView'; -import { WorkbenchTree, WorkbenchTreeController } from 'vs/platform/list/browser/listService'; +import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; +import { IListService, WorkbenchTree, WorkbenchTreeController } from 'vs/platform/list/browser/listService'; import { IOpenerService } from 'vs/platform/opener/common/opener'; -import { inputBackground, inputBorder, inputForeground, registerColor, selectBackground, selectBorder, selectForeground, textLinkForeground } from 'vs/platform/theme/common/colorRegistry'; -import { attachInputBoxStyler, attachSelectBoxStyler, attachButtonStyler } from 'vs/platform/theme/common/styler'; +import { editorBackground, focusBorder, foreground, inputBackground, inputBorder, inputForeground, registerColor, selectBackground, selectBorder, selectForeground, textLinkForeground } from 'vs/platform/theme/common/colorRegistry'; +import { attachButtonStyler, attachInputBoxStyler, attachSelectBoxStyler, attachStyler } from 'vs/platform/theme/common/styler'; import { ICssStyleCollector, ITheme, IThemeService, registerThemingParticipant } from 'vs/platform/theme/common/themeService'; import { SettingsTarget } from 'vs/workbench/parts/preferences/browser/preferencesWidgets'; import { ITOCEntry } from 'vs/workbench/parts/preferences/browser/settingsLayout'; import { ISearchResult, ISetting, ISettingsGroup } from 'vs/workbench/services/preferences/common/preferences'; -import { Color } from 'vs/base/common/color'; const $ = DOM.$; -export const modifiedItemForeground = registerColor('settings.modifiedItemForeground', { - light: '#019001', - dark: '#73C991', - hc: '#73C991' -}, localize('modifiedItemForeground', "(For settings editor preview) The foreground color for a modified setting.")); +export const settingsHeaderForeground = registerColor('settings.headerForeground', { light: '#444444', dark: '#e7e7e7', hc: '#ffffff' }, localize('headerForeground', "(For settings editor preview) The foreground color for a section header/title.")); +export const modifiedItemForeground = registerColor('settings.modifiedItemForeground', { light: '#019001', dark: '#73C991', hc: '#73C991' }, localize('modifiedItemForeground', "(For settings editor preview) The foreground color for a modified setting.")); +export const settingItemInactiveSelectionBorder = registerColor('settings.inactiveSelectedItemBorder', { dark: '#3F3F46', light: '#CCCEDB', hc: null }, localize('settingItemInactiveSelectionBorder', "(For settings editor preview) The color of the selected setting row border, when the settings list does not have focus.")); // Enum control colors -export const settingsSelectBackground = registerColor('settings.dropdownBackground', { dark: selectBackground, light: selectBackground, hc: selectBackground }, localize('settingsDropdownBackground', "Settings editor dropdown background.")); -export const settingsSelectForeground = registerColor('settings.dropdownForeground', { dark: selectForeground, light: selectForeground, hc: selectForeground }, localize('settingsDropdownForeground', "Settings editor dropdown foreground.")); -export const settingsSelectBorder = registerColor('settings.dropdownBorder', { dark: selectBorder, light: selectBorder, hc: selectBorder }, localize('settingsDropdownBorder', "Settings editor dropdown border.")); +export const settingsSelectBackground = registerColor('settings.dropdownBackground', { dark: selectBackground, light: selectBackground, hc: selectBackground }, localize('settingsDropdownBackground', "(For settings editor preview) Settings editor dropdown background.")); +export const settingsSelectForeground = registerColor('settings.dropdownForeground', { dark: selectForeground, light: selectForeground, hc: selectForeground }, localize('settingsDropdownForeground', "(For settings editor preview) Settings editor dropdown foreground.")); +export const settingsSelectBorder = registerColor('settings.dropdownBorder', { dark: selectBorder, light: selectBorder, hc: selectBorder }, localize('settingsDropdownBorder', "(For settings editor preview) Settings editor dropdown border.")); // Bool control colors -export const settingsCheckboxBackground = registerColor('settings.checkboxBackground', { dark: selectBackground, light: selectBackground, hc: selectBackground }, localize('settingsCheckboxBackground', "Settings editor checkbox background.")); -export const settingsCheckboxForeground = registerColor('settings.checkboxForeground', { dark: selectForeground, light: selectForeground, hc: selectForeground }, localize('settingsCheckboxForeground', "Settings editor checkbox foreground.")); -export const settingsCheckboxBorder = registerColor('settings.checkboxBorder', { dark: selectBorder, light: selectBorder, hc: selectBorder }, localize('settingsCheckboxBorder', "Settings editor checkbox border.")); +export const settingsCheckboxBackground = registerColor('settings.checkboxBackground', { dark: selectBackground, light: selectBackground, hc: selectBackground }, localize('settingsCheckboxBackground', "(For settings editor preview) Settings editor checkbox background.")); +export const settingsCheckboxForeground = registerColor('settings.checkboxForeground', { dark: selectForeground, light: selectForeground, hc: selectForeground }, localize('settingsCheckboxForeground', "(For settings editor preview) Settings editor checkbox foreground.")); +export const settingsCheckboxBorder = registerColor('settings.checkboxBorder', { dark: selectBorder, light: selectBorder, hc: selectBorder }, localize('settingsCheckboxBorder', "(For settings editor preview) Settings editor checkbox border.")); // Text control colors -export const settingsTextInputBackground = registerColor('settings.textInputBackground', { dark: inputBackground, light: inputBackground, hc: inputBackground }, localize('textInputBoxBackground', "Settings editor text input box background.")); -export const settingsTextInputForeground = registerColor('settings.textInputForeground', { dark: inputForeground, light: inputForeground, hc: inputForeground }, localize('textInputBoxForeground', "Settings editor text input box foreground.")); -export const settingsTextInputBorder = registerColor('settings.textInputBorder', { dark: inputBorder, light: inputBorder, hc: inputBorder }, localize('textInputBoxBorder', "Settings editor text input box border.")); +export const settingsTextInputBackground = registerColor('settings.textInputBackground', { dark: inputBackground, light: inputBackground, hc: inputBackground }, localize('textInputBoxBackground', "(For settings editor preview) Settings editor text input box background.")); +export const settingsTextInputForeground = registerColor('settings.textInputForeground', { dark: inputForeground, light: inputForeground, hc: inputForeground }, localize('textInputBoxForeground', "(For settings editor preview) Settings editor text input box foreground.")); +export const settingsTextInputBorder = registerColor('settings.textInputBorder', { dark: inputBorder, light: inputBorder, hc: inputBorder }, localize('textInputBoxBorder', "(For settings editor preview) Settings editor text input box border.")); // Number control colors -export const settingsNumberInputBackground = registerColor('settings.numberInputBackground', { dark: inputBackground, light: inputBackground, hc: inputBackground }, localize('numberInputBoxBackground', "Settings editor number input box background.")); -export const settingsNumberInputForeground = registerColor('settings.numberInputForeground', { dark: inputForeground, light: inputForeground, hc: inputForeground }, localize('numberInputBoxForeground', "Settings editor number input box foreground.")); -export const settingsNumberInputBorder = registerColor('settings.numberInputBorder', { dark: inputBorder, light: inputBorder, hc: inputBorder }, localize('numberInputBoxBorder', "Settings editor number input box border.")); +export const settingsNumberInputBackground = registerColor('settings.numberInputBackground', { dark: inputBackground, light: inputBackground, hc: inputBackground }, localize('numberInputBoxBackground', "(For settings editor preview) Settings editor number input box background.")); +export const settingsNumberInputForeground = registerColor('settings.numberInputForeground', { dark: inputForeground, light: inputForeground, hc: inputForeground }, localize('numberInputBoxForeground', "(For settings editor preview) Settings editor number input box foreground.")); +export const settingsNumberInputBorder = registerColor('settings.numberInputBorder', { dark: inputBorder, light: inputBorder, hc: inputBorder }, localize('numberInputBoxBorder', "(For settings editor preview) Settings editor number input box border.")); registerThemingParticipant((theme: ITheme, collector: ICssStyleCollector) => { const modifiedItemForegroundColor = theme.getColor(modifiedItemForeground); if (modifiedItemForegroundColor) { collector.addRule(`.settings-editor > .settings-body > .settings-tree-container .setting-item.is-configured .setting-item-is-configured-label { color: ${modifiedItemForegroundColor}; }`); + collector.addRule(`.settings-editor > .settings-header > .settings-header-controls .settings-header-controls-right .toolbar-toggle-more::before { background-color: ${modifiedItemForegroundColor}; }`); } const checkboxBackgroundColor = theme.getColor(settingsCheckboxBackground); @@ -83,6 +85,11 @@ registerThemingParticipant((theme: ITheme, collector: ICssStyleCollector) => { collector.addRule(`.settings-editor > .settings-body > .settings-tree-container .setting-item .setting-item-description a { color: ${link}; }`); collector.addRule(`.settings-editor > .settings-body > .settings-tree-container .setting-item .setting-item-description a > code { color: ${link}; }`); } + + const headerForegroundColor = theme.getColor(settingsHeaderForeground); + if (headerForegroundColor) { + collector.addRule(`.settings-editor > .settings-header > .settings-header-controls .settings-tabs-widget .action-label.checked { color: ${headerForegroundColor}; border-bottom-color: ${headerForegroundColor} };`); + } }); export abstract class SettingsTreeElement { @@ -508,7 +515,7 @@ export class SettingsRenderer implements IRenderer { getHeight(tree: ITree, element: SettingsTreeElement): number { if (element instanceof SettingsTreeGroupElement) { if (element.isFirstGroup) { - return 28; + return 31; } return 40 + (7 * element.level); @@ -1156,7 +1163,7 @@ export class SearchResultModel { } } -export class NonExpandableTree extends WorkbenchTree { +class NonExpandableTree extends WorkbenchTree { expand(): TPromise { return TPromise.wrap(null); } @@ -1165,3 +1172,86 @@ export class NonExpandableTree extends WorkbenchTree { return TPromise.wrap(null); } } + +export class SettingsTree extends NonExpandableTree { + constructor( + container: HTMLElement, + viewState: ISettingsEditorViewState, + configuration: Partial, + @IContextKeyService contextKeyService: IContextKeyService, + @IListService listService: IListService, + @IThemeService themeService: IThemeService, + @IInstantiationService instantiationService: IInstantiationService, + @IConfigurationService configurationService: IConfigurationService + ) { + const treeClass = 'settings-editor-tree'; + + const fullConfiguration = { + dataSource: instantiationService.createInstance(SettingsDataSource, viewState), + controller: instantiationService.createInstance(SettingsTreeController), + accessibilityProvider: instantiationService.createInstance(SettingsAccessibilityProvider), + filter: instantiationService.createInstance(SettingsTreeFilter, viewState), + styler: new DefaultTreestyler(DOM.createStyleSheet(), treeClass), + + ...configuration + }; + + const options = { + ariaLabel: localize('treeAriaLabel', "Settings"), + showLoading: false, + indentPixels: 0, + twistiePixels: 0, + }; + + super(container, + fullConfiguration, + options, + contextKeyService, + listService, + themeService, + instantiationService, + configurationService); + + this.disposables.push(registerThemingParticipant((theme: ITheme, collector: ICssStyleCollector) => { + const activeBorderColor = theme.getColor(focusBorder); + if (activeBorderColor) { + collector.addRule(`.settings-editor > .settings-body > .settings-tree-container .monaco-tree:focus .monaco-tree-row.focused {outline: solid 1px ${activeBorderColor}; outline-offset: -1px; }`); + } + + const inactiveBorderColor = theme.getColor(settingItemInactiveSelectionBorder); + if (inactiveBorderColor) { + collector.addRule(`.settings-editor > .settings-body > .settings-tree-container .monaco-tree .monaco-tree-row.focused {outline: solid 1px ${inactiveBorderColor}; outline-offset: -1px; }`); + } + + const foregroundColor = theme.getColor(foreground); + if (foregroundColor) { + // Links appear inside other elements in markdown. CSS opacity acts like a mask. So we have to dynamically compute the description color to avoid + // applying an opacity to the link color. + const fgWithOpacity = new Color(new RGBA(foregroundColor.rgba.r, foregroundColor.rgba.g, foregroundColor.rgba.b, .7)); + collector.addRule(`.settings-editor > .settings-body > .settings-tree-container .setting-item .setting-item-description { color: ${fgWithOpacity}; }`); + } + + const headerForegroundColor = theme.getColor(settingsHeaderForeground); + if (headerForegroundColor) { + collector.addRule(`.settings-editor > .settings-body > .settings-tree-container .settings-group-title-label { color: ${headerForegroundColor} };`); + } + })); + + this.getHTMLElement().classList.add(treeClass); + + this.disposables.push(attachStyler(themeService, { + listActiveSelectionBackground: editorBackground, + listActiveSelectionForeground: foreground, + listFocusAndSelectionBackground: editorBackground, + listFocusAndSelectionForeground: foreground, + listFocusBackground: editorBackground, + listFocusForeground: foreground, + listHoverForeground: foreground, + listHoverBackground: editorBackground, + listInactiveSelectionBackground: editorBackground, + listInactiveSelectionForeground: foreground + }, colors => { + this.style(colors); + })); + } +} diff --git a/src/vs/workbench/parts/preferences/electron-browser/preferences.contribution.ts b/src/vs/workbench/parts/preferences/electron-browser/preferences.contribution.ts index b443aabf11b..c8ab50f2ba7 100644 --- a/src/vs/workbench/parts/preferences/electron-browser/preferences.contribution.ts +++ b/src/vs/workbench/parts/preferences/electron-browser/preferences.contribution.ts @@ -8,7 +8,7 @@ import 'vs/css!../browser/media/preferences'; import * as nls from 'vs/nls'; import URI from 'vs/base/common/uri'; import { Registry } from 'vs/platform/registry/common/platform'; -import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry'; +import { KeybindingsRegistry, KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; import { IWorkbenchActionRegistry, Extensions } from 'vs/workbench/common/actions'; import { EditorInput, IEditorInputFactory, IEditorInputFactoryRegistry, Extensions as EditorInputExtensions } from 'vs/workbench/common/editor'; import { SyncActionDescriptor, MenuRegistry, MenuId } from 'vs/platform/actions/common/actions'; @@ -19,7 +19,7 @@ import { PreferencesEditor } from 'vs/workbench/parts/preferences/browser/prefer import { SettingsEditor2 } from 'vs/workbench/parts/preferences/browser/settingsEditor2'; import { DefaultPreferencesEditorInput, PreferencesEditorInput, KeybindingsEditorInput, SettingsEditor2Input } from 'vs/workbench/services/preferences/common/preferencesEditorInput'; import { KeybindingsEditor } from 'vs/workbench/parts/preferences/browser/keybindingsEditor'; -import { OpenRawDefaultSettingsAction, OpenSettingsAction, OpenGlobalSettingsAction, OpenGlobalKeybindingsFileAction, OpenWorkspaceSettingsAction, OpenFolderSettingsAction, ConfigureLanguageBasedSettingsAction, OPEN_FOLDER_SETTINGS_COMMAND, OpenGlobalKeybindingsAction, OpenSettings2Action } from 'vs/workbench/parts/preferences/browser/preferencesActions'; +import { OpenDefaultKeybindingsFileAction, OpenRawDefaultSettingsAction, OpenSettingsAction, OpenGlobalSettingsAction, OpenGlobalKeybindingsFileAction, OpenWorkspaceSettingsAction, OpenFolderSettingsAction, ConfigureLanguageBasedSettingsAction, OPEN_FOLDER_SETTINGS_COMMAND, OpenGlobalKeybindingsAction, OpenSettings2Action } from 'vs/workbench/parts/preferences/browser/preferencesActions'; import { IKeybindingsEditor, IPreferencesSearchService, CONTEXT_KEYBINDING_FOCUS, CONTEXT_KEYBINDINGS_EDITOR, CONTEXT_KEYBINDINGS_SEARCH_FOCUS, KEYBINDINGS_EDITOR_COMMAND_DEFINE, KEYBINDINGS_EDITOR_COMMAND_REMOVE, KEYBINDINGS_EDITOR_COMMAND_SEARCH, KEYBINDINGS_EDITOR_COMMAND_COPY, KEYBINDINGS_EDITOR_COMMAND_RESET, KEYBINDINGS_EDITOR_COMMAND_COPY_COMMAND, KEYBINDINGS_EDITOR_COMMAND_SHOW_SIMILAR, KEYBINDINGS_EDITOR_COMMAND_FOCUS_KEYBINDINGS, KEYBINDINGS_EDITOR_COMMAND_CLEAR_SEARCH_RESULTS, SETTINGS_EDITOR_COMMAND_SEARCH, CONTEXT_SETTINGS_EDITOR, SETTINGS_EDITOR_COMMAND_FOCUS_FILE, CONTEXT_SETTINGS_SEARCH_FOCUS, SETTINGS_EDITOR_COMMAND_CLEAR_SEARCH_RESULTS, SETTINGS_EDITOR_COMMAND_FOCUS_NEXT_SETTING, SETTINGS_EDITOR_COMMAND_FOCUS_PREVIOUS_SETTING, SETTINGS_EDITOR_COMMAND_EDIT_FOCUSED_SETTING, SETTINGS_EDITOR_COMMAND_FOCUS_SEARCH_FROM_SETTINGS, SETTINGS_EDITOR_COMMAND_FOCUS_SETTINGS_FROM_SEARCH, CONTEXT_SETTINGS_FIRST_ROW_FOCUS, CONTEXT_SETTINGS_ROW_FOCUS, CONTEXT_TOC_ROW_FOCUS, SETTINGS_EDITOR_COMMAND_FOCUS_SETTINGS_LIST @@ -195,12 +195,13 @@ registry.registerWorkbenchAction(new SyncActionDescriptor(OpenSettingsAction, Op registry.registerWorkbenchAction(new SyncActionDescriptor(OpenSettings2Action, OpenSettings2Action.ID, OpenSettings2Action.LABEL, { primary: KeyMod.CtrlCmd | KeyCode.US_COMMA }), 'Preferences: Open Settings (Preview)', category); registry.registerWorkbenchAction(new SyncActionDescriptor(OpenGlobalSettingsAction, OpenGlobalSettingsAction.ID, OpenGlobalSettingsAction.LABEL), 'Preferences: Open User Settings', category); registry.registerWorkbenchAction(new SyncActionDescriptor(OpenGlobalKeybindingsAction, OpenGlobalKeybindingsAction.ID, OpenGlobalKeybindingsAction.LABEL, { primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_S) }), 'Preferences: Open Keyboard Shortcuts', category); +registry.registerWorkbenchAction(new SyncActionDescriptor(OpenDefaultKeybindingsFileAction, OpenDefaultKeybindingsFileAction.ID, OpenDefaultKeybindingsFileAction.LABEL), 'Preferences: Open Default Keyboard Shortcuts File', category); registry.registerWorkbenchAction(new SyncActionDescriptor(OpenGlobalKeybindingsFileAction, OpenGlobalKeybindingsFileAction.ID, OpenGlobalKeybindingsFileAction.LABEL, { primary: null }), 'Preferences: Open Keyboard Shortcuts File', category); registry.registerWorkbenchAction(new SyncActionDescriptor(ConfigureLanguageBasedSettingsAction, ConfigureLanguageBasedSettingsAction.ID, ConfigureLanguageBasedSettingsAction.LABEL), 'Preferences: Configure Language Specific Settings...', category); KeybindingsRegistry.registerCommandAndKeybindingRule({ id: KEYBINDINGS_EDITOR_COMMAND_DEFINE, - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: ContextKeyExpr.and(CONTEXT_KEYBINDINGS_EDITOR, CONTEXT_KEYBINDING_FOCUS), primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_K), handler: (accessor, args: any) => { @@ -211,7 +212,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({ KeybindingsRegistry.registerCommandAndKeybindingRule({ id: KEYBINDINGS_EDITOR_COMMAND_REMOVE, - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: ContextKeyExpr.and(CONTEXT_KEYBINDINGS_EDITOR, CONTEXT_KEYBINDING_FOCUS), primary: KeyCode.Delete, mac: { @@ -225,7 +226,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({ KeybindingsRegistry.registerCommandAndKeybindingRule({ id: KEYBINDINGS_EDITOR_COMMAND_RESET, - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: ContextKeyExpr.and(CONTEXT_KEYBINDINGS_EDITOR, CONTEXT_KEYBINDING_FOCUS), primary: null, handler: (accessor, args: any) => { @@ -236,7 +237,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({ KeybindingsRegistry.registerCommandAndKeybindingRule({ id: KEYBINDINGS_EDITOR_COMMAND_SEARCH, - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: ContextKeyExpr.and(CONTEXT_KEYBINDINGS_EDITOR, CONTEXT_KEYBINDING_FOCUS), primary: KeyMod.CtrlCmd | KeyCode.KEY_F, handler: (accessor, args: any) => (accessor.get(IEditorService).activeControl as IKeybindingsEditor).focusSearch() @@ -244,7 +245,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({ KeybindingsRegistry.registerCommandAndKeybindingRule({ id: KEYBINDINGS_EDITOR_COMMAND_SHOW_SIMILAR, - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: ContextKeyExpr.and(CONTEXT_KEYBINDINGS_EDITOR, CONTEXT_KEYBINDING_FOCUS), primary: null, handler: (accessor, args: any) => { @@ -255,7 +256,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({ KeybindingsRegistry.registerCommandAndKeybindingRule({ id: KEYBINDINGS_EDITOR_COMMAND_COPY, - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: ContextKeyExpr.and(CONTEXT_KEYBINDINGS_EDITOR, CONTEXT_KEYBINDING_FOCUS), primary: KeyMod.CtrlCmd | KeyCode.KEY_C, handler: (accessor, args: any) => { @@ -266,7 +267,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({ KeybindingsRegistry.registerCommandAndKeybindingRule({ id: KEYBINDINGS_EDITOR_COMMAND_COPY_COMMAND, - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: ContextKeyExpr.and(CONTEXT_KEYBINDINGS_EDITOR, CONTEXT_KEYBINDING_FOCUS), primary: null, handler: (accessor, args: any) => { @@ -277,7 +278,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({ KeybindingsRegistry.registerCommandAndKeybindingRule({ id: KEYBINDINGS_EDITOR_COMMAND_FOCUS_KEYBINDINGS, - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: ContextKeyExpr.and(CONTEXT_KEYBINDINGS_EDITOR, CONTEXT_KEYBINDINGS_SEARCH_FOCUS), primary: KeyCode.DownArrow, handler: (accessor, args: any) => { @@ -288,7 +289,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({ KeybindingsRegistry.registerCommandAndKeybindingRule({ id: KEYBINDINGS_EDITOR_COMMAND_CLEAR_SEARCH_RESULTS, - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: ContextKeyExpr.and(CONTEXT_KEYBINDINGS_EDITOR, CONTEXT_KEYBINDINGS_SEARCH_FOCUS), primary: KeyCode.Escape, handler: (accessor, args: any) => { @@ -350,9 +351,9 @@ class StartSearchDefaultSettingsCommand extends SettingsCommand { const startSearchCommand = new StartSearchDefaultSettingsCommand({ id: SETTINGS_EDITOR_COMMAND_SEARCH, precondition: ContextKeyExpr.and(CONTEXT_SETTINGS_EDITOR), - kbOpts: { primary: KeyMod.CtrlCmd | KeyCode.KEY_F } + kbOpts: { primary: KeyMod.CtrlCmd | KeyCode.KEY_F, weight: KeybindingWeight.EditorContrib } }); -KeybindingsRegistry.registerCommandAndKeybindingRule(startSearchCommand.toCommandAndKeybindingRule(KeybindingsRegistry.WEIGHT.editorContrib())); +startSearchCommand.register(); class FocusSearchFromSettingsCommand extends SettingsCommand { @@ -366,9 +367,9 @@ class FocusSearchFromSettingsCommand extends SettingsCommand { const focusSearchFromSettingsCommand = new FocusSearchFromSettingsCommand({ id: SETTINGS_EDITOR_COMMAND_FOCUS_SEARCH_FROM_SETTINGS, precondition: ContextKeyExpr.and(CONTEXT_SETTINGS_EDITOR, CONTEXT_SETTINGS_FIRST_ROW_FOCUS), - kbOpts: { primary: KeyCode.UpArrow } + kbOpts: { primary: KeyCode.UpArrow, weight: KeybindingWeight.WorkbenchContrib } }); -KeybindingsRegistry.registerCommandAndKeybindingRule(focusSearchFromSettingsCommand.toCommandAndKeybindingRule(KeybindingsRegistry.WEIGHT.workbenchContrib())); +focusSearchFromSettingsCommand.register(); class ClearSearchResultsCommand extends SettingsCommand { @@ -383,9 +384,9 @@ class ClearSearchResultsCommand extends SettingsCommand { const clearSearchResultsCommand = new ClearSearchResultsCommand({ id: SETTINGS_EDITOR_COMMAND_CLEAR_SEARCH_RESULTS, precondition: CONTEXT_SETTINGS_SEARCH_FOCUS, - kbOpts: { primary: KeyCode.Escape } + kbOpts: { primary: KeyCode.Escape, weight: KeybindingWeight.EditorContrib } }); -KeybindingsRegistry.registerCommandAndKeybindingRule(clearSearchResultsCommand.toCommandAndKeybindingRule(KeybindingsRegistry.WEIGHT.editorContrib())); +clearSearchResultsCommand.register(); class FocusSettingsFileEditorCommand extends SettingsCommand { @@ -401,16 +402,16 @@ class FocusSettingsFileEditorCommand extends SettingsCommand { const focusSettingsFileEditorCommand = new FocusSettingsFileEditorCommand({ id: SETTINGS_EDITOR_COMMAND_FOCUS_FILE, precondition: CONTEXT_SETTINGS_SEARCH_FOCUS, - kbOpts: { primary: KeyCode.DownArrow } + kbOpts: { primary: KeyCode.DownArrow, weight: KeybindingWeight.EditorContrib } }); -KeybindingsRegistry.registerCommandAndKeybindingRule(focusSettingsFileEditorCommand.toCommandAndKeybindingRule(KeybindingsRegistry.WEIGHT.editorContrib())); +focusSettingsFileEditorCommand.register(); const focusSettingsFromSearchCommand = new FocusSettingsFileEditorCommand({ id: SETTINGS_EDITOR_COMMAND_FOCUS_SETTINGS_FROM_SEARCH, precondition: CONTEXT_SETTINGS_SEARCH_FOCUS, - kbOpts: { primary: KeyCode.DownArrow } + kbOpts: { primary: KeyCode.DownArrow, weight: KeybindingWeight.WorkbenchContrib } }); -KeybindingsRegistry.registerCommandAndKeybindingRule(focusSettingsFromSearchCommand.toCommandAndKeybindingRule(KeybindingsRegistry.WEIGHT.workbenchContrib())); +focusSettingsFromSearchCommand.register(); class FocusNextSearchResultCommand extends SettingsCommand { @@ -424,9 +425,9 @@ class FocusNextSearchResultCommand extends SettingsCommand { const focusNextSearchResultCommand = new FocusNextSearchResultCommand({ id: SETTINGS_EDITOR_COMMAND_FOCUS_NEXT_SETTING, precondition: CONTEXT_SETTINGS_SEARCH_FOCUS, - kbOpts: { primary: KeyCode.Enter } + kbOpts: { primary: KeyCode.Enter, weight: KeybindingWeight.EditorContrib } }); -KeybindingsRegistry.registerCommandAndKeybindingRule(focusNextSearchResultCommand.toCommandAndKeybindingRule(KeybindingsRegistry.WEIGHT.editorContrib())); +focusNextSearchResultCommand.register(); class FocusPreviousSearchResultCommand extends SettingsCommand { @@ -440,9 +441,9 @@ class FocusPreviousSearchResultCommand extends SettingsCommand { const focusPreviousSearchResultCommand = new FocusPreviousSearchResultCommand({ id: SETTINGS_EDITOR_COMMAND_FOCUS_PREVIOUS_SETTING, precondition: CONTEXT_SETTINGS_SEARCH_FOCUS, - kbOpts: { primary: KeyMod.Shift | KeyCode.Enter } + kbOpts: { primary: KeyMod.Shift | KeyCode.Enter, weight: KeybindingWeight.EditorContrib } }); -KeybindingsRegistry.registerCommandAndKeybindingRule(focusPreviousSearchResultCommand.toCommandAndKeybindingRule(KeybindingsRegistry.WEIGHT.editorContrib())); +focusPreviousSearchResultCommand.register(); class EditFocusedSettingCommand extends SettingsCommand { @@ -456,9 +457,9 @@ class EditFocusedSettingCommand extends SettingsCommand { const editFocusedSettingCommand = new EditFocusedSettingCommand({ id: SETTINGS_EDITOR_COMMAND_EDIT_FOCUSED_SETTING, precondition: CONTEXT_SETTINGS_SEARCH_FOCUS, - kbOpts: { primary: KeyMod.CtrlCmd | KeyCode.US_DOT } + kbOpts: { primary: KeyMod.CtrlCmd | KeyCode.US_DOT, weight: KeybindingWeight.EditorContrib } }); -KeybindingsRegistry.registerCommandAndKeybindingRule(editFocusedSettingCommand.toCommandAndKeybindingRule(KeybindingsRegistry.WEIGHT.editorContrib())); +editFocusedSettingCommand.register(); class EditFocusedSettingCommand2 extends SettingsCommand { @@ -473,9 +474,9 @@ class EditFocusedSettingCommand2 extends SettingsCommand { const editFocusedSettingCommand2 = new EditFocusedSettingCommand2({ id: SETTINGS_EDITOR_COMMAND_EDIT_FOCUSED_SETTING, precondition: ContextKeyExpr.and(CONTEXT_SETTINGS_EDITOR, CONTEXT_SETTINGS_ROW_FOCUS), - kbOpts: { primary: KeyCode.Enter } + kbOpts: { primary: KeyCode.Enter, weight: KeybindingWeight.WorkbenchContrib } }); -KeybindingsRegistry.registerCommandAndKeybindingRule(editFocusedSettingCommand2.toCommandAndKeybindingRule(KeybindingsRegistry.WEIGHT.workbenchContrib())); +editFocusedSettingCommand2.register(); class FocusSettingsListCommand extends SettingsCommand { @@ -490,9 +491,9 @@ class FocusSettingsListCommand extends SettingsCommand { const focusSettingsListCommand = new FocusSettingsListCommand({ id: SETTINGS_EDITOR_COMMAND_FOCUS_SETTINGS_LIST, precondition: ContextKeyExpr.and(CONTEXT_SETTINGS_EDITOR, CONTEXT_TOC_ROW_FOCUS), - kbOpts: { primary: KeyCode.Enter } + kbOpts: { primary: KeyCode.Enter, weight: KeybindingWeight.WorkbenchContrib } }); -KeybindingsRegistry.registerCommandAndKeybindingRule(focusSettingsListCommand.toCommandAndKeybindingRule(KeybindingsRegistry.WEIGHT.workbenchContrib())); +focusSettingsListCommand.register(); // Preferences menu diff --git a/src/vs/workbench/parts/quickopen/browser/gotoSymbolHandler.ts b/src/vs/workbench/parts/quickopen/browser/gotoSymbolHandler.ts index 0fa751696fc..2880d33cb38 100644 --- a/src/vs/workbench/parts/quickopen/browser/gotoSymbolHandler.ts +++ b/src/vs/workbench/parts/quickopen/browser/gotoSymbolHandler.ts @@ -239,9 +239,10 @@ class SymbolEntry extends EditorQuickOpenEntryGroup { private icon: string; private description: string; private range: IRange; + private revealRange: IRange; private handler: GotoSymbolHandler; - constructor(index: number, name: string, type: string, description: string, icon: string, range: IRange, highlights: IHighlight[], editorService: IEditorService, handler: GotoSymbolHandler) { + constructor(index: number, name: string, type: string, description: string, icon: string, range: IRange, revealRange: IRange, highlights: IHighlight[], editorService: IEditorService, handler: GotoSymbolHandler) { super(); this.index = index; @@ -250,6 +251,7 @@ class SymbolEntry extends EditorQuickOpenEntryGroup { this.icon = icon; this.description = description; this.range = range; + this.revealRange = revealRange || range; this.setHighlights(highlights); this.editorService = editorService; this.handler = handler; @@ -342,10 +344,10 @@ class SymbolEntry extends EditorQuickOpenEntryGroup { private toSelection(): IRange { return { - startLineNumber: this.range.startLineNumber, - startColumn: this.range.startColumn || 1, - endLineNumber: this.range.startLineNumber, - endColumn: this.range.startColumn || 1 + startLineNumber: this.revealRange.startLineNumber, + startColumn: this.revealRange.startColumn || 1, + endLineNumber: this.revealRange.startLineNumber, + endColumn: this.revealRange.startColumn || 1 }; } } @@ -450,7 +452,7 @@ export class GotoSymbolHandler extends QuickOpenHandler { // Add results.push(new SymbolEntry(i, label, icon, description, `symbol-icon ${icon}`, - element.range, null, this.editorService, this + element.range, element.selectionRange, null, this.editorService, this )); } diff --git a/src/vs/workbench/parts/quickopen/browser/quickopen.contribution.ts b/src/vs/workbench/parts/quickopen/browser/quickopen.contribution.ts index 5b8cb97d750..1ce6dc74391 100644 --- a/src/vs/workbench/parts/quickopen/browser/quickopen.contribution.ts +++ b/src/vs/workbench/parts/quickopen/browser/quickopen.contribution.ts @@ -19,7 +19,7 @@ import { HELP_PREFIX, HelpHandler } from 'vs/workbench/parts/quickopen/browser/h import { VIEW_PICKER_PREFIX, OpenViewPickerAction, QuickOpenViewPickerAction, ViewPickerHandler } from 'vs/workbench/parts/quickopen/browser/viewPickerHandler'; import { inQuickOpenContext, getQuickNavigateHandler } from 'vs/workbench/browser/parts/quickopen/quickopen'; import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey'; -import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry'; +import { KeybindingsRegistry, KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; // Register Actions const registry = Registry.as(ActionExtensions.WorkbenchActions); @@ -50,7 +50,7 @@ registry.registerWorkbenchAction(new SyncActionDescriptor(QuickOpenViewPickerAct const quickOpenNavigateNextInViewPickerId = 'workbench.action.quickOpenNavigateNextInViewPicker'; KeybindingsRegistry.registerCommandAndKeybindingRule({ id: quickOpenNavigateNextInViewPickerId, - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(50), + weight: KeybindingWeight.WorkbenchContrib + 50, handler: getQuickNavigateHandler(quickOpenNavigateNextInViewPickerId, true), when: inViewsPickerContext, primary: viewPickerKeybinding.primary, @@ -61,7 +61,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({ const quickOpenNavigatePreviousInViewPickerId = 'workbench.action.quickOpenNavigatePreviousInViewPicker'; KeybindingsRegistry.registerCommandAndKeybindingRule({ id: quickOpenNavigatePreviousInViewPickerId, - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(50), + weight: KeybindingWeight.WorkbenchContrib + 50, handler: getQuickNavigateHandler(quickOpenNavigatePreviousInViewPickerId, false), when: inViewsPickerContext, primary: viewPickerKeybinding.primary | KeyMod.Shift, diff --git a/src/vs/workbench/parts/scm/electron-browser/dirtydiffDecorator.ts b/src/vs/workbench/parts/scm/electron-browser/dirtydiffDecorator.ts index 90a6893cdf4..505f3c8a672 100644 --- a/src/vs/workbench/parts/scm/electron-browser/dirtydiffDecorator.ts +++ b/src/vs/workbench/parts/scm/electron-browser/dirtydiffDecorator.ts @@ -33,7 +33,7 @@ import { EditorContextKeys } from 'vs/editor/common/editorContextKeys'; import { KeyCode, KeyMod } from 'vs/base/common/keyCodes'; import { Position } from 'vs/editor/common/core/position'; import { rot } from 'vs/base/common/numbers'; -import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry'; +import { KeybindingsRegistry, KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; import { peekViewBorder, peekViewTitleBackground, peekViewTitleForeground, peekViewTitleInfoForeground } from 'vs/editor/contrib/referenceSearch/referencesWidget'; import { EmbeddedDiffEditorWidget } from 'vs/editor/browser/widget/embeddedCodeEditorWidget'; import { IDiffEditorOptions } from 'vs/editor/common/config/editorOptions'; @@ -372,7 +372,7 @@ export class ShowPreviousChangeAction extends EditorAction { label: nls.localize('show previous change', "Show Previous Change"), alias: 'Show Previous Change', precondition: null, - kbOpts: { kbExpr: EditorContextKeys.editorTextFocus, primary: KeyMod.Shift | KeyMod.Alt | KeyCode.F3 } + kbOpts: { kbExpr: EditorContextKeys.editorTextFocus, primary: KeyMod.Shift | KeyMod.Alt | KeyCode.F3, weight: KeybindingWeight.EditorContrib } }); } @@ -406,7 +406,7 @@ export class ShowNextChangeAction extends EditorAction { label: nls.localize('show next change', "Show Next Change"), alias: 'Show Next Change', precondition: null, - kbOpts: { kbExpr: EditorContextKeys.editorTextFocus, primary: KeyMod.Alt | KeyCode.F3 } + kbOpts: { kbExpr: EditorContextKeys.editorTextFocus, primary: KeyMod.Alt | KeyCode.F3, weight: KeybindingWeight.EditorContrib } }); } @@ -440,7 +440,7 @@ export class MoveToPreviousChangeAction extends EditorAction { label: nls.localize('move to previous change', "Move to Previous Change"), alias: 'Move to Previous Change', precondition: null, - kbOpts: { kbExpr: EditorContextKeys.editorTextFocus, primary: KeyMod.Shift | KeyMod.Alt | KeyCode.F5 } + kbOpts: { kbExpr: EditorContextKeys.editorTextFocus, primary: KeyMod.Shift | KeyMod.Alt | KeyCode.F5, weight: KeybindingWeight.EditorContrib } }); } @@ -482,7 +482,7 @@ export class MoveToNextChangeAction extends EditorAction { label: nls.localize('move to next change', "Move to Next Change"), alias: 'Move to Next Change', precondition: null, - kbOpts: { kbExpr: EditorContextKeys.editorTextFocus, primary: KeyMod.Alt | KeyCode.F5 } + kbOpts: { kbExpr: EditorContextKeys.editorTextFocus, primary: KeyMod.Alt | KeyCode.F5, weight: KeybindingWeight.EditorContrib } }); } @@ -518,7 +518,7 @@ registerEditorAction(MoveToNextChangeAction); KeybindingsRegistry.registerCommandAndKeybindingRule({ id: 'closeDirtyDiff', - weight: KeybindingsRegistry.WEIGHT.editorContrib(50), + weight: KeybindingWeight.EditorContrib + 50, primary: KeyCode.Escape, secondary: [KeyMod.Shift | KeyCode.Escape], when: ContextKeyExpr.and(isDirtyDiffVisible), diff --git a/src/vs/workbench/parts/search/browser/searchResultsView.ts b/src/vs/workbench/parts/search/browser/searchResultsView.ts index dd4b0933013..a401c67d8ac 100644 --- a/src/vs/workbench/parts/search/browser/searchResultsView.ts +++ b/src/vs/workbench/parts/search/browser/searchResultsView.ts @@ -238,11 +238,11 @@ export class SearchRenderer extends Disposable implements IRenderer { private renderFolderMatch(tree: ITree, folderMatch: FolderMatch, templateData: IFolderMatchTemplate): void { if (folderMatch.hasRoot()) { const workspaceFolder = this.contextService.getWorkspaceFolder(folderMatch.resource()); - const fileKind = workspaceFolder && resources.isEqual(workspaceFolder.uri, folderMatch.resource()) ? - FileKind.ROOT_FOLDER : - FileKind.FOLDER; - - templateData.label.setFile(folderMatch.resource(), { fileKind }); + if (workspaceFolder && resources.isEqual(workspaceFolder.uri, folderMatch.resource())) { + templateData.label.setFile(folderMatch.resource(), { fileKind: FileKind.ROOT_FOLDER, hidePath: true }); + } else { + templateData.label.setFile(folderMatch.resource(), { fileKind: FileKind.FOLDER }); + } } else { templateData.label.setValue(nls.localize('searchFolderMatch.other.label', "Other files")); } diff --git a/src/vs/workbench/parts/search/browser/searchView.ts b/src/vs/workbench/parts/search/browser/searchView.ts index 510fc37cab1..85bd5d5d603 100644 --- a/src/vs/workbench/parts/search/browser/searchView.ts +++ b/src/vs/workbench/parts/search/browser/searchView.ts @@ -5,6 +5,7 @@ 'use strict'; +import 'vs/css!./media/searchview'; import { $, Builder } from 'vs/base/browser/builder'; import * as dom from 'vs/base/browser/dom'; import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent'; @@ -14,15 +15,14 @@ import { MessageType } from 'vs/base/browser/ui/inputbox/inputBox'; import { IAction } from 'vs/base/common/actions'; import { Delayer } from 'vs/base/common/async'; import * as errors from 'vs/base/common/errors'; -import { debounceEvent, Emitter } from 'vs/base/common/event'; +import { debounceEvent, Emitter, anyEvent } from 'vs/base/common/event'; import { KeyCode, KeyMod } from 'vs/base/common/keyCodes'; import * as paths from 'vs/base/common/paths'; import * as env from 'vs/base/common/platform'; import * as strings from 'vs/base/common/strings'; import URI from 'vs/base/common/uri'; import { TPromise } from 'vs/base/common/winjs.base'; -import { IFocusEvent, ITree } from 'vs/base/parts/tree/browser/tree'; -import 'vs/css!./media/searchview'; +import { ITree } from 'vs/base/parts/tree/browser/tree'; import { ICodeEditor, isCodeEditor, isDiffEditor } from 'vs/editor/browser/editorBrowser'; import { IEditorOptions } from 'vs/editor/common/config/editorOptions'; import * as nls from 'vs/nls'; @@ -582,14 +582,9 @@ export class SearchView extends Viewlet implements IViewlet, IPanel { } })); - let treeHasFocus = false; - this.tree.onDidFocus(() => { - treeHasFocus = true; - }); - - this._register(this.tree.onDidChangeFocus((e: IFocusEvent) => { - if (treeHasFocus) { - const focus = e.focus; + this._register(anyEvent(this.tree.onDidFocus, this.tree.onDidChangeFocus)(() => { + if (this.tree.isDOMFocused()) { + const focus = this.tree.getFocus(); this.firstMatchFocused.set(this.tree.getNavigator().first() === focus); this.fileMatchOrMatchFocused.set(!!focus); this.fileMatchFocused.set(focus instanceof FileMatch); @@ -600,7 +595,6 @@ export class SearchView extends Viewlet implements IViewlet, IPanel { })); this._register(this.tree.onDidBlur(e => { - treeHasFocus = false; this.firstMatchFocused.reset(); this.fileMatchOrMatchFocused.reset(); this.fileMatchFocused.reset(); diff --git a/src/vs/workbench/parts/search/browser/searchWidget.ts b/src/vs/workbench/parts/search/browser/searchWidget.ts index 15342de2365..86bf8193435 100644 --- a/src/vs/workbench/parts/search/browser/searchWidget.ts +++ b/src/vs/workbench/parts/search/browser/searchWidget.ts @@ -14,7 +14,7 @@ import { FindInput, IFindInputOptions } from 'vs/base/browser/ui/findinput/findI import { IMessage, HistoryInputBox } from 'vs/base/browser/ui/inputbox/inputBox'; import { Button, IButtonOptions } from 'vs/base/browser/ui/button/button'; import { IKeyboardEvent } from 'vs/base/browser/keyboardEvent'; -import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry'; +import { KeybindingsRegistry, KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding'; import { ContextKeyExpr, IContextKeyService, IContextKey } from 'vs/platform/contextkey/common/contextkey'; import { IContextViewService } from 'vs/platform/contextview/browser/contextView'; @@ -473,7 +473,7 @@ export class SearchWidget extends Widget { export function registerContributions() { KeybindingsRegistry.registerCommandAndKeybindingRule({ id: ReplaceAllAction.ID, - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: ContextKeyExpr.and(Constants.SearchViewVisibleKey, Constants.ReplaceActiveKey, CONTEXT_FIND_WIDGET_NOT_VISIBLE), primary: KeyMod.Alt | KeyMod.CtrlCmd | KeyCode.Enter, handler: accessor => { diff --git a/src/vs/workbench/parts/search/electron-browser/search.contribution.ts b/src/vs/workbench/parts/search/electron-browser/search.contribution.ts index 23a3349681d..af07196b912 100644 --- a/src/vs/workbench/parts/search/electron-browser/search.contribution.ts +++ b/src/vs/workbench/parts/search/electron-browser/search.contribution.ts @@ -19,7 +19,7 @@ import { ExplorerFolderContext, ExplorerRootContext } from 'vs/workbench/parts/f import { SyncActionDescriptor, MenuRegistry, MenuId, ICommandAction } from 'vs/platform/actions/common/actions'; import { IWorkbenchActionRegistry, Extensions as ActionExtensions } from 'vs/workbench/common/actions'; import { QuickOpenHandlerDescriptor, IQuickOpenRegistry, Extensions as QuickOpenExtensions } from 'vs/workbench/browser/quickopen'; -import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry'; +import { KeybindingsRegistry, KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { IQuickOpenService } from 'vs/platform/quickOpen/common/quickOpen'; import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService'; @@ -68,7 +68,7 @@ const category = nls.localize('search', "Search"); KeybindingsRegistry.registerCommandAndKeybindingRule({ id: 'workbench.action.search.toggleQueryDetails', - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: Constants.SearchViewVisibleKey, primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_J, handler: accessor => { @@ -81,7 +81,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({ KeybindingsRegistry.registerCommandAndKeybindingRule({ id: Constants.FocusSearchFromResults, - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: ContextKeyExpr.and(Constants.SearchViewVisibleKey, Constants.FirstMatchFocusKey), primary: KeyMod.CtrlCmd | KeyCode.UpArrow, handler: (accessor, args: any) => { @@ -92,7 +92,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({ KeybindingsRegistry.registerCommandAndKeybindingRule({ id: Constants.OpenMatchToSide, - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: ContextKeyExpr.and(Constants.SearchViewVisibleKey, Constants.FileMatchOrMatchFocusKey), primary: KeyMod.CtrlCmd | KeyCode.Enter, mac: { @@ -107,7 +107,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({ KeybindingsRegistry.registerCommandAndKeybindingRule({ id: Constants.CancelActionId, - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: ContextKeyExpr.and(Constants.SearchViewVisibleKey, WorkbenchListFocusContextKey), primary: KeyCode.Escape, handler: (accessor, args: any) => { @@ -118,7 +118,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({ KeybindingsRegistry.registerCommandAndKeybindingRule({ id: Constants.RemoveActionId, - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: ContextKeyExpr.and(Constants.SearchViewVisibleKey, Constants.FileMatchOrMatchFocusKey), primary: KeyCode.Delete, mac: { @@ -133,7 +133,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({ KeybindingsRegistry.registerCommandAndKeybindingRule({ id: Constants.ReplaceActionId, - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: ContextKeyExpr.and(Constants.SearchViewVisibleKey, Constants.ReplaceActiveKey, Constants.MatchFocusKey), primary: KeyMod.Shift | KeyMod.CtrlCmd | KeyCode.KEY_1, handler: (accessor, args: any) => { @@ -145,7 +145,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({ KeybindingsRegistry.registerCommandAndKeybindingRule({ id: Constants.ReplaceAllInFileActionId, - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: ContextKeyExpr.and(Constants.SearchViewVisibleKey, Constants.ReplaceActiveKey, Constants.FileFocusKey), primary: KeyMod.Shift | KeyMod.CtrlCmd | KeyCode.KEY_1, secondary: [KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.Enter], @@ -158,7 +158,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({ KeybindingsRegistry.registerCommandAndKeybindingRule({ id: Constants.ReplaceAllInFolderActionId, - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: ContextKeyExpr.and(Constants.SearchViewVisibleKey, Constants.ReplaceActiveKey, Constants.FolderFocusKey), primary: KeyMod.Shift | KeyMod.CtrlCmd | KeyCode.KEY_1, secondary: [KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.Enter], @@ -171,7 +171,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({ KeybindingsRegistry.registerCommandAndKeybindingRule({ id: Constants.CloseReplaceWidgetActionId, - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: ContextKeyExpr.and(Constants.SearchViewVisibleKey, Constants.ReplaceInputBoxFocusedKey), primary: KeyCode.Escape, handler: (accessor, args: any) => { @@ -181,7 +181,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({ KeybindingsRegistry.registerCommandAndKeybindingRule({ id: FocusNextInputAction.ID, - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: ContextKeyExpr.and(Constants.SearchViewVisibleKey, Constants.InputBoxFocusedKey), primary: KeyMod.CtrlCmd | KeyCode.DownArrow, handler: (accessor, args: any) => { @@ -191,7 +191,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({ KeybindingsRegistry.registerCommandAndKeybindingRule({ id: FocusPreviousInputAction.ID, - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: ContextKeyExpr.and(Constants.SearchViewVisibleKey, Constants.InputBoxFocusedKey, Constants.SearchInputBoxFocusedKey.toNegated()), primary: KeyMod.CtrlCmd | KeyCode.UpArrow, handler: (accessor, args: any) => { @@ -241,7 +241,7 @@ MenuRegistry.appendMenuItem(MenuId.SearchContext, { KeybindingsRegistry.registerCommandAndKeybindingRule({ id: Constants.CopyMatchCommandId, - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: Constants.FileMatchOrMatchFocusKey, primary: KeyMod.CtrlCmd | KeyCode.KEY_C, handler: copyMatchCommand @@ -259,7 +259,7 @@ MenuRegistry.appendMenuItem(MenuId.SearchContext, { KeybindingsRegistry.registerCommandAndKeybindingRule({ id: Constants.CopyPathCommandId, - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: Constants.FileMatchOrFolderMatchFocusKey, primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.KEY_C, win: { @@ -476,29 +476,45 @@ const registry = Registry.as(ActionExtensions.Workbenc // Show Search 'when' is redundant but if the two conflict with exactly the same keybinding and 'when' clause, then they can show up as "unbound" - #51780 registry.registerWorkbenchAction(new SyncActionDescriptor(FindInFilesAction, VIEW_ID, nls.localize('showSearchViewl', "Show Search"), { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_F }, Constants.SearchViewVisibleKey.toNegated()), 'View: Show Search', nls.localize('view', "View")); registry.registerWorkbenchAction(new SyncActionDescriptor(FindInFilesAction, Constants.FindInFilesActionId, nls.localize('findInFiles', "Find in Files"), { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_F }), 'Find in Files', category); +MenuRegistry.appendMenuItem(MenuId.MenubarEditMenu, { + group: '4_find_global', + command: { + id: Constants.FindInFilesActionId, + title: nls.localize({ key: 'miFindInFiles', comment: ['&& denotes a mnemonic'] }, "Find &&in Files") + }, + order: 1 +}); registry.registerWorkbenchAction(new SyncActionDescriptor(FocusNextSearchResultAction, FocusNextSearchResultAction.ID, FocusNextSearchResultAction.LABEL, { primary: KeyCode.F4 }, ContextKeyExpr.and(Constants.HasSearchResults)), 'Focus Next Search Result', category); registry.registerWorkbenchAction(new SyncActionDescriptor(FocusPreviousSearchResultAction, FocusPreviousSearchResultAction.ID, FocusPreviousSearchResultAction.LABEL, { primary: KeyMod.Shift | KeyCode.F4 }, ContextKeyExpr.and(Constants.HasSearchResults)), 'Focus Previous Search Result', category); registry.registerWorkbenchAction(new SyncActionDescriptor(ReplaceInFilesAction, ReplaceInFilesAction.ID, ReplaceInFilesAction.LABEL, { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_H }), 'Replace in Files', category); +MenuRegistry.appendMenuItem(MenuId.MenubarEditMenu, { + group: '4_find_global', + command: { + id: ReplaceInFilesAction.ID, + title: nls.localize({ key: 'miReplaceInFiles', comment: ['&& denotes a mnemonic'] }, "Replace &&in Files") + }, + order: 2 +}); KeybindingsRegistry.registerCommandAndKeybindingRule(objects.assign({ id: Constants.ToggleCaseSensitiveCommandId, - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: ContextKeyExpr.and(Constants.SearchViewVisibleKey, Constants.SearchInputBoxFocusedKey), handler: toggleCaseSensitiveCommand }, ToggleCaseSensitiveKeybinding)); KeybindingsRegistry.registerCommandAndKeybindingRule(objects.assign({ id: Constants.ToggleWholeWordCommandId, - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: ContextKeyExpr.and(Constants.SearchViewVisibleKey, Constants.SearchInputBoxFocusedKey), handler: toggleWholeWordCommand }, ToggleWholeWordKeybinding)); KeybindingsRegistry.registerCommandAndKeybindingRule(objects.assign({ id: Constants.ToggleRegexCommandId, - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: ContextKeyExpr.and(Constants.SearchViewVisibleKey, Constants.SearchInputBoxFocusedKey), handler: toggleRegexCommand }, ToggleRegexKeybinding)); diff --git a/src/vs/workbench/parts/snippets/electron-browser/tabCompletion.ts b/src/vs/workbench/parts/snippets/electron-browser/tabCompletion.ts index 9b2b047160c..93c0e82a043 100644 --- a/src/vs/workbench/parts/snippets/electron-browser/tabCompletion.ts +++ b/src/vs/workbench/parts/snippets/electron-browser/tabCompletion.ts @@ -8,7 +8,7 @@ import { localize } from 'vs/nls'; import { KeyCode } from 'vs/base/common/keyCodes'; import { RawContextKey, IContextKeyService, ContextKeyExpr, IContextKey } from 'vs/platform/contextkey/common/contextkey'; -import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry'; +import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; import { ISnippetsService } from 'vs/workbench/parts/snippets/electron-browser/snippets.contribution'; import { getNonWhitespacePrefix, SnippetSuggestion } from 'vs/workbench/parts/snippets/electron-browser/snippetsService'; import { Registry } from 'vs/platform/registry/common/platform'; @@ -142,7 +142,7 @@ registerEditorCommand(new TabCompletionCommand({ precondition: TabCompletionController.ContextKey, handler: x => x.performSnippetCompletions(), kbOpts: { - weight: KeybindingsRegistry.WEIGHT.editorContrib(), + weight: KeybindingWeight.EditorContrib, kbExpr: ContextKeyExpr.and( EditorContextKeys.editorTextFocus, EditorContextKeys.tabDoesNotMoveFocus, diff --git a/src/vs/workbench/parts/tasks/electron-browser/task.contribution.ts b/src/vs/workbench/parts/tasks/electron-browser/task.contribution.ts index f301f5471da..a4e284cf727 100644 --- a/src/vs/workbench/parts/tasks/electron-browser/task.contribution.ts +++ b/src/vs/workbench/parts/tasks/electron-browser/task.contribution.ts @@ -39,7 +39,7 @@ import { IConfigurationService, ConfigurationTarget } from 'vs/platform/configur import { IFileService, IFileStat } from 'vs/platform/files/common/files'; import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions'; import { CommandsRegistry } from 'vs/platform/commands/common/commands'; -import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry'; +import { KeybindingsRegistry, KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; import { ProblemMatcherRegistry, NamedProblemMatcher } from 'vs/workbench/parts/tasks/common/problemMatcher'; import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage'; import { IProgressService2, IProgressOptions, ProgressLocation } from 'vs/workbench/services/progress/common/progress'; @@ -566,7 +566,7 @@ class TaskService implements ITaskService { KeybindingsRegistry.registerKeybindingRule({ id: 'workbench.action.tasks.build', - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: undefined, primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_B }); diff --git a/src/vs/workbench/parts/terminal/common/terminal.ts b/src/vs/workbench/parts/terminal/common/terminal.ts index 3e637c51d8f..245a8ac3a6e 100644 --- a/src/vs/workbench/parts/terminal/common/terminal.ts +++ b/src/vs/workbench/parts/terminal/common/terminal.ts @@ -542,6 +542,8 @@ export interface ITerminalInstance { setDimensions(dimensions: ITerminalDimensions): void; addDisposable(disposable: IDisposable): void; + + toggleEscapeSequenceLogging(): void; } export interface ITerminalCommandTracker { diff --git a/src/vs/workbench/parts/terminal/common/terminalCommands.ts b/src/vs/workbench/parts/terminal/common/terminalCommands.ts index fa7471a2316..8d5345ed224 100644 --- a/src/vs/workbench/parts/terminal/common/terminalCommands.ts +++ b/src/vs/workbench/parts/terminal/common/terminalCommands.ts @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry'; +import { KeybindingsRegistry, KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; import { ITerminalService } from 'vs/workbench/parts/terminal/common/terminal'; export const enum TERMINAL_COMMAND_ID { @@ -54,6 +54,7 @@ export const enum TERMINAL_COMMAND_ID { SELECT_TO_NEXT_COMMAND = 'workbench.action.terminal.selectToNextCommand', SELECT_TO_PREVIOUS_LINE = 'workbench.action.terminal.selectToPreviousLine', SELECT_TO_NEXT_LINE = 'workbench.action.terminal.selectToNextLine', + TOGGLE_ESCAPE_SEQUENCE_LOGGING = 'toggleEscapeSequenceLogging' } @@ -68,7 +69,7 @@ function registerOpenTerminalAtIndexCommands(): void { KeybindingsRegistry.registerCommandAndKeybindingRule({ id: `workbench.action.terminal.focusAtIndex${visibleIndex}`, - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: void 0, primary: null, handler: accessor => { diff --git a/src/vs/workbench/parts/terminal/electron-browser/terminal.contribution.ts b/src/vs/workbench/parts/terminal/electron-browser/terminal.contribution.ts index 74c5d15af9b..835be4cc86f 100644 --- a/src/vs/workbench/parts/terminal/electron-browser/terminal.contribution.ts +++ b/src/vs/workbench/parts/terminal/electron-browser/terminal.contribution.ts @@ -17,14 +17,14 @@ import { getTerminalDefaultShellUnixLike, getTerminalDefaultShellWindows } from import { IWorkbenchActionRegistry, Extensions as ActionExtensions } from 'vs/workbench/common/actions'; import { KeyCode, KeyMod } from 'vs/base/common/keyCodes'; import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey'; -import { KillTerminalAction, ClearSelectionTerminalAction, CopyTerminalSelectionAction, CreateNewTerminalAction, CreateNewInActiveWorkspaceTerminalAction, FocusActiveTerminalAction, FocusNextTerminalAction, FocusPreviousTerminalAction, SelectDefaultShellWindowsTerminalAction, RunSelectedTextInTerminalAction, RunActiveFileInTerminalAction, ScrollDownTerminalAction, ScrollDownPageTerminalAction, ScrollToBottomTerminalAction, ScrollUpTerminalAction, ScrollUpPageTerminalAction, ScrollToTopTerminalAction, TerminalPasteAction, ToggleTerminalAction, ClearTerminalAction, AllowWorkspaceShellTerminalCommand, DisallowWorkspaceShellTerminalCommand, RenameTerminalAction, SelectAllTerminalAction, FocusTerminalFindWidgetAction, HideTerminalFindWidgetAction, DeleteWordLeftTerminalAction, DeleteWordRightTerminalAction, QuickOpenActionTermContributor, QuickOpenTermAction, TERMINAL_PICKER_PREFIX, MoveToLineStartTerminalAction, MoveToLineEndTerminalAction, SplitTerminalAction, SplitInActiveWorkspaceTerminalAction, FocusPreviousPaneTerminalAction, FocusNextPaneTerminalAction, ResizePaneLeftTerminalAction, ResizePaneRightTerminalAction, ResizePaneUpTerminalAction, ResizePaneDownTerminalAction, ScrollToPreviousCommandAction, ScrollToNextCommandAction, SelectToPreviousCommandAction, SelectToNextCommandAction, SelectToPreviousLineAction, SelectToNextLineAction } from 'vs/workbench/parts/terminal/electron-browser/terminalActions'; +import { KillTerminalAction, ClearSelectionTerminalAction, CopyTerminalSelectionAction, CreateNewTerminalAction, CreateNewInActiveWorkspaceTerminalAction, FocusActiveTerminalAction, FocusNextTerminalAction, FocusPreviousTerminalAction, SelectDefaultShellWindowsTerminalAction, RunSelectedTextInTerminalAction, RunActiveFileInTerminalAction, ScrollDownTerminalAction, ScrollDownPageTerminalAction, ScrollToBottomTerminalAction, ScrollUpTerminalAction, ScrollUpPageTerminalAction, ScrollToTopTerminalAction, TerminalPasteAction, ToggleTerminalAction, ClearTerminalAction, AllowWorkspaceShellTerminalCommand, DisallowWorkspaceShellTerminalCommand, RenameTerminalAction, SelectAllTerminalAction, FocusTerminalFindWidgetAction, HideTerminalFindWidgetAction, DeleteWordLeftTerminalAction, DeleteWordRightTerminalAction, QuickOpenActionTermContributor, QuickOpenTermAction, TERMINAL_PICKER_PREFIX, MoveToLineStartTerminalAction, MoveToLineEndTerminalAction, SplitTerminalAction, SplitInActiveWorkspaceTerminalAction, FocusPreviousPaneTerminalAction, FocusNextPaneTerminalAction, ResizePaneLeftTerminalAction, ResizePaneRightTerminalAction, ResizePaneUpTerminalAction, ResizePaneDownTerminalAction, ScrollToPreviousCommandAction, ScrollToNextCommandAction, SelectToPreviousCommandAction, SelectToNextCommandAction, SelectToPreviousLineAction, SelectToNextLineAction, ToggleEscapeSequenceLoggingAction } from 'vs/workbench/parts/terminal/electron-browser/terminalActions'; import { Registry } from 'vs/platform/registry/common/platform'; import { ShowAllCommandsAction } from 'vs/workbench/parts/quickopen/browser/commandsHandler'; import { SyncActionDescriptor } from 'vs/platform/actions/common/actions'; import { TerminalService } from 'vs/workbench/parts/terminal/electron-browser/terminalService'; import { ToggleTabFocusModeAction } from 'vs/editor/contrib/toggleTabFocusMode/toggleTabFocusMode'; import { registerSingleton } from 'vs/platform/instantiation/common/extensions'; -import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry'; +import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; import { OpenNextRecentlyUsedEditorInGroupAction, OpenPreviousRecentlyUsedEditorInGroupAction, FocusActiveGroupAction, FocusFirstGroupAction, FocusLastGroupAction, OpenFirstEditorInGroup, OpenLastEditorInGroup } from 'vs/workbench/browser/parts/editor/editorActions'; import { EDITOR_FONT_DEFAULTS } from 'vs/editor/common/config/editorOptions'; import { registerColors } from 'vs/workbench/parts/terminal/common/terminalColorRegistry'; @@ -75,12 +75,12 @@ configurationRegistry.registerConfiguration({ type: 'object', properties: { 'terminal.integrated.shell.linux': { - description: nls.localize('terminal.integrated.shell.linux', "The path of the shell that the terminal uses on Linux."), + description: nls.localize('terminal.integrated.shell.linux', "The path of the shell that the terminal uses on Linux. [Read more about configuring the shell](https://code.visualstudio.com/docs/editor/integrated-terminal#_configuration)."), type: 'string', default: getTerminalDefaultShellUnixLike() }, 'terminal.integrated.shellArgs.linux': { - description: nls.localize('terminal.integrated.shellArgs.linux', "The command line arguments to use when on the Linux terminal."), + description: nls.localize('terminal.integrated.shellArgs.linux', "The command line arguments to use when on the Linux terminal. [Read more about configuring the shell](https://code.visualstudio.com/docs/editor/integrated-terminal#_configuration)."), type: 'array', items: { type: 'string' @@ -88,12 +88,12 @@ configurationRegistry.registerConfiguration({ default: [] }, 'terminal.integrated.shell.osx': { - description: nls.localize('terminal.integrated.shell.osx', "The path of the shell that the terminal uses on macOS."), + description: nls.localize('terminal.integrated.shell.osx', "The path of the shell that the terminal uses on macOS. [Read more about configuring the shell](https://code.visualstudio.com/docs/editor/integrated-terminal#_configuration)."), type: 'string', default: getTerminalDefaultShellUnixLike() }, 'terminal.integrated.shellArgs.osx': { - description: nls.localize('terminal.integrated.shellArgs.osx', "The command line arguments to use when on the macOS terminal."), + description: nls.localize('terminal.integrated.shellArgs.osx', "The command line arguments to use when on the macOS terminal. [Read more about configuring the shell](https://code.visualstudio.com/docs/editor/integrated-terminal#_configuration)."), type: 'array', items: { type: 'string' @@ -104,12 +104,12 @@ configurationRegistry.registerConfiguration({ default: ['-l'] }, 'terminal.integrated.shell.windows': { - description: nls.localize('terminal.integrated.shell.windows', "The path of the shell that the terminal uses on Windows. When using shells shipped with Windows (cmd, PowerShell or Bash on Ubuntu)."), + description: nls.localize('terminal.integrated.shell.windows', "The path of the shell that the terminal uses on Windows. [Read more about configuring the shell](https://code.visualstudio.com/docs/editor/integrated-terminal#_configuration)."), type: 'string', default: getTerminalDefaultShellWindows() }, 'terminal.integrated.shellArgs.windows': { - description: nls.localize('terminal.integrated.shellArgs.windows', "The command line arguments to use when on the Windows terminal."), + description: nls.localize('terminal.integrated.shellArgs.windows', "The command line arguments to use when on the Windows terminal. [Read more about configuring the shell](https://code.visualstudio.com/docs/editor/integrated-terminal#_configuration)."), type: 'array', items: { type: 'string' @@ -117,22 +117,22 @@ configurationRegistry.registerConfiguration({ default: [] }, 'terminal.integrated.macOptionIsMeta': { - description: nls.localize('terminal.integrated.macOptionIsMeta', "Treat the option key as the meta key in the terminal on macOS."), + description: nls.localize('terminal.integrated.macOptionIsMeta', "Controls whether to treat the option key as the meta key in the terminal on macOS."), type: 'boolean', default: false }, 'terminal.integrated.macOptionClickForcesSelection': { - description: nls.localize('terminal.integrated.macOptionClickForcesSelection', "Whether to force selection when using Option+click on macOS. This will force a regular (line) selection and disallow the use of column selection mode. This enables copying and pasting using the regular terminal selection, for example, when mouse mode is enabled in tmux."), + description: nls.localize('terminal.integrated.macOptionClickForcesSelection', "Controls whether to force selection when using Option+click on macOS. This will force a regular (line) selection and disallow the use of column selection mode. This enables copying and pasting using the regular terminal selection, for example, when mouse mode is enabled in tmux."), type: 'boolean', default: false }, 'terminal.integrated.copyOnSelection': { - description: nls.localize('terminal.integrated.copyOnSelection', "When set, text selected in the terminal will be copied to the clipboard."), + description: nls.localize('terminal.integrated.copyOnSelection', "Controls whether text selected in the terminal will be copied to the clipboard."), type: 'boolean', default: false }, 'terminal.integrated.drawBoldTextInBrightColors': { - description: nls.localize('terminal.integrated.drawBoldTextInBrightColors', "When set, bold text in the terminal will always use the \"bright\" ANSI color variant."), + description: nls.localize('terminal.integrated.drawBoldTextInBrightColors', "Controls whether bold text in the terminal will always use the \"bright\" ANSI color variant."), type: 'boolean', default: true }, @@ -221,12 +221,12 @@ configurationRegistry.registerConfiguration({ default: undefined }, 'terminal.integrated.confirmOnExit': { - description: nls.localize('terminal.integrated.confirmOnExit', "Whether to confirm on exit if there are active terminal sessions."), + description: nls.localize('terminal.integrated.confirmOnExit', "Controls whether to confirm on exit if there are active terminal sessions."), type: 'boolean', default: false }, 'terminal.integrated.enableBell': { - description: nls.localize('terminal.integrated.enableBell', "Whether the terminal bell is enabled or not."), + description: nls.localize('terminal.integrated.enableBell', "Controls whether the terminal bell is enabled."), type: 'boolean', default: false }, @@ -353,12 +353,12 @@ configurationRegistry.registerConfiguration({ default: {} }, 'terminal.integrated.showExitAlert': { - description: nls.localize('terminal.integrated.showExitAlert', "Show alert \"The terminal process terminated with exit code\" when exit code is non-zero."), + description: nls.localize('terminal.integrated.showExitAlert', "Controls whether to show the alert \"The terminal process terminated with exit code\" when exit code is non-zero."), type: 'boolean', default: true }, 'terminal.integrated.experimentalRestore': { - description: nls.localize('terminal.integrated.experimentalRestore', "Whether to restore terminal sessions for the workspace automatically when launching VS Code. This is an experimental setting; it may be buggy and could change or be removed in the future."), + description: nls.localize('terminal.integrated.experimentalRestore', "Controls whether to restore terminal sessions for the workspace automatically when launching VS Code. This is an experimental setting; it may be buggy and could change or be removed in the future."), type: 'boolean', default: false }, @@ -451,7 +451,7 @@ actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(ScrollToTopTermi actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(ClearTerminalAction, ClearTerminalAction.ID, ClearTerminalAction.LABEL, { primary: KeyMod.CtrlCmd | KeyCode.KEY_K, linux: { primary: null } -}, KEYBINDING_CONTEXT_TERMINAL_FOCUS, KeybindingsRegistry.WEIGHT.workbenchContrib(1)), 'Terminal: Clear', category); +}, KEYBINDING_CONTEXT_TERMINAL_FOCUS, KeybindingWeight.WorkbenchContrib + 1), 'Terminal: Clear', category); if (platform.isWindows) { actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(SelectDefaultShellWindowsTerminalAction, SelectDefaultShellWindowsTerminalAction.ID, SelectDefaultShellWindowsTerminalAction.LABEL), 'Terminal: Select Default Shell', category); } @@ -544,6 +544,7 @@ actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(SelectToNextComm }, KEYBINDING_CONTEXT_TERMINAL_FOCUS), 'Terminal: Select To Next Command', category); actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(SelectToPreviousLineAction, SelectToPreviousLineAction.ID, SelectToPreviousLineAction.LABEL), 'Terminal: Select To Previous Line', category); actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(SelectToNextLineAction, SelectToNextLineAction.ID, SelectToNextLineAction.LABEL), 'Terminal: Select To Next Line', category); +actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(ToggleEscapeSequenceLoggingAction, ToggleEscapeSequenceLoggingAction.ID, ToggleEscapeSequenceLoggingAction.LABEL), 'Terminal: Toggle Escape Sequence Logging', category); setupTerminalCommands(); setupTerminalMenu(); diff --git a/src/vs/workbench/parts/terminal/electron-browser/terminalActions.ts b/src/vs/workbench/parts/terminal/electron-browser/terminalActions.ts index 69e8c6a7ae6..25b65e9eafc 100644 --- a/src/vs/workbench/parts/terminal/electron-browser/terminalActions.ts +++ b/src/vs/workbench/parts/terminal/electron-browser/terminalActions.ts @@ -1141,3 +1141,24 @@ export class SelectToNextLineAction extends Action { return TPromise.as(void 0); } } + + +export class ToggleEscapeSequenceLoggingAction extends Action { + public static readonly ID = TERMINAL_COMMAND_ID.TOGGLE_ESCAPE_SEQUENCE_LOGGING; + public static readonly LABEL = nls.localize('workbench.action.terminal.toggleEscapeSequenceLogging', "Toggle Escape Sequence Logging"); + + constructor( + id: string, label: string, + @ITerminalService private terminalService: ITerminalService + ) { + super(id, label); + } + + public run(): TPromise { + const instance = this.terminalService.getActiveInstance(); + if (instance) { + instance.toggleEscapeSequenceLogging(); + } + return TPromise.as(void 0); + } +} diff --git a/src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts b/src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts index 6b98f364797..df30323b6a6 100644 --- a/src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts +++ b/src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts @@ -1068,6 +1068,11 @@ export class TerminalInstance implements ITerminalInstance { private _updateTheme(theme?: ITheme): void { this._xterm.setOption('theme', this._getXtermTheme(theme)); } + + public toggleEscapeSequenceLogging(): void { + this._xterm._core.debug = !this._xterm._core.debug; + this._xterm.setOption('debug', this._xterm._core.debug); + } } registerThemingParticipant((theme: ITheme, collector: ICssStyleCollector) => { diff --git a/src/vs/workbench/parts/webview/electron-browser/baseWebviewEditor.ts b/src/vs/workbench/parts/webview/electron-browser/baseWebviewEditor.ts index aca88aff9df..7cbbbb07f67 100644 --- a/src/vs/workbench/parts/webview/electron-browser/baseWebviewEditor.ts +++ b/src/vs/workbench/parts/webview/electron-browser/baseWebviewEditor.ts @@ -77,4 +77,10 @@ export abstract class BaseWebviewEditor extends BaseEditor { this._webview.focus(); } } + + public selectAll(): void { + if (this._webview) { + this._webview.selectAll(); + } + } } diff --git a/src/vs/workbench/parts/webview/electron-browser/webview.contribution.ts b/src/vs/workbench/parts/webview/electron-browser/webview.contribution.ts index 3b34b5184ee..45e3dab5b9a 100644 --- a/src/vs/workbench/parts/webview/electron-browser/webview.contribution.ts +++ b/src/vs/workbench/parts/webview/electron-browser/webview.contribution.ts @@ -9,14 +9,14 @@ import { SyncActionDescriptor } from 'vs/platform/actions/common/actions'; import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey'; import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors'; import { registerSingleton } from 'vs/platform/instantiation/common/extensions'; -import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry'; +import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; import { Registry } from 'vs/platform/registry/common/platform'; import { EditorDescriptor, Extensions as EditorExtensions, IEditorRegistry } from 'vs/workbench/browser/editor'; import { Extensions as ActionExtensions, IWorkbenchActionRegistry } from 'vs/workbench/common/actions'; import { Extensions as EditorInputExtensions, IEditorInputFactoryRegistry } from 'vs/workbench/common/editor'; import { WebviewEditorInputFactory } from 'vs/workbench/parts/webview/electron-browser/webviewEditorInputFactory'; import { KEYBINDING_CONTEXT_WEBVIEWEDITOR_FOCUS, KEYBINDING_CONTEXT_WEBVIEW_FIND_WIDGET_VISIBLE } from './baseWebviewEditor'; -import { HideWebViewEditorFindCommand, OpenWebviewDeveloperToolsAction, ReloadWebviewAction, ShowWebViewEditorFindWidgetCommand } from './webviewCommands'; +import { HideWebViewEditorFindCommand, OpenWebviewDeveloperToolsAction, ReloadWebviewAction, ShowWebViewEditorFindWidgetCommand, SelectAllWebviewEditorCommand } from './webviewCommands'; import { WebviewEditor } from './webviewEditor'; import { WebviewEditorInput } from './webviewEditorInput'; import { IWebviewEditorService, WebviewEditorService } from './webviewEditorService'; @@ -42,10 +42,11 @@ const showNextFindWdigetCommand = new ShowWebViewEditorFindWidgetCommand({ id: ShowWebViewEditorFindWidgetCommand.ID, precondition: KEYBINDING_CONTEXT_WEBVIEWEDITOR_FOCUS, kbOpts: { - primary: KeyMod.CtrlCmd | KeyCode.KEY_F + primary: KeyMod.CtrlCmd | KeyCode.KEY_F, + weight: KeybindingWeight.EditorContrib } }); -KeybindingsRegistry.registerCommandAndKeybindingRule(showNextFindWdigetCommand.toCommandAndKeybindingRule(KeybindingsRegistry.WEIGHT.editorContrib())); +showNextFindWdigetCommand.register(); const hideCommand = new HideWebViewEditorFindCommand({ id: HideWebViewEditorFindCommand.ID, @@ -53,11 +54,21 @@ const hideCommand = new HideWebViewEditorFindCommand({ KEYBINDING_CONTEXT_WEBVIEWEDITOR_FOCUS, KEYBINDING_CONTEXT_WEBVIEW_FIND_WIDGET_VISIBLE), kbOpts: { - primary: KeyCode.Escape + primary: KeyCode.Escape, + weight: KeybindingWeight.EditorContrib } }); -KeybindingsRegistry.registerCommandAndKeybindingRule(hideCommand.toCommandAndKeybindingRule(KeybindingsRegistry.WEIGHT.editorContrib())); +hideCommand.register(); +const selectAllCommand = new SelectAllWebviewEditorCommand({ + id: SelectAllWebviewEditorCommand.ID, + precondition: KEYBINDING_CONTEXT_WEBVIEWEDITOR_FOCUS, + kbOpts: { + primary: KeyMod.CtrlCmd | KeyCode.KEY_A, + weight: KeybindingWeight.EditorContrib + } +}); +selectAllCommand.register(); actionRegistry.registerWorkbenchAction( new SyncActionDescriptor(OpenWebviewDeveloperToolsAction, OpenWebviewDeveloperToolsAction.ID, OpenWebviewDeveloperToolsAction.LABEL), diff --git a/src/vs/workbench/parts/webview/electron-browser/webviewCommands.ts b/src/vs/workbench/parts/webview/electron-browser/webviewCommands.ts index c30d4fa8c85..5866fcdbec6 100644 --- a/src/vs/workbench/parts/webview/electron-browser/webviewCommands.ts +++ b/src/vs/workbench/parts/webview/electron-browser/webviewCommands.ts @@ -33,6 +33,17 @@ export class HideWebViewEditorFindCommand extends Command { } } +export class SelectAllWebviewEditorCommand extends Command { + public static readonly ID = 'editor.action.webvieweditor.selectAll'; + + public runCommand(accessor: ServicesAccessor, args: any): void { + const webViewEditor = getActiveWebviewEditor(accessor); + if (webViewEditor) { + webViewEditor.selectAll(); + } + } +} + export class OpenWebviewDeveloperToolsAction extends Action { static readonly ID = 'workbench.action.webview.openDeveloperTools'; static readonly LABEL = nls.localize('openToolsLabel', "Open Webview Developer Tools"); diff --git a/src/vs/workbench/parts/webview/electron-browser/webviewEditor.ts b/src/vs/workbench/parts/webview/electron-browser/webviewEditor.ts index 82252859c77..8eb67ef6b68 100644 --- a/src/vs/workbench/parts/webview/electron-browser/webviewEditor.ts +++ b/src/vs/workbench/parts/webview/electron-browser/webviewEditor.ts @@ -5,6 +5,7 @@ import * as DOM from 'vs/base/browser/dom'; import { domEvent } from 'vs/base/browser/event'; +import { CancellationToken } from 'vs/base/common/cancellation'; import { Emitter, Event } from 'vs/base/common/event'; import { IDisposable } from 'vs/base/common/lifecycle'; import URI from 'vs/base/common/uri'; @@ -14,13 +15,12 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { IThemeService } from 'vs/platform/theme/common/themeService'; import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace'; import { EditorOptions } from 'vs/workbench/common/editor'; -import { IEditorGroup } from 'vs/workbench/services/group/common/editorGroupsService'; import { WebviewEditorInput } from 'vs/workbench/parts/webview/electron-browser/webviewEditorInput'; import { IEditorService } from 'vs/workbench/services/editor/common/editorService'; +import { IEditorGroup } from 'vs/workbench/services/group/common/editorGroupsService'; import { IPartService, Parts } from 'vs/workbench/services/part/common/partService'; import { BaseWebviewEditor, KEYBINDING_CONTEXT_WEBVIEWEDITOR_FIND_WIDGET_INPUT_FOCUSED, KEYBINDING_CONTEXT_WEBVIEWEDITOR_FOCUS, KEYBINDING_CONTEXT_WEBVIEW_FIND_WIDGET_VISIBLE } from './baseWebviewEditor'; import { WebviewElement } from './webviewElement'; -import { CancellationToken } from 'vs/base/common/cancellation'; export class WebviewEditor extends BaseWebviewEditor { diff --git a/src/vs/workbench/parts/webview/electron-browser/webviewEditorInput.ts b/src/vs/workbench/parts/webview/electron-browser/webviewEditorInput.ts index 6d48bf36101..07f44326ef7 100644 --- a/src/vs/workbench/parts/webview/electron-browser/webviewEditorInput.ts +++ b/src/vs/workbench/parts/webview/electron-browser/webviewEditorInput.ts @@ -3,15 +3,16 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { IDisposable, dispose } from 'vs/base/common/lifecycle'; +import { Emitter } from 'vs/base/common/event'; +import { dispose, IDisposable } from 'vs/base/common/lifecycle'; import URI from 'vs/base/common/uri'; import { TPromise } from 'vs/base/common/winjs.base'; import { IEditorModel } from 'vs/platform/editor/common/editor'; -import { EditorInput, EditorModel, IEditorInput, GroupIdentifier } from 'vs/workbench/common/editor'; +import { EditorInput, EditorModel, GroupIdentifier, IEditorInput } from 'vs/workbench/common/editor'; import { IPartService, Parts } from 'vs/workbench/services/part/common/partService'; +import * as vscode from 'vscode'; import { WebviewEvents, WebviewInputOptions, WebviewReviver } from './webviewEditorService'; import { WebviewElement } from './webviewElement'; -import * as vscode from 'vscode'; export class WebviewEditorInput extends EditorInput { private static handlePool = 0; @@ -35,6 +36,7 @@ export class WebviewEditorInput extends EditorInput { private _revived: boolean = false; public readonly extensionLocation: URI | undefined; + private readonly _id: number; constructor( public readonly viewType: string, @@ -47,6 +49,7 @@ export class WebviewEditorInput extends EditorInput { @IPartService private readonly _partService: IPartService, ) { super(); + this._id = WebviewEditorInput.handlePool++; this._name = name; this._options = options; this._events = events; @@ -58,6 +61,13 @@ export class WebviewEditorInput extends EditorInput { return WebviewEditorInput.typeId; } + public getId(): number { + return this._id; + } + + private readonly _onDidChangeIcon = this._register(new Emitter()); + public readonly onDidChangeIcon = this._onDidChangeIcon.event; + public dispose() { this.disposeWebview(); @@ -76,7 +86,10 @@ export class WebviewEditorInput extends EditorInput { } public getResource(): URI { - return null; + return URI.from({ + scheme: 'webview-panel', + path: `webview-panel/webview-${this._id}` + }); } public getName(): string { @@ -169,9 +182,8 @@ export class WebviewEditorInput extends EditorInput { public get container(): HTMLElement { if (!this._container) { - const id = WebviewEditorInput.handlePool++; this._container = document.createElement('div'); - this._container.id = `webview-${id}`; + this._container.id = `webview-${this._id}`; this._partService.getContainer(Parts.EDITOR_PART).appendChild(this._container); } return this._container; diff --git a/src/vs/workbench/parts/webview/electron-browser/webviewElement.ts b/src/vs/workbench/parts/webview/electron-browser/webviewElement.ts index a97e8f8fd1c..330e72730c4 100644 --- a/src/vs/workbench/parts/webview/electron-browser/webviewElement.ts +++ b/src/vs/workbench/parts/webview/electron-browser/webviewElement.ts @@ -443,6 +443,10 @@ export class WebviewElement extends Disposable { public reload() { this.contents = this._contents; } + + public selectAll() { + this._webview.selectAll(); + } } diff --git a/src/vs/workbench/parts/welcome/gettingStarted/electron-browser/telemetryOptOut.ts b/src/vs/workbench/parts/welcome/gettingStarted/electron-browser/telemetryOptOut.ts index 32cd90f5570..257d791463e 100644 --- a/src/vs/workbench/parts/welcome/gettingStarted/electron-browser/telemetryOptOut.ts +++ b/src/vs/workbench/parts/welcome/gettingStarted/electron-browser/telemetryOptOut.ts @@ -45,29 +45,30 @@ export class TelemetryOptOut implements IWorkbenchContribution { } storageService.store(TelemetryOptOut.TELEMETRY_OPT_OUT_SHOWN, true); + const optOutUrl = product.telemetryOptOutUrl; + const privacyUrl = product.privacyStatementUrl || product.telemetryOptOutUrl; + if (experimentState && experimentState.state === ExperimentState.Run && telemetryService.isOptedIn) { notificationService.prompt( Severity.Info, - localize('telemetryOptOut.optOutOption', "Microsoft collects usage data to improve VS Code. You may choose to opt out."), + localize('telemetryOptOut.optOutOption', "Please help Microsoft improve Visual Studio Code by allowing the collection of usage data. Read our [privacy statement]({0}) for more details.", privacyUrl), [ { - label: localize('telemetryOptOut.OptOut', "Opt out"), + label: localize('telemetryOptOut.OptIn', "Yes, glad to help"), + run: () => { } + }, + { + label: localize('telemetryOptOut.OptOut', "No, thanks"), run: () => { configurationService.updateValue('telemetry.enableTelemetry', false); configurationService.updateValue('telemetry.enableCrashReporter', false); } - }, - { - label: localize('telemetryOptOut.readMore', "Read More"), - run: () => openerService.open(URI.parse(product.telemetryOptOutUrl)) }] ); experimentService.markAsCompleted(experimentId); return; } - const optOutUrl = product.telemetryOptOutUrl; - const privacyUrl = product.privacyStatementUrl || product.telemetryOptOutUrl; const optOutNotice = localize('telemetryOptOut.optOutNotice', "Help improve VS Code by allowing Microsoft to collect usage data. Read our [privacy statement]({0}) and learn how to [opt out]({1}).", privacyUrl, optOutUrl); const optInNotice = localize('telemetryOptOut.optInNotice', "Help improve VS Code by allowing Microsoft to collect usage data. Read our [privacy statement]({0}) and learn how to [opt in]({1}).", privacyUrl, optOutUrl); diff --git a/src/vs/workbench/parts/welcome/walkThrough/electron-browser/walkThroughActions.ts b/src/vs/workbench/parts/welcome/walkThrough/electron-browser/walkThroughActions.ts index 5a838046aa8..6fc211d61f6 100644 --- a/src/vs/workbench/parts/welcome/walkThrough/electron-browser/walkThroughActions.ts +++ b/src/vs/workbench/parts/welcome/walkThrough/electron-browser/walkThroughActions.ts @@ -6,14 +6,14 @@ import { IEditorService } from 'vs/workbench/services/editor/common/editorService'; import { WalkThroughPart, WALK_THROUGH_FOCUS } from 'vs/workbench/parts/welcome/walkThrough/electron-browser/walkThroughPart'; -import { ICommandAndKeybindingRule, KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry'; +import { ICommandAndKeybindingRule, KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; import { EditorContextKeys } from 'vs/editor/common/editorContextKeys'; import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey'; import { KeyCode } from 'vs/base/common/keyCodes'; export const WalkThroughArrowUp: ICommandAndKeybindingRule = { id: 'workbench.action.interactivePlayground.arrowUp', - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: ContextKeyExpr.and(WALK_THROUGH_FOCUS, EditorContextKeys.editorTextFocus.toNegated()), primary: KeyCode.UpArrow, handler: accessor => { @@ -27,7 +27,7 @@ export const WalkThroughArrowUp: ICommandAndKeybindingRule = { export const WalkThroughArrowDown: ICommandAndKeybindingRule = { id: 'workbench.action.interactivePlayground.arrowDown', - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: ContextKeyExpr.and(WALK_THROUGH_FOCUS, EditorContextKeys.editorTextFocus.toNegated()), primary: KeyCode.DownArrow, handler: accessor => { @@ -41,7 +41,7 @@ export const WalkThroughArrowDown: ICommandAndKeybindingRule = { export const WalkThroughPageUp: ICommandAndKeybindingRule = { id: 'workbench.action.interactivePlayground.pageUp', - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: ContextKeyExpr.and(WALK_THROUGH_FOCUS, EditorContextKeys.editorTextFocus.toNegated()), primary: KeyCode.PageUp, handler: accessor => { @@ -55,7 +55,7 @@ export const WalkThroughPageUp: ICommandAndKeybindingRule = { export const WalkThroughPageDown: ICommandAndKeybindingRule = { id: 'workbench.action.interactivePlayground.pageDown', - weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), + weight: KeybindingWeight.WorkbenchContrib, when: ContextKeyExpr.and(WALK_THROUGH_FOCUS, EditorContextKeys.editorTextFocus.toNegated()), primary: KeyCode.PageDown, handler: accessor => { diff --git a/src/vs/workbench/services/bulkEdit/electron-browser/bulkEditService.ts b/src/vs/workbench/services/bulkEdit/electron-browser/bulkEditService.ts index a0a69bf0c88..dd3d391644c 100644 --- a/src/vs/workbench/services/bulkEdit/electron-browser/bulkEditService.ts +++ b/src/vs/workbench/services/bulkEdit/electron-browser/bulkEditService.ts @@ -47,11 +47,14 @@ abstract class Recording { abstract hasChanged(resource: URI): boolean; } +type ValidationResult = { canApply: true } | { canApply: false, reason: URI }; + class ModelEditTask implements IDisposable { private readonly _model: ITextModel; protected _edits: IIdentifiedSingleEditOperation[]; + private _expectedModelVersionId: number | undefined; protected _newEol: EndOfLineSequence; constructor(private readonly _modelReference: IReference) { @@ -64,6 +67,7 @@ class ModelEditTask implements IDisposable { } addEdit(resourceEdit: ResourceTextEdit): void { + this._expectedModelVersionId = resourceEdit.modelVersionId; for (const edit of resourceEdit.edits) { if (typeof edit.eol === 'number') { // honor eol-change @@ -82,6 +86,13 @@ class ModelEditTask implements IDisposable { } } + validate(): ValidationResult { + if (typeof this._expectedModelVersionId === 'undefined' || this._model.getVersionId() === this._expectedModelVersionId) { + return { canApply: true }; + } + return { canApply: false, reason: this._model.uri }; + } + apply(): void { if (this._edits.length > 0) { this._edits = mergeSort(this._edits, (a, b) => Range.compareRangesUsingStarts(a.range, b.range)); @@ -191,6 +202,16 @@ class BulkEditModel implements IDisposable { return this; } + validate(): ValidationResult { + for (const task of this._tasks) { + const result = task.validate(); + if (!result.canApply) { + return result; + } + } + return { canApply: true }; + } + apply(): void { for (const task of this._tasks) { task.apply(); @@ -330,6 +351,11 @@ export class BulkEdit { throw new Error(localize('conflict', "These files have changed in the meantime: {0}", conflicts.join(', '))); } + const validationResult = model.validate(); + if (validationResult.canApply === false) { + throw new Error(`${validationResult.reason.toString()} has changed in the meantime`); + } + await model.apply(); model.dispose(); } diff --git a/src/vs/workbench/services/keybinding/electron-browser/keybindingService.ts b/src/vs/workbench/services/keybinding/electron-browser/keybindingService.ts index e7f59e3cd19..c0521529d6e 100644 --- a/src/vs/workbench/services/keybinding/electron-browser/keybindingService.ts +++ b/src/vs/workbench/services/keybinding/electron-browser/keybindingService.ts @@ -16,7 +16,7 @@ import { KeybindingResolver } from 'vs/platform/keybinding/common/keybindingReso import { ICommandService } from 'vs/platform/commands/common/commands'; import { IKeybindingEvent, IUserFriendlyKeybinding, KeybindingSource, IKeyboardEvent } from 'vs/platform/keybinding/common/keybinding'; import { ContextKeyExpr, IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; -import { IKeybindingItem, KeybindingsRegistry, IKeybindingRule2, KeybindingRuleSource } from 'vs/platform/keybinding/common/keybindingsRegistry'; +import { IKeybindingItem, KeybindingsRegistry, IKeybindingRule2, KeybindingRuleSource, KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; import { Registry } from 'vs/platform/registry/common/platform'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { keybindingsTelemetry } from 'vs/platform/telemetry/common/telemetryUtils'; @@ -485,9 +485,9 @@ export class WorkbenchKeybindingService extends AbstractKeybindingService { let weight: number; if (isBuiltin) { - weight = KeybindingsRegistry.WEIGHT.builtinExtension(idx); + weight = KeybindingWeight.BuiltinExtension + idx; } else { - weight = KeybindingsRegistry.WEIGHT.externalExtension(idx); + weight = KeybindingWeight.ExternalExtension + idx; } let desc = { diff --git a/src/vs/workbench/services/preferences/browser/preferencesService.ts b/src/vs/workbench/services/preferences/browser/preferencesService.ts index f963de4c85d..f0c69877821 100644 --- a/src/vs/workbench/services/preferences/browser/preferencesService.ts +++ b/src/vs/workbench/services/preferences/browser/preferencesService.ts @@ -221,21 +221,30 @@ export class PreferencesService extends Disposable implements IPreferencesServic if (textual) { const emptyContents = '// ' + nls.localize('emptyKeybindingsHeader', "Place your key bindings in this file to overwrite the defaults") + '\n[\n]'; const editableKeybindings = URI.file(this.environmentService.appKeybindingsPath); + const openDefaultKeybindings = !!this.configurationService.getValue('workbench.settings.openDefaultKeybindings'); // Create as needed and open in editor return this.createIfNotExists(editableKeybindings, emptyContents).then(() => { - const activeEditorGroup = this.editorGroupService.activeGroup; - const sideEditorGroup = this.editorGroupService.addGroup(activeEditorGroup.id, GroupDirection.RIGHT); - - return TPromise.join([ - this.editorService.openEditor({ resource: this.defaultKeybindingsResource, options: { pinned: true, preserveFocus: true }, label: nls.localize('defaultKeybindings', "Default Keybindings"), description: '' }), - this.editorService.openEditor({ resource: editableKeybindings, options: { pinned: true } }, sideEditorGroup.id) - ]).then(editors => void 0); + if (openDefaultKeybindings) { + const activeEditorGroup = this.editorGroupService.activeGroup; + const sideEditorGroup = this.editorGroupService.addGroup(activeEditorGroup.id, GroupDirection.RIGHT); + return TPromise.join([ + this.editorService.openEditor({ resource: this.defaultKeybindingsResource, options: { pinned: true, preserveFocus: true }, label: nls.localize('defaultKeybindings', "Default Keybindings"), description: '' }), + this.editorService.openEditor({ resource: editableKeybindings, options: { pinned: true } }, sideEditorGroup.id) + ]).then(editors => void 0); + } else { + return this.editorService.openEditor({ resource: editableKeybindings, options: { pinned: true } }).then(() => void 0); + } }); } + return this.editorService.openEditor(this.instantiationService.createInstance(KeybindingsEditorInput), { pinned: true }).then(() => null); } + openDefaultKeybindingsFile(): TPromise { + return this.editorService.openEditor({ resource: this.defaultKeybindingsResource }); + } + configureSettingsForLanguage(language: string): void { this.openGlobalSettings() .then(editor => this.createPreferencesEditorModel(this.userSettingsResource) diff --git a/src/vs/workbench/services/preferences/common/preferences.ts b/src/vs/workbench/services/preferences/common/preferences.ts index 93be98d9f2b..c3174c92663 100644 --- a/src/vs/workbench/services/preferences/common/preferences.ts +++ b/src/vs/workbench/services/preferences/common/preferences.ts @@ -152,6 +152,7 @@ export interface IPreferencesService { openFolderSettings(folder: URI, options?: IEditorOptions, group?: IEditorGroup): TPromise; switchSettings(target: ConfigurationTarget, resource: URI): TPromise; openGlobalKeybindingSettings(textual: boolean): TPromise; + openDefaultKeybindingsFile(): TPromise; configureSettingsForLanguage(language: string): void; } diff --git a/src/vs/workbench/services/search/node/searchService.ts b/src/vs/workbench/services/search/node/searchService.ts index 7053106bc18..dad4ec17770 100644 --- a/src/vs/workbench/services/search/node/searchService.ts +++ b/src/vs/workbench/services/search/node/searchService.ts @@ -4,37 +4,35 @@ *--------------------------------------------------------------------------------------------*/ 'use strict'; -import { PPromise, TPromise } from 'vs/base/common/winjs.base'; -import uri from 'vs/base/common/uri'; import * as arrays from 'vs/base/common/arrays'; +import { Event } from 'vs/base/common/event'; +import { Disposable, IDisposable, toDisposable } from 'vs/base/common/lifecycle'; +import { ResourceMap } from 'vs/base/common/map'; +import { Schemas } from 'vs/base/common/network'; import * as objects from 'vs/base/common/objects'; import * as strings from 'vs/base/common/strings'; +import uri from 'vs/base/common/uri'; +import { TPromise } from 'vs/base/common/winjs.base'; +import * as pfs from 'vs/base/node/pfs'; import { getNextTickChannel } from 'vs/base/parts/ipc/common/ipc'; import { Client, IIPCOptions } from 'vs/base/parts/ipc/node/ipc.cp'; -import { IProgress, LineMatch, FileMatch, ISearchComplete, ISearchProgressItem, QueryType, IFileMatch, ISearchQuery, IFolderQuery, ISearchConfiguration, ISearchService, pathIncludedInQuery, ISearchResultProvider } from 'vs/platform/search/common/search'; -import { IUntitledEditorService } from 'vs/workbench/services/untitled/common/untitledEditorService'; import { IModelService } from 'vs/editor/common/services/modelService'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; -import { IRawSearch, ISerializedSearchComplete, ISerializedSearchProgressItem, ISerializedFileMatch, IRawSearchService, ITelemetryEvent, isSerializedSearchComplete, isSerializedSearchSuccess, ISerializedSearchSuccess } from './search'; -import { ISearchChannel, SearchChannelClient } from './searchIpc'; -import { IEnvironmentService, IDebugParams } from 'vs/platform/environment/common/environment'; -import { ResourceMap } from 'vs/base/common/map'; -import { IDisposable, toDisposable } from 'vs/base/common/lifecycle'; -import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; -import { onUnexpectedError } from 'vs/base/common/errors'; -import { Schemas } from 'vs/base/common/network'; -import * as pfs from 'vs/base/node/pfs'; +import { IDebugParams, IEnvironmentService } from 'vs/platform/environment/common/environment'; import { ILogService } from 'vs/platform/log/common/log'; +import { FileMatch, IFileMatch, IFolderQuery, IProgress, ISearchComplete, ISearchConfiguration, ISearchProgressItem, ISearchQuery, ISearchResultProvider, ISearchService, LineMatch, pathIncludedInQuery, QueryType } from 'vs/platform/search/common/search'; +import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions'; -import { Event } from 'vs/base/common/event'; +import { IUntitledEditorService } from 'vs/workbench/services/untitled/common/untitledEditorService'; +import { IRawSearch, IRawSearchService, ISerializedFileMatch, ISerializedSearchComplete, ISerializedSearchProgressItem, isSerializedSearchComplete, isSerializedSearchSuccess, ITelemetryEvent } from './search'; +import { ISearchChannel, SearchChannelClient } from './searchIpc'; -export class SearchService implements ISearchService { +export class SearchService extends Disposable implements ISearchService { public _serviceBrand: any; private diskSearch: DiskSearch; private readonly searchProviders: ISearchResultProvider[] = []; private fileSearchProvider: ISearchResultProvider; - private forwardingTelemetry: PPromise; constructor( @IModelService private modelService: IModelService, @@ -45,7 +43,11 @@ export class SearchService implements ISearchService { @ILogService private logService: ILogService, @IExtensionService private extensionService: IExtensionService ) { + super(); this.diskSearch = new DiskSearch(!environmentService.isBuilt || environmentService.verbose, /*timeout=*/undefined, environmentService.debugSearch); + this._register(this.diskSearch.onTelemetry(event => { + this.telemetryService.publicLog(event.eventName, event.data); + })); } public registerSearchResultProvider(scheme: string, provider: ISearchResultProvider): IDisposable { @@ -90,8 +92,6 @@ export class SearchService implements ISearchService { } public search(query: ISearchQuery, onProgress?: (item: ISearchProgressItem) => void): TPromise { - this.forwardTelemetry(); - let combinedPromise: TPromise; return new TPromise((onComplete, onError) => { @@ -105,24 +105,24 @@ export class SearchService implements ISearchService { this.logService.trace('SearchService#search', JSON.stringify(query)); - const startTime = Date.now(); - const searchWithProvider = (provider: ISearchResultProvider) => TPromise.wrap(provider.search(query)).then(e => e, - null, - progress => { - if (progress.resource) { - // Match - if (!localResults.has(progress.resource) && onProgress) { // don't override local results - onProgress(progress); - } - } else if (onProgress) { - // Progress - onProgress(progress); + const onProviderProgress = progress => { + if (progress.resource) { + // Match + if (!localResults.has(progress.resource) && onProgress) { // don't override local results + onProgress(progress); } + } else if (onProgress) { + // Progress + onProgress(progress); + } - if (progress.message) { - this.logService.debug('SearchService#search', progress.message); - } - }); + if (progress.message) { + this.logService.debug('SearchService#search', progress.message); + } + }; + + const startTime = Date.now(); + const searchWithProvider = (provider: ISearchResultProvider) => TPromise.as(provider.search(query, onProviderProgress)); const schemesInQuery = query.folderQueries.map(fq => fq.folder.scheme); const providerActivations = schemesInQuery.map(scheme => this.extensionService.activateByEvent(`onSearch:${scheme}`)); @@ -268,15 +268,6 @@ export class SearchService implements ISearchService { ].map(provider => provider && provider.clearCache(cacheKey))) .then(() => { }); } - - private forwardTelemetry() { - if (!this.forwardingTelemetry) { - this.forwardingTelemetry = this.diskSearch.fetchTelemetry() - .then(null, onUnexpectedError, event => { - this.telemetryService.publicLog(event.eventName, event.data); - }); - } - } } export class DiskSearch implements ISearchResultProvider { @@ -316,7 +307,11 @@ export class DiskSearch implements ISearchResultProvider { this.raw = new SearchChannelClient(channel); } - public search(query: ISearchQuery): PPromise { + public get onTelemetry(): Event { + return this.raw.onTelemetry; + } + + public search(query: ISearchQuery, onProgress?: (p: ISearchProgressItem) => void): TPromise { const folderQueries = query.folderQueries || []; return TPromise.join(folderQueries.map(q => q.folder.scheme === Schemas.file && pfs.exists(q.folder.fsPath))) .then(exists => { @@ -330,7 +325,7 @@ export class DiskSearch implements ISearchResultProvider { event = this.raw.textSearch(rawSearch); } - return DiskSearch.collectResultsFromEvent(event); + return DiskSearch.collectResultsFromEvent(event, onProgress); }); } @@ -375,58 +370,52 @@ export class DiskSearch implements ISearchResultProvider { return rawSearch; } - public static collectResultsFromEvent(event: Event): PPromise { - const promise = new PPromise((c, e, p) => { - setTimeout(() => { - const listener = event(ev => { - if (isSerializedSearchComplete(ev)) { - if (isSerializedSearchSuccess(ev)) { - c(ev); - } else { - e(ev.error); - } - listener.dispose(); - } else { - p(ev); - } - }); - }, 0); - }); - - return DiskSearch.collectResults(promise); - } - - public static collectResults(request: PPromise): PPromise { + public static collectResultsFromEvent(event: Event, onProgress?: (p: ISearchProgressItem) => void): TPromise { let result: IFileMatch[] = []; - return new PPromise((c, e, p) => { - request.done((complete) => { - c({ - limitHit: complete.limitHit, - results: result, - stats: complete.stats - }); - }, e, (data) => { - // Matches - if (Array.isArray(data)) { - const fileMatches = data.map(d => this.createFileMatch(d)); - result = result.concat(fileMatches); - fileMatches.forEach(p); - } + let listener: IDisposable; + return new TPromise((c, e) => { + listener = event(ev => { + if (isSerializedSearchComplete(ev)) { + if (isSerializedSearchSuccess(ev)) { + c({ + limitHit: ev.limitHit, + results: result, + stats: ev.stats + }); + } else { + e(ev.error); + } - // Match - else if ((data).path) { - const fileMatch = this.createFileMatch(data); - result.push(fileMatch); - p(fileMatch); - } + listener.dispose(); + } else { + // Matches + if (Array.isArray(ev)) { + const fileMatches = ev.map(d => this.createFileMatch(d)); + result = result.concat(fileMatches); + if (onProgress) { + fileMatches.forEach(onProgress); + } + } - // Progress - else { - p(data); + // Match + else if ((ev).path) { + const fileMatch = this.createFileMatch(ev); + result.push(fileMatch); + + if (onProgress) { + onProgress(fileMatch); + } + } + + // Progress + else if (onProgress) { + onProgress(ev); + } } }); - }, () => request.cancel()); + }, + () => listener && listener.dispose()); } private static createFileMatch(data: ISerializedFileMatch): FileMatch { @@ -442,10 +431,4 @@ export class DiskSearch implements ISearchResultProvider { public clearCache(cacheKey: string): TPromise { return this.raw.clearCache(cacheKey); } - - public fetchTelemetry(): PPromise { - return new PPromise((c, e, p) => { - this.raw.onTelemetry(p); - }); - } } diff --git a/src/vs/workbench/services/search/test/node/searchService.test.ts b/src/vs/workbench/services/search/test/node/searchService.test.ts index 9ceecbfa748..eb205675ab0 100644 --- a/src/vs/workbench/services/search/test/node/searchService.test.ts +++ b/src/vs/workbench/services/search/test/node/searchService.test.ts @@ -165,13 +165,15 @@ suite('SearchService', () => { } const progressResults = []; - return DiskSearch.collectResultsFromEvent(fileSearch(rawSearch, 10)) + const onProgress = match => { + assert.strictEqual(match.resource.path, uriPath); + progressResults.push(match); + }; + + return DiskSearch.collectResultsFromEvent(fileSearch(rawSearch, 10), onProgress) .then(result => { assert.strictEqual(result.results.length, 25, 'Result'); assert.strictEqual(progressResults.length, 25, 'Progress'); - }, null, match => { - assert.strictEqual(match.resource.path, uriPath); - progressResults.push(match); }); }); diff --git a/src/vs/workbench/test/browser/parts/editor/breadcrumbModel.test.ts b/src/vs/workbench/test/browser/parts/editor/breadcrumbModel.test.ts index bb0721629f8..e524bcd9ef2 100644 --- a/src/vs/workbench/test/browser/parts/editor/breadcrumbModel.test.ts +++ b/src/vs/workbench/test/browser/parts/editor/breadcrumbModel.test.ts @@ -11,6 +11,7 @@ import { Workspace, WorkspaceFolder } from 'vs/platform/workspace/common/workspa import { EditorBreadcrumbsModel, FileElement } from 'vs/workbench/browser/parts/editor/breadcrumbsModel'; import { TestContextService } from 'vs/workbench/test/workbenchTestServices'; import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService'; +import { FileKind } from 'vs/platform/files/common/files'; suite('Breadcrumb Model', function () { @@ -35,9 +36,9 @@ suite('Breadcrumb Model', function () { assert.equal(elements.length, 3); let [one, two, three] = elements as FileElement[]; - assert.equal(one.isFile, false); - assert.equal(two.isFile, false); - assert.equal(three.isFile, true); + assert.equal(one.kind, FileKind.FOLDER); + assert.equal(two.kind, FileKind.FOLDER); + assert.equal(three.kind, FileKind.FILE); assert.equal(one.uri.toString(), 'foo:/bar/baz/ws/some'); assert.equal(two.uri.toString(), 'foo:/bar/baz/ws/some/path'); assert.equal(three.uri.toString(), 'foo:/bar/baz/ws/some/path/file.ts'); @@ -50,8 +51,8 @@ suite('Breadcrumb Model', function () { assert.equal(elements.length, 2); let [one, two] = elements as FileElement[]; - assert.equal(one.isFile, false); - assert.equal(two.isFile, true); + assert.equal(one.kind, FileKind.FOLDER); + assert.equal(two.kind, FileKind.FILE); assert.equal(one.uri.toString(), 'foo:/outside'); assert.equal(two.uri.toString(), 'foo:/outside/file.ts'); }); diff --git a/src/vs/workbench/test/electron-browser/api/extHostTreeViews.test.ts b/src/vs/workbench/test/electron-browser/api/extHostTreeViews.test.ts index 57894ee26cd..a62fde4bcb8 100644 --- a/src/vs/workbench/test/electron-browser/api/extHostTreeViews.test.ts +++ b/src/vs/workbench/test/electron-browser/api/extHostTreeViews.test.ts @@ -72,7 +72,7 @@ suite('ExtHostTreeView', function () { rpcProtocol.set(MainContext.MainThreadCommands, inst.createInstance(MainThreadCommands, rpcProtocol)); target = new RecordingShape(); - testObject = new ExtHostTreeViews(target, new ExtHostCommands(rpcProtocol, new ExtHostHeapService(), new NullLogService())); + testObject = new ExtHostTreeViews(target, new ExtHostCommands(rpcProtocol, new ExtHostHeapService(), new NullLogService()), new NullLogService()); onDidChangeTreeNode = new Emitter<{ key: string }>(); onDidChangeTreeNodeWithId = new Emitter<{ key: string }>(); testObject.createTreeView('testNodeTreeProvider', { treeDataProvider: aNodeTreeDataProvider() }); diff --git a/src/vs/workbench/test/electron-browser/api/mainThreadEditors.test.ts b/src/vs/workbench/test/electron-browser/api/mainThreadEditors.test.ts index 0589271ab33..fdb4b5575c3 100644 --- a/src/vs/workbench/test/electron-browser/api/mainThreadEditors.test.ts +++ b/src/vs/workbench/test/electron-browser/api/mainThreadEditors.test.ts @@ -26,6 +26,8 @@ import { TPromise } from 'vs/base/common/winjs.base'; import { ResourceTextEdit } from 'vs/editor/common/modes'; import { BulkEditService } from 'vs/workbench/services/bulkEdit/electron-browser/bulkEditService'; import { NullLogService } from 'vs/platform/log/common/log'; +import { ITextModelService, ITextEditorModel } from 'vs/editor/common/services/resolverService'; +import { IReference, ImmortalReference } from 'vs/base/common/lifecycle'; suite('MainThreadEditors', () => { @@ -71,8 +73,16 @@ suite('MainThreadEditors', () => { }; const workbenchEditorService = new TestEditorService(); const editorGroupService = new TestEditorGroupsService(); + const textModelService = new class extends mock() { + createModelReference(resource: URI): TPromise> { + const textEditorModel: ITextEditorModel = new class extends mock() { + textEditorModel = modelService.getModel(resource); + }; + return TPromise.as(new ImmortalReference(textEditorModel)); + } + }; - const bulkEditService = new BulkEditService(new NullLogService(), modelService, new TestEditorService(), null, new TestFileService(), textFileService, TestEnvironmentService, new TestContextService()); + const bulkEditService = new BulkEditService(new NullLogService(), modelService, new TestEditorService(), textModelService, new TestFileService(), textFileService, TestEnvironmentService, new TestContextService()); const rpcProtocol = new TestRPCProtocol(); rpcProtocol.set(ExtHostContext.ExtHostDocuments, new class extends mock() { @@ -129,7 +139,39 @@ suite('MainThreadEditors', () => { }); }); - test(`pasero applyWorkspaceEdit with only resource edit`, () => { + test(`issue #54773: applyWorkspaceEdit checks model version in race situation`, () => { + + let model = modelService.createModel('something', null, resource); + + let workspaceResourceEdit1: ResourceTextEdit = { + resource: resource, + modelVersionId: model.getVersionId(), + edits: [{ + text: 'asdfg', + range: new Range(1, 1, 1, 1) + }] + }; + let workspaceResourceEdit2: ResourceTextEdit = { + resource: resource, + modelVersionId: model.getVersionId(), + edits: [{ + text: 'asdfg', + range: new Range(1, 1, 1, 1) + }] + }; + + let p1 = editors.$tryApplyWorkspaceEdit({ edits: [workspaceResourceEdit1] }).then((result) => { + // first edit request succeeds + assert.equal(result, true); + }); + let p2 = editors.$tryApplyWorkspaceEdit({ edits: [workspaceResourceEdit2] }).then((result) => { + // second edit request fails + assert.equal(result, false); + }); + return TPromise.join([p1, p2]); + }); + + test(`applyWorkspaceEdit with only resource edit`, () => { return editors.$tryApplyWorkspaceEdit({ edits: [ { oldUri: resource, newUri: resource, options: undefined }, diff --git a/test/smoke/src/areas/preferences/keybindings.ts b/test/smoke/src/areas/preferences/keybindings.ts index 235621574f0..c9f1273d0c1 100644 --- a/test/smoke/src/areas/preferences/keybindings.ts +++ b/test/smoke/src/areas/preferences/keybindings.ts @@ -21,14 +21,14 @@ export class KeybindingsEditor { await this.code.waitForActiveElement(SEARCH_INPUT); await this.code.waitForSetValue(SEARCH_INPUT, command); - await this.code.waitAndClick('div[aria-label="Keybindings"] .monaco-list-row.keybinding-item'); - await this.code.waitForElement('div[aria-label="Keybindings"] .monaco-list-row.keybinding-item.focused.selected'); + await this.code.waitAndClick('.keybindings-list-container .monaco-list-row.keybinding-item'); + await this.code.waitForElement('.keybindings-list-container .monaco-list-row.keybinding-item.focused.selected'); - await this.code.waitAndClick('div[aria-label="Keybindings"] .monaco-list-row.keybinding-item .action-item .icon.add'); + await this.code.waitAndClick('.keybindings-list-container .monaco-list-row.keybinding-item .action-item .icon.add'); await this.code.waitForActiveElement('.defineKeybindingWidget .monaco-inputbox input'); await this.code.dispatchKeybinding(keybinding); await this.code.dispatchKeybinding('enter'); - await this.code.waitForElement(`div[aria-label="Keybindings"] div[aria-label="Keybinding is ${ariaLabel}."]`); + await this.code.waitForElement(`.keybindings-list-container div[aria-label="Keybinding is ${ariaLabel}."]`); } } \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index cb804128177..f3796744e72 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6256,9 +6256,13 @@ vscode-textmate@^4.0.1: dependencies: oniguruma "^7.0.0" -vscode-xterm@3.6.0-beta3: - version "3.6.0-beta3" - resolved "https://registry.yarnpkg.com/vscode-xterm/-/vscode-xterm-3.6.0-beta3.tgz#fe383ff8df66603088e36c1f9ac987b0de68bd1b" +vscode-uri@1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/vscode-uri/-/vscode-uri-1.0.5.tgz#3b899a8ef71c37f3054d79bdbdda31c7bf36f20d" + +vscode-xterm@3.6.0-beta5: + version "3.6.0-beta5" + resolved "https://registry.yarnpkg.com/vscode-xterm/-/vscode-xterm-3.6.0-beta5.tgz#b44fd70451944624f148bd9f0be4925b52b7a7e0" vso-node-api@^6.1.2-preview: version "6.1.2-preview"