From 6c3a9a66a7a0ab0dd493ad2c281c9dd343d5301f Mon Sep 17 00:00:00 2001 From: Alice Koreman Date: Tue, 23 Apr 2024 13:14:02 +0200 Subject: [PATCH 01/23] fix: account for `this.popup` being potentially undefined in completion mousewheel listener (#5537) * fix: account for popup being potentially undefined is mousewheel listene --- src/autocomplete.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/autocomplete.js b/src/autocomplete.js index e921caa9c50..520c74ec070 100644 --- a/src/autocomplete.js +++ b/src/autocomplete.js @@ -431,7 +431,7 @@ class Autocomplete { } mousewheelListener(e) { - if (!this.popup.isMouseOver) + if (this.popup && !this.popup.isMouseOver) this.detach(); } From 15f6be2f7befc72c23aa486a292315cac47a4222 Mon Sep 17 00:00:00 2001 From: Alice Koreman Date: Tue, 23 Apr 2024 15:15:07 +0200 Subject: [PATCH 02/23] release v1.33.1 --- CHANGELOG.md | 7 +++++++ build | 2 +- package.json | 2 +- src/config.js | 2 +- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b7434095e77..0b8668462fc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +### [1.33.1](https://github.com/ajaxorg/ace/compare/v1.33.0...v1.33.1) (2024-04-23) + + +### Bug Fixes + +* account for `this.popup` being potentially undefined in completion mousewheel listener ([#5537](https://github.com/ajaxorg/ace/issues/5537)) ([6c3a9a6](https://github.com/ajaxorg/ace/commit/6c3a9a66a7a0ab0dd493ad2c281c9dd343d5301f)) + ## [1.33.0](https://github.com/ajaxorg/ace/compare/v1.32.9...v1.33.0) (2024-04-12) diff --git a/build b/build index 2bf49c643c5..98d379e25ea 160000 --- a/build +++ b/build @@ -1 +1 @@ -Subproject commit 2bf49c643c53995a4d69123b2553a5460833eff9 +Subproject commit 98d379e25ea28dcc97c580c33a92f508176f763d diff --git a/package.json b/package.json index 3a852ec9feb..26566d38c28 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "ace-code", "description": "Ajax.org Code Editor is a full featured source code highlighting editor that powers the Cloud9 IDE", - "version": "1.33.0", + "version": "1.33.1", "homepage": "http://github.com/ajaxorg/ace", "engines": { "node": ">= 0.6.0" diff --git a/src/config.js b/src/config.js index fd91f82c27b..8bd38acbfa3 100644 --- a/src/config.js +++ b/src/config.js @@ -194,6 +194,6 @@ var reportErrorIfPathIsNotConfigured = function() { } }; -exports.version = "1.33.0"; +exports.version = "1.33.1"; From 4041489bb38ffe609d5f9b43b4a7637e47fc4739 Mon Sep 17 00:00:00 2001 From: Azat Alimov <32402726+mkslanc@users.noreply.github.com> Date: Fri, 26 Apr 2024 18:16:32 +0400 Subject: [PATCH 03/23] fix: wrong token type (#5535) --- demo/kitchen-sink/docs/erlang.erl | 5 ++++- src/mode/_test/tokens_erlang.json | 30 ++++++++++++++++++++++++++++++ src/mode/erlang_highlight_rules.js | 30 +++++++++++++++--------------- 3 files changed, 49 insertions(+), 16 deletions(-) diff --git a/demo/kitchen-sink/docs/erlang.erl b/demo/kitchen-sink/docs/erlang.erl index 705642b3c28..b3915967a3c 100644 --- a/demo/kitchen-sink/docs/erlang.erl +++ b/demo/kitchen-sink/docs/erlang.erl @@ -17,4 +17,7 @@ % Force the use of 'codeswitch/1' from the latest MODULE version end. - codeswitch(Sum) -> loop(Sum). \ No newline at end of file + codeswitch(Sum) -> loop(Sum). + + % Print the data using the pretty print specifier + io:format("Here is the data: ~p~n", [Data]). diff --git a/src/mode/_test/tokens_erlang.json b/src/mode/_test/tokens_erlang.json index 8a8289760b2..0d585f84331 100644 --- a/src/mode/_test/tokens_erlang.json +++ b/src/mode/_test/tokens_erlang.json @@ -163,4 +163,34 @@ ["variable.other.erlang","Sum"], ["punctuation.definition.parameters.end.erlang",")"], ["punctuation.terminator.function.erlang","."] +],[ + "start", + ["text"," "] +],[ + "start", + ["text"," "], + ["punctuation.definition.comment.erlang","% Print the data using the pretty print specifier"] +],[ + "start", + ["text"," "], + ["entity.name.type.class.module.erlang","io"], + ["punctuation.separator.module-function.erlang",":"], + ["entity.name.function.erlang","format"], + ["punctuation.definition.parameters.begin.erlang","("], + ["punctuation.definition.string.begin.erlang","\""], + ["string.quoted.double.erlang","Here is the data: "], + ["punctuation.definition.erlang","~"], + ["constant.other.erlang","p"], + ["punctuation.definition.erlang","~"], + ["constant.other.erlang","n"], + ["punctuation.definition.string.end.erlang","\""], + ["punctuation.separator.parameters.erlang",","], + ["text"," "], + ["punctuation.definition.list.begin.erlang","["], + ["variable.other.erlang","Data"], + ["punctuation.definition.list.end.erlang","]"], + ["punctuation.definition.parameters.end.erlang",")"], + ["text","."] +],[ + "start" ]] \ No newline at end of file diff --git a/src/mode/erlang_highlight_rules.js b/src/mode/erlang_highlight_rules.js index c90b6d9dab8..aab17398f9e 100644 --- a/src/mode/erlang_highlight_rules.js +++ b/src/mode/erlang_highlight_rules.js @@ -789,23 +789,23 @@ var ErlangHighlightRules = function() { regex: '(\\\\)(?:([bdefnrstv\\\\\'"])|(\\^)([@-_])|([0-7]{1,3}))' }, { token: 'invalid.illegal.string.erlang', regex: '\\\\\\^?.?' }, { token: - [ 'punctuation.definition.placeholder.erlang', - 'punctuation.separator.placeholder-parts.erlang', - 'constant.other.placeholder.erlang', - 'punctuation.separator.placeholder-parts.erlang', - 'punctuation.separator.placeholder-parts.erlang', - 'constant.other.placeholder.erlang', - 'punctuation.separator.placeholder-parts.erlang', - 'punctuation.separator.placeholder-parts.erlang', - 'punctuation.separator.placeholder-parts.erlang', - 'constant.other.placeholder.erlang', - 'constant.other.placeholder.erlang' ], + [ 'punctuation.definition.erlang', + 'punctuation.separator.erlang', + 'constant.other.erlang', + 'punctuation.separator.erlang', + 'punctuation.separator.erlang', + 'constant.other.erlang', + 'punctuation.separator.erlang', + 'punctuation.separator.erlang', + 'punctuation.separator.erlang', + 'constant.other.erlang', + 'constant.other.erlang' ], regex: '(~)(?:((?:\\-)?)(\\d+)|(\\*))?(?:(\\.)(?:(\\d+)|(\\*)))?(?:(\\.)(?:(\\*)|(.)))?([~cfegswpWPBX#bx\\+ni])' }, { token: - [ 'punctuation.definition.placeholder.erlang', - 'punctuation.separator.placeholder-parts.erlang', - 'constant.other.placeholder.erlang', - 'constant.other.placeholder.erlang' ], + [ 'punctuation.definition.erlang', + 'punctuation.separator.erlang', + 'constant.other.erlang', + 'constant.other.erlang' ], regex: '(~)((?:\\*)?)((?:\\d+)?)([~du\\-#fsacl])' }, { token: 'invalid.illegal.string.erlang', regex: '~.?' }, { defaultToken: 'string.quoted.double.erlang' } ] } ], From ceca6f7b38f6b3347988f17579ae6a2e758137dd Mon Sep 17 00:00:00 2001 From: Azat Alimov <32402726+mkslanc@users.noreply.github.com> Date: Fri, 26 Apr 2024 18:22:25 +0400 Subject: [PATCH 04/23] fix: generator function's determination; wrong parameter highlighting (#5538) --- src/mode/_test/text_javascript.txt | 19 +- src/mode/_test/tokens_flix.json | 540 ++--- src/mode/_test/tokens_javascript.json | 176 +- src/mode/_test/tokens_jsx.json | 12 +- src/mode/_test/tokens_typescript.json | 4 +- src/mode/_test/tokens_vue.json | 2608 ++++++------------------ src/mode/javascript_highlight_rules.js | 81 +- 7 files changed, 1115 insertions(+), 2325 deletions(-) diff --git a/src/mode/_test/text_javascript.txt b/src/mode/_test/text_javascript.txt index faa075282da..b9c65d9fabd 100644 --- a/src/mode/_test/text_javascript.txt +++ b/src/mode/_test/text_javascript.txt @@ -81,7 +81,7 @@ a = { z>>=t<>r>>>s>=0b1 -foo.protoype.d = function(a, b, +foo.prototype.d = function(a, b, c, d) foo.d =function(a, b) foo.d =function(a, /*****/ d"string" @@ -160,4 +160,19 @@ async param => expression; }}/> { console.log("Test") -}}/> \ No newline at end of file +}}/> + +//test different generator functions use cases +function* generator() {} +function*generator() {} +Sound.play = function* play() { } +foobar: function * () { } + +//func's args shouldn't be determined as arrow function +func (a,b,1,2,3, async () => {}) +func(a,b,innerCall(c,d), () => {}) + +//async arrow function with default params +async (param1, param2, ...paramN) => { + statements +} diff --git a/src/mode/_test/tokens_flix.json b/src/mode/_test/tokens_flix.json index 2182c6d9a98..cb1bc7137f6 100644 --- a/src/mode/_test/tokens_flix.json +++ b/src/mode/_test/tokens_flix.json @@ -1,293 +1,299 @@ [[ - "start", - ["text", " "] + "start", + ["text"," "] ],[ - "start", - ["comment.block", "/* Hello comment */"], - ["text", "\n"], - ["comment.block", "/* Hello \n comment */"], - ["text", "\n"], - ["comment.line", "// Hello comment"] + "start", + ["comment.block","/* Hello comment */"] ],[ - "start", - ["keyword", "use"], - ["text", " "], - ["identifier", "Add"], - ["text", "."], - ["identifier", "add"] + "comment", + ["comment.block","/* Hello "] ],[ - "start", - ["storage.type", "mod"], - ["text", " "], - ["paren.lparen", "{"], - ["storage.type", "def"], - ["text", " "], - ["identifier", "main"], - ["paren.lparen", "("], - ["paren.rparen", ")"], - ["text", ": "], - ["support.type", "Int32"], - ["text", " = "], - ["constant.numeric", "42"], - ["paren.rparen", "}"] + "start", + ["comment.block"," comment */"] ],[ - "start", - ["storage.type", "class"], - ["text", " "], - ["identifier", "Add"], - ["paren.lparen", "["], - ["identifier", "a"], - ["paren.rparen", "]"], - ["text", " "], - ["paren.lparen", "{"], - ["paren.rparen", "}"] + "start", + ["comment.line","// Hello comment"] ],[ - "start", - ["storage.type", "enum"], - ["text", " "], - ["identifier", "Down"], - ["paren.lparen", "["], - ["identifier", "a"], - ["paren.rparen", "]"], - ["text", " "], - ["storage.modifier", "with"], - ["text", " "], - ["identifier", "Sendable"], - ["text", " "], - ["paren.lparen", "{"], - ["storage.type", "case"], - ["text", " "], - ["identifier", "Down"], - ["paren.lparen", "("], - ["identifier", "a"], - ["paren.rparen", ")}"] + "start", + ["keyword","use"], + ["text"," "], + ["identifier","Add"], + ["text","."], + ["identifier","add"] ],[ - "start", - ["storage.type", "eff"], - ["text", " "], - ["identifier", "NonDet"] + "start", + ["storage.type","mod"], + ["text"," "], + ["paren.lparen","{"], + ["storage.type","def"], + ["text"," "], + ["identifier","main"], + ["paren.lparen","("], + ["paren.rparen",")"], + ["text",": "], + ["support.type","Int32"], + ["text"," = "], + ["constant.numeric","42"], + ["paren.rparen","}"] ],[ - "start", - ["storage.type", "type"], - ["text", " "], - ["storage.type", "alias"], - ["text", " "], - ["identifier", "Static"], - ["text", " = "], - ["identifier", "Impure"] + "start", + ["storage.type","class"], + ["text"," "], + ["identifier","Add"], + ["paren.lparen","["], + ["identifier","a"], + ["paren.rparen","]"], + ["text"," "], + ["paren.lparen","{"], + ["paren.rparen","}"] ],[ - "start", - ["storage.type", "def"], - ["text", " "], - ["identifier", "main"], - ["paren.lparen", "("], - ["paren.rparen", ")"], - ["text", ": "], - ["support.type", "Int32"], - ["text", " = "], - ["paren.lparen", "{"], - ["constant.numeric", "42"], - ["paren.rparen", "}"] + "start", + ["storage.type","enum"], + ["text"," "], + ["identifier","Down"], + ["paren.lparen","["], + ["identifier","a"], + ["paren.rparen","]"], + ["text"," "], + ["storage.modifier","with"], + ["text"," "], + ["identifier","Sendable"], + ["text"," "], + ["paren.lparen","{"], + ["storage.type","case"], + ["text"," "], + ["identifier","Down"], + ["paren.lparen","("], + ["identifier","a"], + ["paren.rparen",")}"] ],[ - "start", - ["storage.type", "def"], - ["text", " "], - ["identifier", "main"], - ["paren.lparen", "("], - ["paren.rparen", ")"], - ["text", ": "], - ["support.type", "Float64"], - ["text", " = "], - ["keyword.control", "if"], - ["paren.lparen", "("], - ["constant.language.boolean", "true"], - ["paren.rparen", ")"], - ["paren.lparen", "{"], - ["constant.numeric", "42.0"], - ["paren.rparen", "}"], - ["keyword.control", "else"], - ["paren.lparen", "{"], - ["constant.numeric", "43.0"], - ["paren.rparen", "}"] + "start", + ["storage.type","eff"], + ["text"," "], + ["identifier","NonDet"] ],[ - "start", - ["storage.type", "def"], - ["text", " "], - ["identifier", "main"], - ["paren.lparen", "("], - ["paren.rparen", ")"], - ["text", ": "], - ["support.type", "String"], - ["text", " = "], - ["string", "\"Hello"], - ["constant.character.escape", "\\\""], - ["string", "World"], - ["constant.character.escape", "\\u0021"], - ["string", "\""] + "start", + ["storage.type","type"], + ["text"," "], + ["storage.type","alias"], + ["text"," "], + ["identifier","Static"], + ["text"," = "], + ["identifier","Impure"] ],[ - "start", - ["storage.type", "def"], - ["text", " "], - ["identifier", "main"], - ["paren.lparen", "("], - ["paren.rparen", ")"], - ["text", ": "], - ["support.type", "Char"], - ["text", " = "], - ["constant.character", "'a'"] + "start", + ["storage.type","def"], + ["text"," "], + ["identifier","main"], + ["paren.lparen","("], + ["paren.rparen",")"], + ["text",": "], + ["support.type","Int32"], + ["text"," = "], + ["paren.lparen","{"], + ["constant.numeric","42"], + ["paren.rparen","}"] ],[ - "start", - ["storage.type", "def"], - ["text", " "], - ["identifier", "main"], - ["paren.lparen", "("], - ["paren.rparen", ")"], - ["text", ": "], - ["support.type", "Char"], - ["text", " = "], - ["constant.character", "'"], - ["constant.character.escape", "\\u0021"], - ["constant.character", "'"] + "start", + ["storage.type","def"], + ["text"," "], + ["identifier","main"], + ["paren.lparen","("], + ["paren.rparen",")"], + ["text",": "], + ["support.type","Float64"], + ["text"," = "], + ["keyword.control","if"], + ["paren.lparen","("], + ["constant.language.boolean","true"], + ["paren.rparen",")"], + ["paren.lparen","{"], + ["constant.numeric","42.0"], + ["paren.rparen","}"], + ["keyword.control","else"], + ["paren.lparen","{"], + ["constant.numeric","43.0"], + ["paren.rparen","}"] ],[ - "start", - ["storage.type", "def"], - ["text", " "], - ["identifier", "main"], - ["paren.lparen", "("], - ["paren.rparen", ")"], - ["text", ": "], - ["support.type", "Char"], - ["text", " = "], - ["constant.character", "'"], - ["constant.character.escape", "\\'"], - ["constant.character", "'"] + "start", + ["storage.type","def"], + ["text"," "], + ["identifier","main"], + ["paren.lparen","("], + ["paren.rparen",")"], + ["text",": "], + ["support.type","String"], + ["text"," = "], + ["string","\"Hello"], + ["constant.character.escape","\\\""], + ["string","World"], + ["constant.character.escape","\\u0021"], + ["string","\""] ],[ - "start", - ["storage.type", "def"], - ["text", " "], - ["identifier", "main"], - ["paren.lparen", "("], - ["paren.rparen", ")"], - ["text", ": "], - ["identifier", "Regex"], - ["text", " = "], - ["string.regexp", "regex\"Hello"], - ["constant.character.escape", "\\\""], - ["string.regexp", "World"], - ["constant.character.escape", "\\u0021"], - ["string.regexp", "\""] + "start", + ["storage.type","def"], + ["text"," "], + ["identifier","main"], + ["paren.lparen","("], + ["paren.rparen",")"], + ["text",": "], + ["support.type","Char"], + ["text"," = "], + ["constant.character","'a'"] ],[ - "start", - ["storage.type", "def"], - ["text", " "], - ["identifier", "main"], - ["paren.lparen", "("], - ["paren.rparen", ")"], - ["text", ": "], - ["support.type", "String"], - ["text", " = "], - ["keyword", "???"] + "start", + ["storage.type","def"], + ["text"," "], + ["identifier","main"], + ["paren.lparen","("], + ["paren.rparen",")"], + ["text",": "], + ["support.type","Char"], + ["text"," = "], + ["constant.character","'"], + ["constant.character.escape","\\u0021"], + ["constant.character","'"] ],[ - "start", - ["storage.type", "def"], - ["text", " "], - ["identifier", "main"], - ["paren.lparen", "("], - ["paren.rparen", ")"], - ["text", ": "], - ["support.type", "String"], - ["text", " = "], - ["keyword", "?someHole"] + "start", + ["storage.type","def"], + ["text"," "], + ["identifier","main"], + ["paren.lparen","("], + ["paren.rparen",")"], + ["text",": "], + ["support.type","Char"], + ["text"," = "], + ["constant.character","'"], + ["constant.character.escape","\\'"], + ["constant.character","'"] ],[ - "start", - ["storage.type", "def"], - ["text", " "], - ["identifier", "main"], - ["paren.lparen", "("], - ["paren.rparen", ")"], - ["text", ": "], - ["support.type", "Int32"], - ["text", " = "], - ["constant.numeric", "0x123i32"] + "start", + ["storage.type","def"], + ["text"," "], + ["identifier","main"], + ["paren.lparen","("], + ["paren.rparen",")"], + ["text",": "], + ["identifier","Regex"], + ["text"," = "], + ["string.regexp","regex\"Hello"], + ["constant.character.escape","\\\""], + ["string.regexp","World"], + ["constant.character.escape","\\u0021"], + ["string.regexp","\""] ],[ - "start", - ["storage.type", "def"], - ["text", " "], - ["identifier", "main"], - ["paren.lparen", "("], - ["paren.rparen", ")"], - ["text", ": "], - ["support.type", "Int32"], - ["text", " = "], - ["constant.numeric", "42i32"] + "start", + ["storage.type","def"], + ["text"," "], + ["identifier","main"], + ["paren.lparen","("], + ["paren.rparen",")"], + ["text",": "], + ["support.type","String"], + ["text"," = "], + ["keyword","???"] ],[ - "start", - ["storage.type", "def"], - ["text", " "], - ["identifier", "main"], - ["paren.lparen", "("], - ["paren.rparen", ")"], - ["text", ": "], - ["support.type", "Float64"], - ["text", " = "], - ["constant.numeric", "42.0f64"] + "start", + ["storage.type","def"], + ["text"," "], + ["identifier","main"], + ["paren.lparen","("], + ["paren.rparen",")"], + ["text",": "], + ["support.type","String"], + ["text"," = "], + ["keyword","?someHole"] ],[ - "start", - ["storage.type", "def"], - ["text", " "], - ["identifier", "main"], - ["paren.lparen", "("], - ["paren.rparen", ")"], - ["text", ": "], - ["support.type", "Bool"], - ["text", " = "], - ["constant.language.boolean", "true"] + "start", + ["storage.type","def"], + ["text"," "], + ["identifier","main"], + ["paren.lparen","("], + ["paren.rparen",")"], + ["text",": "], + ["support.type","Int32"], + ["text"," = "], + ["constant.numeric","0x123i32"] ],[ - "start", - ["storage.type", "def"], - ["text", " "], - ["identifier", "main"], - ["paren.lparen", "("], - ["paren.rparen", ")"], - ["text", ": "], - ["support.type", "Bool"], - ["text", " = "], - ["constant.language.boolean", "false"] + "start", + ["storage.type","def"], + ["text"," "], + ["identifier","main"], + ["paren.lparen","("], + ["paren.rparen",")"], + ["text",": "], + ["support.type","Int32"], + ["text"," = "], + ["constant.numeric","42i32"] ],[ - "start", - ["storage.type", "def"], - ["text", " "], - ["identifier", "main"], - ["paren.lparen", "("], - ["paren.rparen", ")"], - ["text", ": "], - ["identifier", "Null"], - ["text", " = "], - ["constant.language", "null"] + "start", + ["storage.type","def"], + ["text"," "], + ["identifier","main"], + ["paren.lparen","("], + ["paren.rparen",")"], + ["text",": "], + ["support.type","Float64"], + ["text"," = "], + ["constant.numeric","42.0f64"] ],[ - "start", - ["storage.modifier", "@Lazy"], - ["text", "\n"], - ["storage.type", "def"], - ["text", " "], - ["identifier", "main"], - ["paren.lparen", "("], - ["paren.rparen", ")"], - ["text", ": "], - ["support.type", "Int32"], - ["text", " = "], - ["constant.numeric", "42"] + "start", + ["storage.type","def"], + ["text"," "], + ["identifier","main"], + ["paren.lparen","("], + ["paren.rparen",")"], + ["text",": "], + ["support.type","Bool"], + ["text"," = "], + ["constant.language.boolean","true"] ],[ - "start", - ["storage.modifier", "pub"], - ["text", " "], - ["storage.type", "def"], - ["text", " "], - ["identifier", "main"], - ["paren.lparen", "("], - ["paren.rparen", ")"], - ["text", ": "], - ["support.type", "Int32"], - ["text", " = "], - ["constant.numeric", "42"] + "start", + ["storage.type","def"], + ["text"," "], + ["identifier","main"], + ["paren.lparen","("], + ["paren.rparen",")"], + ["text",": "], + ["support.type","Bool"], + ["text"," = "], + ["constant.language.boolean","false"] +],[ + "start", + ["storage.type","def"], + ["text"," "], + ["identifier","main"], + ["paren.lparen","("], + ["paren.rparen",")"], + ["text",": "], + ["identifier","Null"], + ["text"," = "], + ["constant.language","null"] +],[ + "start", + ["storage.modifier","@Lazy"] +],[ + "start", + ["storage.type","def"], + ["text"," "], + ["identifier","main"], + ["paren.lparen","("], + ["paren.rparen",")"], + ["text",": "], + ["support.type","Int32"], + ["text"," = "], + ["constant.numeric","42"] +],[ + "start", + ["storage.modifier","pub"], + ["text"," "], + ["storage.type","def"], + ["text"," "], + ["identifier","main"], + ["paren.lparen","("], + ["paren.rparen",")"], + ["text",": "], + ["support.type","Int32"], + ["text"," = "], + ["constant.numeric","42"] ]] \ No newline at end of file diff --git a/src/mode/_test/tokens_javascript.json b/src/mode/_test/tokens_javascript.json index ddee3d0f480..7e11d31fae5 100644 --- a/src/mode/_test/tokens_javascript.json +++ b/src/mode/_test/tokens_javascript.json @@ -549,9 +549,9 @@ "function_arguments", ["identifier","foo"], ["punctuation.operator","."], - ["storage.type","protoype"], + ["support.function","prototype"], ["punctuation.operator","."], - ["entity.name.function","d"], + ["identifier","d"], ["text"," "], ["keyword.operator","="], ["text"," "], @@ -572,9 +572,9 @@ ["paren.rparen",")"] ],[ "no_regex", - ["storage.type","foo"], + ["identifier","foo"], ["punctuation.operator","."], - ["entity.name.function","d"], + ["identifier","d"], ["text"," "], ["keyword.operator","="], ["storage.type","function"], @@ -586,9 +586,9 @@ ["paren.rparen",")"] ],[ "no_regex", - ["storage.type","foo"], + ["identifier","foo"], ["punctuation.operator","."], - ["entity.name.function","d"], + ["identifier","d"], ["text"," "], ["keyword.operator","="], ["storage.type","function"], @@ -662,27 +662,18 @@ ["meta.tag.punctuation.tag-close.xml",">"] ],[ ["jsx",1], - [ - "string.xml", - "1 " - ], + ["string.xml","1 "], ["meta.tag.punctuation.tag-open.xml","<"], ["meta.tag.tag-name.xml","a"], ["meta.tag.punctuation.tag-close.xml",">"], - [ - "string.xml", - " " - ], + ["string.xml"," "], ["paren.quasi.start","{"], ["text"," "], ["keyword.operator","++"], ["identifier","x"], ["text"," "], ["paren.quasi.end","}"], - [ - "string.xml", - " " - ], + ["string.xml"," "], ["meta.tag.punctuation.end-tag-open.xml",""] @@ -742,7 +733,8 @@ ["comment","//test generator function"] ],[ "start", - ["storage.type","function*"], + ["storage.type","function"], + ["storage.type","*"], ["text"," "], ["entity.name.function","range"], ["text"," "], @@ -1322,4 +1314,148 @@ ["paren.rparen","}"], ["paren.quasi.end","}"], ["meta.tag.punctuation.tag-close.xml","/>"] -]] +],[ + "start" +],[ + "start", + ["comment","//test different generator functions use cases"] +],[ + "no_regex", + ["storage.type","function"], + ["storage.type","*"], + ["text"," "], + ["entity.name.function","generator"], + ["paren.lparen","("], + ["paren.rparen",")"], + ["text"," "], + ["paren.lparen","{"], + ["paren.rparen","}"] +],[ + "no_regex", + ["storage.type","function"], + ["storage.type","*"], + ["entity.name.function","generator"], + ["paren.lparen","("], + ["paren.rparen",")"], + ["text"," "], + ["paren.lparen","{"], + ["paren.rparen","}"] +],[ + "no_regex", + ["identifier","Sound"], + ["punctuation.operator","."], + ["identifier","play"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["storage.type","function"], + ["storage.type","*"], + ["text"," "], + ["entity.name.function","play"], + ["paren.lparen","("], + ["paren.rparen",")"], + ["text"," "], + ["paren.lparen","{"], + ["text"," "], + ["paren.rparen","}"] +],[ + "no_regex", + ["entity.name.function","foobar"], + ["punctuation.operator",":"], + ["text"," "], + ["storage.type","function"], + ["text"," "], + ["storage.type","*"], + ["text"," "], + ["paren.lparen","("], + ["paren.rparen",")"], + ["text"," "], + ["paren.lparen","{"], + ["text"," "], + ["paren.rparen","}"] +],[ + "no_regex" +],[ + "no_regex", + ["comment","//func's args shouldn't be determined as arrow function"] +],[ + "no_regex", + ["identifier","func"], + ["text"," "], + ["paren.lparen","("], + ["identifier","a"], + ["punctuation.operator",","], + ["identifier","b"], + ["punctuation.operator",","], + ["constant.numeric","1"], + ["punctuation.operator",","], + ["constant.numeric","2"], + ["punctuation.operator",","], + ["constant.numeric","3"], + ["punctuation.operator",","], + ["text"," "], + ["keyword","async"], + ["text"," "], + ["paren.lparen","("], + ["paren.rparen",")"], + ["text"," "], + ["storage.type","=>"], + ["text"," "], + ["paren.lparen","{"], + ["paren.rparen","})"] +],[ + "no_regex", + ["identifier","func"], + ["paren.lparen","("], + ["identifier","a"], + ["punctuation.operator",","], + ["identifier","b"], + ["punctuation.operator",","], + ["identifier","innerCall"], + ["paren.lparen","("], + ["identifier","c"], + ["punctuation.operator",","], + ["identifier","d"], + ["paren.rparen",")"], + ["punctuation.operator",","], + ["text"," "], + ["paren.lparen","("], + ["paren.rparen",")"], + ["text"," "], + ["storage.type","=>"], + ["text"," "], + ["paren.lparen","{"], + ["paren.rparen","})"] +],[ + "no_regex" +],[ + "no_regex", + ["comment","//async arrow function with default params"] +],[ + "start", + ["keyword","async"], + ["text"," "], + ["paren.lparen","("], + ["variable.parameter","param1"], + ["punctuation.operator",","], + ["text"," "], + ["variable.parameter","param2"], + ["punctuation.operator",","], + ["text"," "], + ["keyword.operator","..."], + ["variable.parameter","paramN"], + ["paren.rparen",")"], + ["text"," "], + ["storage.type","=>"], + ["text"," "], + ["paren.lparen","{"] +],[ + "no_regex", + ["text"," "], + ["identifier","statements"] +],[ + "no_regex", + ["paren.rparen","}"] +],[ + "no_regex" +]] \ No newline at end of file diff --git a/src/mode/_test/tokens_jsx.json b/src/mode/_test/tokens_jsx.json index e247cb8c13a..6da36017f30 100644 --- a/src/mode/_test/tokens_jsx.json +++ b/src/mode/_test/tokens_jsx.json @@ -44,16 +44,10 @@ ["meta.tag.punctuation.tag-close.xml",">"] ],[ ["jsx",1], - [ - "string.xml", - " Keywords here are not highlighted, for example class or instance." - ] + ["string.xml"," Keywords here are not highlighted, for example class or instance."] ],[ "start", - [ - "string.xml", - " " - ], + ["string.xml"," "], ["meta.tag.punctuation.end-tag-open.xml",""] @@ -65,4 +59,4 @@ ],[ "no_regex", ["paren.rparen","}"] -]] +]] \ No newline at end of file diff --git a/src/mode/_test/tokens_typescript.json b/src/mode/_test/tokens_typescript.json index 592aa8b71d0..b76bcd0bad3 100644 --- a/src/mode/_test/tokens_typescript.json +++ b/src/mode/_test/tokens_typescript.json @@ -115,9 +115,9 @@ ["punctuation.operator",";"] ],[ "start", - ["storage.type","button"], + ["identifier","button"], ["punctuation.operator","."], - ["entity.name.function","onclick"], + ["identifier","onclick"], ["text"," "], ["keyword.operator","="], ["text"," "], diff --git a/src/mode/_test/tokens_vue.json b/src/mode/_test/tokens_vue.json index c41cb3f50a6..78654aa55d6 100644 --- a/src/mode/_test/tokens_vue.json +++ b/src/mode/_test/tokens_vue.json @@ -1,1983 +1,625 @@ -[ - [ - "comment", - [ - "comment.start.xml", - "" - ] - ], - [ - "start" - ], - [ - "start", - [ - "meta.tag.punctuation.tag-open.xml", - "<" - ], - [ - "meta.tag.tag-name.xml", - "template" - ], - [ - "meta.tag.punctuation.tag-close.xml", - ">" - ] - ], - [ - "start", - [ - "text.xml", - " " - ], - [ - "meta.tag.punctuation.tag-open.xml", - "<" - ], - [ - "meta.tag.tag-name.xml", - "div" - ], - [ - "meta.tag.punctuation.tag-close.xml", - ">" - ] - ], - [ - "start", - [ - "text.xml", - " " - ], - [ - "punctuation", - "{{" - ], - [ - "text", - " " - ], - [ - "identifier", - "foo" - ], - [ - "text", - " " - ], - [ - "keyword.operator", - "*" - ], - [ - "text", - " " - ], - [ - "constant.numeric", - "10" - ], - [ - "text", - " " - ], - [ - "keyword.operator", - "+" - ], - [ - "text", - " " - ], - [ - "string", - "'hi'" - ], - [ - "text", - " " - ], - [ - "punctuation", - "}}" - ] - ], - [ - "tag_stuff", - [ - "text.xml", - " " - ], - [ - "meta.tag.punctuation.tag-open.xml", - "<" - ], - [ - "meta.tag.tag-name.xml", - "span" - ] - ], - [ - "tag_stuff", - [ - "text.tag-whitespace.xml", - " " - ], - [ - "entity.other.attribute-name.xml", - "v-" - ], - [ - "entity.other.attribute-name.xml", - "text" - ], - [ - "punctuation.separator.key-value.xml", - "=" - ], - [ - "string", - "\"" - ], - [ - "identifier", - "foo" - ], - [ - "text", - " " - ], - [ - "keyword.operator", - "*" - ], - [ - "text", - " " - ], - [ - "constant.numeric", - "10" - ], - [ - "text", - " " - ], - [ - "keyword.operator", - "+" - ], - [ - "text", - " " - ], - [ - "string", - "'hi'" - ], - [ - "string", - "\"" - ], - [ - "text.tag-whitespace.xml", - " " - ], - [ - "punctuation.separator.key-value.xml", - ":" - ], - [ - "entity.other.attribute-name.xml", - "id" - ], - [ - "punctuation.separator.key-value.xml", - "=" - ], - [ - "string", - "\"" - ], - [ - "identifier", - "foo" - ], - [ - "text", - " " - ], - [ - "keyword.operator", - "+" - ], - [ - "text", - " " - ], - [ - "string", - "'baz'" - ], - [ - "string", - "\"" - ] - ], - [ - "tag_stuff", - [ - "text.tag-whitespace.xml", - " " - ], - [ - "punctuation.separator.key-value.xml", - "@" - ], - [ - "entity.other.attribute-name.xml", - "click" - ], - [ - "punctuation.separator.key-value.xml", - "=" - ], - [ - "string", - "\"" - ], - [ - "identifier", - "onClick" - ], - [ - "paren.lparen", - "(" - ], - [ - "string", - "'hello'" - ], - [ - "paren.rparen", - ")" - ], - [ - "string", - "\"" - ] - ], - [ - "start", - [ - "text.tag-whitespace.xml", - " " - ], - [ - "punctuation.separator.key-value.xml", - "@" - ], - [ - "entity.other.attribute-name.xml", - "click.prevent" - ], - [ - "punctuation.separator.key-value.xml", - "=" - ], - [ - "string", - "\"" - ], - [ - "identifier", - "onClick" - ], - [ - "paren.lparen", - "(" - ], - [ - "string", - "'hello'" - ], - [ - "paren.rparen", - ")" - ], - [ - "string", - "\"" - ], - [ - "meta.tag.punctuation.tag-close.xml", - ">" - ] - ], - [ - "start", - [ - "text.xml", - " Hello" - ] - ], - [ - "start", - [ - "text.xml", - " " - ], - [ - "meta.tag.punctuation.end-tag-open.xml", - "" - ] - ], - [ - "start", - [ - "text.xml", - " " - ], - [ - "meta.tag.punctuation.end-tag-open.xml", - "" - ] - ], - [ - "start", - [ - "meta.tag.punctuation.end-tag-open.xml", - "" - ] - ], - [ - "start" - ], - [ - "js-start", - [ - "meta.tag.punctuation.tag-open.xml", - "<" - ], - [ - "meta.tag.script.tag-name.xml", - "script" - ], - [ - "meta.tag.punctuation.tag-close.xml", - ">" - ] - ], - [ - "js-start", - [ - "keyword", - "export" - ], - [ - "text", - " " - ], - [ - "keyword", - "default" - ], - [ - "text", - " " - ], - [ - "paren.lparen", - "{" - ] - ], - [ - "js-start", - [ - "text", - " " - ], - [ - "identifier", - "data" - ], - [ - "punctuation.operator", - ":" - ], - [ - "text", - " " - ], - [ - "paren.lparen", - "(" - ], - [ - "paren.rparen", - ")" - ], - [ - "text", - " " - ], - [ - "storage.type", - "=>" - ], - [ - "text", - " " - ], - [ - "paren.lparen", - "({" - ] - ], - [ - "js-no_regex", - [ - "text", - " " - ], - [ - "identifier", - "foo" - ], - [ - "punctuation.operator", - ":" - ], - [ - "text", - " " - ], - [ - "string", - "'bar'" - ] - ], - [ - "js-no_regex", - [ - "text", - " " - ], - [ - "paren.rparen", - "})" - ] - ], - [ - "js-start", - [ - "paren.rparen", - "}" - ], - [ - "punctuation.operator", - ";" - ] - ], - [ - "start", - [ - "meta.tag.punctuation.end-tag-open.xml", - "" - ] - ], - [ - "start" - ], - [ - "css-start", - [ - "meta.tag.punctuation.tag-open.xml", - "<" - ], - [ - "meta.tag.style.tag-name.xml", - "style" - ], - [ - "meta.tag.punctuation.tag-close.style.xml", - ">" - ] - ], - [ - "css-ruleset", - [ - "constant", - "div" - ], - [ - "text", - " " - ], - [ - "paren.lparen", - "{" - ] - ], - [ - "css-ruleset", - [ - "text", - " " - ], - [ - "support.type", - "color" - ], - [ - "punctuation.operator", - ":" - ], - [ - "text", - " " - ], - [ - "support.constant.color", - "red" - ], - [ - "punctuation.operator", - ";" - ] - ], - [ - "css-start", - [ - "paren.rparen", - "}" - ] - ], - [ - "start", - [ - "meta.tag.punctuation.end-tag-open.xml", - "" - ] - ], - [ - "start" - ], - [ - "sass-start", - [ - "meta.tag.punctuation.tag-open.xml", - "<" - ], - [ - "meta.tag.style.tag-name.xml", - "style" - ], - [ - "text.tag-whitespace.xml", - " " - ], - [ - "entity.other.attribute-name.xml", - "lang" - ], - [ - "keyword.operator.attribute-equals.xml", - "=" - ], - [ - "string.attribute-value.xml", - "\"sass\"" - ], - [ - "meta.tag.punctuation.tag-close.style.xml", - ">" - ] - ], - [ - "sass-start", - [ - "comment", - "// sass ace mode;" - ] - ], - [ - "sass-start" - ], - [ - "sass-start", - [ - "keyword", - "@import" - ], - [ - "text", - " " - ], - [ - "support.function", - "url(" - ], - [ - "string", - "http://fonts.googleapis.com/css?family=Ace:700" - ], - [ - "support.function", - ")" - ] - ], - [ - "sass-start" - ], - [ - "sass-start", - [ - "variable.language", - "html" - ], - [ - "text", - ", " - ], - [ - "variable.language", - "body" - ] - ], - [ - "sass-start", - [ - "support.type", - " :background-color " - ], - [ - "constant.numeric", - "#ace" - ] - ], - [ - "sass-start", - [ - "text", - " " - ], - [ - "support.type", - "text-align" - ], - [ - "text", - ": " - ], - [ - "constant.language", - "center" - ] - ], - [ - "sass-start", - [ - "text", - " " - ], - [ - "support.type", - "height" - ], - [ - "text", - ": " - ], - [ - "constant.numeric", - "100%" - ] - ], - [ - [ - "sass-comment", - -1, - 2, - "sass-start" - ], - [ - "comment", - " /*;*********;" - ] - ], - [ - [ - "sass-comment", - 3, - 2, - "sass-start" - ], - [ - "comment", - " ;comment ;" - ] - ], - [ - [ - "sass-comment", - 3, - 2, - "sass-start" - ], - [ - "comment", - " ;*********;" - ] - ], - [ - "sass-start" - ], - [ - "sass-start" - ], - [ - "sass-start", - [ - "text", - " &" - ], - [ - "variable.language", - ":before" - ] - ], - [ - "sass-start", - [ - "text", - " " - ], - [ - "variable", - "$radius" - ], - [ - "text", - ": " - ], - [ - "variable", - "$size" - ], - [ - "text", - " " - ], - [ - "keyword.operator", - "*" - ], - [ - "text", - " " - ], - [ - "constant.numeric", - "0.845" - ] - ], - [ - "sass-start", - [ - "text", - " " - ], - [ - "variable", - "$glow" - ], - [ - "text", - ": " - ], - [ - "variable", - "$size" - ], - [ - "text", - " " - ], - [ - "keyword.operator", - "*" - ], - [ - "text", - " " - ], - [ - "constant.numeric", - "0.125" - ] - ], - [ - "sass-start" - ], - [ - "sass-start", - [ - "text", - " " - ], - [ - "support.type", - "box-shadow" - ], - [ - "text", - ": " - ], - [ - "constant.numeric", - "0" - ], - [ - "text", - " " - ], - [ - "constant.numeric", - "0" - ], - [ - "text", - " " - ], - [ - "variable", - "$glow" - ], - [ - "text", - " " - ], - [ - "variable", - "$glow" - ], - [ - "text", - " / " - ], - [ - "constant.numeric", - "2" - ], - [ - "text", - " " - ], - [ - "constant.numeric", - "#fff" - ] - ], - [ - "sass-start", - [ - "text", - " " - ], - [ - "support.type", - "border-radius" - ], - [ - "text", - ": " - ], - [ - "variable", - "$radius" - ] - ], - [ - "sass-start" - ], - [ - "sass-start", - [ - "text", - " &" - ], - [ - "variable.language", - ":active" - ] - ], - [ - "sass-start", - [ - "text", - " ~ " - ], - [ - "variable.language", - ".button" - ] - ], - [ - "sass-start", - [ - "text", - " " - ], - [ - "support.type", - "box-shadow" - ], - [ - "text", - ": " - ], - [ - "constant.numeric", - "0" - ], - [ - "text", - " " - ], - [ - "constant.numeric", - "15px" - ], - [ - "text", - " " - ], - [ - "constant.numeric", - "25px" - ], - [ - "text", - " " - ], - [ - "constant.numeric", - "-4px" - ], - [ - "text", - " " - ], - [ - "support.function", - "rgba" - ], - [ - "paren.lparen", - "(" - ], - [ - "constant.numeric", - "0" - ], - [ - "text", - ", " - ], - [ - "constant.numeric", - "0" - ], - [ - "text", - ", " - ], - [ - "constant.numeric", - "0" - ], - [ - "text", - ", " - ], - [ - "constant.numeric", - "0.4" - ], - [ - "paren.rparen", - ")" - ] - ], - [ - "sass-start" - ], - [ - "sass-start", - [ - "text", - " ~ " - ], - [ - "variable.language", - ".label" - ] - ], - [ - "sass-start", - [ - "text", - " " - ], - [ - "support.type", - "font-size" - ], - [ - "text", - ": " - ], - [ - "constant.numeric", - "40px" - ] - ], - [ - "sass-start", - [ - "text", - " " - ], - [ - "support.type", - "color" - ], - [ - "text", - ": " - ], - [ - "support.function", - "rgba" - ], - [ - "paren.lparen", - "(" - ], - [ - "constant.numeric", - "0" - ], - [ - "text", - ", " - ], - [ - "constant.numeric", - "0" - ], - [ - "text", - ", " - ], - [ - "constant.numeric", - "0" - ], - [ - "text", - ", " - ], - [ - "constant.numeric", - "0.45" - ], - [ - "paren.rparen", - ")" - ] - ], - [ - "sass-start" - ], - [ - "sass-start", - [ - "text", - " &" - ], - [ - "variable.language", - ":checked" - ] - ], - [ - "sass-start", - [ - "text", - " ~ " - ], - [ - "variable.language", - ".button" - ] - ], - [ - "sass-start", - [ - "text", - " " - ], - [ - "support.type", - "box-shadow" - ], - [ - "text", - ": " - ], - [ - "constant.numeric", - "0" - ], - [ - "text", - " " - ], - [ - "constant.numeric", - "15px" - ], - [ - "text", - " " - ], - [ - "constant.numeric", - "25px" - ], - [ - "text", - " " - ], - [ - "constant.numeric", - "-4px" - ], - [ - "text", - " " - ], - [ - "constant.numeric", - "#ace" - ] - ], - [ - "sass-start" - ], - [ - "sass-start", - [ - "text", - " ~ " - ], - [ - "variable.language", - ".label" - ] - ], - [ - "sass-start", - [ - "text", - " " - ], - [ - "support.type", - "font-size" - ], - [ - "text", - ": " - ], - [ - "constant.numeric", - "40px" - ] - ], - [ - "sass-start", - [ - "text", - " " - ], - [ - "support.type", - "color" - ], - [ - "text", - ": " - ], - [ - "constant.numeric", - "#c9c9c9" - ] - ], - [ - "start", - [ - "meta.tag.punctuation.end-tag-open.xml", - "" - ] - ], - [ - "start" - ], - [ - "scss-start", - [ - "meta.tag.punctuation.tag-open.xml", - "<" - ], - [ - "meta.tag.style.tag-name.xml", - "style" - ], - [ - "text.tag-whitespace.xml", - " " - ], - [ - "entity.other.attribute-name.xml", - "lang" - ], - [ - "keyword.operator.attribute-equals.xml", - "=" - ], - [ - "string.attribute-value.xml", - "\"scss\"" - ], - [ - "meta.tag.punctuation.tag-close.style.xml", - ">" - ] - ], - [ - "scss-start", - [ - "comment", - "/* style.scss */" - ] - ], - [ - "scss-start" - ], - [ - "scss-start", - [ - "variable.language", - "#navbar" - ], - [ - "text", - " " - ], - [ - "paren.lparen", - "{" - ] - ], - [ - "scss-start", - [ - "text", - " " - ], - [ - "variable", - "$navbar-width" - ], - [ - "text", - ": " - ], - [ - "constant.numeric", - "800px" - ], - [ - "text", - ";" - ] - ], - [ - "scss-start", - [ - "text", - " " - ], - [ - "variable", - "$items" - ], - [ - "text", - ": " - ], - [ - "constant.numeric", - "5" - ], - [ - "text", - ";" - ] - ], - [ - "scss-start", - [ - "text", - " " - ], - [ - "variable", - "$navbar-color" - ], - [ - "text", - ": " - ], - [ - "constant.numeric", - "#ce4dd6" - ], - [ - "text", - ";" - ] - ], - [ - "scss-start" - ], - [ - "scss-start", - [ - "text", - " " - ], - [ - "support.type", - "width" - ], - [ - "text", - ": " - ], - [ - "variable", - "$navbar-width" - ], - [ - "text", - ";" - ] - ], - [ - "scss-start", - [ - "text", - " " - ], - [ - "support.type", - "border-bottom" - ], - [ - "text", - ": " - ], - [ - "constant.numeric", - "2px" - ], - [ - "text", - " " - ], - [ - "constant.language", - "solid" - ], - [ - "text", - " " - ], - [ - "variable", - "$navbar-color" - ], - [ - "text", - ";" - ] - ], - [ - "scss-start" - ], - [ - "scss-start", - [ - "text", - " " - ], - [ - "variable.language", - "li" - ], - [ - "text", - " " - ], - [ - "paren.lparen", - "{" - ] - ], - [ - "scss-start", - [ - "text", - " " - ], - [ - "support.type", - "float" - ], - [ - "text", - ": " - ], - [ - "support.type", - "left" - ], - [ - "text", - ";" - ] - ], - [ - "scss-start", - [ - "text", - " " - ], - [ - "support.type", - "width" - ], - [ - "text", - ": " - ], - [ - "variable", - "$navbar-width" - ], - [ - "text", - "/" - ], - [ - "variable", - "$items" - ], - [ - "text", - " " - ], - [ - "constant", - "-" - ], - [ - "text", - " " - ], - [ - "constant.numeric", - "10px" - ], - [ - "text", - ";" - ] - ], - [ - "scss-start" - ], - [ - "scss-start", - [ - "text", - " " - ], - [ - "support.type", - "background-color" - ], - [ - "text", - ": " - ], - [ - "support.function", - "lighten" - ], - [ - "paren.lparen", - "(" - ], - [ - "variable", - "$navbar-color" - ], - [ - "text", - ", " - ], - [ - "constant.numeric", - "20%" - ], - [ - "paren.rparen", - ")" - ], - [ - "text", - ";" - ] - ], - [ - "scss-start" - ], - [ - "scss-start", - [ - "text", - " &" - ], - [ - "variable.language", - ":hover" - ], - [ - "text", - " " - ], - [ - "paren.lparen", - "{" - ] - ], - [ - "scss-start", - [ - "text", - " " - ], - [ - "support.type", - "background-color" - ], - [ - "text", - ": " - ], - [ - "support.function", - "lighten" - ], - [ - "paren.lparen", - "(" - ], - [ - "variable", - "$navbar-color" - ], - [ - "text", - ", " - ], - [ - "constant.numeric", - "10%" - ], - [ - "paren.rparen", - ")" - ], - [ - "text", - ";" - ] - ], - [ - "scss-start", - [ - "text", - " " - ], - [ - "paren.rparen", - "}" - ] - ], - [ - "scss-start", - [ - "text", - " " - ], - [ - "paren.rparen", - "}" - ] - ], - [ - "scss-start", - [ - "paren.rparen", - "}" - ] - ], - [ - "scss-start" - ], - [ - "start", - [ - "meta.tag.punctuation.end-tag-open.xml", - "" - ] - ], - [ - "start" - ], - [ - "jade-start", - [ - "meta.tag.punctuation.tag-open.xml", - "<" - ], - [ - "meta.tag.template.tag-name.xml", - "template" - ], - [ - "text.tag-whitespace.xml", - " " - ], - [ - "entity.other.attribute-name.xml", - "lang" - ], - [ - "keyword.operator.attribute-equals.xml", - "=" - ], - [ - "string.attribute-value.xml", - "\"jade\"" - ], - [ - "meta.tag.punctuation.tag-close.template.xml", - ">" - ] - ], - [ - "jade-start", - [ - "storage.type.function.jade", - " mixin" - ], - [ - "entity.name.function.jade", - " article" - ], - [ - "punctuation.definition.parameters.begin.jade", - "(" - ], - [ - "variable.parameter.function.jade", - "obj, parents" - ], - [ - "punctuation.definition.parameters.end.jade", - ")" - ] - ], - [ - "jade-start", - [ - "source.js.embedded.jade", - " -" - ], - [ - "storage.type", - "var" - ], - [ - "text", - " " - ], - [ - "identifier", - "x" - ], - [ - "text", - " " - ], - [ - "keyword.operator", - "=" - ], - [ - "text", - " " - ], - [ - "string", - "\"0\"" - ], - [ - "text", - ";" - ] - ], - [ - "jade-start", - [ - "text", - " " - ] - ], - [ - "jade-start", - [ - "source.js.embedded.jade", - " -" - ], - [ - "text", - " " - ], - [ - "storage.type", - "var" - ], - [ - "text", - " " - ], - [ - "identifier", - "items" - ], - [ - "text", - " " - ], - [ - "keyword.operator", - "=" - ], - [ - "text", - " " - ], - [ - "paren.lparen", - "[" - ], - [ - "string", - "\"one\"" - ], - [ - "punctuation.operator", - "," - ], - [ - "text", - " " - ], - [ - "string", - "\"two\"" - ], - [ - "punctuation.operator", - "," - ], - [ - "text", - " " - ], - [ - "string", - "\"three\"" - ], - [ - "text", - "]" - ] - ], - [ - "jade-start", - [ - "meta.tag.any.jade", - " each" - ], - [ - "text", - " item in items" - ] - ], - [ - "jade-start", - [ - "meta.tag.any.jade", - " li" - ], - [ - "text", - "= item" - ] - ], - [ - "start", - [ - "meta.tag.punctuation.end-tag-open.xml", - "" - ] - ], - [ - "start" - ] -] +[[ + "comment", + ["comment.start.xml",""] +],[ + "start" +],[ + "start", + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","template"], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","div"], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "start", + ["text.xml"," "], + ["punctuation","{{"], + ["text"," "], + ["identifier","foo"], + ["text"," "], + ["keyword.operator","*"], + ["text"," "], + ["constant.numeric","10"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["string","'hi'"], + ["text"," "], + ["punctuation","}}"] +],[ + "tag_stuff", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","span"] +],[ + "tag_stuff", + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","v-"], + ["entity.other.attribute-name.xml","text"], + ["punctuation.separator.key-value.xml","="], + ["string","\""], + ["identifier","foo"], + ["text"," "], + ["keyword.operator","*"], + ["text"," "], + ["constant.numeric","10"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["string","'hi'"], + ["string","\""], + ["text.tag-whitespace.xml"," "], + ["punctuation.separator.key-value.xml",":"], + ["entity.other.attribute-name.xml","id"], + ["punctuation.separator.key-value.xml","="], + ["string","\""], + ["identifier","foo"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["string","'baz'"], + ["string","\""] +],[ + "tag_stuff", + ["text.tag-whitespace.xml"," "], + ["punctuation.separator.key-value.xml","@"], + ["entity.other.attribute-name.xml","click"], + ["punctuation.separator.key-value.xml","="], + ["string","\""], + ["identifier","onClick"], + ["paren.lparen","("], + ["string","'hello'"], + ["paren.rparen",")"], + ["string","\""] +],[ + "start", + ["text.tag-whitespace.xml"," "], + ["punctuation.separator.key-value.xml","@"], + ["entity.other.attribute-name.xml","click.prevent"], + ["punctuation.separator.key-value.xml","="], + ["string","\""], + ["identifier","onClick"], + ["paren.lparen","("], + ["string","'hello'"], + ["paren.rparen",")"], + ["string","\""], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "start", + ["text.xml"," Hello"] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start" +],[ + "js-start", + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.script.tag-name.xml","script"], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "js-start", + ["keyword","export"], + ["text"," "], + ["keyword","default"], + ["text"," "], + ["paren.lparen","{"] +],[ + "js-start", + ["text"," "], + ["identifier","data"], + ["punctuation.operator",":"], + ["text"," "], + ["paren.lparen","("], + ["paren.rparen",")"], + ["text"," "], + ["storage.type","=>"], + ["text"," "], + ["paren.lparen","({"] +],[ + "js-no_regex", + ["text"," "], + ["identifier","foo"], + ["punctuation.operator",":"], + ["text"," "], + ["string","'bar'"] +],[ + "js-no_regex", + ["text"," "], + ["paren.rparen","})"] +],[ + "js-start", + ["paren.rparen","}"], + ["punctuation.operator",";"] +],[ + "start", + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start" +],[ + "css-start", + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.style.tag-name.xml","style"], + ["meta.tag.punctuation.tag-close.style.xml",">"] +],[ + "css-ruleset", + ["constant","div"], + ["text"," "], + ["paren.lparen","{"] +],[ + "css-ruleset", + ["text"," "], + ["support.type","color"], + ["punctuation.operator",":"], + ["text"," "], + ["support.constant.color","red"], + ["punctuation.operator",";"] +],[ + "css-start", + ["paren.rparen","}"] +],[ + "start", + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start" +],[ + "sass-start", + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.style.tag-name.xml","style"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","lang"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"sass\""], + ["meta.tag.punctuation.tag-close.style.xml",">"] +],[ + "sass-start", + ["comment","// sass ace mode;"] +],[ + "sass-start" +],[ + "sass-start", + ["keyword","@import"], + ["text"," "], + ["support.function","url("], + ["string","http://fonts.googleapis.com/css?family=Ace:700"], + ["support.function",")"] +],[ + "sass-start" +],[ + "sass-start", + ["variable.language","html"], + ["text",", "], + ["variable.language","body"] +],[ + "sass-start", + ["support.type"," :background-color "], + ["constant.numeric","#ace"] +],[ + "sass-start", + ["text"," "], + ["support.type","text-align"], + ["text",": "], + ["constant.language","center"] +],[ + "sass-start", + ["text"," "], + ["support.type","height"], + ["text",": "], + ["constant.numeric","100%"] +],[ + ["sass-comment",-1,2,"sass-start"], + ["comment"," /*;*********;"] +],[ + ["sass-comment",3,2,"sass-start"], + ["comment"," ;comment ;"] +],[ + ["sass-comment",3,2,"sass-start"], + ["comment"," ;*********;"] +],[ + "sass-start" +],[ + "sass-start" +],[ + "sass-start", + ["text"," &"], + ["variable.language",":before"] +],[ + "sass-start", + ["text"," "], + ["variable","$radius"], + ["text",": "], + ["variable","$size"], + ["text"," "], + ["keyword.operator","*"], + ["text"," "], + ["constant.numeric","0.845"] +],[ + "sass-start", + ["text"," "], + ["variable","$glow"], + ["text",": "], + ["variable","$size"], + ["text"," "], + ["keyword.operator","*"], + ["text"," "], + ["constant.numeric","0.125"] +],[ + "sass-start" +],[ + "sass-start", + ["text"," "], + ["support.type","box-shadow"], + ["text",": "], + ["constant.numeric","0"], + ["text"," "], + ["constant.numeric","0"], + ["text"," "], + ["variable","$glow"], + ["text"," "], + ["variable","$glow"], + ["text"," / "], + ["constant.numeric","2"], + ["text"," "], + ["constant.numeric","#fff"] +],[ + "sass-start", + ["text"," "], + ["support.type","border-radius"], + ["text",": "], + ["variable","$radius"] +],[ + "sass-start" +],[ + "sass-start", + ["text"," &"], + ["variable.language",":active"] +],[ + "sass-start", + ["text"," ~ "], + ["variable.language",".button"] +],[ + "sass-start", + ["text"," "], + ["support.type","box-shadow"], + ["text",": "], + ["constant.numeric","0"], + ["text"," "], + ["constant.numeric","15px"], + ["text"," "], + ["constant.numeric","25px"], + ["text"," "], + ["constant.numeric","-4px"], + ["text"," "], + ["support.function","rgba"], + ["paren.lparen","("], + ["constant.numeric","0"], + ["text",", "], + ["constant.numeric","0"], + ["text",", "], + ["constant.numeric","0"], + ["text",", "], + ["constant.numeric","0.4"], + ["paren.rparen",")"] +],[ + "sass-start" +],[ + "sass-start", + ["text"," ~ "], + ["variable.language",".label"] +],[ + "sass-start", + ["text"," "], + ["support.type","font-size"], + ["text",": "], + ["constant.numeric","40px"] +],[ + "sass-start", + ["text"," "], + ["support.type","color"], + ["text",": "], + ["support.function","rgba"], + ["paren.lparen","("], + ["constant.numeric","0"], + ["text",", "], + ["constant.numeric","0"], + ["text",", "], + ["constant.numeric","0"], + ["text",", "], + ["constant.numeric","0.45"], + ["paren.rparen",")"] +],[ + "sass-start" +],[ + "sass-start", + ["text"," &"], + ["variable.language",":checked"] +],[ + "sass-start", + ["text"," ~ "], + ["variable.language",".button"] +],[ + "sass-start", + ["text"," "], + ["support.type","box-shadow"], + ["text",": "], + ["constant.numeric","0"], + ["text"," "], + ["constant.numeric","15px"], + ["text"," "], + ["constant.numeric","25px"], + ["text"," "], + ["constant.numeric","-4px"], + ["text"," "], + ["constant.numeric","#ace"] +],[ + "sass-start" +],[ + "sass-start", + ["text"," ~ "], + ["variable.language",".label"] +],[ + "sass-start", + ["text"," "], + ["support.type","font-size"], + ["text",": "], + ["constant.numeric","40px"] +],[ + "sass-start", + ["text"," "], + ["support.type","color"], + ["text",": "], + ["constant.numeric","#c9c9c9"] +],[ + "start", + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start" +],[ + "scss-start", + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.style.tag-name.xml","style"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","lang"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"scss\""], + ["meta.tag.punctuation.tag-close.style.xml",">"] +],[ + "scss-start", + ["comment","/* style.scss */"] +],[ + "scss-start" +],[ + "scss-start", + ["variable.language","#navbar"], + ["text"," "], + ["paren.lparen","{"] +],[ + "scss-start", + ["text"," "], + ["variable","$navbar-width"], + ["text",": "], + ["constant.numeric","800px"], + ["text",";"] +],[ + "scss-start", + ["text"," "], + ["variable","$items"], + ["text",": "], + ["constant.numeric","5"], + ["text",";"] +],[ + "scss-start", + ["text"," "], + ["variable","$navbar-color"], + ["text",": "], + ["constant.numeric","#ce4dd6"], + ["text",";"] +],[ + "scss-start" +],[ + "scss-start", + ["text"," "], + ["support.type","width"], + ["text",": "], + ["variable","$navbar-width"], + ["text",";"] +],[ + "scss-start", + ["text"," "], + ["support.type","border-bottom"], + ["text",": "], + ["constant.numeric","2px"], + ["text"," "], + ["constant.language","solid"], + ["text"," "], + ["variable","$navbar-color"], + ["text",";"] +],[ + "scss-start" +],[ + "scss-start", + ["text"," "], + ["variable.language","li"], + ["text"," "], + ["paren.lparen","{"] +],[ + "scss-start", + ["text"," "], + ["support.type","float"], + ["text",": "], + ["support.type","left"], + ["text",";"] +],[ + "scss-start", + ["text"," "], + ["support.type","width"], + ["text",": "], + ["variable","$navbar-width"], + ["text","/"], + ["variable","$items"], + ["text"," "], + ["constant","-"], + ["text"," "], + ["constant.numeric","10px"], + ["text",";"] +],[ + "scss-start" +],[ + "scss-start", + ["text"," "], + ["support.type","background-color"], + ["text",": "], + ["support.function","lighten"], + ["paren.lparen","("], + ["variable","$navbar-color"], + ["text",", "], + ["constant.numeric","20%"], + ["paren.rparen",")"], + ["text",";"] +],[ + "scss-start" +],[ + "scss-start", + ["text"," &"], + ["variable.language",":hover"], + ["text"," "], + ["paren.lparen","{"] +],[ + "scss-start", + ["text"," "], + ["support.type","background-color"], + ["text",": "], + ["support.function","lighten"], + ["paren.lparen","("], + ["variable","$navbar-color"], + ["text",", "], + ["constant.numeric","10%"], + ["paren.rparen",")"], + ["text",";"] +],[ + "scss-start", + ["text"," "], + ["paren.rparen","}"] +],[ + "scss-start", + ["text"," "], + ["paren.rparen","}"] +],[ + "scss-start", + ["paren.rparen","}"] +],[ + "scss-start" +],[ + "start", + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start" +],[ + "jade-start", + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.template.tag-name.xml","template"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","lang"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"jade\""], + ["meta.tag.punctuation.tag-close.template.xml",">"] +],[ + "jade-start", + ["storage.type.function.jade"," mixin"], + ["entity.name.function.jade"," article"], + ["punctuation.definition.parameters.begin.jade","("], + ["variable.parameter.function.jade","obj, parents"], + ["punctuation.definition.parameters.end.jade",")"] +],[ + "jade-start", + ["source.js.embedded.jade"," -"], + ["storage.type","var"], + ["text"," "], + ["identifier","x"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["string","\"0\""], + ["text",";"] +],[ + "jade-start", + ["text"," "] +],[ + "jade-start", + ["source.js.embedded.jade"," -"], + ["text"," "], + ["storage.type","var"], + ["text"," "], + ["identifier","items"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["paren.lparen","["], + ["string","\"one\""], + ["punctuation.operator",","], + ["text"," "], + ["string","\"two\""], + ["punctuation.operator",","], + ["text"," "], + ["string","\"three\""], + ["text","]"] +],[ + "jade-start", + ["meta.tag.any.jade"," each"], + ["text"," item in items"] +],[ + "jade-start", + ["meta.tag.any.jade"," li"], + ["text","= item"] +],[ + "start", + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start" +]] \ No newline at end of file diff --git a/src/mode/javascript_highlight_rules.js b/src/mode/javascript_highlight_rules.js index bae2c5fd025..1fe1f43a311 100644 --- a/src/mode/javascript_highlight_rules.js +++ b/src/mode/javascript_highlight_rules.js @@ -9,7 +9,8 @@ var identifierRe = "[a-zA-Z\\$_\u00a1-\uffff][a-zA-Z\\d\\$_\u00a1-\uffff]*"; var JavaScriptHighlightRules = function(options) { // see: https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects - var keywordMapper = this.createKeywordMapper({ + + var keywords = { "variable.language": "Array|Boolean|Date|Function|Iterator|Number|Object|RegExp|String|Proxy|Symbol|" + // Constructors "Namespace|QName|XML|XMLList|" + // E4X @@ -23,7 +24,7 @@ var JavaScriptHighlightRules = function(options) { "this|arguments|prototype|window|document" , // Pseudo "keyword": "const|yield|import|get|set|async|await|" + - "break|case|catch|continue|default|delete|do|else|finally|for|function|" + + "break|case|catch|continue|default|delete|do|else|finally|for|" + "if|in|of|instanceof|new|return|switch|throw|try|typeof|let|var|while|with|debugger|" + // invalid or reserved "__parent__|__count__|escape|unescape|with|__proto__|" + @@ -35,7 +36,9 @@ var JavaScriptHighlightRules = function(options) { "support.function": "alert", "constant.language.boolean": "true|false" - }, "identifier"); + }; + + var keywordMapper = this.createKeywordMapper(keywords, "identifier"); // keywords which can be followed by regular expressions var kwBeforeRe = "case|do|else|finally|in|instanceof|return|throw|try|typeof|yield|void"; @@ -49,11 +52,19 @@ var JavaScriptHighlightRules = function(options) { ".)"; // regexp must not have capturing parentheses. Use (?:) instead. // regexps are ordered -> the first match is used + + var anonymousFunctionRe = "(function)(\\s*)(\\*?)"; + + var functionCallStartRule = { //just simple function call + token: ["identifier", "text", "paren.lparen"], + regex: "(\\b(?!" + Object.values(keywords).join("|") + "\\b)" + identifierRe + ")(\\s*)(\\()" + }; this.$rules = { "no_regex" : [ DocCommentHighlightRules.getStartRule("doc-start"), comments("no_regex"), + functionCallStartRule, { token : "string", regex : "'(?=.)", @@ -68,60 +79,35 @@ var JavaScriptHighlightRules = function(options) { }, { token : "constant.numeric", // decimal integers and floats regex : /(?:\d\d*(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+\b)?/ - }, { - // Sound.prototype.play = - token : [ - "storage.type", "punctuation.operator", "support.function", - "punctuation.operator", "entity.name.function", "text","keyword.operator" - ], - regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)", - next: "function_arguments" - }, { - // Sound.play = function() { } - token : [ - "storage.type", "punctuation.operator", "entity.name.function", "text", - "keyword.operator", "text", "storage.type", "text", "paren.lparen" - ], - regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function\\*?)(\\s*)(\\()", - next: "function_arguments" }, { // play = function() { } token : [ "entity.name.function", "text", "keyword.operator", "text", "storage.type", - "text", "paren.lparen" - ], - regex : "(" + identifierRe +")(\\s*)(=)(\\s*)(function\\*?)(\\s*)(\\()", - next: "function_arguments" - }, { - // Sound.play = function play() { } - token : [ - "storage.type", "punctuation.operator", "entity.name.function", "text", - "keyword.operator", "text", - "storage.type", "text", "entity.name.function", "text", "paren.lparen" + "text", "storage.type", "text", "paren.lparen" ], - regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function\\*?)(\\s+)(\\w+)(\\s*)(\\()", + regex : "(" + identifierRe +")(\\s*)(=)(\\s*)" + anonymousFunctionRe + "(\\s*)(\\()", next: "function_arguments" }, { // function myFunc(arg) { } token : [ - "storage.type", "text", "entity.name.function", "text", "paren.lparen" + "storage.type", "text", "storage.type", "text", "text", "entity.name.function", "text", "paren.lparen" ], - regex : "(function\\*?)(\\s+)(" + identifierRe + ")(\\s*)(\\()", + regex : "(function)(?:(?:(\\s*)(\\*)(\\s*))|(\\s+))(" + identifierRe + ")(\\s*)(\\()", next: "function_arguments" }, { // foobar: function() { } token : [ "entity.name.function", "text", "punctuation.operator", - "text", "storage.type", "text", "paren.lparen" + "text", "storage.type", "text", "storage.type", "text", "paren.lparen" ], - regex : "(" + identifierRe + ")(\\s*)(:)(\\s*)(function\\*?)(\\s*)(\\()", + regex : "(" + identifierRe + ")(\\s*)(:)(\\s*)" + anonymousFunctionRe + "(\\s*)(\\()", next: "function_arguments" }, { // : function() { } (this is for issues with 'foo': function() { }) token : [ - "text", "text", "storage.type", "text", "paren.lparen" + "text", "text", "storage.type", "text", "storage.type", "text", "paren.lparen" ], - regex : "(:)(\\s*)(function\\*?)(\\s*)(\\()", + regex : "(:)(\\s*)" + anonymousFunctionRe + "(\\s*)(\\()", next: "function_arguments" }, { // from "module-path" (this is the only case where 'from' should be a keyword) @@ -172,17 +158,28 @@ var JavaScriptHighlightRules = function(options) { token : "text", regex : "\\s+" }, { - // Sound.play = function play() { } + token: "keyword.operator", + regex: /=/ + }, { + // Sound.play = function() { } token : [ - "storage.type", "punctuation.operator", "entity.name.function", "text", - "keyword.operator", "text", - "storage.type", "text", "entity.name.function", "text", "paren.lparen" + "storage.type", "text", "storage.type", "text", "paren.lparen" ], - regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function\\*?)(?:(\\s+)(\\w+))?(\\s*)(\\()", + regex : anonymousFunctionRe + "(\\s*)(\\()", + next: "function_arguments" + }, { + // Sound.play = function play() { } + token: [ + "storage.type", "text", "storage.type", "text", "text", "entity.name.function", "text", "paren.lparen" + ], + regex: "(function)(?:(?:(\\s*)(\\*)(\\s*))|(\\s+))(\\w+)(\\s*)(\\()", next: "function_arguments" }, { token : "punctuation.operator", regex : /[.](?![.])/ + }, { + token : "support.function", + regex: "prototype" }, { token : "support.function", regex : /(s(?:h(?:ift|ow(?:Mod(?:elessDialog|alDialog)|Help))|croll(?:X|By(?:Pages|Lines)?|Y|To)?|t(?:op|rike)|i(?:n|zeToContent|debar|gnText)|ort|u(?:p|b(?:str(?:ing)?)?)|pli(?:ce|t)|e(?:nd|t(?:Re(?:sizable|questHeader)|M(?:i(?:nutes|lliseconds)|onth)|Seconds|Ho(?:tKeys|urs)|Year|Cursor|Time(?:out)?|Interval|ZOptions|Date|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Date|FullYear)|FullYear|Active)|arch)|qrt|lice|avePreferences|mall)|h(?:ome|andleEvent)|navigate|c(?:har(?:CodeAt|At)|o(?:s|n(?:cat|textual|firm)|mpile)|eil|lear(?:Timeout|Interval)?|a(?:ptureEvents|ll)|reate(?:StyleSheet|Popup|EventObject))|t(?:o(?:GMTString|S(?:tring|ource)|U(?:TCString|pperCase)|Lo(?:caleString|werCase))|est|a(?:n|int(?:Enabled)?))|i(?:s(?:NaN|Finite)|ndexOf|talics)|d(?:isableExternalCapture|ump|etachEvent)|u(?:n(?:shift|taint|escape|watch)|pdateCommands)|j(?:oin|avaEnabled)|p(?:o(?:p|w)|ush|lugins.refresh|a(?:ddings|rse(?:Int|Float)?)|r(?:int|ompt|eference))|e(?:scape|nableExternalCapture|val|lementFromPoint|x(?:p|ec(?:Script|Command)?))|valueOf|UTC|queryCommand(?:State|Indeterm|Enabled|Value)|f(?:i(?:nd|lter|le(?:ModifiedDate|Size|CreatedDate|UpdatedDate)|xed)|o(?:nt(?:size|color)|rward|rEach)|loor|romCharCode)|watch|l(?:ink|o(?:ad|g)|astIndexOf)|a(?:sin|nchor|cos|t(?:tachEvent|ob|an(?:2)?)|pply|lert|b(?:s|ort))|r(?:ou(?:nd|teEvents)|e(?:size(?:By|To)|calc|turnValue|place|verse|l(?:oad|ease(?:Capture|Events)))|andom)|g(?:o|et(?:ResponseHeader|M(?:i(?:nutes|lliseconds)|onth)|Se(?:conds|lection)|Hours|Year|Time(?:zoneOffset)?|Da(?:y|te)|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Da(?:y|te)|FullYear)|FullYear|A(?:ttention|llResponseHeaders)))|m(?:in|ove(?:B(?:y|elow)|To(?:Absolute)?|Above)|ergeAttributes|a(?:tch|rgins|x))|b(?:toa|ig|o(?:ld|rderWidths)|link|ack))\b(?=\()/ @@ -417,7 +414,7 @@ var JavaScriptHighlightRules = function(options) { regex: "(" + identifierRe + ")(\\s*)(?=\\=>)" }, { token: "paren.lparen", - regex: "(\\()(?=.+\\s*=>)", + regex: "(\\()(?=[^\\(]+\\s*=>)", next: "function_arguments" }, { token: "variable.language", From 65a7f38713cffb729dab530711351c0a17c5801f Mon Sep 17 00:00:00 2001 From: Azat Alimov <32402726+mkslanc@users.noreply.github.com> Date: Fri, 26 Apr 2024 18:52:53 +0400 Subject: [PATCH 05/23] fix: incorrect spans style (#5539) --- src/autocomplete/popup.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/autocomplete/popup.js b/src/autocomplete/popup.js index 99afd326ac9..2a164758ce8 100644 --- a/src/autocomplete/popup.js +++ b/src/autocomplete/popup.js @@ -476,7 +476,6 @@ dom.importCssString(` .ace_autocomplete .ace_line .ace_ { flex: 0 1 auto; overflow: hidden; - white-space: nowrap; text-overflow: ellipsis; } .ace_autocomplete .ace_completion-spacer { From 6a26b277d0050b38cd766e00f93be4b9f3170f68 Mon Sep 17 00:00:00 2001 From: Azat Alimov <32402726+mkslanc@users.noreply.github.com> Date: Tue, 30 Apr 2024 16:50:59 +0400 Subject: [PATCH 06/23] Fix: Add soft wrap for ghost text (#5540) * add soft wrap for ghost text * fix: tests; display of multiline completions * add wrap symbol for wrapped lines in ghost text --- src/autocomplete/inline_test.js | 4 +-- src/css/editor-css.js | 12 +++++++ src/ext/inline_autocomplete_test.js | 4 +-- src/line_widgets.js | 1 + src/virtual_renderer.js | 55 +++++++++++++++++++++++++---- src/virtual_renderer_test.js | 21 ++++++++++- 6 files changed, 85 insertions(+), 12 deletions(-) diff --git a/src/autocomplete/inline_test.js b/src/autocomplete/inline_test.js index 019e4b2a483..3fd48d42d5b 100644 --- a/src/autocomplete/inline_test.js +++ b/src/autocomplete/inline_test.js @@ -101,8 +101,8 @@ module.exports = { inline.show(editor, completions[3], "f"); editor.renderer.$loop._flush(); assert.strictEqual(getAllLines(), textBase + "function foo() {"); - assert.strictEqual(editor.renderer.$ghostTextWidget.text, " console.log('test');\n }"); - assert.strictEqual(editor.renderer.$ghostTextWidget.el.textContent, " console.log('test');\n }"); + assert.strictEqual(editor.renderer.$ghostTextWidget.html, "
console.log('test');
}
"); + assert.strictEqual(editor.renderer.$ghostTextWidget.el.innerHTML, "
console.log('test');
}
"); done(); }, "test: boundary tests": function(done) { diff --git a/src/css/editor-css.js b/src/css/editor-css.js index bdcde97a02b..04245a30131 100644 --- a/src/css/editor-css.js +++ b/src/css/editor-css.js @@ -656,9 +656,21 @@ module.exports = ` .ace_ghost_text { opacity: 0.5; font-style: italic; +} + +.ace_ghost_text > div { white-space: pre; } +.ghost_text_line_wrapped::after { + content: "↩"; + position: absolute; +} + +.ace_lineWidgetContainer.ace_ghost_text { + margin: 0px 4px +} + .ace_screenreader-only { position:absolute; left:-10000px; diff --git a/src/ext/inline_autocomplete_test.js b/src/ext/inline_autocomplete_test.js index ae97bad367c..af98a6e81e6 100644 --- a/src/ext/inline_autocomplete_test.js +++ b/src/ext/inline_autocomplete_test.js @@ -30,7 +30,7 @@ var getAllLines = function() { return node.textContent; }).join("\n"); if (editor.renderer.$ghostTextWidget) { - return text + "\n" + editor.renderer.$ghostTextWidget.text; + return text + "\n" + editor.renderer.$ghostTextWidget.html; } return text; }; @@ -358,7 +358,7 @@ module.exports = { typeAndChange("u", "n"); editor.renderer.$loop._flush(); assert.strictEqual(autocomplete.isOpen(), true); - assert.equal(getAllLines(), "function foo() {\n console.log('test');\n}"); + assert.equal(getAllLines(), "function foo() {\n
console.log('test');
}
"); typeAndChange("d"); editor.renderer.$loop._flush(); diff --git a/src/line_widgets.js b/src/line_widgets.js index 55db6f6ccc9..8d781db79a8 100644 --- a/src/line_widgets.js +++ b/src/line_widgets.js @@ -388,6 +388,7 @@ class LineWidgets { renderer.$cursorLayer.config = config; for (var i = first; i <= last; i++) { + /**@type{LineWidget}*/ var w = lineWidgets[i]; if (!w || !w.el) continue; if (w.hidden) { diff --git a/src/virtual_renderer.js b/src/virtual_renderer.js index 622cf09ac06..ce160fd81e8 100644 --- a/src/virtual_renderer.js +++ b/src/virtual_renderer.js @@ -1757,9 +1757,10 @@ class VirtualRenderer { var insertPosition = position || { row: cursor.row, column: cursor.column }; this.removeGhostText(); - - var textLines = text.split("\n"); - this.addToken(textLines[0], "ghost_text", insertPosition.row, insertPosition.column); + + var textChunks = this.$calculateWrappedTextChunks(text, insertPosition); + this.addToken(textChunks[0].text, "ghost_text", insertPosition.row, insertPosition.column); + this.$ghostText = { text: text, position: { @@ -1767,9 +1768,13 @@ class VirtualRenderer { column: insertPosition. column } }; - if (textLines.length > 1) { + if (textChunks.length > 1) { + var divs = textChunks.slice(1).map(el => { + return `${el.text}`; + }); + this.$ghostTextWidget = { - text: textLines.slice(1).join("\n"), + html: divs.join(""), row: insertPosition.row, column: insertPosition.column, className: "ace_ghost_text" @@ -1780,7 +1785,7 @@ class VirtualRenderer { var pixelPosition = this.$cursorLayer.getPixelPosition(insertPosition, true); var el = this.container; var height = el.getBoundingClientRect().height; - var ghostTextHeight = textLines.length * this.lineHeight; + var ghostTextHeight = textChunks.length * this.lineHeight; var fitsY = ghostTextHeight < (height - pixelPosition.top); // If it fits, no action needed @@ -1790,7 +1795,7 @@ class VirtualRenderer { // if it cannot fully fit, scroll so that the row with the cursor // is at the top of the screen. if (ghostTextHeight < height) { - this.scrollBy(0, (textLines.length - 1) * this.lineHeight); + this.scrollBy(0, (textChunks.length - 1) * this.lineHeight); } else { this.scrollToRow(insertPosition.row); } @@ -1798,6 +1803,42 @@ class VirtualRenderer { } + /** + * Calculates and organizes text into wrapped chunks. Initially splits the text by newline characters, + * then further processes each line based on display tokens and session settings for tab size and wrapping limits. + * + * @param {string} text + * @param {Point} position + * @return {{text: string, wrapped: boolean}[]} + */ + $calculateWrappedTextChunks(text, position) { + var availableWidth = this.$size.scrollerWidth - this.$padding * 2; + var limit = Math.floor(availableWidth / this.characterWidth) - 2; + limit = limit <= 0 ? 60 : limit; // this is a hack to prevent the editor from crashing when the window is too small + + var textLines = text.split(/\r?\n/); + var textChunks = []; + for (var i = 0; i < textLines.length; i++) { + var displayTokens = this.session.$getDisplayTokens(textLines[i], position.column); + var wrapSplits = this.session.$computeWrapSplits(displayTokens, limit, this.session.$tabSize); + + if (wrapSplits.length > 0) { + var start = 0; + wrapSplits.push(textLines[i].length); + + for (var j = 0; j < wrapSplits.length; j++) { + let textSlice = textLines[i].slice(start, wrapSplits[j]); + textChunks.push({text: textSlice, wrapped: true}); + start = wrapSplits[j]; + } + } + else { + textChunks.push({text: textLines[i], wrapped: false}); + } + } + return textChunks; + } + removeGhostText() { if (!this.$ghostText) return; diff --git a/src/virtual_renderer_test.js b/src/virtual_renderer_test.js index 85753b43714..366e4482a41 100644 --- a/src/virtual_renderer_test.js +++ b/src/virtual_renderer_test.js @@ -338,7 +338,7 @@ module.exports = { editor.renderer.$loop._flush(); assert.equal(editor.renderer.content.textContent, "abcdefGhost1"); - assert.equal(editor.session.lineWidgets[0].el.textContent, "Ghost2\nGhost3"); + assert.equal(editor.session.lineWidgets[0].el.innerHTML, "
Ghost2
Ghost3
"); editor.removeGhostText(); @@ -347,6 +347,25 @@ module.exports = { assert.equal(editor.session.lineWidgets, null); }, + "test long multiline ghost text": function() { + editor.session.setValue("abcdef"); + editor.renderer.$loop._flush(); + + editor.setGhostText("This is a long test text that is longer than 30 characters\n\nGhost3", + {row: 0, column: 6}); + + editor.renderer.$loop._flush(); + assert.equal(editor.renderer.content.textContent, "abcdefThis is a long test text that is longer than "); + + assert.equal(editor.session.lineWidgets[0].el.innerHTML, "
30 characters
Ghost3
"); + + editor.removeGhostText(); + + editor.renderer.$loop._flush(); + assert.equal(editor.renderer.content.textContent, "abcdef"); + + assert.equal(editor.session.lineWidgets, null); + }, "test: brackets highlighting": function (done) { var renderer = editor.renderer; editor.session.setValue( From 8e51966576d83d6d79f7b9a68a4cd80d2e5d8fc2 Mon Sep 17 00:00:00 2001 From: Oyku Yilmaz <12100596+oykuyilmaz@users.noreply.github.com> Date: Mon, 6 May 2024 11:35:13 +0200 Subject: [PATCH 07/23] chore: add Hyena Code to users on website (#5546) --- index.html | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/index.html b/index.html index 46354f3e81f..bb73b73a452 100644 --- a/index.html +++ b/index.html @@ -1166,14 +1166,18 @@

Projects Using Ace

Funcdown -
  • +
  • SQLtest.online
  • -
  • +
  • HirenJS Code Editor -
  • + +
  • + + Hyena Code +
  • +

    Your Site Here From 759112016370e56642cfe547132d2cb9465ce1f7 Mon Sep 17 00:00:00 2001 From: Harutyun Amirjanyan Date: Wed, 8 May 2024 15:09:16 +0400 Subject: [PATCH 08/23] handle events without deprecated keyCode property (#5543) --- src/editor_commands_test.js | 10 ++ src/lib/event.js | 4 + src/lib/keys.js | 285 ++++++++++++++++++------------------ 3 files changed, 156 insertions(+), 143 deletions(-) diff --git a/src/editor_commands_test.js b/src/editor_commands_test.js index 860d057ab9f..fbb7fe267c2 100644 --- a/src/editor_commands_test.js +++ b/src/editor_commands_test.js @@ -564,6 +564,16 @@ module.exports = { url = editor.findLinkAt(1, 5); assert.equal(url, "https://www.google.com/"); + }, + "test handle events without deprecated keyCode property": function() { + var e = new CustomEvent("keydown"); + e.code = "KeyA"; + e.ctrlKey = true; + editor = new Editor(new MockRenderer()); + editor.session.setValue("123"); + assert.equal(editor.getSelectedText(), ""); + editor.textInput.getElement().dispatchEvent(e); + assert.equal(editor.getSelectedText(), "123"); } }; diff --git a/src/lib/event.js b/src/lib/event.js index c7e88e1ce25..6025acfc17a 100644 --- a/src/lib/event.js +++ b/src/lib/event.js @@ -203,6 +203,10 @@ exports.getModifierString = function(e) { function normalizeCommandKeys(callback, e, keyCode) { var hashId = getModifierHash(e); + if (!keyCode && e.code) { + keyCode = keys.$codeToKeyCode[e.code] || keyCode; + } + if (!useragent.isMac && pressedKeys) { if (e.getModifierState && (e.getModifierState("OS") || e.getModifierState("Win"))) hashId |= 8; diff --git a/src/lib/keys.js b/src/lib/keys.js index ef8ddfcd3d2..4e23cb371e8 100644 --- a/src/lib/keys.js +++ b/src/lib/keys.js @@ -1,154 +1,153 @@ -/*! @license -========================================================================== -SproutCore -- JavaScript Application Framework -copyright 2006-2009, Sprout Systems Inc., Apple Inc. and contributors. - -Permission is hereby granted, free of charge, to any person obtaining a -copy of this software and associated documentation files (the "Software"), -to deal in the Software without restriction, including without limitation -the rights to use, copy, modify, merge, publish, distribute, sublicense, -and/or sell copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -DEALINGS IN THE SOFTWARE. - -SproutCore and the SproutCore logo are trademarks of Sprout Systems, Inc. - -For more information about SproutCore, visit http://www.sproutcore.com - - -========================================================================== -@license */ - -// Most of the following code is taken from SproutCore with a few changes. - "use strict"; var oop = require("./oop"); -/* - * Helper functions and hashes for key handling. - */ -var Keys = (function() { - var ret = { - MODIFIER_KEYS: { - 16: 'Shift', 17: 'Ctrl', 18: 'Alt', 224: 'Meta', - 91: 'MetaLeft', 92: 'MetaRight', 93: 'ContextMenu' - }, - - KEY_MODS: { - "ctrl": 1, "alt": 2, "option" : 2, "shift": 4, - "super": 8, "meta": 8, "command": 8, "cmd": 8, - "control": 1 - }, - - FUNCTION_KEYS : { - 8 : "Backspace", - 9 : "Tab", - 13 : "Return", - 19 : "Pause", - 27 : "Esc", - 32 : "Space", - 33 : "PageUp", - 34 : "PageDown", - 35 : "End", - 36 : "Home", - 37 : "Left", - 38 : "Up", - 39 : "Right", - 40 : "Down", - 44 : "Print", - 45 : "Insert", - 46 : "Delete", - 96 : "Numpad0", - 97 : "Numpad1", - 98 : "Numpad2", - 99 : "Numpad3", - 100: "Numpad4", - 101: "Numpad5", - 102: "Numpad6", - 103: "Numpad7", - 104: "Numpad8", - 105: "Numpad9", - '-13': "NumpadEnter", - 112: "F1", - 113: "F2", - 114: "F3", - 115: "F4", - 116: "F5", - 117: "F6", - 118: "F7", - 119: "F8", - 120: "F9", - 121: "F10", - 122: "F11", - 123: "F12", - 144: "Numlock", - 145: "Scrolllock" - }, - - PRINTABLE_KEYS: { - 32: ' ', 48: '0', 49: '1', 50: '2', 51: '3', 52: '4', 53: '5', - 54: '6', 55: '7', 56: '8', 57: '9', 59: ';', 61: '=', 65: 'a', - 66: 'b', 67: 'c', 68: 'd', 69: 'e', 70: 'f', 71: 'g', 72: 'h', - 73: 'i', 74: 'j', 75: 'k', 76: 'l', 77: 'm', 78: 'n', 79: 'o', - 80: 'p', 81: 'q', 82: 'r', 83: 's', 84: 't', 85: 'u', 86: 'v', - 87: 'w', 88: 'x', 89: 'y', 90: 'z', 107: '+', 109: '-', 110: '.', - 186: ';', 187: '=', 188: ',', 189: '-', 190: '.', 191: '/', 192: '`', - 219: '[', 220: '\\',221: ']', 222: "'", 111: '/', 106: '*' - } - }; - - // workaround for firefox bug - ret.PRINTABLE_KEYS[173] = '-'; - - // A reverse map of FUNCTION_KEYS - var name, i; - for (i in ret.FUNCTION_KEYS) { - name = ret.FUNCTION_KEYS[i].toLowerCase(); - ret[name] = parseInt(i, 10); - } - // A reverse map of PRINTABLE_KEYS - for (i in ret.PRINTABLE_KEYS) { - name = ret.PRINTABLE_KEYS[i].toLowerCase(); - ret[name] = parseInt(i, 10); +var Keys = { + MODIFIER_KEYS: { + 16: 'Shift', 17: 'Ctrl', 18: 'Alt', 224: 'Meta', + 91: 'MetaLeft', 92: 'MetaRight', 93: 'ContextMenu' + }, + + KEY_MODS: { + "ctrl": 1, "alt": 2, "option" : 2, "shift": 4, + "super": 8, "meta": 8, "command": 8, "cmd": 8, + "control": 1 + }, + + FUNCTION_KEYS : { + 8 : "Backspace", + 9 : "Tab", + 13 : "Return", + 19 : "Pause", + 27 : "Esc", + 32 : "Space", + 33 : "PageUp", + 34 : "PageDown", + 35 : "End", + 36 : "Home", + 37 : "Left", + 38 : "Up", + 39 : "Right", + 40 : "Down", + 44 : "Print", + 45 : "Insert", + 46 : "Delete", + '-13': "NumpadEnter", + 144: "Numlock", + 145: "Scrolllock" + }, + + PRINTABLE_KEYS: { + 32: ' ', 59: ';', 61: '=', 107: '+', 109: '-', 110: '.', + 186: ';', 187: '=', 188: ',', 189: '-', 190: '.', 191: '/', 192: '`', + 219: '[', 220: '\\',221: ']', 222: "'", 111: '/', 106: '*' } +}; - // Add the MODIFIER_KEYS, FUNCTION_KEYS and PRINTABLE_KEYS to the KEY - // variables as well. - oop.mixin(ret, ret.MODIFIER_KEYS); - oop.mixin(ret, ret.PRINTABLE_KEYS); - oop.mixin(ret, ret.FUNCTION_KEYS); - - // aliases - ret.enter = ret["return"]; - ret.escape = ret.esc; - ret.del = ret["delete"]; - - (function() { - var mods = ["cmd", "ctrl", "alt", "shift"]; - for (var i = Math.pow(2, mods.length); i--;) { - ret.KEY_MODS[i] = mods.filter(function(x) { - return i & ret.KEY_MODS[x]; - }).join("-") + "-"; - } - })(); - - ret.KEY_MODS[0] = ""; - ret.KEY_MODS[-1] = "input-"; - - return ret; +var codeToKeyCode = { + Command: 224, + Backspace: 8, + Tab: 9, + Return: 13, + Enter: 13, + Pause: 19, + Escape: 27, + PageUp: 33, + PageDown: 34, + End: 35, + Home: 36, + Insert: 45, + Delete: 46, + ArrowLeft: 37, + ArrowUp: 38, + ArrowRight: 39, + ArrowDown: 40, + // special keys + Backquote: 192, + Minus: 189, + Equal: 187, + BracketLeft: 219, + Backslash: 220, + BracketRight: 221, + Semicolon: 186, + Quote: 222, + Comma: 188, + Period: 190, + Slash: 191, + Space: 32, + NumpadAdd: 107, + NumpadDecimal: 110, + NumpadSubtract: 109, + NumpadDivide: 111, + NumpadMultiply: 106 +}; +for (var i = 0; i < 10; i++) { + codeToKeyCode["Digit" + i] = 48 + i; + codeToKeyCode["Numpad" + i] = 96 + i; + Keys.PRINTABLE_KEYS[48 + i] = "" + i; + Keys.FUNCTION_KEYS[96 + i] = "Numpad" + i; +} +for (var i = 65; i < 91; i++) { + var chr = String.fromCharCode(i + 32); + codeToKeyCode["Key" + chr.toUpperCase()] = i; + Keys.PRINTABLE_KEYS[i] = chr; +} +for (var i = 1; i < 13; i++) { + codeToKeyCode["F" + i] = 111 + i; + Keys.FUNCTION_KEYS[111 + i] = "F" + i; +} +var modifiers = { + Shift: 16, + Control: 17, + Alt: 18, + Meta: 224 +}; +for (var mod in modifiers) { + codeToKeyCode[mod] = codeToKeyCode[mod + "Left"] + = codeToKeyCode[mod + "Right"] = modifiers[mod]; +} +exports.$codeToKeyCode = codeToKeyCode; + +// workaround for firefox bug +Keys.PRINTABLE_KEYS[173] = '-'; + +// A reverse map of FUNCTION_KEYS +for (var j in Keys.FUNCTION_KEYS) { + var name = Keys.FUNCTION_KEYS[j].toLowerCase(); + Keys[name] = parseInt(j, 10); +} + +// A reverse map of PRINTABLE_KEYS +for (var j in Keys.PRINTABLE_KEYS) { + var name = Keys.PRINTABLE_KEYS[j].toLowerCase(); + Keys[name] = parseInt(j, 10); +} + +// Add the MODIFIER_KEYS, FUNCTION_KEYS and PRINTABLE_KEYS to the KEY +// variables as well. +oop.mixin(Keys, Keys.MODIFIER_KEYS); +oop.mixin(Keys, Keys.PRINTABLE_KEYS); +oop.mixin(Keys, Keys.FUNCTION_KEYS); + +// aliases +Keys.enter = Keys["return"]; +Keys.escape = Keys.esc; +Keys.del = Keys["delete"]; + +(function() { + var mods = ["cmd", "ctrl", "alt", "shift"]; + for (var i = Math.pow(2, mods.length); i--;) { + Keys.KEY_MODS[i] = mods.filter(function(x) { + return i & Keys.KEY_MODS[x]; + }).join("-") + "-"; + } })(); + +Keys.KEY_MODS[0] = ""; +Keys.KEY_MODS[-1] = "input-"; + + oop.mixin(exports, Keys); exports.default = exports; From 7a5199292f55dfa1a8ea8830ea1a9d98be097161 Mon Sep 17 00:00:00 2001 From: Azat Alimov <32402726+mkslanc@users.noreply.github.com> Date: Wed, 8 May 2024 15:15:46 +0400 Subject: [PATCH 09/23] fix: not determined folding widgets for html tags (#5548) --- src/mode/folding/php.js | 32 +++++++++---------- src/mode/folding/php_test.js | 59 +++++++++++++++++++++++++++++++----- src/mode/php.js | 15 +++++++-- 3 files changed, 79 insertions(+), 27 deletions(-) diff --git a/src/mode/folding/php.js b/src/mode/folding/php.js index 0b20322fe3e..56b9bab317e 100644 --- a/src/mode/folding/php.js +++ b/src/mode/folding/php.js @@ -1,24 +1,20 @@ "use strict"; var oop = require("../../lib/oop"); -var MixedFoldMode = require("./mixed").FoldMode; var CstyleFoldMode = require("./cstyle").FoldMode; var Range = require("../../range").Range; var TokenIterator = require("../../token_iterator").TokenIterator; var FoldMode = exports.FoldMode = function () { - this.cstyleFoldMode = new CstyleFoldMode(); - MixedFoldMode.call(this, this, { - "js-": new CstyleFoldMode(), - "css-": new CstyleFoldMode(), - "php-": this - }); }; -oop.inherits(FoldMode, MixedFoldMode); +oop.inherits(FoldMode, CstyleFoldMode); (function () { + this.getFoldWidgetRangeBase = this.getFoldWidgetRange; + this.getFoldWidgetBase = this.getFoldWidget; + this.indentKeywords = { "if": 1, "while": 1, @@ -34,31 +30,31 @@ oop.inherits(FoldMode, MixedFoldMode); "endswitch": -1 }; - this.foldingStartMarker = /(?:\s|^)(if|else|elseif|while|for|foreach|switch).*\:/i; - this.foldingStopMarker = /(?:\s|^)(endif|endwhile|endfor|endforeach|endswitch)\;/i; + this.foldingStartMarkerPhp = /(?:\s|^)(if|else|elseif|while|for|foreach|switch).*\:/i; + this.foldingStopMarkerPhp = /(?:\s|^)(endif|endwhile|endfor|endforeach|endswitch)\;/i; this.getFoldWidgetRange = function (session, foldStyle, row) { var line = session.doc.getLine(row); - var match = this.foldingStartMarker.exec(line); + var match = this.foldingStartMarkerPhp.exec(line); if (match) { return this.phpBlock(session, row, match.index + 2); } - var match = this.foldingStopMarker.exec(line); + var match = this.foldingStopMarkerPhp.exec(line); if (match) { return this.phpBlock(session, row, match.index + 2); } - return this.cstyleFoldMode.getFoldWidgetRange(session, foldStyle, row); + return this.getFoldWidgetRangeBase(session, foldStyle, row); }; // must return "" if there's no fold, to enable caching this.getFoldWidget = function (session, foldStyle, row) { var line = session.getLine(row); - var isStart = this.foldingStartMarker.test(line); - var isEnd = this.foldingStopMarker.test(line); + var isStart = this.foldingStartMarkerPhp.test(line); + var isEnd = this.foldingStopMarkerPhp.test(line); if (isStart && !isEnd) { - var match = this.foldingStartMarker.exec(line); + var match = this.foldingStartMarkerPhp.exec(line); var keyword = match && match[1].toLowerCase(); if (keyword) { var type = session.getTokenAt(row, match.index + 2).type; @@ -68,7 +64,7 @@ oop.inherits(FoldMode, MixedFoldMode); } } if (isEnd && foldStyle === "markbeginend") { - var match = this.foldingStopMarker.exec(line); + var match = this.foldingStopMarkerPhp.exec(line); var keyword = match && match[1].toLowerCase(); if (keyword) { var type = session.getTokenAt(row, match.index + 2).type; @@ -77,7 +73,7 @@ oop.inherits(FoldMode, MixedFoldMode); } } } - return this.cstyleFoldMode.getFoldWidget(session, foldStyle, row); + return this.getFoldWidgetBase(session, foldStyle, row); }; this.phpBlock = function (session, row, column, tokenRange) { diff --git a/src/mode/folding/php_test.js b/src/mode/folding/php_test.js index 84c1200f697..026c25edd79 100644 --- a/src/mode/folding/php_test.js +++ b/src/mode/folding/php_test.js @@ -13,13 +13,38 @@ module.exports = { "test: php folding with alternative syntax": function () { var session = new EditSession([ - ' 0):', - ' echo "Number is positive";', ' else:', - ' echo "Number is negative";', 'endif;', ' break;', ' default:', - ' echo "Number is not zero";', ' }', 'foreach (array(1, 2, 3) as $num):', - ' echo "Num: $num";', ' endforeach;', '}', '?>' + ' 0):', + ' echo "Number is positive";', + ' else:', + ' echo "Number is negative";', + 'endif;', + ' break;', + ' default:', + ' echo "Number is not zero";', + ' }', 'foreach (array(1, 2, 3) as $num):', + ' echo "Num: $num";', + ' endforeach;', + '}', + '?>', + '', + '', + '' ]); session.setFoldStyle("markbeginend"); @@ -41,6 +66,18 @@ module.exports = { assert.equal(session.getFoldWidget(17), "start"); assert.equal(session.getFoldWidget(19), "end"); assert.equal(session.getFoldWidget(20), "end"); + assert.equal(session.getFoldWidget(21), ""); + assert.equal(session.getFoldWidget(22), ""); + assert.equal(session.getFoldWidget(23), "start"); + assert.equal(session.getFoldWidget(24), "start"); + assert.equal(session.getFoldWidget(25), ""); + assert.equal(session.getFoldWidget(26), "end"); + assert.equal(session.getFoldWidget(27), "end"); + assert.equal(session.getFoldWidget(28), "start"); + assert.equal(session.getFoldWidget(29), "start"); + assert.equal(session.getFoldWidget(30), ""); + assert.equal(session.getFoldWidget(31), "end"); + assert.equal(session.getFoldWidget(32), "end"); assert.range(session.getFoldWidgetRange(2), 2, 1, 20, 0); // Range for the function's foldable section assert.range(session.getFoldWidgetRange(3), 3, 21, 16, 7); // Range for the 'switch' statement @@ -50,6 +87,14 @@ module.exports = { assert.range(session.getFoldWidgetRange(12), 10, 16, 12, 0); // Range for the 'endif' line assert.range(session.getFoldWidgetRange(17), 17, 33, 19, 3); assert.range(session.getFoldWidgetRange(19), 17, 33, 19, 3); + assert.range(session.getFoldWidgetRange(23), 23, 8, 27, 0); // Range for script tag + assert.range(session.getFoldWidgetRange(24), 24, 21, 26, 4); // Range for cstyle { } block + assert.range(session.getFoldWidgetRange(26), 24, 21, 26, 4); // Range for closing cstyle { } block + assert.range(session.getFoldWidgetRange(27), 23, 8, 27, 0); // Range for closing script tag + assert.range(session.getFoldWidgetRange(28), 28, 7, 32, 0); // Range for openning style tag + assert.range(session.getFoldWidgetRange(29), 29, 9, 31, 4); // Range for cstyle { } block + assert.range(session.getFoldWidgetRange(31), 29, 9, 31, 4); // Range for closing cstyle { } block + assert.range(session.getFoldWidgetRange(32), 28, 7, 32, 0); // Range for closing style tag } }; diff --git a/src/mode/php.js b/src/mode/php.js index b665067bb8d..04a6fd3eb3e 100644 --- a/src/mode/php.js +++ b/src/mode/php.js @@ -9,6 +9,9 @@ var WorkerClient = require("../worker/worker_client").WorkerClient; var PhpCompletions = require("./php_completions").PhpCompletions; var PhpFoldMode = require("./folding/php").FoldMode; var unicode = require("../unicode"); +var MixedFoldMode = require("./folding/mixed").FoldMode; +var HtmlFoldMode = require("./folding/html").FoldMode; +var CstyleFoldMode = require("./folding/cstyle").FoldMode; var HtmlMode = require("./html").Mode; var JavaScriptMode = require("./javascript").Mode; var CssMode = require("./css").Mode; @@ -18,7 +21,11 @@ var PhpMode = function(opts) { this.$outdent = new MatchingBraceOutdent(); this.$behaviour = this.$defaultBehaviour; this.$completer = new PhpCompletions(); - this.foldingRules = new PhpFoldMode(); + this.foldingRules = new MixedFoldMode(new HtmlFoldMode(), { + "js-": new CstyleFoldMode(), + "css-": new CstyleFoldMode(), + "php-": new PhpFoldMode() + }); }; oop.inherits(PhpMode, TextMode); @@ -91,7 +98,11 @@ var Mode = function(opts) { "css-": CssMode, "php-": PhpMode }); - this.foldingRules = new PhpFoldMode(); + this.foldingRules = new MixedFoldMode(new HtmlFoldMode(), { + "js-": new CstyleFoldMode(), + "css-": new CstyleFoldMode(), + "php-": new PhpFoldMode() + }); }; oop.inherits(Mode, HtmlMode); From b20c6877f5b62c9a6ff1ac5fd69acc3066001264 Mon Sep 17 00:00:00 2001 From: Rahul Kumar Singh <37482171+rahulkumarsingh73690@users.noreply.github.com> Date: Fri, 10 May 2024 21:21:47 +0530 Subject: [PATCH 10/23] Update index.html (#5553) Added techcopes --- index.html | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/index.html b/index.html index bb73b73a452..92811533df6 100644 --- a/index.html +++ b/index.html @@ -1178,6 +1178,10 @@

    Projects Using Ace

    Hyena Code
  • +
  • + + Techcopes +
  • +

    Your Site Here From 3c902de04c3bf29c2d85161ab4c52dfd7b6321d6 Mon Sep 17 00:00:00 2001 From: Zakhar Kozlov Date: Mon, 13 May 2024 12:01:44 +0200 Subject: [PATCH 11/23] release v1.33.2 --- CHANGELOG.md | 11 +++++++++++ build | 2 +- package.json | 2 +- src/config.js | 2 +- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b8668462fc..b22c25e50b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,17 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +### [1.33.2](https://github.com/ajaxorg/ace/compare/v1.33.1...v1.33.2) (2024-05-13) + + +### Bug Fixes + +* Add soft wrap for ghost text ([#5540](https://github.com/ajaxorg/ace/issues/5540)) ([6a26b27](https://github.com/ajaxorg/ace/commit/6a26b277d0050b38cd766e00f93be4b9f3170f68)) +* generator function's determination; wrong parameter highlighting ([#5538](https://github.com/ajaxorg/ace/issues/5538)) ([ceca6f7](https://github.com/ajaxorg/ace/commit/ceca6f7b38f6b3347988f17579ae6a2e758137dd)) +* incorrect spans style ([#5539](https://github.com/ajaxorg/ace/issues/5539)) ([65a7f38](https://github.com/ajaxorg/ace/commit/65a7f38713cffb729dab530711351c0a17c5801f)) +* not determined folding widgets for html tags ([#5548](https://github.com/ajaxorg/ace/issues/5548)) ([7a51992](https://github.com/ajaxorg/ace/commit/7a5199292f55dfa1a8ea8830ea1a9d98be097161)) +* wrong token type ([#5535](https://github.com/ajaxorg/ace/issues/5535)) ([4041489](https://github.com/ajaxorg/ace/commit/4041489bb38ffe609d5f9b43b4a7637e47fc4739)) + ### [1.33.1](https://github.com/ajaxorg/ace/compare/v1.33.0...v1.33.1) (2024-04-23) diff --git a/build b/build index 98d379e25ea..655c20ab324 160000 --- a/build +++ b/build @@ -1 +1 @@ -Subproject commit 98d379e25ea28dcc97c580c33a92f508176f763d +Subproject commit 655c20ab3243bf0603dadbb3905e73ebbdb633cd diff --git a/package.json b/package.json index 26566d38c28..640d9e22d44 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "ace-code", "description": "Ajax.org Code Editor is a full featured source code highlighting editor that powers the Cloud9 IDE", - "version": "1.33.1", + "version": "1.33.2", "homepage": "http://github.com/ajaxorg/ace", "engines": { "node": ">= 0.6.0" diff --git a/src/config.js b/src/config.js index 8bd38acbfa3..3c7fa18fe6c 100644 --- a/src/config.js +++ b/src/config.js @@ -194,6 +194,6 @@ var reportErrorIfPathIsNotConfigured = function() { } }; -exports.version = "1.33.1"; +exports.version = "1.33.2"; From b3dfa11ade723874e58a1abfdefb6a12c321f76c Mon Sep 17 00:00:00 2001 From: Harutyun Amirjanyan Date: Tue, 21 May 2024 17:34:17 +0400 Subject: [PATCH 12/23] fix bracket highlighting in css mode (#5557) fixes #5556 by assigning compatible classnames to { and } --- src/mode/css_highlight_rules.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/mode/css_highlight_rules.js b/src/mode/css_highlight_rules.js index f76bf8b1d7e..b8f727f16d9 100644 --- a/src/mode/css_highlight_rules.js +++ b/src/mode/css_highlight_rules.js @@ -133,6 +133,9 @@ var CssHighlightRules = function() { }, { token : keywordMapper, regex : "\\-?[a-zA-Z_][a-zA-Z0-9_\\-]*" + }, { + token: "paren.lparen", + regex: "\\{" }, { caseInsensitive: true }], From b8877f0f725b3973961cb639127402c9f56609de Mon Sep 17 00:00:00 2001 From: Alice Koreman Date: Tue, 21 May 2024 18:13:04 +0200 Subject: [PATCH 13/23] fix: contrast completion meta contrast cloud editor themes (#5558) --- src/theme/cloud_editor-css.js | 1 + src/theme/cloud_editor_dark-css.js | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/theme/cloud_editor-css.js b/src/theme/cloud_editor-css.js index c14a00d7114..ba384dd419d 100644 --- a/src/theme/cloud_editor-css.js +++ b/src/theme/cloud_editor-css.js @@ -196,6 +196,7 @@ module.exports = ` } .ace-cloud_editor.ace_editor.ace_autocomplete .ace_completion-meta { color: #545b64; + opacity: 1; } .ace-cloud_editor.ace_editor.ace_autocomplete .ace_completion-highlight{ color: #0F68AE; diff --git a/src/theme/cloud_editor_dark-css.js b/src/theme/cloud_editor_dark-css.js index 4ba2af62af6..fb3a9a3a6b7 100644 --- a/src/theme/cloud_editor_dark-css.js +++ b/src/theme/cloud_editor_dark-css.js @@ -198,7 +198,8 @@ module.exports = ` background: #272A30; } .ace-cloud_editor_dark.ace_dark.ace_editor.ace_autocomplete .ace_completion-meta { - color: #ACB8B9; + color: #95a5a6; + opacity: 1; } .ace-cloud_editor_dark.ace_dark.ace_editor.ace_autocomplete .ace_completion-highlight{ color: #2AA0BC; From 36353db2feb316c0a244da7503a04a46c6d2b52a Mon Sep 17 00:00:00 2001 From: Alice Koreman Date: Tue, 21 May 2024 18:23:56 +0200 Subject: [PATCH 14/23] release v1.33.3 --- CHANGELOG.md | 7 +++++++ build | 2 +- package.json | 2 +- src/config.js | 2 +- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b22c25e50b6..7e9654cddae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +### [1.33.3](https://github.com/ajaxorg/ace/compare/v1.33.2...v1.33.3) (2024-05-21) + + +### Bug Fixes + +* contrast completion meta contrast cloud editor themes ([#5558](https://github.com/ajaxorg/ace/issues/5558)) ([b8877f0](https://github.com/ajaxorg/ace/commit/b8877f0f725b3973961cb639127402c9f56609de)) + ### [1.33.2](https://github.com/ajaxorg/ace/compare/v1.33.1...v1.33.2) (2024-05-13) diff --git a/build b/build index 655c20ab324..d97de5f5d82 160000 --- a/build +++ b/build @@ -1 +1 @@ -Subproject commit 655c20ab3243bf0603dadbb3905e73ebbdb633cd +Subproject commit d97de5f5d823b6b669a6f93ea26fe94b05a12405 diff --git a/package.json b/package.json index 640d9e22d44..8b76aa28d13 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "ace-code", "description": "Ajax.org Code Editor is a full featured source code highlighting editor that powers the Cloud9 IDE", - "version": "1.33.2", + "version": "1.33.3", "homepage": "http://github.com/ajaxorg/ace", "engines": { "node": ">= 0.6.0" diff --git a/src/config.js b/src/config.js index 3c7fa18fe6c..60d5b766b77 100644 --- a/src/config.js +++ b/src/config.js @@ -194,6 +194,6 @@ var reportErrorIfPathIsNotConfigured = function() { } }; -exports.version = "1.33.2"; +exports.version = "1.33.3"; From 8d7dfb69392960aba61def982f4bea8f3a5caa70 Mon Sep 17 00:00:00 2001 From: Alice Koreman Date: Wed, 22 May 2024 17:47:42 +0200 Subject: [PATCH 15/23] feat: allow users to add arialabel to text input (#5560) * feat: allow users to add arialabel to text input --- ace.d.ts | 1 + src/editor.js | 4 ++++ src/keyboard/textinput.js | 7 ++++++- src/keyboard/textinput_test.js | 23 +++++++++++++++++++++++ 4 files changed, 34 insertions(+), 1 deletion(-) diff --git a/ace.d.ts b/ace.d.ts index d22d3d23572..5bf4e978465 100644 --- a/ace.d.ts +++ b/ace.d.ts @@ -235,6 +235,7 @@ export namespace Ace { relativeLineNumbers: boolean; enableMultiselect: boolean; enableKeyboardAccessibility: boolean; + textInputAriaLabel: string; } export interface SearchOptions { diff --git a/src/editor.js b/src/editor.js index dfde1c8edd4..3b0b4d6c4b8 100644 --- a/src/editor.js +++ b/src/editor.js @@ -3002,6 +3002,10 @@ config.defineOptions(Editor.prototype, "editor", { }, initialValue: false }, + textInputAriaLabel: { + set: function(val) { this.$textInputAriaLabel = val; }, + initialValue: "" + }, customScrollbar: "renderer", hScrollBarAlwaysVisible: "renderer", vScrollBarAlwaysVisible: "renderer", diff --git a/src/keyboard/textinput.js b/src/keyboard/textinput.js index 7a316c21ab5..d1951961a82 100644 --- a/src/keyboard/textinput.js +++ b/src/keyboard/textinput.js @@ -90,7 +90,12 @@ TextInput= function(parentNode, host) { text.setAttribute("aria-roledescription", nls("text-input.aria-roledescription", "editor")); if(host.session) { var row = host.session.selection.cursor.row; - text.setAttribute("aria-label", nls("text-input.aria-label", "Cursor at row $0", [row + 1])); + var arialLabel = ""; + if (host.$textInputAriaLabel) { + arialLabel += `${host.$textInputAriaLabel}, `; + } + arialLabel += nls("text-input.aria-label", "Cursor at row $0", [row + 1]); + text.setAttribute("aria-label", arialLabel); } } }; diff --git a/src/keyboard/textinput_test.js b/src/keyboard/textinput_test.js index 7d8a3928a34..d35f6e50d4a 100644 --- a/src/keyboard/textinput_test.js +++ b/src/keyboard/textinput_test.js @@ -753,6 +753,29 @@ module.exports = { assert.equal(editor.getValue(), ""); sendEvent("input", {key: {inputType: "historyRedo"}}); assert.equal(editor.getValue(), "x"); + }, + + "test: text input aria label without extra label set": function() { + editor.setValue("x x", -1); + editor.setOption('enableKeyboardAccessibility', true); + editor.renderer.$loop._flush(); + + editor.focus(); + + let text = editor.container.querySelector(".ace_text-input"); + assert.equal(text.getAttribute("aria-label"), "Cursor at row 1"); + }, + + "test: text input aria label with extra label set": function() { + editor.setValue("x x", -1); + editor.setOption('textInputAriaLabel', "super cool editor"); + editor.setOption('enableKeyboardAccessibility', true); + editor.renderer.$loop._flush(); + + editor.focus(); + + let text = editor.container.querySelector(".ace_text-input"); + assert.equal(text.getAttribute("aria-label"), "super cool editor, Cursor at row 1"); } }; From 2330d80f56cae97abbd56350a5fd44d64d7073a3 Mon Sep 17 00:00:00 2001 From: Alice Koreman Date: Wed, 22 May 2024 17:51:34 +0200 Subject: [PATCH 16/23] release v1.34.0 --- CHANGELOG.md | 7 +++++++ build | 2 +- package.json | 2 +- src/config.js | 2 +- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7e9654cddae..32c41913143 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +## [1.34.0](https://github.com/ajaxorg/ace/compare/v1.33.3...v1.34.0) (2024-05-22) + + +### Features + +* allow users to add arialabel to text input ([#5560](https://github.com/ajaxorg/ace/issues/5560)) ([8d7dfb6](https://github.com/ajaxorg/ace/commit/8d7dfb69392960aba61def982f4bea8f3a5caa70)) + ### [1.33.3](https://github.com/ajaxorg/ace/compare/v1.33.2...v1.33.3) (2024-05-21) diff --git a/build b/build index d97de5f5d82..6eacdd5d726 160000 --- a/build +++ b/build @@ -1 +1 @@ -Subproject commit d97de5f5d823b6b669a6f93ea26fe94b05a12405 +Subproject commit 6eacdd5d726dd7cf07d94cc42d9cc81638296fbf diff --git a/package.json b/package.json index 8b76aa28d13..8e0c9002278 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "ace-code", "description": "Ajax.org Code Editor is a full featured source code highlighting editor that powers the Cloud9 IDE", - "version": "1.33.3", + "version": "1.34.0", "homepage": "http://github.com/ajaxorg/ace", "engines": { "node": ">= 0.6.0" diff --git a/src/config.js b/src/config.js index 60d5b766b77..1a93a708115 100644 --- a/src/config.js +++ b/src/config.js @@ -194,6 +194,6 @@ var reportErrorIfPathIsNotConfigured = function() { } }; -exports.version = "1.33.3"; +exports.version = "1.34.0"; From 00346fde824beabb69f677631ad52815665eaef4 Mon Sep 17 00:00:00 2001 From: Alice Koreman Date: Fri, 24 May 2024 11:02:25 +0200 Subject: [PATCH 17/23] fix: always set aria-label to text input in a11y mode (#5563) * fix: always set aria-label to text input in a11y mode --- src/editor.js | 5 +++++ src/keyboard/textinput.js | 10 +++++----- src/keyboard/textinput_test.js | 19 ++++++++++++++++--- 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/src/editor.js b/src/editor.js index 3b0b4d6c4b8..ab0ce713404 100644 --- a/src/editor.js +++ b/src/editor.js @@ -2939,6 +2939,7 @@ config.defineOptions(Editor.prototype, "editor", { // - Prevent tab-trapping. // - Hide irrelevant elements from assistive technology. // - On Windows, set more lines to the textarea. + // - set aria-label to the text input. if (value){ this.renderer.enableKeyboardAccessibility = true; this.renderer.keyboardFocusClassName = "ace_keyboard-focus"; @@ -2973,6 +2974,10 @@ config.defineOptions(Editor.prototype, "editor", { gutterKeyboardHandler = new GutterKeyboardHandler(this); gutterKeyboardHandler.addListener(); + + this.textInput.setAriaOptions({ + setLabel: true + }); } else { this.renderer.enableKeyboardAccessibility = false; diff --git a/src/keyboard/textinput.js b/src/keyboard/textinput.js index d1951961a82..81743b7f242 100644 --- a/src/keyboard/textinput.js +++ b/src/keyboard/textinput.js @@ -88,15 +88,15 @@ TextInput= function(parentNode, host) { } if (options.setLabel) { text.setAttribute("aria-roledescription", nls("text-input.aria-roledescription", "editor")); + var arialLabel = ""; + if (host.$textInputAriaLabel) { + arialLabel += `${host.$textInputAriaLabel}, `; + } if(host.session) { var row = host.session.selection.cursor.row; - var arialLabel = ""; - if (host.$textInputAriaLabel) { - arialLabel += `${host.$textInputAriaLabel}, `; - } arialLabel += nls("text-input.aria-label", "Cursor at row $0", [row + 1]); - text.setAttribute("aria-label", arialLabel); } + text.setAttribute("aria-label", arialLabel); } }; diff --git a/src/keyboard/textinput_test.js b/src/keyboard/textinput_test.js index d35f6e50d4a..f912bfbf250 100644 --- a/src/keyboard/textinput_test.js +++ b/src/keyboard/textinput_test.js @@ -760,10 +760,25 @@ module.exports = { editor.setOption('enableKeyboardAccessibility', true); editor.renderer.$loop._flush(); - editor.focus(); + let text = editor.container.querySelector(".ace_text-input"); + assert.equal(text.getAttribute("aria-label"), "Cursor at row 1"); + }, + + "test: text input aria label updated on focus": function() { + editor.setValue("x x\ny y", -1); + editor.setOption('enableKeyboardAccessibility', true); + editor.renderer.$loop._flush(); let text = editor.container.querySelector(".ace_text-input"); assert.equal(text.getAttribute("aria-label"), "Cursor at row 1"); + + editor.focus(); + sendEvent("keydown", {key: { code: "ArrowDown", key: "ArrowDown", keyCode: 40}}); + editor.renderer.$loop._flush(); + + editor.blur(); + editor.focus(); + assert.equal(text.getAttribute("aria-label"), "Cursor at row 2"); }, "test: text input aria label with extra label set": function() { @@ -772,8 +787,6 @@ module.exports = { editor.setOption('enableKeyboardAccessibility', true); editor.renderer.$loop._flush(); - editor.focus(); - let text = editor.container.querySelector(".ace_text-input"); assert.equal(text.getAttribute("aria-label"), "super cool editor, Cursor at row 1"); } From f4d0e33dac270ce21df09a96a39f50e16d6354db Mon Sep 17 00:00:00 2001 From: Azat Alimov <32402726+mkslanc@users.noreply.github.com> Date: Fri, 24 May 2024 13:02:56 +0400 Subject: [PATCH 18/23] Fix: Folding for comments and different modes (#5533) * fix: comments fold range determination in xml langs * fix: `getCommentFoldRange` * improve doc comments highlight rules * fix: lua comment/string folding ranges --- ace-internal.d.ts | 17 +- src/background_tokenizer.js | 3 +- src/edit_session.js | 2 +- src/edit_session/folding.js | 12 +- src/editor.js | 1 + src/ext/static_highlight_test.js | 21 +- src/mode/_test/tokens_drools.json | 54 ++- src/mode/_test/tokens_flix.json | 488 ++++++++++++++-------- src/mode/_test/tokens_javascript.json | 93 ++++- src/mode/_test/tokens_lua.json | 66 ++- src/mode/_test/tokens_luapage.json | 34 +- src/mode/_test/tokens_pgsql.json | 22 +- src/mode/_test/tokens_sac.json | 75 +++- src/mode/_test/tokens_sqlserver.json | 16 +- src/mode/doc_comment_highlight_rules.js | 4 +- src/mode/folding/cstyle_test.js | 4 +- src/mode/folding/javascript_test.js | 4 +- src/mode/folding/lua_test.js | 37 ++ src/mode/folding/xml.js | 8 +- src/mode/folding/xml_test.js | 29 ++ src/mode/jsdoc_comment_highlight_rules.js | 4 +- src/mode/lua_highlight_rules.js | 2 +- 22 files changed, 718 insertions(+), 278 deletions(-) create mode 100644 src/mode/folding/lua_test.js diff --git a/ace-internal.d.ts b/ace-internal.d.ts index 4066f585241..9beea6bd076 100644 --- a/ace-internal.d.ts +++ b/ace-internal.d.ts @@ -783,7 +783,10 @@ export namespace Ace { closingBracketBlock(session: EditSession, bracket: string, row: number, column: number, typeRe?: RegExp): Range | undefined; } - type BehaviorAction = (state: string, action: string, editor: Editor, session: EditSession, text: string | Range) => ({ text: string, selection: number[] } | Range) & { [key: string]: any } | undefined; + type BehaviorAction = (state: string | string[], action: string, editor: Editor, session: EditSession, text: string | Range) => ({ + text: string, + selection: number[] + } | Range) & { [key: string]: any } | undefined; type BehaviorMap = Record>; interface Behaviour { @@ -841,21 +844,21 @@ export namespace Ace { getTokenizer(): Tokenizer; - toggleCommentLines(state: any, + toggleCommentLines(state: string | string[], session: EditSession, startRow: number, endRow: number): void; - toggleBlockComment(state: any, + toggleBlockComment(state: string | string[], session: EditSession, range: Range, cursor: Point): void; - getNextLineIndent(state: any, line: string, tab: string): string; + getNextLineIndent(state: string | string[], line: string, tab: string): string; - checkOutdent(state: any, line: string, input: string): boolean; + checkOutdent(state: string | string[], line: string, input: string): boolean; - autoOutdent(state: any, doc: EditSession, row: number): void; + autoOutdent(state: string | string[], doc: EditSession, row: number): void; // TODO implement WorkerClient types createWorker(session: EditSession): any; @@ -864,7 +867,7 @@ export namespace Ace { getKeywords(append?: boolean): Array; - getCompletions(state: string, + getCompletions(state: string | string[], session: EditSession, pos: Point, prefix: string): Completion[]; diff --git a/src/background_tokenizer.js b/src/background_tokenizer.js index f52649caea8..f96599350b8 100644 --- a/src/background_tokenizer.js +++ b/src/background_tokenizer.js @@ -23,6 +23,7 @@ class BackgroundTokenizer { /**@type {false|number}*/ this.running = false; this.lines = []; + /**@type {string[]|string[][]}*/ this.states = []; this.currentLine = 0; this.tokenizer = tokenizer; @@ -176,7 +177,7 @@ class BackgroundTokenizer { /** * Returns the state of tokenization at the end of a row. * @param {Number} row The row to get state at - * @returns {string} + * @returns {string | string[]} **/ getState(row) { if (this.currentLine == row) diff --git a/src/edit_session.js b/src/edit_session.js index 9b3c248a1fb..9cb28439f8b 100644 --- a/src/edit_session.js +++ b/src/edit_session.js @@ -272,7 +272,7 @@ class EditSession { /** * {:BackgroundTokenizer.getState} * @param {Number} row The row to start at - * @returns {string} + * @returns {string | string[]} * @related BackgroundTokenizer.getState **/ getState(row) { diff --git a/src/edit_session/folding.js b/src/edit_session/folding.js index 19deef96980..2951d695c76 100644 --- a/src/edit_session/folding.js +++ b/src/edit_session/folding.js @@ -716,14 +716,15 @@ function Folding() { if (dir != 1) { do { token = iterator.stepBackward(); - } while (token && re.test(token.type) && !/^comment.end/.test(token.type)); + } while (token && re.test(token.type)); token = iterator.stepForward(); } range.start.row = iterator.getCurrentTokenRow(); - range.start.column = iterator.getCurrentTokenColumn() + (/^comment.start/.test(token.type) ? token.value.length : 2); + range.start.column = iterator.getCurrentTokenColumn() + token.value.length; iterator = new TokenIterator(this, row, column); + var initState = this.getState(iterator.$row); if (dir != -1) { var lastRow = -1; @@ -731,21 +732,18 @@ function Folding() { token = iterator.stepForward(); if (lastRow == -1) { var state = this.getState(iterator.$row); - if (!re.test(state)) + if (initState.toString() !== state.toString()) lastRow = iterator.$row; } else if (iterator.$row > lastRow) { break; } - } while (token && re.test(token.type) && !/^comment.start/.test(token.type)); + } while (token && re.test(token.type)); token = iterator.stepBackward(); } else token = iterator.getCurrentToken(); range.end.row = iterator.getCurrentTokenRow(); range.end.column = iterator.getCurrentTokenColumn(); - if (!/^comment.end/.test(token.type)) { - range.end.column += token.value.length - 2; - } return range; } }; diff --git a/src/editor.js b/src/editor.js index ab0ce713404..048f503b054 100644 --- a/src/editor.js +++ b/src/editor.js @@ -983,6 +983,7 @@ class Editor { ? [new Range(0, 0, session.doc.getLength() - 1, 0)] : this.selection.getAllRanges(); + /**@type{string|string[]}*/ var prevLineState = ""; var prevLine = ""; var lineIndent = ""; diff --git a/src/ext/static_highlight_test.js b/src/ext/static_highlight_test.js index e9f4a8cb690..6275fe88dab 100644 --- a/src/ext/static_highlight_test.js +++ b/src/ext/static_highlight_test.js @@ -39,17 +39,16 @@ module.exports = { ].join("\n"); var mode = new JavaScriptMode(); var result = highlighter.render(snippet, mode, theme); - assert.equal(result.html, "
    " - + "
    /** this is a function\n
    " - + "
    *\n
    " - + "
    */\n
    " - + "
    \n
    " - + "
    function hello (a, b, c) {\n
    " - + "
    console.log(a * b + c + 'sup$');\n
    " - + "
    //\n
    " - + "
    //\n
    " - + "
    }\n
    " - + "
    "); + assert.equal(result.html, `
    /** this is a function +
    * +
    */ +
    +
    function hello (a, b, c) { +
    console.log(a * b + c + 'sup$'); +
    // +
    // +
    } +
    `); assert.ok(!!result.css); next(); }, diff --git a/src/mode/_test/tokens_drools.json b/src/mode/_test/tokens_drools.json index e312d03d442..a55bb8d95ca 100644 --- a/src/mode/_test/tokens_drools.json +++ b/src/mode/_test/tokens_drools.json @@ -206,12 +206,25 @@ ["comment.doc","/**"] ],[ "doc-start", - ["comment.doc"," * "], + [ + "comment.doc.body", + " * " + ], ["comment.doc.tag","@param"], - ["comment.doc"," name who we'll salute?"] + [ + "comment.doc.body", + " name who we'll salute?" + ] ],[ "start", - ["comment.doc"," */"] + [ + "comment.doc.body", + " " + ], + [ + "comment.doc", + "*/" + ] ],[ "start", ["keyword","function"], @@ -419,12 +432,25 @@ ["comment.doc","/**"] ],[ "java-doc-start", - ["comment.doc"," * "], + [ + "comment.doc.body", + " * " + ], ["comment.doc.tag.storage.type","TODO"], - ["comment.doc"," There mus be better way"] + [ + "comment.doc.body", + " There mus be better way" + ] ],[ "java-start", - ["comment.doc"," */"] + [ + "comment.doc.body", + " " + ], + [ + "comment.doc", + "*/" + ] ],[ "java-start", ["text"," "], @@ -751,10 +777,20 @@ ["comment.doc","/**"] ],[ "doc-start", - ["comment.doc"," * Go Right"] + [ + "comment.doc.body", + " * Go Right" + ] ],[ "start", - ["comment.doc"," */"] + [ + "comment.doc.body", + " " + ], + [ + "comment.doc", + "*/" + ] ],[ "start", ["keyword","rule"], @@ -932,4 +968,4 @@ ["keyword","end"] ],[ "start" -]] \ No newline at end of file +]] diff --git a/src/mode/_test/tokens_flix.json b/src/mode/_test/tokens_flix.json index cb1bc7137f6..add7a042a23 100644 --- a/src/mode/_test/tokens_flix.json +++ b/src/mode/_test/tokens_flix.json @@ -1,171 +1,240 @@ [[ "start", - ["text"," "] + ["comment.line","/// Mooo's `n` times on channel `c`."] ],[ "start", - ["comment.block","/* Hello comment */"] -],[ - "comment", - ["comment.block","/* Hello "] -],[ - "start", - ["comment.block"," comment */"] -],[ - "start", - ["comment.line","// Hello comment"] -],[ - "start", - ["keyword","use"], - ["text"," "], - ["identifier","Add"], - ["text","."], - ["identifier","add"] -],[ - "start", - ["storage.type","mod"], - ["text"," "], - ["paren.lparen","{"], ["storage.type","def"], ["text"," "], - ["identifier","main"], + ["identifier","mooo"], ["paren.lparen","("], - ["paren.rparen",")"], + ["identifier","tx"], + ["text",": "], + ["identifier","Sender"], + ["paren.lparen","["], + ["support.type","String"], + ["text",", "], + ["identifier","r"], + ["paren.rparen","]"], + ["text",", "], + ["identifier","n"], ["text",": "], ["support.type","Int32"], - ["text"," = "], - ["constant.numeric","42"], - ["paren.rparen","}"] + ["paren.rparen",")"], + ["text",": "], + ["support.type","Unit"], + ["text"," \\ "], + ["identifier","IO"], + ["text"," ="] ],[ "start", - ["storage.type","class"], + ["text"," "], + ["keyword.control","match"], ["text"," "], - ["identifier","Add"], - ["paren.lparen","["], - ["identifier","a"], - ["paren.rparen","]"], + ["identifier","n"], ["text"," "], - ["paren.lparen","{"], - ["paren.rparen","}"] + ["paren.lparen","{"] ],[ "start", - ["storage.type","enum"], - ["text"," "], - ["identifier","Down"], - ["paren.lparen","["], - ["identifier","a"], - ["paren.rparen","]"], + ["text"," "], + ["storage.type","case"], ["text"," "], - ["storage.modifier","with"], + ["constant.numeric","0"], ["text"," "], - ["identifier","Sendable"], + ["keyword.operator","=>"], ["text"," "], - ["paren.lparen","{"], + ["paren.lparen","("], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], ["storage.type","case"], ["text"," "], - ["identifier","Down"], + ["identifier","x"], + ["text"," "], + ["keyword.operator","=>"], + ["text"," "], + ["identifier","Channel"], + ["text","."], + ["identifier","send"], + ["paren.lparen","("], + ["string","\"Mooo!\""], + ["text",", "], + ["identifier","tx"], + ["paren.rparen",")"], + ["text","; "], + ["identifier","mooo"], ["paren.lparen","("], - ["identifier","a"], - ["paren.rparen",")}"] + ["identifier","tx"], + ["text",", "], + ["identifier","x"], + ["text"," - "], + ["constant.numeric","1"], + ["paren.rparen",")"] ],[ "start", - ["storage.type","eff"], - ["text"," "], - ["identifier","NonDet"] + ["text"," "], + ["paren.rparen","}"] +],[ + "start" ],[ "start", - ["storage.type","type"], - ["text"," "], - ["storage.type","alias"], - ["text"," "], - ["identifier","Static"], - ["text"," = "], - ["identifier","Impure"] + ["comment.line","/// Meow's `n` times on channel `c`."] ],[ "start", ["storage.type","def"], ["text"," "], - ["identifier","main"], + ["identifier","meow"], ["paren.lparen","("], - ["paren.rparen",")"], + ["identifier","tx"], + ["text",": "], + ["identifier","Sender"], + ["paren.lparen","["], + ["support.type","String"], + ["text",", "], + ["identifier","r"], + ["paren.rparen","]"], + ["text",", "], + ["identifier","n"], ["text",": "], ["support.type","Int32"], - ["text"," = "], - ["paren.lparen","{"], - ["constant.numeric","42"], - ["paren.rparen","}"] + ["paren.rparen",")"], + ["text",": "], + ["support.type","Unit"], + ["text"," \\ "], + ["identifier","IO"], + ["text"," ="] ],[ "start", - ["storage.type","def"], + ["text"," "], + ["keyword.control","match"], + ["text"," "], + ["identifier","n"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["storage.type","case"], + ["text"," "], + ["constant.numeric","0"], + ["text"," "], + ["keyword.operator","=>"], ["text"," "], - ["identifier","main"], ["paren.lparen","("], - ["paren.rparen",")"], - ["text",": "], - ["support.type","Float64"], - ["text"," = "], - ["keyword.control","if"], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["storage.type","case"], + ["text"," "], + ["identifier","x"], + ["text"," "], + ["keyword.operator","=>"], + ["text"," "], + ["identifier","Channel"], + ["text","."], + ["identifier","send"], ["paren.lparen","("], - ["constant.language.boolean","true"], + ["string","\"Meow!\""], + ["text",", "], + ["identifier","tx"], ["paren.rparen",")"], - ["paren.lparen","{"], - ["constant.numeric","42.0"], - ["paren.rparen","}"], - ["keyword.control","else"], - ["paren.lparen","{"], - ["constant.numeric","43.0"], + ["text","; "], + ["identifier","meow"], + ["paren.lparen","("], + ["identifier","tx"], + ["text",", "], + ["identifier","x"], + ["text"," - "], + ["constant.numeric","1"], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], ["paren.rparen","}"] +],[ + "start" +],[ + "start", + ["comment.line","/// Hiss'es `n` times on channel `c`."] ],[ "start", ["storage.type","def"], ["text"," "], - ["identifier","main"], + ["identifier","hiss"], ["paren.lparen","("], - ["paren.rparen",")"], + ["identifier","tx"], ["text",": "], + ["identifier","Sender"], + ["paren.lparen","["], ["support.type","String"], - ["text"," = "], - ["string","\"Hello"], - ["constant.character.escape","\\\""], - ["string","World"], - ["constant.character.escape","\\u0021"], - ["string","\""] + ["text",", "], + ["identifier","r"], + ["paren.rparen","]"], + ["text",", "], + ["identifier","n"], + ["text",": "], + ["support.type","Int32"], + ["paren.rparen",")"], + ["text",": "], + ["support.type","Unit"], + ["text"," \\ "], + ["identifier","IO"], + ["text"," ="] ],[ "start", - ["storage.type","def"], + ["text"," "], + ["keyword.control","match"], ["text"," "], - ["identifier","main"], - ["paren.lparen","("], - ["paren.rparen",")"], - ["text",": "], - ["support.type","Char"], - ["text"," = "], - ["constant.character","'a'"] + ["identifier","n"], + ["text"," "], + ["paren.lparen","{"] ],[ "start", - ["storage.type","def"], + ["text"," "], + ["storage.type","case"], + ["text"," "], + ["constant.numeric","0"], + ["text"," "], + ["keyword.operator","=>"], ["text"," "], - ["identifier","main"], ["paren.lparen","("], - ["paren.rparen",")"], - ["text",": "], - ["support.type","Char"], - ["text"," = "], - ["constant.character","'"], - ["constant.character.escape","\\u0021"], - ["constant.character","'"] + ["paren.rparen",")"] ],[ "start", - ["storage.type","def"], + ["text"," "], + ["storage.type","case"], ["text"," "], - ["identifier","main"], + ["identifier","x"], + ["text"," "], + ["keyword.operator","=>"], + ["text"," "], + ["identifier","Channel"], + ["text","."], + ["identifier","send"], ["paren.lparen","("], + ["string","\"Hiss!\""], + ["text",", "], + ["identifier","tx"], ["paren.rparen",")"], - ["text",": "], - ["support.type","Char"], - ["text"," = "], - ["constant.character","'"], - ["constant.character.escape","\\'"], - ["constant.character","'"] + ["text","; "], + ["identifier","hiss"], + ["paren.lparen","("], + ["identifier","tx"], + ["text",", "], + ["identifier","x"], + ["text"," - "], + ["constant.numeric","1"], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start" +],[ + "start", + ["comment.line","/// Start the animal farm..."] ],[ "start", ["storage.type","def"], @@ -174,126 +243,187 @@ ["paren.lparen","("], ["paren.rparen",")"], ["text",": "], - ["identifier","Regex"], + ["support.type","Unit"], + ["text"," \\ "], + ["identifier","IO"], ["text"," = "], - ["string.regexp","regex\"Hello"], - ["constant.character.escape","\\\""], - ["string.regexp","World"], - ["constant.character.escape","\\u0021"], - ["string.regexp","\""] + ["keyword","region"], + ["text"," "], + ["identifier","rc"], + ["text"," "], + ["paren.lparen","{"] ],[ "start", - ["storage.type","def"], + ["text"," "], + ["storage.type","let"], ["text"," "], - ["identifier","main"], ["paren.lparen","("], + ["identifier","tx1"], + ["text",", "], + ["identifier","rx1"], ["paren.rparen",")"], - ["text",": "], - ["support.type","String"], ["text"," = "], - ["keyword","???"] + ["identifier","Channel"], + ["text","."], + ["identifier","buffered"], + ["paren.lparen","("], + ["identifier","rc"], + ["text",", "], + ["constant.numeric","10"], + ["paren.rparen",")"], + ["text",";"] ],[ "start", - ["storage.type","def"], + ["text"," "], + ["storage.type","let"], ["text"," "], - ["identifier","main"], ["paren.lparen","("], + ["identifier","tx2"], + ["text",", "], + ["identifier","rx2"], ["paren.rparen",")"], - ["text",": "], - ["support.type","String"], ["text"," = "], - ["keyword","?someHole"] + ["identifier","Channel"], + ["text","."], + ["identifier","buffered"], + ["paren.lparen","("], + ["identifier","rc"], + ["text",", "], + ["constant.numeric","10"], + ["paren.rparen",")"], + ["text",";"] ],[ "start", - ["storage.type","def"], + ["text"," "], + ["storage.type","let"], ["text"," "], - ["identifier","main"], ["paren.lparen","("], + ["identifier","tx3"], + ["text",", "], + ["identifier","rx3"], ["paren.rparen",")"], - ["text",": "], - ["support.type","Int32"], ["text"," = "], - ["constant.numeric","0x123i32"] + ["identifier","Channel"], + ["text","."], + ["identifier","buffered"], + ["paren.lparen","("], + ["identifier","rc"], + ["text",", "], + ["constant.numeric","10"], + ["paren.rparen",")"], + ["text",";"] ],[ "start", - ["storage.type","def"], + ["text"," "], + ["keyword.control","spawn"], ["text"," "], - ["identifier","main"], + ["identifier","mooo"], ["paren.lparen","("], + ["identifier","tx1"], + ["text",", "], + ["constant.numeric","0"], ["paren.rparen",")"], - ["text",": "], - ["support.type","Int32"], - ["text"," = "], - ["constant.numeric","42i32"] + ["text"," @ "], + ["identifier","rc"], + ["text",";"] ],[ "start", - ["storage.type","def"], + ["text"," "], + ["keyword.control","spawn"], ["text"," "], - ["identifier","main"], + ["identifier","meow"], ["paren.lparen","("], + ["identifier","tx2"], + ["text",", "], + ["constant.numeric","3"], ["paren.rparen",")"], - ["text",": "], - ["support.type","Float64"], - ["text"," = "], - ["constant.numeric","42.0f64"] + ["text"," @ "], + ["identifier","rc"], + ["text",";"] ],[ "start", - ["storage.type","def"], + ["text"," "], + ["keyword.control","spawn"], ["text"," "], - ["identifier","main"], + ["identifier","hiss"], ["paren.lparen","("], + ["identifier","tx3"], + ["text",", "], + ["constant.numeric","7"], ["paren.rparen",")"], - ["text",": "], - ["support.type","Bool"], - ["text"," = "], - ["constant.language.boolean","true"] + ["text"," @ "], + ["identifier","rc"], + ["text",";"] ],[ "start", - ["storage.type","def"], + ["text"," "], + ["keyword","select"], ["text"," "], - ["identifier","main"], - ["paren.lparen","("], - ["paren.rparen",")"], - ["text",": "], - ["support.type","Bool"], - ["text"," = "], - ["constant.language.boolean","false"] + ["paren.lparen","{"] ],[ "start", - ["storage.type","def"], + ["text"," "], + ["storage.type","case"], ["text"," "], - ["identifier","main"], + ["identifier","m"], + ["text"," "], + ["keyword.operator","<-"], + ["text"," "], + ["identifier","recv"], ["paren.lparen","("], + ["identifier","rx1"], ["paren.rparen",")"], - ["text",": "], - ["identifier","Null"], - ["text"," = "], - ["constant.language","null"] -],[ - "start", - ["storage.modifier","@Lazy"] + ["text"," "], + ["keyword.operator","=>"], + ["text"," "], + ["identifier","m"], + ["text"," |> "], + ["identifier","println"] ],[ "start", - ["storage.type","def"], + ["text"," "], + ["storage.type","case"], ["text"," "], - ["identifier","main"], + ["identifier","m"], + ["text"," "], + ["keyword.operator","<-"], + ["text"," "], + ["identifier","recv"], ["paren.lparen","("], + ["identifier","rx2"], ["paren.rparen",")"], - ["text",": "], - ["support.type","Int32"], - ["text"," = "], - ["constant.numeric","42"] + ["text"," "], + ["keyword.operator","=>"], + ["text"," "], + ["identifier","m"], + ["text"," |> "], + ["identifier","println"] ],[ "start", - ["storage.modifier","pub"], + ["text"," "], + ["storage.type","case"], ["text"," "], - ["storage.type","def"], + ["identifier","m"], ["text"," "], - ["identifier","main"], + ["keyword.operator","<-"], + ["text"," "], + ["identifier","recv"], ["paren.lparen","("], + ["identifier","rx3"], ["paren.rparen",")"], - ["text",": "], - ["support.type","Int32"], - ["text"," = "], - ["constant.numeric","42"] + ["text"," "], + ["keyword.operator","=>"], + ["text"," "], + ["identifier","m"], + ["text"," |> "], + ["identifier","println"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["paren.rparen","}"] +],[ + "start" ]] \ No newline at end of file diff --git a/src/mode/_test/tokens_javascript.json b/src/mode/_test/tokens_javascript.json index 7e11d31fae5..bfb91f78a74 100644 --- a/src/mode/_test/tokens_javascript.json +++ b/src/mode/_test/tokens_javascript.json @@ -32,14 +32,39 @@ ["identifier","test"], ["punctuation.operator",":"], ["text"," "], - ["comment.doc","/**tokenize doc*/"], + [ + "comment.doc", + "/**" + ], + [ + "comment.doc.body", + "tokenize doc" + ], + [ + "comment.doc", + "*/" + ], ["text"," "], ["identifier","comment"] ],[ "no_regex", - ["comment.doc","/**tokenize doc comment with "], + [ + "comment.doc", + "/**" + ], + [ + "comment.doc.body", + "tokenize doc comment with " + ], ["comment.doc.tag","@tag"], - ["comment.doc"," {}*/"] + [ + "comment.doc.body", + " {}" + ], + [ + "comment.doc", + "*/" + ] ],[ "no_regex", ["comment","//test: tokenize parens"] @@ -333,10 +358,32 @@ ],[ "no_regex", ["text"," "], - ["comment.doc","/************************************/"] -],[ - "no_regex", - ["comment.doc","/** total mess, tricky to highlight**/"] + [ + "comment.doc", + "/**" + ], + [ + "comment.doc.body", + "*********************************" + ], + [ + "comment.doc", + "*/" + ] +],[ + "no_regex", + [ + "comment.doc", + "/**" + ], + [ + "comment.doc.body", + " total mess, tricky to highlight*" + ], + [ + "comment.doc", + "*/" + ] ],[ "no_regex" ],[ @@ -353,10 +400,20 @@ ["comment.doc","/**"] ],[ "doc-start", - ["comment.doc","\t * docComment"] + [ + "comment.doc.body", + "\t * docComment" + ] ],[ "no_regex", - ["comment.doc","\t **/"] + [ + "comment.doc.body", + "\t *" + ], + [ + "comment.doc", + "*/" + ] ],[ "no_regex", ["text","\t"], @@ -483,10 +540,20 @@ ["comment.doc","/**"] ],[ "doc-start", - ["comment.doc"," *doc"] -],[ - "no_regex", - ["comment.doc"," */"] + [ + "comment.doc.body", + " *doc" + ] +],[ + "no_regex", + [ + "comment.doc.body", + " " + ], + [ + "comment.doc", + "*/" + ] ],[ "no_regex" ],[ diff --git a/src/mode/_test/tokens_lua.json b/src/mode/_test/tokens_lua.json index cc6d849391c..c721a8284da 100644 --- a/src/mode/_test/tokens_lua.json +++ b/src/mode/_test/tokens_lua.json @@ -1,15 +1,35 @@ [[ ["bracketedComment",2,"start"], - ["comment","--[[--"] + [ + "comment", + "--[[" + ], + [ + "comment.body", + "--" + ] ],[ ["bracketedComment",2,"start"], - ["comment","num_args takes in 5.1 byte code and extracts the number of arguments"] + [ + "comment.body", + "num_args takes in 5.1 byte code and extracts the number of arguments" + ] ],[ ["bracketedComment",2,"start"], - ["comment","from its function header."] + [ + "comment.body", + "from its function header." + ] ],[ "start", - ["comment","--]]--"] + [ + "comment.body", + "--" + ], + [ + "comment", + "]]--" + ] ],[ "start" ],[ @@ -302,13 +322,30 @@ "start" ],[ ["bracketedComment",3,"start"], - ["comment","--[=[--"] + [ + "comment", + "--[=[" + ], + [ + "comment.body", + "--" + ] ],[ ["bracketedComment",3,"start"], - ["comment","table.maxn is deprecated, use # instead."] + [ + "comment.body", + "table.maxn is deprecated, use # instead." + ] ],[ "start", - ["comment","--]=]--"] + [ + "comment.body", + "--" + ], + [ + "comment", + "]=]--" + ] ],[ "start", ["support.function","print"], @@ -343,6 +380,17 @@ ["paren.lparen","("], ["constant.numeric","5"], ["text"," "], - ["comment","--[[ blah ]]"], + [ + "comment", + "--[[" + ], + [ + "comment.body", + " blah " + ], + [ + "comment", + "]]" + ], ["paren.rparen",")"] -]] \ No newline at end of file +]] diff --git a/src/mode/_test/tokens_luapage.json b/src/mode/_test/tokens_luapage.json index fda36eba4c8..55d43ec74d2 100644 --- a/src/mode/_test/tokens_luapage.json +++ b/src/mode/_test/tokens_luapage.json @@ -23,16 +23,36 @@ ["lua-bracketedComment",2,"lua-start"], ["keyword","<%"], ["text"," "], - ["comment","--[[--"] + [ + "comment", + "--[[" + ], + [ + "comment.body", + "--" + ] ],[ ["lua-bracketedComment",2,"lua-start"], - ["comment"," index.lp from the Kepler Project's LuaDoc HTML doclet."] + [ + "comment.body", + " index.lp from the Kepler Project's LuaDoc HTML doclet." + ] ],[ ["lua-bracketedComment",2,"lua-start"], - ["comment"," http://keplerproject.github.com/luadoc/"] -],[ - "start", - ["comment","--]]"], + [ + "comment.body", + " http://keplerproject.github.com/luadoc/" + ] +],[ + "start", + [ + "comment.body", + "--" + ], + [ + "comment", + "]]" + ], ["text"," "], ["keyword","%>"] ],[ @@ -648,4 +668,4 @@ ["meta.tag.punctuation.tag-close.xml",">"] ],[ "start" -]] \ No newline at end of file +]] diff --git a/src/mode/_test/tokens_pgsql.json b/src/mode/_test/tokens_pgsql.json index 6f66d730af0..ed22fcb5efe 100644 --- a/src/mode/_test/tokens_pgsql.json +++ b/src/mode/_test/tokens_pgsql.json @@ -11,7 +11,10 @@ ["comment.doc","/**"] ],[ "doc-start", - ["comment.doc","* Samples from PostgreSQL src/tutorial/basics.source"] + [ + "comment.doc.body", + "* Samples from PostgreSQL src/tutorial/basics.source" + ] ],[ "start", ["comment.doc","*/"] @@ -294,13 +297,22 @@ ["comment.doc","/**"] ],[ "doc-start", - ["comment.doc","* Dollar quotes starting at the end of the line are colored as SQL unless"] + [ + "comment.doc.body", + "* Dollar quotes starting at the end of the line are colored as SQL unless" + ] ],[ "doc-start", - ["comment.doc","* a special language tag is used. Dollar quote syntax coloring is implemented"] + [ + "comment.doc.body", + "* a special language tag is used. Dollar quote syntax coloring is implemented" + ] ],[ "doc-start", - ["comment.doc","* for Perl, Python, JavaScript, and Json."] + [ + "comment.doc.body", + "* for Perl, Python, JavaScript, and Json." + ] ],[ "start", ["comment.doc","*/"] @@ -934,4 +946,4 @@ ["statementEnd",";"] ],[ "start" -]] \ No newline at end of file +]] diff --git a/src/mode/_test/tokens_sac.json b/src/mode/_test/tokens_sac.json index 18350f158e4..2c5a1a12415 100644 --- a/src/mode/_test/tokens_sac.json +++ b/src/mode/_test/tokens_sac.json @@ -1,42 +1,89 @@ [[ "doc-start", - ["comment.doc","/*****************************************************************************"] + [ + "comment.doc", + "/**" + ], + [ + "comment.doc.body", + "***************************************************************************" + ] ],[ "doc-start", - ["comment.doc"," *"] + [ + "comment.doc.body", + " *" + ] ],[ "doc-start", - ["comment.doc"," * SAC demo program"] + [ + "comment.doc.body", + " * SAC demo program" + ] ],[ "doc-start", - ["comment.doc"," *"] + [ + "comment.doc.body", + " *" + ] ],[ "doc-start", - ["comment.doc"," * This SAC demo program implements 2-dimensional relaxation on double"] + [ + "comment.doc.body", + " * This SAC demo program implements 2-dimensional relaxation on double" + ] ],[ "doc-start", - ["comment.doc"," * precision floating point numbers applying a 4-point stencil and fixed"] + [ + "comment.doc.body", + " * precision floating point numbers applying a 4-point stencil and fixed" + ] ],[ "doc-start", - ["comment.doc"," * boundary conditions."] + [ + "comment.doc.body", + " * boundary conditions." + ] ],[ "doc-start", - ["comment.doc"," *"] + [ + "comment.doc.body", + " *" + ] ],[ "doc-start", - ["comment.doc"," * The vertical (SIZE1) and the horizontal (SIZE2) array size as well as"] + [ + "comment.doc.body", + " * The vertical (SIZE1) and the horizontal (SIZE2) array size as well as" + ] ],[ "doc-start", - ["comment.doc"," * the number of iterations to be performed (LOOP) may be set at compile"] + [ + "comment.doc.body", + " * the number of iterations to be performed (LOOP) may be set at compile" + ] ],[ "doc-start", - ["comment.doc"," * time."] + [ + "comment.doc.body", + " * time." + ] ],[ "doc-start", - ["comment.doc"," *"] + [ + "comment.doc.body", + " *" + ] ],[ "start", - ["comment.doc"," *****************************************************************************/"] + [ + "comment.doc.body", + " ****************************************************************************" + ], + [ + "comment.doc", + "*/" + ] ],[ "start" ],[ @@ -541,4 +588,4 @@ "start" ],[ "start" -]] \ No newline at end of file +]] diff --git a/src/mode/_test/tokens_sqlserver.json b/src/mode/_test/tokens_sqlserver.json index 446f52ccd76..a4693b9ac00 100644 --- a/src/mode/_test/tokens_sqlserver.json +++ b/src/mode/_test/tokens_sqlserver.json @@ -149,10 +149,20 @@ ["comment.doc","/**"] ],[ "doc-start", - ["comment.doc","\t * These comments will produce a fold widget"] + [ + "comment.doc.body", + "\t * These comments will produce a fold widget" + ] ],[ "start", - ["comment.doc","\t */"] + [ + "comment.doc.body", + "\t " + ], + [ + "comment.doc", + "*/" + ] ],[ "start", ["text","\t"] @@ -454,4 +464,4 @@ ["keyword","END"] ],[ "start" -]] \ No newline at end of file +]] diff --git a/src/mode/doc_comment_highlight_rules.js b/src/mode/doc_comment_highlight_rules.js index b0f3ca353b3..5b10e9ba2bd 100644 --- a/src/mode/doc_comment_highlight_rules.js +++ b/src/mode/doc_comment_highlight_rules.js @@ -10,7 +10,7 @@ var DocCommentHighlightRules = function () { token: "comment.doc.tag", regex: "@\\w+(?=\\s|$)" }, DocCommentHighlightRules.getTagRule(), { - defaultToken: "comment.doc", + defaultToken: "comment.doc.body", caseInsensitive: true } ] @@ -29,7 +29,7 @@ DocCommentHighlightRules.getTagRule = function(start) { DocCommentHighlightRules.getStartRule = function(start) { return { token : "comment.doc", // doc comment - regex : "\\/\\*(?=\\*)", + regex: /\/\*\*(?!\/)/, next : start }; }; diff --git a/src/mode/folding/cstyle_test.js b/src/mode/folding/cstyle_test.js index e88d22f3f44..5b48032c604 100644 --- a/src/mode/folding/cstyle_test.js +++ b/src/mode/folding/cstyle_test.js @@ -43,8 +43,8 @@ module.exports = { assert.equal(session.getFoldWidget(1), ""); assert.equal(session.getFoldWidget(2), "end"); - assert.range(session.getFoldWidgetRange(0), 0, 2, 2, 7); - assert.range(session.getFoldWidgetRange(2), 0, 2, 2, 7); + assert.range(session.getFoldWidgetRange(0), 0, 3, 2, 7); + assert.range(session.getFoldWidgetRange(2), 0, 3, 2, 7); }, "test: fold sections": function() { diff --git a/src/mode/folding/javascript_test.js b/src/mode/folding/javascript_test.js index dac74eb1546..366968f4124 100644 --- a/src/mode/folding/javascript_test.js +++ b/src/mode/folding/javascript_test.js @@ -27,8 +27,8 @@ module.exports = { assert.equal(session.getFoldWidget(3), ""); assert.equal(session.getFoldWidget(4), "end"); - assert.range(session.getFoldWidgetRange(0), 0, 2, 4, 0); - assert.range(session.getFoldWidgetRange(4), 0, 2, 4, 0); + assert.range(session.getFoldWidgetRange(0), 0, 3, 4, 0); + assert.range(session.getFoldWidgetRange(4), 0, 3, 4, 0); }, "test: fold mixed js and jsx": function () { var session = new EditSession([ diff --git a/src/mode/folding/lua_test.js b/src/mode/folding/lua_test.js new file mode 100644 index 00000000000..380d9874e43 --- /dev/null +++ b/src/mode/folding/lua_test.js @@ -0,0 +1,37 @@ +if (typeof process !== "undefined") require("amd-loader"); + +"use strict"; + +var LuaMode = require("../lua").Mode; +var EditSession = require("../../edit_session").EditSession; +var assert = require("../../test/assertions"); + +module.exports = { + "test: lua multi-line comment and string folding": function () { + var session = new EditSession([ + '--[[This is a multi-line comment in Lua', 'It can span multiple lines until it encounters', ']]--', '', + 'local title = [[This is a multi-line string in Lua', + 'It can also span multiple lines until it encounters ]]' + ]); + + var luaMode = new LuaMode(); + session.setFoldStyle("markbeginend"); + session.setMode(luaMode); + session.bgTokenizer.$worker(); + + assert.equal(session.getFoldWidget(0), "start"); // Comment starts + assert.equal(session.getFoldWidget(1), ""); + assert.equal(session.getFoldWidget(2), "end"); + assert.equal(session.getFoldWidget(3), ""); + assert.equal(session.getFoldWidget(4), "start"); // String starts + assert.equal(session.getFoldWidget(5), "end"); + + assert.range(session.getFoldWidgetRange(0), 0, 4, 2, 0); + assert.range(session.getFoldWidgetRange(2), 0, 4, 2, 0); + assert.range(session.getFoldWidgetRange(4), 4, 16, 5, 52); + assert.range(session.getFoldWidgetRange(5), 4, 16, 5, 52); + } + +}; + +if (typeof module !== "undefined" && module === require.main) require("asyncjs").test.testcase(module.exports).exec(); diff --git a/src/mode/folding/xml.js b/src/mode/folding/xml.js index 22f4f2c0b7b..5ed806901a5 100644 --- a/src/mode/folding/xml.js +++ b/src/mode/folding/xml.js @@ -114,13 +114,15 @@ function is(token, type) { }; this.getFoldWidgetRange = function(session, foldStyle, row) { + var firstTag = this._getFirstTagInLine(session, row); + if (!firstTag) { + return this.getCommentFoldWidget(session, row) && session.getCommentFoldRange( + row, session.getLine(row).length); + } var tags = session.getMatchingTags({row: row, column: 0}); if (tags) { return new Range( tags.openTag.end.row, tags.openTag.end.column, tags.closeTag.start.row, tags.closeTag.start.column); - } else { - return this.getCommentFoldWidget(session, row) - && session.getCommentFoldRange(row, session.getLine(row).length); } }; diff --git a/src/mode/folding/xml_test.js b/src/mode/folding/xml_test.js index b958734904f..ea9d799ab57 100644 --- a/src/mode/folding/xml_test.js +++ b/src/mode/folding/xml_test.js @@ -70,7 +70,36 @@ module.exports = { assert.range(session.getFoldWidgetRange(1), 1, 9, 3, 19); assert.range(session.getFoldWidgetRange(3), 1, 9, 3, 19); assert.range(session.getFoldWidgetRange(4), 0, 8, 4, 0); + }, + "test: fold should handle multi-line comments inside nested elements correctly": function () { + var session = new EditSession([ + '', ' ', ' text ', ' ', ' ', + ' ', ' ', '' + ]); + + var mode = new XmlMode(); + session.setMode(mode); + session.setFoldStyle("markbeginend"); + + // Checks for the parentElement + assert.equal(session.getFoldWidget(0), "start"); + assert.equal(session.getFoldWidget(10), "end"); + + // Checks for multi-line comment folding + assert.equal(session.getFoldWidget(2), "start"); + + // Checks for anotherChildElement folding (with single-line comment) + assert.equal(session.getFoldWidget(7), "start"); + assert.equal(session.getFoldWidget(8), ""); + assert.equal(session.getFoldWidget(9), "end"); + + // Verifying fold ranges + assert.range(session.getFoldWidgetRange(0), 0, 15, 10, 0); + assert.range(session.getFoldWidgetRange(2), 2, 13, 5, 4); + assert.equal(session.getFoldWidgetRange(8), ""); } + }; diff --git a/src/mode/jsdoc_comment_highlight_rules.js b/src/mode/jsdoc_comment_highlight_rules.js index 4c3577d115f..8883d30d069 100644 --- a/src/mode/jsdoc_comment_highlight_rules.js +++ b/src/mode/jsdoc_comment_highlight_rules.js @@ -84,7 +84,7 @@ var JsDocCommentHighlightRules = function() { }, JsDocCommentHighlightRules.getTagRule(), { - defaultToken : "comment.doc", + defaultToken: "comment.doc.body", caseInsensitive: true }], "doc-syntax": [{ @@ -110,7 +110,7 @@ JsDocCommentHighlightRules.getTagRule = function(start) { JsDocCommentHighlightRules.getStartRule = function(start) { return { token : "comment.doc", // doc comment - regex : "\\/\\*(?=\\*)", + regex: /\/\*\*(?!\/)/, next : start }; }; diff --git a/src/mode/lua_highlight_rules.js b/src/mode/lua_highlight_rules.js index 43da728cc4f..b03286dc78b 100644 --- a/src/mode/lua_highlight_rules.js +++ b/src/mode/lua_highlight_rules.js @@ -84,7 +84,7 @@ var LuaHighlightRules = function() { regex : /\]=*\]/, next : "start" }, { - defaultToken : "comment" + defaultToken: "comment.body" } ] }, From e9e04919da9ed30e473ece2f742ee74ae18f4998 Mon Sep 17 00:00:00 2001 From: Alice Koreman Date: Fri, 24 May 2024 11:05:46 +0200 Subject: [PATCH 19/23] release v1.34.1 --- CHANGELOG.md | 8 ++++++++ build | 2 +- package.json | 2 +- src/config.js | 2 +- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 32c41913143..9f668425add 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,14 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +### [1.34.1](https://github.com/ajaxorg/ace/compare/v1.34.0...v1.34.1) (2024-05-24) + + +### Bug Fixes + +* always set aria-label to text input in a11y mode ([#5563](https://github.com/ajaxorg/ace/issues/5563)) ([00346fd](https://github.com/ajaxorg/ace/commit/00346fde824beabb69f677631ad52815665eaef4)) +* Folding for comments and different modes ([#5533](https://github.com/ajaxorg/ace/issues/5533)) ([f4d0e33](https://github.com/ajaxorg/ace/commit/f4d0e33dac270ce21df09a96a39f50e16d6354db)) + ## [1.34.0](https://github.com/ajaxorg/ace/compare/v1.33.3...v1.34.0) (2024-05-22) diff --git a/build b/build index 6eacdd5d726..81232a2f0bc 160000 --- a/build +++ b/build @@ -1 +1 @@ -Subproject commit 6eacdd5d726dd7cf07d94cc42d9cc81638296fbf +Subproject commit 81232a2f0bc32b565dcf8913ec6b4046c44431d5 diff --git a/package.json b/package.json index 8e0c9002278..b7d378fff55 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "ace-code", "description": "Ajax.org Code Editor is a full featured source code highlighting editor that powers the Cloud9 IDE", - "version": "1.34.0", + "version": "1.34.1", "homepage": "http://github.com/ajaxorg/ace", "engines": { "node": ">= 0.6.0" diff --git a/src/config.js b/src/config.js index 1a93a708115..6333cb6df63 100644 --- a/src/config.js +++ b/src/config.js @@ -194,6 +194,6 @@ var reportErrorIfPathIsNotConfigured = function() { } }; -exports.version = "1.34.0"; +exports.version = "1.34.1"; From 20bae4bf2a8908613516cde022267f103d0db62b Mon Sep 17 00:00:00 2001 From: Harutyun Amirjanyan Date: Mon, 27 May 2024 11:52:09 +0400 Subject: [PATCH 20/23] fix autoresize leaving 0 height editor in some situations (#5566) --- demo/autoresize.html | 1 - src/virtual_renderer.js | 12 +++++++++-- src/virtual_renderer_test.js | 40 +++++++++++++++++++++++++++++++++++- 3 files changed, 49 insertions(+), 4 deletions(-) diff --git a/demo/autoresize.html b/demo/autoresize.html index 030ebb34300..00f8f1b7fb6 100644 --- a/demo/autoresize.html +++ b/demo/autoresize.html @@ -9,7 +9,6 @@ .ace_editor { border: 1px solid lightgray; margin: auto; - height: 200px; width: 80%; } .scrollmargin { diff --git a/src/virtual_renderer.js b/src/virtual_renderer.js index ce160fd81e8..61249b67d2f 100644 --- a/src/virtual_renderer.js +++ b/src/virtual_renderer.js @@ -322,11 +322,19 @@ class VirtualRenderer { this.resizing++; else this.resizing = force ? 1 : 0; - // `|| el.scrollHeight` is required for outosizing editors on ie - // where elements with clientHeight = 0 alsoe have clientWidth = 0 + // `|| el.scrollHeight` is required for autosizing editors on ie + // where elements with clientHeight = 0 also have clientWidth = 0 var el = this.container; if (!height) height = el.clientHeight || el.scrollHeight; + if (!height && this.$maxLines && this.lineHeight > 1) { + // if we are supposed to fit to content set height at least to 1 + // so that render does not exit early before calling $autosize + if (!el.style.height || el.style.height == "0px") { + el.style.height = "1px"; + height = el.clientHeight || el.scrollHeight; + } + } if (!width) width = el.clientWidth || el.scrollWidth; var changes = this.$updateCachedSize(force, gutterWidth, width, height); diff --git a/src/virtual_renderer_test.js b/src/virtual_renderer_test.js index 366e4482a41..db94fb3d30b 100644 --- a/src/virtual_renderer_test.js +++ b/src/virtual_renderer_test.js @@ -42,7 +42,7 @@ module.exports = { var renderer = new VirtualRenderer(el); editor = new Editor(renderer); editor.on("destroy", function() { - document.body.removeChild(el); + el.remove(); }); }, tearDown: function() { @@ -133,6 +133,44 @@ module.exports = { }, 0); }); }, + + "test autosize from 0 height": function() { + editor.container.style.height = "0px"; + editor.textInput.getElement().style.position = "fixed"; + editor.container.style.lineHeight = 1; + editor.setOptions({ + fontSize: 9 + }); + + editor.resize(true); + editor.setOptions({ + maxLines: 100 + }); + + editor.resize(true); + + editor.resize(true); + editor.renderer.$size = {}; + + var renderCount = 0; + editor.renderer.on("afterRender", function(e) { + renderCount++; + }); + editor.setValue("1"); + editor.renderer.$loop._flush(); + assert.equal(editor.container.style.height, "9px"); + + editor.setValue("\n\n"); + editor.renderer.$loop._flush(); + assert.equal(editor.container.style.height, "27px"); + + editor.container.remove(); + editor.setValue("\n\n\n"); + editor.resize(true); + editor.renderer.$loop._flush(); + editor.resize(true); + assert.equal(renderCount, 2); + }, "test invalid valus of minLines": function() { editor.setOptions({ From 1f166eb85484cd81e66476ee431de85016457463 Mon Sep 17 00:00:00 2001 From: Alice Koreman Date: Mon, 27 May 2024 09:58:02 +0200 Subject: [PATCH 21/23] chore: update website with new users (#5564) --- index.html | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/index.html b/index.html index 92811533df6..cf3446fb00a 100644 --- a/index.html +++ b/index.html @@ -1178,10 +1178,30 @@

    Projects Using Ace

    Hyena Code
  • -
  • +
  • Techcopes +
  • +
  • + + Geeks for geeks +
  • +
  • + + JSONEdit +
  • +
  • + + Bastify +
  • +
  • + + Html playground
  • +
  • + + XUÂN TUYẾN Education +
  • +

    Your Site Here From 75b24c86bec3241a16cee03bdeb5b1193cab1331 Mon Sep 17 00:00:00 2001 From: Alice Koreman Date: Mon, 27 May 2024 10:28:20 +0200 Subject: [PATCH 22/23] release v1.34.2 --- CHANGELOG.md | 2 ++ build | 2 +- package.json | 2 +- src/config.js | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9f668425add..475d182731f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +### [1.34.2](https://github.com/ajaxorg/ace/compare/v1.34.1...v1.34.2) (2024-05-27) + ### [1.34.1](https://github.com/ajaxorg/ace/compare/v1.34.0...v1.34.1) (2024-05-24) diff --git a/build b/build index 81232a2f0bc..007a5a0a42c 160000 --- a/build +++ b/build @@ -1 +1 @@ -Subproject commit 81232a2f0bc32b565dcf8913ec6b4046c44431d5 +Subproject commit 007a5a0a42cdc549c121256e2dd40b0ff731410c diff --git a/package.json b/package.json index b7d378fff55..8a3f981e275 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "ace-code", "description": "Ajax.org Code Editor is a full featured source code highlighting editor that powers the Cloud9 IDE", - "version": "1.34.1", + "version": "1.34.2", "homepage": "http://github.com/ajaxorg/ace", "engines": { "node": ">= 0.6.0" diff --git a/src/config.js b/src/config.js index 6333cb6df63..4273a44c071 100644 --- a/src/config.js +++ b/src/config.js @@ -194,6 +194,6 @@ var reportErrorIfPathIsNotConfigured = function() { } }; -exports.version = "1.34.1"; +exports.version = "1.34.2"; From a3277eaef554bdf6393e3957d60f5420e1d7130f Mon Sep 17 00:00:00 2001 From: Marin Sokol Date: Mon, 27 May 2024 11:21:00 +0200 Subject: [PATCH 23/23] chore: preventing directory traversal in dev server (#5567) * chore: preventing directory traversal in dev server * chore: adding top-level JS files to lint checker --- package.json | 4 ++-- static.js | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 8a3f981e275..de0400ea1d3 100644 --- a/package.json +++ b/package.json @@ -42,8 +42,8 @@ "start": "node static.js", "test": "node src/test/all.js", "cover": "istanbul cover src/test/all.js", - "lint": "eslint \"src/**/*.js\"", - "fix": "eslint --fix \"src/**/*.js\"", + "lint": "eslint \"src/**/*.js\" \"*.js\"", + "fix": "npm run lint -- --fix", "typecheck": "tsc -p tsconfig.json", "update-types": "node ./tool/modes-declaration-generator.js", "changelog": "standard-version", diff --git a/static.js b/static.js index 4eb03931130..d6583b35061 100755 --- a/static.js +++ b/static.js @@ -31,6 +31,13 @@ if (allowSave) http.createServer(function(req, res) { var uri = unescape(url.parse(req.url).pathname); + + // We don't allow for relative URIs, such as ../../X, to prevent directory traversal in case the server is shared with other actors. + // See more at https://cwe.mitre.org/data/definitions/22.html + if (path.normalize(uri) !== uri) { + return error(res, 400, "400 Bad request: Directory traversal is not allowed."); + } + var filename = path.join(process.cwd(), uri); if (req.method == "OPTIONS") {