From 5e1ca4f62d7f06c95f4d847ee60dcb52cb89d9e2 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Thu, 27 Aug 2015 11:29:03 +0200 Subject: [PATCH 0001/2444] [css mode] Make @import highlighting consistent with other contexts Closes #3475 --- mode/css/css.js | 19 ++++++++++++++----- mode/css/test.js | 2 +- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/mode/css/css.js b/mode/css/css.js index 6e16627ee0..83fdcdd7c8 100644 --- a/mode/css/css.js +++ b/mode/css/css.js @@ -164,9 +164,11 @@ CodeMirror.defineMode("css", function(config, parserConfig) { return popContext(state); } else if (supportsAtComponent && /@component/.test(type)) { return pushContext(state, stream, "atComponentBlock"); - } else if (/@(media|supports|(-moz-)?document)/.test(type)) { + } else if (/^@(-moz-)?document$/.test(type)) { + return pushContext(state, stream, "documentTypes"); + } else if (/^@(media|supports|(-moz-)?document|import)$/.test(type)) { return pushContext(state, stream, "atBlock"); - } else if (/@(font-face|counter-style)/.test(type)) { + } else if (/^@(font-face|counter-style)/.test(type)) { state.stateArg = type; return "restricted_atBlock_before"; } else if (/^@(-(moz|ms|o|webkit)-)?keyframes$/.test(type)) { @@ -259,17 +261,24 @@ CodeMirror.defineMode("css", function(config, parserConfig) { return pass(type, stream, state); }; + states.documentTypes = function(type, stream, state) { + if (type == "word" && documentTypes.hasOwnProperty(stream.current())) { + override = "tag"; + return state.context.type; + } else { + return states.atBlock(type, stream, state); + } + }; + states.atBlock = function(type, stream, state) { if (type == "(") return pushContext(state, stream, "atBlock_parens"); - if (type == "}") return popAndPass(type, stream, state); + if (type == "}" || type == ";") return popAndPass(type, stream, state); if (type == "{") return popContext(state) && pushContext(state, stream, allowNested ? "block" : "top"); if (type == "word") { var word = stream.current().toLowerCase(); if (word == "only" || word == "not" || word == "and" || word == "or") override = "keyword"; - else if (documentTypes.hasOwnProperty(word)) - override = "tag"; else if (mediaTypes.hasOwnProperty(word)) override = "attribute"; else if (mediaFeatures.hasOwnProperty(word)) diff --git a/mode/css/test.js b/mode/css/test.js index 7d78135de4..91046141d9 100644 --- a/mode/css/test.js +++ b/mode/css/test.js @@ -120,7 +120,7 @@ "}"); MT("empty_url", - "[def @import] [tag url]() [tag screen];"); + "[def @import] [atom url]() [attribute screen];"); MT("parens", "[qualifier .foo] {", From bfbb9c716d1b399699afda39e4bfca5e1bbd5d17 Mon Sep 17 00:00:00 2001 From: karevn Date: Thu, 20 Aug 2015 22:58:06 +0500 Subject: [PATCH 0002/2444] [vue mode, htmlmixed mode] Implement vue mode by extending htmlmixed --- mode/htmlmixed/htmlmixed.js | 267 ++++++++++++++++++++++++------------ mode/vue/index.html | 84 ++++++++++++ mode/vue/vue.js | 94 +++++++++++++ 3 files changed, 357 insertions(+), 88 deletions(-) create mode 100644 mode/vue/index.html create mode 100644 mode/vue/vue.js diff --git a/mode/htmlmixed/htmlmixed.js b/mode/htmlmixed/htmlmixed.js index 24552e2d80..4c9aafbb15 100644 --- a/mode/htmlmixed/htmlmixed.js +++ b/mode/htmlmixed/htmlmixed.js @@ -10,112 +10,203 @@ mod(CodeMirror); })(function(CodeMirror) { "use strict"; +var nestedModes = { + script: { + attributes: { + lang: { + javascript: /(javascript|babel)/i + }, + type: { + javascript: /^(?:text|application)\/(?:x-)?(?:java|ecma)script$|^$/i + } + }, + defaultMode: 'javascript' + }, + style: { + attributes: { + lang: { + css: /^css$/i + }, + type: { + css: /^(text\/)?(x-)?stylesheet$/i + } + }, + defaultMode: 'css' + } + }, attrRegexpCache = {}, tagRegexpCache = {}; -CodeMirror.defineMode("htmlmixed", function(config, parserConfig) { - var htmlMode = CodeMirror.getMode(config, {name: "xml", - htmlMode: true, - multilineTagIndentFactor: parserConfig.multilineTagIndentFactor, - multilineTagIndentPastTag: parserConfig.multilineTagIndentPastTag}); - var cssMode = CodeMirror.getMode(config, "css"); - - var scriptTypes = [], scriptTypesConf = parserConfig && parserConfig.scriptTypes; - scriptTypes.push({matches: /^(?:text|application)\/(?:x-)?(?:java|ecma)script$|^$/i, - mode: CodeMirror.getMode(config, "javascript")}); - if (scriptTypesConf) for (var i = 0; i < scriptTypesConf.length; ++i) { - var conf = scriptTypesConf[i]; - scriptTypes.push({matches: conf.matches, mode: conf.mode && CodeMirror.getMode(config, conf.mode)}); - } - scriptTypes.push({matches: /./, - mode: CodeMirror.getMode(config, "text/plain")}); - - function html(stream, state) { - var tagName = state.htmlState.tagName; - if (tagName) tagName = tagName.toLowerCase(); - var style = htmlMode.token(stream, state.htmlState); - if (tagName == "script" && /\btag\b/.test(style) && stream.current() == ">") { - // Script block: mode to change to depends on type attribute - var scriptType = stream.string.slice(Math.max(0, stream.pos - 100), stream.pos).match(/\btype\s*=\s*("[^"]+"|'[^']+'|\S+)[^<]*$/i); - scriptType = scriptType ? scriptType[1] : ""; - if (scriptType && /[\"\']/.test(scriptType.charAt(0))) scriptType = scriptType.slice(1, scriptType.length - 1); - for (var i = 0; i < scriptTypes.length; ++i) { - var tp = scriptTypes[i]; - if (typeof tp.matches == "string" ? scriptType == tp.matches : tp.matches.test(scriptType)) { - if (tp.mode) { - state.token = script; - state.localMode = tp.mode; - state.localState = tp.mode.startState && tp.mode.startState(htmlMode.indent(state.htmlState, "")); - } - break; + function deepmerge(target, src) { + var array = Array.isArray(src); + var dst = array && [] || {}; + + if (array) { + target = target || []; + dst = dst.concat(target); + src.forEach(function(e, i) { + if (typeof dst[i] === 'undefined') { + dst[i] = e; + } else if (typeof e === 'object') { + dst[i] = deepmerge(target[i], e); + } else { + if (target.indexOf(e) === -1) { + dst.push(e); + } + } + }); + } else { + if (target && typeof target === 'object') { + Object.keys(target).forEach(function (key) { + dst[key] = target[key]; + }) } - } - } else if (tagName == "style" && /\btag\b/.test(style) && stream.current() == ">") { - state.token = css; - state.localMode = cssMode; - state.localState = cssMode.startState(htmlMode.indent(state.htmlState, "")); + Object.keys(src).forEach(function (key) { + if (typeof src[key] !== 'object' || !src[key]) { + dst[key] = src[key]; + } + else { + if (!target[key]) { + dst[key] = src[key]; + } else { + dst[key] = deepmerge(target[key], src[key]); + } + } + }); } - return style; + + return dst; } + function maybeBackup(stream, pat, style) { - var cur = stream.current(); - var close = cur.search(pat); - if (close > -1) stream.backUp(cur.length - close); - else if (cur.match(/<\/?$/)) { + var cur = stream.current(), close = cur.search(pat); + if (close > -1) { + stream.backUp(cur.length - close); + } else if (cur.match(/<\/?$/)) { stream.backUp(cur.length); - if (!stream.match(pat, false)) stream.match(cur); + if (!stream.match(pat, false)) { + stream.match(cur); + } } return style; } - function script(stream, state) { - if (stream.match(/^<\/\s*script\s*>/i, false)) { - state.token = html; - state.localState = state.localMode = null; - return null; + + function getAttrRegexp(attr) { + var regexp; + if (regexp = attrRegexpCache[attr]) { + return regexp; } - return maybeBackup(stream, /<\/\s*script\s*>/, - state.localMode.token(stream, state.localState)); + return attrRegexpCache[attr] = new RegExp("\\s+" + attr + "\\s*=\\s*('|\")?([^'\"]+)('|\")?\\s*"); } - function css(stream, state) { - if (stream.match(/^<\/\s*style\s*>/i, false)) { - state.token = html; - state.localState = state.localMode = null; - return null; + + function getAttrValue(stream, attr) { + var pos = stream.pos, match; + while (pos >= 0 && stream.string.charAt(pos) !== "<") { + pos -= 1; + } + if (pos < 0) { + return pos; + } + if (match = stream.string.slice(pos, stream.pos).match(getAttrRegexp(attr))) { + return match[2]; } - return maybeBackup(stream, /<\/\s*style\s*>/, - cssMode.token(stream, state.localState)); } - return { - startState: function() { - var state = htmlMode.startState(); - return {token: html, localMode: null, localState: null, htmlState: state}; - }, + function getMode(modes, tagName, value) { + if (!value) { + return modes[tagName].defaultMode; + } + var attr, mode; + modes = modes[tagName]; + for (attr in modes.attributes){ + for (mode in modes.attributes[attr]) { + if (modes.attributes[attr][mode].test(value)) { + return mode; + } + } + } + return modes.defaultMode; + } - copyState: function(state) { - if (state.localState) - var local = CodeMirror.copyState(state.localMode, state.localState); - return {token: state.token, localMode: state.localMode, localState: local, - htmlState: CodeMirror.copyState(htmlMode, state.htmlState)}; - }, + function getTagRegexp(tagName) { + var regexp; + if (regexp = tagRegexpCache[tagName]) { + return regexp; + } + return tagRegexpCache[tagName] = new RegExp("^<\/\s*" + tagName + "\s*>", 'i'); + } - token: function(stream, state) { - return state.token(stream, state); - }, + CodeMirror.defineMode("htmlmixed", function (config, parserConfig) { + var htmlMode = CodeMirror.getMode(config, {name: "xml", + htmlMode: true, + multilineTagIndentFactor: parserConfig.multilineTagIndentFactor, + multilineTagIndentPastTag: parserConfig.multilineTagIndentPastTag}), + html, modes; + modes = deepmerge(deepmerge({}, nestedModes), parserConfig.modes || {}); + if (parserConfig.scriptTypes) { + for (var i = 0; i < parserConfig.scriptTypes.length; ++i) { + var conf = parserConfig.scriptTypes[i]; + modes.script.attributes[conf.mode] = conf.matches; + } + } + html = function (stream, state) { + var tagName = state.htmlState.tagName, + style = htmlMode.token(stream, state.htmlState), + mode, tag; + if (tagName) { + tagName = tagName.toLowerCase(); + } + tag = modes[tagName]; + if (stream.current() === ">" && tag && /\btag\b/.test(style) && + (mode = getMode(modes, tagName, getAttrValue(stream, 'lang')))) { + state.token = function (stream, state) { + var regexp = getTagRegexp(tagName); + if (stream.match(regexp, false)) { + state.token = html; + state.localState = state.localMode = null; + return null; + } + return maybeBackup(stream, regexp, state.localMode.token(stream, state.localState)); + } + mode = CodeMirror.getMode(config, mode); + state.localMode = mode; + state.localState = mode.startState && mode.startState(htmlMode.indent(state.htmlState, "")); + } + return style; + }; - indent: function(state, textAfter) { - if (!state.localMode || /^\s*<\//.test(textAfter)) - return htmlMode.indent(state.htmlState, textAfter); - else if (state.localMode.indent) - return state.localMode.indent(state.localState, textAfter); - else - return CodeMirror.Pass; - }, + return { + startState: function () { + var state = htmlMode.startState(); + return {token: html, localMode: null, localState: null, htmlState: state}; + }, - innerMode: function(state) { - return {state: state.localState || state.htmlState, mode: state.localMode || htmlMode}; - } - }; -}, "xml", "javascript", "css"); + copyState: function (state) { + var local; + if (state.localState) { + local = CodeMirror.copyState(state.localMode, state.localState); + } + return {token: state.token, localMode: state.localMode, localState: local, + htmlState: CodeMirror.copyState(htmlMode, state.htmlState)}; + }, -CodeMirror.defineMIME("text/html", "htmlmixed"); + token: function (stream, state) { + return state.token(stream, state); + }, + indent: function (state, textAfter) { + if (!state.localMode || /^\s*<\//.test(textAfter)) { + return htmlMode.indent(state.htmlState, textAfter); + } else if (state.localMode.indent) { + return state.localMode.indent(state.localState, textAfter); + } else { + return CodeMirror.Pass; + } + }, + + innerMode: function (state) { + return {state: state.localState || state.htmlState, mode: state.localMode || htmlMode}; + } + }; + }, "xml", "javascript", "css"); + +CodeMirror.defineMIME("text/html", "htmlmixed"); }); diff --git a/mode/vue/index.html b/mode/vue/index.html new file mode 100644 index 0000000000..e291f679a5 --- /dev/null +++ b/mode/vue/index.html @@ -0,0 +1,84 @@ + + +CodeMirror: Vue.js mode + + + + + + + + + + + + + + + + + + + + + +
+

Vue.js mode

+
+ + +

The HTML mixed mode depends on the XML, JavaScript, and CSS modes.

+ +

It takes an optional mode configuration + option, scriptTypes, which can be used to add custom + behavior for specific <script type="..."> tags. If + given, it should hold an array of {matches, mode} + objects, where matches is a string or regexp that + matches the script type, and mode is + either null, for script types that should stay in + HTML mode, or a mode + spec corresponding to the mode that should be used for the + script.

+ +

MIME types defined: text/x-vue + (redefined, only takes effect if you load this parser after the + XML parser).

+ +
diff --git a/mode/vue/vue.js b/mode/vue/vue.js new file mode 100644 index 0000000000..01bb5ecacf --- /dev/null +++ b/mode/vue/vue.js @@ -0,0 +1,94 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: http://codemirror.net/LICENSE + +(function (mod) { + "use strict"; + if (typeof exports === "object" && typeof module === "object") {// CommonJS + mod(require("../../lib/codemirror"), + require("../xml/xml"), + require("../javascript/javascript"), + require("../coffeescript/coffeescript"), + require("../css/css"), + require("../sass/sass"), + require("../stylus/stylus"), + require("../jade/jade"), + require("../handlebars/handlebars")); + } else if (typeof define === "function" && define.amd) { // AMD + define(["../../lib/codemirror", + "../xml/xml", + "../javascript/javascript", + "../coffeescript/coffeescript", + "../css/css", + "../sass/sass", + "../stylus/stylus", + "../jade/jade", + "../handlebars/handlebars"], mod); + } else { // Plain browser env + mod(CodeMirror); + } +})(function (CodeMirror) { + var nestedModes = { + script: { + attributes: { + lang: { + coffeescript: /coffee(script)?/ + }, + type: { + coffeescript: /^(?:text|application)\/(?:x-)?coffee(?:script)?$/ + } + } + }, + style: { + attributes: { + lang: { + stylus: /^stylus$/i, + sass: /^sass$/i + }, + type: { + stylus: /^(text\/)?(x-)?styl(us)?$/i, + sass: /^text\/sass/i + } + } + }, + template: { + attributes: { + lang: { + vue: /^vue-template$/i, + jade: /^jade$/i, + handlebars: /^handlebars$/i + }, + type: { + jade: /^(text\/)?(x-)?jade$/i, + handlebars: /^text\/x-handlebars-template$/i + } + }, + defaultMode: 'vue-template' + } + }; + + CodeMirror.defineMode("vue-template", function (config, parserConfig) { + "use strict"; + var mustacheOverlay = { + token: function (stream) { + var ch; + if (stream.match("{{")) { + while ((ch = stream.next()) !== null) { + if (ch === "}" && stream.next() === "}") { + stream.eat("}"); + return "mustache"; + } + } + } + while (stream.next() && !stream.match("{{", false)) {} + return null; + } + }; + return CodeMirror.overlayMode(CodeMirror.getMode(config, parserConfig.backdrop || "text/html"), mustacheOverlay); + }); + + CodeMirror.defineMode("vue", function (config) { + return CodeMirror.getMode(config, {name: "htmlmixed", modes: nestedModes}); + },"htmlmixed", "xml", "javascript", "coffeescript", "css", "sass", "stylus", "jade", "handlebars"); + + CodeMirror.defineMIME("script/x-vue", "vue"); +}); From eb56e9111910acf860fe21466524f029bc1b81f0 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Thu, 27 Aug 2015 12:56:34 +0200 Subject: [PATCH 0003/2444] [htmlmixed mode] Revise changes from patch bfbb9c716d1b Issue #3462 --- doc/compress.html | 1 + mode/htmlmixed/htmlmixed.js | 202 +++++++++++++----------------------- mode/index.html | 1 + mode/vue/index.html | 17 +-- mode/vue/vue.js | 73 +++++-------- 5 files changed, 97 insertions(+), 197 deletions(-) diff --git a/doc/compress.html b/doc/compress.html index 7dff44dcd6..86575be7c4 100644 --- a/doc/compress.html +++ b/doc/compress.html @@ -211,6 +211,7 @@

Script compression helper

+ diff --git a/mode/htmlmixed/htmlmixed.js b/mode/htmlmixed/htmlmixed.js index 4c9aafbb15..670fd62bf1 100644 --- a/mode/htmlmixed/htmlmixed.js +++ b/mode/htmlmixed/htmlmixed.js @@ -9,72 +9,22 @@ else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { -"use strict"; -var nestedModes = { - script: { - attributes: { - lang: { - javascript: /(javascript|babel)/i - }, - type: { - javascript: /^(?:text|application)\/(?:x-)?(?:java|ecma)script$|^$/i - } - }, - defaultMode: 'javascript' - }, - style: { - attributes: { - lang: { - css: /^css$/i - }, - type: { - css: /^(text\/)?(x-)?stylesheet$/i - } - }, - defaultMode: 'css' - } - }, attrRegexpCache = {}, tagRegexpCache = {}; - - function deepmerge(target, src) { - var array = Array.isArray(src); - var dst = array && [] || {}; - - if (array) { - target = target || []; - dst = dst.concat(target); - src.forEach(function(e, i) { - if (typeof dst[i] === 'undefined') { - dst[i] = e; - } else if (typeof e === 'object') { - dst[i] = deepmerge(target[i], e); - } else { - if (target.indexOf(e) === -1) { - dst.push(e); - } - } - }); - } else { - if (target && typeof target === 'object') { - Object.keys(target).forEach(function (key) { - dst[key] = target[key]; - }) - } - Object.keys(src).forEach(function (key) { - if (typeof src[key] !== 'object' || !src[key]) { - dst[key] = src[key]; - } - else { - if (!target[key]) { - dst[key] = src[key]; - } else { - dst[key] = deepmerge(target[key], src[key]); - } - } - }); - } - - return dst; - } + "use strict"; + + var defaultTags = { + script: [ + ["lang", /(javascript|babel)/i, "javascript"], + ["type", /^(?:text|application)\/(?:x-)?(?:java|ecma)script$|^$/i, "javascript"], + ["type", /./, "text/plain"], + [null, null, "javascript"] + ], + style: [ + ["lang", /^css$/i, "css"], + ["type", /^(text\/)?(x-)?(stylesheet|css)$/i, "css"], + ["type", /./, "text/plain"], + [null, null, "css"] + ] + }; function maybeBackup(stream, pat, style) { var cur = stream.current(), close = cur.search(pat); @@ -82,93 +32,82 @@ var nestedModes = { stream.backUp(cur.length - close); } else if (cur.match(/<\/?$/)) { stream.backUp(cur.length); - if (!stream.match(pat, false)) { - stream.match(cur); - } + if (!stream.match(pat, false)) stream.match(cur); } return style; } + var attrRegexpCache = {}; function getAttrRegexp(attr) { - var regexp; - if (regexp = attrRegexpCache[attr]) { - return regexp; - } + var regexp = attrRegexpCache[attr]; + if (regexp) return regexp; return attrRegexpCache[attr] = new RegExp("\\s+" + attr + "\\s*=\\s*('|\")?([^'\"]+)('|\")?\\s*"); } function getAttrValue(stream, attr) { var pos = stream.pos, match; - while (pos >= 0 && stream.string.charAt(pos) !== "<") { - pos -= 1; - } - if (pos < 0) { - return pos; - } - if (match = stream.string.slice(pos, stream.pos).match(getAttrRegexp(attr))) { + while (pos >= 0 && stream.string.charAt(pos) !== "<") pos--; + if (pos < 0) return pos; + if (match = stream.string.slice(pos, stream.pos).match(getAttrRegexp(attr))) return match[2]; - } + return ""; } - function getMode(modes, tagName, value) { - if (!value) { - return modes[tagName].defaultMode; - } - var attr, mode; - modes = modes[tagName]; - for (attr in modes.attributes){ - for (mode in modes.attributes[attr]) { - if (modes.attributes[attr][mode].test(value)) { - return mode; - } - } + function getTagRegexp(tagName, anchored) { + return new RegExp((anchored ? "^" : "") + "<\/\s*" + tagName + "\s*>", "i"); + } + + function addTags(from, to) { + for (var tag in from) { + var dest = to[tag] || (to[tag] = []); + var source = from[tag]; + for (var i = source.length - 1; i >= 0; i--) + dest.unshift(source[i]) } - return modes.defaultMode; } - function getTagRegexp(tagName) { - var regexp; - if (regexp = tagRegexpCache[tagName]) { - return regexp; + function findMatchingMode(tagInfo, stream) { + for (var i = 0; i < tagInfo.length; i++) { + var spec = tagInfo[i]; + if (!spec[0] || spec[1].test(getAttrValue(stream, spec[0]))) return spec[2]; } - return tagRegexpCache[tagName] = new RegExp("^<\/\s*" + tagName + "\s*>", 'i'); } CodeMirror.defineMode("htmlmixed", function (config, parserConfig) { - var htmlMode = CodeMirror.getMode(config, {name: "xml", - htmlMode: true, - multilineTagIndentFactor: parserConfig.multilineTagIndentFactor, - multilineTagIndentPastTag: parserConfig.multilineTagIndentPastTag}), - html, modes; - modes = deepmerge(deepmerge({}, nestedModes), parserConfig.modes || {}); - if (parserConfig.scriptTypes) { - for (var i = 0; i < parserConfig.scriptTypes.length; ++i) { - var conf = parserConfig.scriptTypes[i]; - modes.script.attributes[conf.mode] = conf.matches; - } - } - html = function (stream, state) { - var tagName = state.htmlState.tagName, - style = htmlMode.token(stream, state.htmlState), - mode, tag; - if (tagName) { - tagName = tagName.toLowerCase(); - } - tag = modes[tagName]; - if (stream.current() === ">" && tag && /\btag\b/.test(style) && - (mode = getMode(modes, tagName, getAttrValue(stream, 'lang')))) { + var htmlMode = CodeMirror.getMode(config, { + name: "xml", + htmlMode: true, + multilineTagIndentFactor: parserConfig.multilineTagIndentFactor, + multilineTagIndentPastTag: parserConfig.multilineTagIndentPastTag + }); + + var tags = {}; + var configTags = parserConfig && parserConfig.tags, configScript = parserConfig && parserConfig.scriptTypes; + addTags(defaultTags, tags); + if (configTags) addTags(configTags, tags); + if (configScript) for (var i = configScript.length - 1; i >= 0; i--) + tags.script.unshift(["type", configScript[i].matches, configScript[i].mode]) + + function html(stream, state) { + var tagName = state.htmlState.tagName; + var tagInfo = tagName && tags[tagName.toLowerCase()]; + + var style = htmlMode.token(stream, state.htmlState), modeSpec; + + if (tagInfo && /\btag\b/.test(style) && stream.current() === ">" && + (modeSpec = findMatchingMode(tagInfo, stream))) { + var mode = CodeMirror.getMode(config, modeSpec); + var endTagA = getTagRegexp(tagName, true), endTag = getTagRegexp(tagName, false); state.token = function (stream, state) { - var regexp = getTagRegexp(tagName); - if (stream.match(regexp, false)) { + if (stream.match(endTagA, false)) { state.token = html; state.localState = state.localMode = null; return null; } - return maybeBackup(stream, regexp, state.localMode.token(stream, state.localState)); - } - mode = CodeMirror.getMode(config, mode); + return maybeBackup(stream, endTag, state.localMode.token(stream, state.localState)); + }; state.localMode = mode; - state.localState = mode.startState && mode.startState(htmlMode.indent(state.htmlState, "")); + state.localState = CodeMirror.startState(mode, htmlMode.indent(state.htmlState, "")); } return style; }; @@ -193,13 +132,12 @@ var nestedModes = { }, indent: function (state, textAfter) { - if (!state.localMode || /^\s*<\//.test(textAfter)) { + if (!state.localMode || /^\s*<\//.test(textAfter)) return htmlMode.indent(state.htmlState, textAfter); - } else if (state.localMode.indent) { + else if (state.localMode.indent) return state.localMode.indent(state.localState, textAfter); - } else { + else return CodeMirror.Pass; - } }, innerMode: function (state) { @@ -208,5 +146,5 @@ var nestedModes = { }; }, "xml", "javascript", "css"); -CodeMirror.defineMIME("text/html", "htmlmixed"); + CodeMirror.defineMIME("text/html", "htmlmixed"); }); diff --git a/mode/index.html b/mode/index.html index 9bb8beff92..8b1678e6c0 100644 --- a/mode/index.html +++ b/mode/index.html @@ -140,6 +140,7 @@

Language modes

  • Velocity
  • Verilog/SystemVerilog
  • VHDL
  • +
  • Vue.js app
  • XML/HTML
  • XQuery
  • YAML
  • diff --git a/mode/vue/index.html b/mode/vue/index.html index e291f679a5..cccb9764f3 100644 --- a/mode/vue/index.html +++ b/mode/vue/index.html @@ -64,21 +64,6 @@

    Vue.js mode

    }); -

    The HTML mixed mode depends on the XML, JavaScript, and CSS modes.

    - -

    It takes an optional mode configuration - option, scriptTypes, which can be used to add custom - behavior for specific <script type="..."> tags. If - given, it should hold an array of {matches, mode} - objects, where matches is a string or regexp that - matches the script type, and mode is - either null, for script types that should stay in - HTML mode, or a mode - spec corresponding to the mode that should be used for the - script.

    - -

    MIME types defined: text/x-vue - (redefined, only takes effect if you load this parser after the - XML parser).

    +

    MIME types defined: text/x-vue

    diff --git a/mode/vue/vue.js b/mode/vue/vue.js index 01bb5ecacf..d89a552387 100644 --- a/mode/vue/vue.js +++ b/mode/vue/vue.js @@ -5,6 +5,7 @@ "use strict"; if (typeof exports === "object" && typeof module === "object") {// CommonJS mod(require("../../lib/codemirror"), + require("../../addon/mode/overlay"), require("../xml/xml"), require("../javascript/javascript"), require("../coffeescript/coffeescript"), @@ -15,6 +16,7 @@ require("../handlebars/handlebars")); } else if (typeof define === "function" && define.amd) { // AMD define(["../../lib/codemirror", + "../../addon/mode/overlay", "../xml/xml", "../javascript/javascript", "../coffeescript/coffeescript", @@ -27,58 +29,31 @@ mod(CodeMirror); } })(function (CodeMirror) { - var nestedModes = { - script: { - attributes: { - lang: { - coffeescript: /coffee(script)?/ - }, - type: { - coffeescript: /^(?:text|application)\/(?:x-)?coffee(?:script)?$/ - } - } - }, - style: { - attributes: { - lang: { - stylus: /^stylus$/i, - sass: /^sass$/i - }, - type: { - stylus: /^(text\/)?(x-)?styl(us)?$/i, - sass: /^text\/sass/i - } - } - }, - template: { - attributes: { - lang: { - vue: /^vue-template$/i, - jade: /^jade$/i, - handlebars: /^handlebars$/i - }, - type: { - jade: /^(text\/)?(x-)?jade$/i, - handlebars: /^text\/x-handlebars-template$/i - } - }, - defaultMode: 'vue-template' - } + var tagLanguages = { + script: [ + ["lang", /coffee(script)?/, "coffeescript"], + ["type", /^(?:text|application)\/(?:x-)?coffee(?:script)?$/, "coffeescript"] + ], + style: [ + ["lang", /^stylus$/i, "stylus"], + ["lang", /^sass$/i, "sass"], + ["type", /^(text\/)?(x-)?styl(us)?$/i, "stylus"], + ["type", /^text\/sass/i, "sass"] + ], + template: [ + ["lang", /^vue-template$/i, "vue"], + ["lang", /^jade$/i, "jade"], + ["lang", /^handlebars$/i, "handlebars"], + ["type", /^(text\/)?(x-)?jade$/i, "jade"], + ["type", /^text\/x-handlebars-template$/i, "handlebars"], + [null, null, "vue-template"] + ] }; CodeMirror.defineMode("vue-template", function (config, parserConfig) { - "use strict"; var mustacheOverlay = { token: function (stream) { - var ch; - if (stream.match("{{")) { - while ((ch = stream.next()) !== null) { - if (ch === "}" && stream.next() === "}") { - stream.eat("}"); - return "mustache"; - } - } - } + if (stream.match(/^\{\{.*?\}\}/)) return "meta mustache"; while (stream.next() && !stream.match("{{", false)) {} return null; } @@ -87,8 +62,8 @@ }); CodeMirror.defineMode("vue", function (config) { - return CodeMirror.getMode(config, {name: "htmlmixed", modes: nestedModes}); - },"htmlmixed", "xml", "javascript", "coffeescript", "css", "sass", "stylus", "jade", "handlebars"); + return CodeMirror.getMode(config, {name: "htmlmixed", tags: tagLanguages}); + }, "htmlmixed", "xml", "javascript", "coffeescript", "css", "sass", "stylus", "jade", "handlebars"); CodeMirror.defineMIME("script/x-vue", "vue"); }); From 94fc3b71e8e9f52b9239276a34658023933aac68 Mon Sep 17 00:00:00 2001 From: Martin Zagora Date: Wed, 26 Aug 2015 11:08:30 +1000 Subject: [PATCH 0004/2444] [javascript mode] attempt to fix parsing when async/await are present --- mode/javascript/javascript.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/mode/javascript/javascript.js b/mode/javascript/javascript.js index 341a43d592..4451d65b4f 100644 --- a/mode/javascript/javascript.js +++ b/mode/javascript/javascript.js @@ -32,12 +32,12 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { "if": kw("if"), "while": A, "with": A, "else": B, "do": B, "try": B, "finally": B, "return": C, "break": C, "continue": C, "new": C, "delete": C, "throw": C, "debugger": C, "var": kw("var"), "const": kw("var"), "let": kw("var"), - "function": kw("function"), "catch": kw("catch"), + "async": kw("async"), "function": kw("function"), "catch": kw("catch"), "for": kw("for"), "switch": kw("switch"), "case": kw("case"), "default": kw("default"), "in": operator, "typeof": operator, "instanceof": operator, "true": atom, "false": atom, "null": atom, "undefined": atom, "NaN": atom, "Infinity": atom, "this": kw("this"), "class": kw("class"), "super": kw("atom"), - "yield": C, "export": kw("export"), "import": kw("import"), "extends": C + "await": C, "yield": C, "export": kw("export"), "import": kw("import"), "extends": C }; // Extend the 'normal' keywords with the TypeScript language extensions @@ -367,6 +367,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { var maybeop = noComma ? maybeoperatorNoComma : maybeoperatorComma; if (atomicTypes.hasOwnProperty(type)) return cont(maybeop); + if (type == "async") return cont(expression); if (type == "function") return cont(functiondef, maybeop); if (type == "keyword c") return cont(noComma ? maybeexpressionNoComma : maybeexpression); if (type == "(") return cont(pushlex(")"), maybeexpression, comprehension, expect(")"), poplex, maybeop); @@ -432,7 +433,9 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { if (type == "variable") {cx.marked = "property"; return cont();} } function objprop(type, value) { - if (type == "variable" || cx.style == "keyword") { + if (type == "async") { + return cont(objprop); + } else if (type == "variable" || cx.style == "keyword") { cx.marked = "property"; if (value == "get" || value == "set") return cont(getterSetter); return cont(afterprop); From 756ddc5c8b58c7a47e48762496771aebe08623b4 Mon Sep 17 00:00:00 2001 From: Matt Pass Date: Wed, 26 Aug 2015 11:30:16 +0100 Subject: [PATCH 0005/2444] [icecoder theme] Activeline background added --- theme/icecoder.css | 1 + 1 file changed, 1 insertion(+) diff --git a/theme/icecoder.css b/theme/icecoder.css index 37561d4b9f..d70d26e820 100644 --- a/theme/icecoder.css +++ b/theme/icecoder.css @@ -40,3 +40,4 @@ ICEcoder default theme by Matt Pass, used in code editor available at https://ic .cm-s-icecoder .CodeMirror-gutters { background: #141612; min-width: 41px; border-right: 0; } .cm-s-icecoder .CodeMirror-linenumber { color: #555; cursor: default; } .cm-s-icecoder .CodeMirror-matchingbracket { border: 1px solid grey; color: black !important; } +.cm-s-icecoder .CodeMirror-activeline-background { background: #000; } \ No newline at end of file From 3d18f89f77c285e36419d6a1ca3714c236d8041c Mon Sep 17 00:00:00 2001 From: David Barnett Date: Sat, 22 Aug 2015 15:36:24 -0700 Subject: [PATCH 0006/2444] [css mode] Adjust indent to align with parent context when closing blocks --- mode/css/css.js | 18 ++++++++++++------ mode/css/test.js | 2 +- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/mode/css/css.js b/mode/css/css.js index 83fdcdd7c8..7300850399 100644 --- a/mode/css/css.js +++ b/mode/css/css.js @@ -387,12 +387,18 @@ CodeMirror.defineMode("css", function(config, parserConfig) { var cx = state.context, ch = textAfter && textAfter.charAt(0); var indent = cx.indent; if (cx.type == "prop" && (ch == "}" || ch == ")")) cx = cx.prev; - if (cx.prev && - (ch == "}" && (cx.type == "block" || cx.type == "top" || cx.type == "interpolation" || cx.type == "restricted_atBlock") || - ch == ")" && (cx.type == "parens" || cx.type == "atBlock_parens") || - ch == "{" && (cx.type == "at" || cx.type == "atBlock"))) { - indent = Math.max(0, cx.indent - indentUnit); - cx = cx.prev; + if (cx.prev) { + if (ch == "}" && (cx.type == "block" || cx.type == "top" || + cx.type == "interpolation" || cx.type == "restricted_atBlock")) { + // Resume indentation from parent context. + cx = cx.prev; + indent = cx.indent; + } else if (ch == ")" && (cx.type == "parens" || cx.type == "atBlock_parens") || + ch == "{" && (cx.type == "at" || cx.type == "atBlock")) { + // Dedent relative to current context. + indent = Math.max(0, cx.indent - indentUnit); + cx = cx.prev; + } } return indent; }, diff --git a/mode/css/test.js b/mode/css/test.js index 91046141d9..60f9c837f6 100644 --- a/mode/css/test.js +++ b/mode/css/test.js @@ -156,7 +156,7 @@ " [tag foo] {", " [property font-family]: [variable Verdana], [atom sans-serif];", " }", - " }"); + "}"); MT("document_url", "[def @document] [tag url]([string http://blah]) { [qualifier .class] { } }"); From cfdd017c503eeff779b9adb424a0f5d06028ec7e Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Tue, 1 Sep 2015 14:34:46 +0200 Subject: [PATCH 0007/2444] [placeholder addon] Allow a DOM node to be given as placeholder content Issue #3487 --- addon/display/placeholder.js | 4 +++- doc/manual.html | 7 ++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/addon/display/placeholder.js b/addon/display/placeholder.js index bb0c3931e4..babddfb1fe 100644 --- a/addon/display/placeholder.js +++ b/addon/display/placeholder.js @@ -37,7 +37,9 @@ var elt = cm.state.placeholder = document.createElement("pre"); elt.style.cssText = "height: 0; overflow: visible"; elt.className = "CodeMirror-placeholder"; - elt.appendChild(document.createTextNode(cm.getOption("placeholder"))); + var placeHolder = cm.getOption("placeholder") + if (typeof placeHolder == "string") placeHolder = document.createTextNode(placeHolder) + elt.appendChild(placeHolder) cm.display.lineSpace.insertBefore(elt, cm.display.lineSpace.firstChild); } diff --git a/doc/manual.html b/doc/manual.html index e59e6f3fca..0c32e80d93 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -2762,9 +2762,10 @@

    Addons

    display/placeholder.js
    Adds a placeholder option that can be used to - make text appear in the editor when it is empty and not focused. - Also gives the editor a CodeMirror-empty CSS class - whenever it doesn't contain any text. + make content appear in the editor when it is empty and not + focused. It can hold either a string or a DOM node. Also gives + the editor a CodeMirror-empty CSS class whenever it + doesn't contain any text. See the demo.
    display/fullscreen.js
    From 9018087c161f32abac9f3ba43e6591f1b9bcab05 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Tue, 1 Sep 2015 14:56:13 +0200 Subject: [PATCH 0008/2444] [php mode] Indent php code when in nested HTML Issue #3488 --- mode/php/php.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mode/php/php.js b/mode/php/php.js index f4594d4a46..b174a49283 100644 --- a/mode/php/php.js +++ b/mode/php/php.js @@ -160,6 +160,7 @@ if (!isPHP) { if (stream.match(/^<\?\w*/)) { state.curMode = phpMode; + if (!state.php) state.php = CodeMirror.startState(phpMode, htmlMode.indent(state.html, "")) state.curState = state.php; return "meta"; } @@ -183,6 +184,7 @@ } else if (isPHP && state.php.tokenize == null && stream.match("?>")) { state.curMode = htmlMode; state.curState = state.html; + if (!state.php.context.prev) state.php = null; return "meta"; } else { return phpMode.token(stream, state.curState); @@ -191,7 +193,8 @@ return { startState: function() { - var html = CodeMirror.startState(htmlMode), php = CodeMirror.startState(phpMode); + var html = CodeMirror.startState(htmlMode) + var php = parserConfig.startOpen ? CodeMirror.startState(phpMode) : null return {html: html, php: php, curMode: parserConfig.startOpen ? phpMode : htmlMode, @@ -201,7 +204,7 @@ copyState: function(state) { var html = state.html, htmlNew = CodeMirror.copyState(htmlMode, html), - php = state.php, phpNew = CodeMirror.copyState(phpMode, php), cur; + php = state.php, phpNew = php && CodeMirror.copyState(phpMode, php), cur; if (state.curMode == htmlMode) cur = htmlNew; else cur = phpNew; return {html: htmlNew, php: phpNew, curMode: state.curMode, curState: cur, From 0cd2432caa007afaddebccb7f315d678b3396695 Mon Sep 17 00:00:00 2001 From: anthonygego Date: Fri, 14 Aug 2015 11:47:12 +0200 Subject: [PATCH 0009/2444] [oz mode] Add --- doc/compress.html | 1 + mode/index.html | 1 + mode/meta.js | 1 + mode/oz/index.html | 59 +++++++++++ mode/oz/oz.js | 242 +++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 304 insertions(+) create mode 100644 mode/oz/index.html create mode 100644 mode/oz/oz.js diff --git a/doc/compress.html b/doc/compress.html index 86575be7c4..335a025917 100644 --- a/doc/compress.html +++ b/doc/compress.html @@ -165,6 +165,7 @@

    Script compression helper

    + diff --git a/mode/index.html b/mode/index.html index 8b1678e6c0..f63e83684c 100644 --- a/mode/index.html +++ b/mode/index.html @@ -91,6 +91,7 @@

    Language modes

  • Objective C
  • OCaml
  • Octave (MATLAB)
  • +
  • Oz
  • Pascal
  • PEG.js
  • Perl
  • diff --git a/mode/meta.js b/mode/meta.js index aff0cc7c62..55f11da8b6 100644 --- a/mode/meta.js +++ b/mode/meta.js @@ -87,6 +87,7 @@ {name: "Objective C", mime: "text/x-objectivec", mode: "clike", ext: ["m", "mm"]}, {name: "OCaml", mime: "text/x-ocaml", mode: "mllike", ext: ["ml", "mli", "mll", "mly"]}, {name: "Octave", mime: "text/x-octave", mode: "octave", ext: ["m"]}, + {name: "Oz", mime: "text/x-oz", mode: "oz", ext: ["oz"]}, {name: "Pascal", mime: "text/x-pascal", mode: "pascal", ext: ["p", "pas"]}, {name: "PEG.js", mime: "null", mode: "pegjs", ext: ["jsonld"]}, {name: "Perl", mime: "text/x-perl", mode: "perl", ext: ["pl", "pm"]}, diff --git a/mode/oz/index.html b/mode/oz/index.html new file mode 100644 index 0000000000..febd82a59a --- /dev/null +++ b/mode/oz/index.html @@ -0,0 +1,59 @@ + + +CodeMirror: Oz mode + + + + + + + + + + +
    +

    Oz mode

    + +

    MIME type defined: text/x-oz.

    + + +
    diff --git a/mode/oz/oz.js b/mode/oz/oz.js new file mode 100644 index 0000000000..91ea13c22c --- /dev/null +++ b/mode/oz/oz.js @@ -0,0 +1,242 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: http://codemirror.net/LICENSE + +(function(mod) { + if (typeof exports == "object" && typeof module == "object") // CommonJS + mod(require("../../lib/codemirror")); + else if (typeof define == "function" && define.amd) // AMD + define(["../../lib/codemirror"], mod); + else // Plain browser env + mod(CodeMirror); +})(function(CodeMirror) { +"use strict"; + +CodeMirror.defineMode("oz", function (conf) { + + function wordRegexp(words) { + return new RegExp("^((" + words.join(")|(") + "))\\b"); + } + + var singleOperators = /[\^@!\|<>#~\.\*\-\+\\/,=]/; + var doubleOperators = /(<-)|(:=)|(=<)|(>=)|(<=)|(<:)|(>:)|(=:)|(\\=)|(\\=:)|(!!)|(==)|(::)/; + var tripleOperators = /(:::)|(\.\.\.)|(=<:)|(>=:)/; + + var atoms = wordRegexp(["true", "false", "nil", "unit"]); + var openingKeywords = wordRegexp(["local", "proc", "fun", "case", "class", "if", "cond", "or", "dis", + "choice", "not", "thread", "try", "raise", "lock", "for", "suchthat", "meth", "functor"]); + var middleKeywords = wordRegexp(["in", "then", "else", "of", "elseof", "elsecase", "elseif", "catch", + "finally", "with", "require", "prepare", "import", "export", "define", "do"]); + var commonKeywords = wordRegexp(["andthen", "at", "attr", "declare", "feat", "from", "lex", + "mod", "mode", "orelse", "parser", "prod", "prop", "scanner", "self", "syn", "token"]); + var endKeywords = wordRegexp(["end"]); + + // Tokenizers + function tokenBase(stream, state) { + if (stream.eatSpace()) { + return null; + } + + // Brackets + if(stream.match(/[{}]/)) { + return "bracket"; + } + + // Special [] keyword + if (stream.match(/(\[])/)) { + return "keyword" + } + + // Operators + if (stream.match(tripleOperators) || stream.match(doubleOperators)) { + return "operator"; + } + + // Atoms + if(stream.match(atoms)) { + return 'atom'; + } + + // Opening keywords + var matched = stream.match(openingKeywords); + if (matched) { + if (!state.doInCurrentLine) + state.currentIndent++; + else + state.doInCurrentLine = false; + + // Special matching for signatures + if(matched[0] == "proc" || matched[0] == "fun") + state.tokenize = tokenFunProc; + else if(matched[0] == "class") + state.tokenize = tokenClass; + else if(matched[0] == "meth") + state.tokenize = tokenMeth; + + return 'keyword'; + } + + // Middle and other keywords + if (stream.match(middleKeywords) || stream.match(commonKeywords)) { + return "keyword" + } + + // End keywords + if (stream.match(endKeywords)) { + state.currentIndent--; + return 'keyword'; + } + + // Eat the next char for next comparisons + var ch = stream.next(); + + // Strings + if (ch == '"' || ch == "'") { + state.tokenize = tokenString(ch); + return state.tokenize(stream, state); + } + + // Numbers + if (/[~\d]/.test(ch)) { + if (ch == "~") { + if(! /^[0-9]/.test(stream.peek())) + return null; + else if (( stream.next() == "0" && stream.match(/^[xX][0-9a-fA-F]+/)) || stream.match(/^[0-9]*(\.[0-9]+)?([eE][~+]?[0-9]+)?/)) + return "number"; + } + + if ((ch == "0" && stream.match(/^[xX][0-9a-fA-F]+/)) || stream.match(/^[0-9]*(\.[0-9]+)?([eE][~+]?[0-9]+)?/)) + return "number"; + + return null; + } + + // Comments + if (ch == "%") { + stream.skipToEnd(); + return 'comment'; + } + else if (ch == "/") { + if (stream.eat("*")) { + state.tokenize = tokenComment; + return tokenComment(stream, state); + } + } + + // Single operators + if(singleOperators.test(ch)) { + return "operator"; + } + + // If nothing match, we skip the entire alphanumerical block + stream.eatWhile(/\w/); + + return "variable"; + } + + function tokenClass(stream, state) { + if (stream.eatSpace()) { + return null; + } + stream.match(/([A-Z][A-Za-z0-9_]*)|(`.+`)/); + state.tokenize = tokenBase; + return "variable-3" + } + + function tokenMeth(stream, state) { + if (stream.eatSpace()) { + return null; + } + stream.match(/([a-zA-Z][A-Za-z0-9_]*)|(`.+`)/); + state.tokenize = tokenBase; + return "def" + } + + function tokenFunProc(stream, state) { + if (stream.eatSpace()) { + return null; + } + + if(!state.hasPassedFirstStage && stream.eat("{")) { + state.hasPassedFirstStage = true; + return "bracket"; + } + else if(state.hasPassedFirstStage) { + stream.match(/([A-Z][A-Za-z0-9_]*)|(`.+`)|\$/); + state.hasPassedFirstStage = false; + state.tokenize = tokenBase; + return "def" + } + else { + state.tokenize = tokenBase; + return null; + } + } + + function tokenComment(stream, state) { + var maybeEnd = false, ch; + while (ch = stream.next()) { + if (ch == "/" && maybeEnd) { + state.tokenize = tokenBase; + break; + } + maybeEnd = (ch == "*"); + } + return "comment"; + } + + function tokenString(quote) { + return function (stream, state) { + var escaped = false, next, end = false; + while ((next = stream.next()) != null) { + if (next == quote && !escaped) { + end = true; + break; + } + escaped = !escaped && next == "\\"; + } + if (end || !escaped) + state.tokenize = tokenBase; + return "string"; + }; + } + + return { + + startState: function () { + return { + tokenize: tokenBase, + currentIndent: 0, + doInCurrentLine: false, + hasPassedFirstStage: false + }; + }, + + token: function (stream, state) { + if (stream.sol()) + state.doInCurrentLine = 0; + + return state.tokenize(stream, state); + }, + + indent: function (state, textAfter) { + var trueText = textAfter.replace(/^\s+|\s+$/g, ''); + + if (trueText.match(endKeywords) || trueText.match(middleKeywords) || trueText.match(/(\[])/)) + return conf.indentUnit * (state.currentIndent - 1); + + if (state.currentIndent < 0) + return 0; + + return state.currentIndent * conf.indentUnit; + }, + fold: "indent", + electricChars: "eEdDtTnNiIoOfFhHyY[]", + lineComment: "%", + blockCommentStart: "/*", + blockCommentEnd: "*/" + }; +}); + +CodeMirror.defineMIME("text/x-oz", "oz"); + +}); From a2cc9c0a5551f634e498f8d7c7378ab793fe9eb3 Mon Sep 17 00:00:00 2001 From: Stephen Lavelle Date: Tue, 1 Sep 2015 13:02:32 +0100 Subject: [PATCH 0010/2444] [haxe mode] Don't close strings at end of line Closes #3492 --- mode/haxe/haxe.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mode/haxe/haxe.js b/mode/haxe/haxe.js index d49ad70f99..eb1ecd31c5 100644 --- a/mode/haxe/haxe.js +++ b/mode/haxe/haxe.js @@ -48,7 +48,7 @@ CodeMirror.defineMode("haxe", function(config, parserConfig) { return false; escaped = !escaped && next == "\\"; } - return escaped; + return true; } // Used as scratch variables to communicate multiple values without From 61ca2db598f3f1d79e837f326bc740e8bc49e62a Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Tue, 1 Sep 2015 15:26:56 +0200 Subject: [PATCH 0011/2444] [haxe mode] Clean up messy formatting --- mode/haxe/haxe.js | 131 ++++++++++++++++++++-------------------------- 1 file changed, 57 insertions(+), 74 deletions(-) diff --git a/mode/haxe/haxe.js b/mode/haxe/haxe.js index eb1ecd31c5..fd4a0df1e9 100644 --- a/mode/haxe/haxe.js +++ b/mode/haxe/haxe.js @@ -16,23 +16,21 @@ CodeMirror.defineMode("haxe", function(config, parserConfig) { // Tokenizer - var keywords = function(){ - function kw(type) {return {type: type, style: "keyword"};} - var A = kw("keyword a"), B = kw("keyword b"), C = kw("keyword c"); - var operator = kw("operator"), atom = {type: "atom", style: "atom"}, attribute = {type:"attribute", style: "attribute"}; + function kw(type) {return {type: type, style: "keyword"};} + var A = kw("keyword a"), B = kw("keyword b"), C = kw("keyword c"); + var operator = kw("operator"), atom = {type: "atom", style: "atom"}, attribute = {type:"attribute", style: "attribute"}; var type = kw("typedef"); - return { - "if": A, "while": A, "else": B, "do": B, "try": B, - "return": C, "break": C, "continue": C, "new": C, "throw": C, - "var": kw("var"), "inline":attribute, "static": attribute, "using":kw("import"), + var keywords = { + "if": A, "while": A, "else": B, "do": B, "try": B, + "return": C, "break": C, "continue": C, "new": C, "throw": C, + "var": kw("var"), "inline":attribute, "static": attribute, "using":kw("import"), "public": attribute, "private": attribute, "cast": kw("cast"), "import": kw("import"), "macro": kw("macro"), - "function": kw("function"), "catch": kw("catch"), "untyped": kw("untyped"), "callback": kw("cb"), - "for": kw("for"), "switch": kw("switch"), "case": kw("case"), "default": kw("default"), - "in": operator, "never": kw("property_access"), "trace":kw("trace"), + "function": kw("function"), "catch": kw("catch"), "untyped": kw("untyped"), "callback": kw("cb"), + "for": kw("for"), "switch": kw("switch"), "case": kw("case"), "default": kw("default"), + "in": operator, "never": kw("property_access"), "trace":kw("trace"), "class": type, "abstract":type, "enum":type, "interface":type, "typedef":type, "extends":type, "implements":type, "dynamic":type, - "true": atom, "false": atom, "null": atom - }; - }(); + "true": atom, "false": atom, "null": atom + }; var isOperatorChar = /[+\-*&%=<>!?|]/; @@ -41,14 +39,13 @@ CodeMirror.defineMode("haxe", function(config, parserConfig) { return f(stream, state); } - function nextUntilUnescaped(stream, end) { + function toUnescaped(stream, end) { var escaped = false, next; while ((next = stream.next()) != null) { if (next == end && !escaped) - return false; + return true; escaped = !escaped && next == "\\"; } - return true; } // Used as scratch variables to communicate multiple values without @@ -61,70 +58,58 @@ CodeMirror.defineMode("haxe", function(config, parserConfig) { function haxeTokenBase(stream, state) { var ch = stream.next(); - if (ch == '"' || ch == "'") + if (ch == '"' || ch == "'") { return chain(stream, state, haxeTokenString(ch)); - else if (/[\[\]{}\(\),;\:\.]/.test(ch)) + } else if (/[\[\]{}\(\),;\:\.]/.test(ch)) { return ret(ch); - else if (ch == "0" && stream.eat(/x/i)) { + } else if (ch == "0" && stream.eat(/x/i)) { stream.eatWhile(/[\da-f]/i); return ret("number", "number"); - } - else if (/\d/.test(ch) || ch == "-" && stream.eat(/\d/)) { + } else if (/\d/.test(ch) || ch == "-" && stream.eat(/\d/)) { stream.match(/^\d*(?:\.\d*)?(?:[eE][+\-]?\d+)?/); return ret("number", "number"); - } - else if (state.reAllowed && (ch == "~" && stream.eat(/\//))) { - nextUntilUnescaped(stream, "/"); + } else if (state.reAllowed && (ch == "~" && stream.eat(/\//))) { + toUnescaped(stream, "/"); stream.eatWhile(/[gimsu]/); return ret("regexp", "string-2"); - } - else if (ch == "/") { + } else if (ch == "/") { if (stream.eat("*")) { return chain(stream, state, haxeTokenComment); - } - else if (stream.eat("/")) { + } else if (stream.eat("/")) { stream.skipToEnd(); return ret("comment", "comment"); - } - else { + } else { stream.eatWhile(isOperatorChar); return ret("operator", null, stream.current()); } - } - else if (ch == "#") { + } else if (ch == "#") { stream.skipToEnd(); return ret("conditional", "meta"); - } - else if (ch == "@") { + } else if (ch == "@") { stream.eat(/:/); stream.eatWhile(/[\w_]/); return ret ("metadata", "meta"); - } - else if (isOperatorChar.test(ch)) { + } else if (isOperatorChar.test(ch)) { stream.eatWhile(isOperatorChar); return ret("operator", null, stream.current()); - } - else { - var word; - if(/[A-Z]/.test(ch)) - { - stream.eatWhile(/[\w_<>]/); - word = stream.current(); - return ret("type", "variable-3", word); - } - else - { + } else { + var word; + if(/[A-Z]/.test(ch)) { + stream.eatWhile(/[\w_<>]/); + word = stream.current(); + return ret("type", "variable-3", word); + } else { stream.eatWhile(/[\w_]/); var word = stream.current(), known = keywords.propertyIsEnumerable(word) && keywords[word]; return (known && state.kwAllowed) ? ret(known.type, known.style, word) : ret("variable", "variable", word); - } + } } } function haxeTokenString(quote) { return function(stream, state) { - if (!nextUntilUnescaped(stream, quote)) + if (toUnescaped(stream, quote)) state.tokenize = haxeTokenBase; return ret("string", "string"); }; @@ -176,27 +161,25 @@ CodeMirror.defineMode("haxe", function(config, parserConfig) { cc.pop()(); if (cx.marked) return cx.marked; if (type == "variable" && inScope(state, content)) return "variable-2"; - if (type == "variable" && imported(state, content)) return "variable-3"; + if (type == "variable" && imported(state, content)) return "variable-3"; return style; } } } - function imported(state, typename) - { - if (/[a-z]/.test(typename.charAt(0))) - return false; - var len = state.importedtypes.length; - for (var i = 0; i Date: Wed, 2 Sep 2015 12:07:43 +0200 Subject: [PATCH 0012/2444] [haxe mode] Fix indentation after braces and parsing of for specs Closes #3494 --- mode/haxe/haxe.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/mode/haxe/haxe.js b/mode/haxe/haxe.js index fd4a0df1e9..548cbe1b47 100644 --- a/mode/haxe/haxe.js +++ b/mode/haxe/haxe.js @@ -212,6 +212,7 @@ CodeMirror.defineMode("haxe", function(config, parserConfig) { cx.state.localVars = cx.state.context.vars; cx.state.context = cx.state.context.prev; } + popcontext.lex = true; function pushlex(type, info) { var result = function() { var state = cx.state; @@ -235,7 +236,7 @@ CodeMirror.defineMode("haxe", function(config, parserConfig) { if (type == wanted) return cont(); else if (wanted == ";") return pass(); else return cont(f); - }; + } return f; } @@ -348,8 +349,10 @@ CodeMirror.defineMode("haxe", function(config, parserConfig) { function forspec1(type, value) { if (type == "variable") { register(value); + return cont(forin, expression) + } else { + return pass() } - return cont(pushlex(")"), pushcontext, forin, expression, poplex, statement, popcontext); } function forin(_type, value) { if (value == "in") return cont(); @@ -378,7 +381,7 @@ CodeMirror.defineMode("haxe", function(config, parserConfig) { return { startState: function(basecolumn) { - var defaulttypes = ["Int", "Float", "String", "Void", "Std", "Bool", "Dynamic", "Array"]; + var defaulttypes = ["Int", "Float", "String", "Void", "Std", "Bool", "Dynamic", "Array"]; return { tokenize: haxeTokenBase, reAllowed: true, @@ -386,7 +389,7 @@ CodeMirror.defineMode("haxe", function(config, parserConfig) { cc: [], lexical: new HaxeLexical((basecolumn || 0) - indentUnit, 0, "block", false), localVars: parserConfig.localVars, - importedtypes: defaulttypes, + importedtypes: defaulttypes, context: parserConfig.localVars && {vars: parserConfig.localVars}, indented: 0 }; From 20e70382fd3e2f8cc8abeed732abd2399449bc36 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Wed, 2 Sep 2015 12:17:06 +0200 Subject: [PATCH 0013/2444] Add few more names for numpad keys Issue #2101 --- lib/codemirror.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/codemirror.js b/lib/codemirror.js index bf5c4064bd..d9d136a66c 100644 --- a/lib/codemirror.js +++ b/lib/codemirror.js @@ -8504,14 +8504,16 @@ // KEY NAMES - var keyNames = {3: "Enter", 8: "Backspace", 9: "Tab", 13: "Enter", 16: "Shift", 17: "Ctrl", 18: "Alt", - 19: "Pause", 20: "CapsLock", 27: "Esc", 32: "Space", 33: "PageUp", 34: "PageDown", 35: "End", - 36: "Home", 37: "Left", 38: "Up", 39: "Right", 40: "Down", 44: "PrintScrn", 45: "Insert", - 46: "Delete", 59: ";", 61: "=", 91: "Mod", 92: "Mod", 93: "Mod", 107: "=", 109: "-", 127: "Delete", - 173: "-", 186: ";", 187: "=", 188: ",", 189: "-", 190: ".", 191: "/", 192: "`", 219: "[", 220: "\\", - 221: "]", 222: "'", 63232: "Up", 63233: "Down", 63234: "Left", 63235: "Right", 63272: "Delete", - 63273: "Home", 63275: "End", 63276: "PageUp", 63277: "PageDown", 63302: "Insert"}; - CodeMirror.keyNames = keyNames; + var keyNames = CodeMirror.keyNames = { + 3: "Enter", 8: "Backspace", 9: "Tab", 13: "Enter", 16: "Shift", 17: "Ctrl", 18: "Alt", + 19: "Pause", 20: "CapsLock", 27: "Esc", 32: "Space", 33: "PageUp", 34: "PageDown", 35: "End", + 36: "Home", 37: "Left", 38: "Up", 39: "Right", 40: "Down", 44: "PrintScrn", 45: "Insert", + 46: "Delete", 59: ";", 61: "=", 91: "Mod", 92: "Mod", 93: "Mod", + 106: "*", 107: "=", 109: "-", 110: ".", 111: "/", 127: "Delete", + 173: "-", 186: ";", 187: "=", 188: ",", 189: "-", 190: ".", 191: "/", 192: "`", 219: "[", 220: "\\", + 221: "]", 222: "'", 63232: "Up", 63233: "Down", 63234: "Left", 63235: "Right", 63272: "Delete", + 63273: "Home", 63275: "End", 63276: "PageUp", 63277: "PageDown", 63302: "Insert" + }; (function() { // Number keys for (var i = 0; i < 10; i++) keyNames[i + 48] = keyNames[i + 96] = String(i); From 7a8197fc53c04f6130ae648cf8c2296b48753f3f Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Wed, 2 Sep 2015 12:37:00 +0200 Subject: [PATCH 0014/2444] [javascript mode] Don't open a form scope for import/export Closes #3458 --- mode/javascript/javascript.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mode/javascript/javascript.js b/mode/javascript/javascript.js index 4451d65b4f..a30872bfa9 100644 --- a/mode/javascript/javascript.js +++ b/mode/javascript/javascript.js @@ -348,8 +348,8 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { if (type == "catch") return cont(pushlex("form"), pushcontext, expect("("), funarg, expect(")"), statement, poplex, popcontext); if (type == "class") return cont(pushlex("form"), className, poplex); - if (type == "export") return cont(pushlex("form"), afterExport, poplex); - if (type == "import") return cont(pushlex("form"), afterImport, poplex); + if (type == "export") return cont(pushlex("stat"), afterExport, poplex); + if (type == "import") return cont(pushlex("stat"), afterImport, poplex); return pass(pushlex("stat"), expression, expect(";"), poplex); } function expression(type) { From 15e6088b0db36f76708d068b51a557bb7760e2dc Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Wed, 2 Sep 2015 12:51:01 +0200 Subject: [PATCH 0015/2444] [search addon] Add 'all' option in replace confirm dialog Issue #3431 --- addon/search/search.js | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/addon/search/search.js b/addon/search/search.js index 5ec6ed6fb1..adb2bccadd 100644 --- a/addon/search/search.js +++ b/addon/search/search.js @@ -158,7 +158,18 @@ var replaceQueryDialog = 'Replace: (Use /re/ syntax for regexp search)'; var replacementQueryDialog = 'With: '; - var doReplaceConfirm = "Replace? "; + var doReplaceConfirm = "Replace? "; + + function replaceAll(cm, query, text) { + cm.operation(function() { + for (var cursor = getSearchCursor(cm, query); cursor.findNext();) { + if (typeof query != "string") { + var match = cm.getRange(cursor.from(), cursor.to()).match(query); + cursor.replace(text.replace(/\$(\d)/g, function(_, i) {return match[i];})); + } else cursor.replace(text); + } + }); + } function replace(cm, all) { if (cm.getOption("readOnly")) return; @@ -169,14 +180,7 @@ dialog(cm, replacementQueryDialog, "Replace with:", "", function(text) { text = parseString(text) if (all) { - cm.operation(function() { - for (var cursor = getSearchCursor(cm, query); cursor.findNext();) { - if (typeof query != "string") { - var match = cm.getRange(cursor.from(), cursor.to()).match(query); - cursor.replace(text.replace(/\$(\d)/g, function(_, i) {return match[i];})); - } else cursor.replace(text); - } - }); + replaceAll(cm, query, text) } else { clearSearch(cm); var cursor = getSearchCursor(cm, query, cm.getCursor()); @@ -190,7 +194,8 @@ cm.setSelection(cursor.from(), cursor.to()); cm.scrollIntoView({from: cursor.from(), to: cursor.to()}); confirmDialog(cm, doReplaceConfirm, "Replace?", - [function() {doReplace(match);}, advance]); + [function() {doReplace(match);}, advance, + function() {replaceAll(cm, query, text)}]); }; var doReplace = function(match) { cursor.replace(typeof query == "string" ? text : From 5c27f7aeab457a6746e3fc906b61b250da6051d9 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Wed, 2 Sep 2015 12:54:07 +0200 Subject: [PATCH 0016/2444] [search addon] Say 'Replace all' in dialog when replacing all Issue #3431 --- addon/search/search.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/addon/search/search.js b/addon/search/search.js index adb2bccadd..122b86e45c 100644 --- a/addon/search/search.js +++ b/addon/search/search.js @@ -156,7 +156,7 @@ });} var replaceQueryDialog = - 'Replace: (Use /re/ syntax for regexp search)'; + ' (Use /re/ syntax for regexp search)'; var replacementQueryDialog = 'With: '; var doReplaceConfirm = "Replace? "; @@ -174,7 +174,8 @@ function replace(cm, all) { if (cm.getOption("readOnly")) return; var query = cm.getSelection() || getSearchState(cm).lastQuery; - dialog(cm, replaceQueryDialog, "Replace:", query, function(query) { + var dialogText = all ? "Replace all:" : "Replace:" + dialog(cm, dialogText + replaceQueryDialog, dialogText, query, function(query) { if (!query) return; query = parseQuery(query); dialog(cm, replacementQueryDialog, "Replace with:", "", function(text) { From f1b8de57027ea3146cd1a0b69f31e91a51b9777a Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Wed, 2 Sep 2015 13:09:50 +0200 Subject: [PATCH 0017/2444] [search addon] Make persistent dialog transparent when hiding current match Issue #3431 --- addon/search/search.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/addon/search/search.js b/addon/search/search.js index 122b86e45c..ac0f3254d7 100644 --- a/addon/search/search.js +++ b/addon/search/search.js @@ -117,11 +117,19 @@ if (state.query) return findNext(cm, rev); var q = cm.getSelection() || state.lastQuery; if (persistent && cm.openDialog) { + var hiding = null persistentDialog(cm, queryDialog, q, function(query, event) { CodeMirror.e_stop(event); if (!query) return; if (query != state.queryText) startSearch(cm, state, query); - findNext(cm, event.shiftKey); + if (hiding) hiding.style.opacity = 1 + findNext(cm, event.shiftKey, function(_, to) { + var dialog + if (to.line < 3 && document.querySelector && + (dialog = cm.display.wrapper.querySelector(".CodeMirror-dialog")) && + dialog.getBoundingClientRect().bottom - 4 > cm.cursorCoords(to, "window").top) + (hiding = dialog).style.opacity = .4 + }) }); } else { dialog(cm, queryDialog, "Search for:", q, function(query) { @@ -134,7 +142,7 @@ } } - function findNext(cm, rev) {cm.operation(function() { + function findNext(cm, rev, callback) {cm.operation(function() { var state = getSearchState(cm); var cursor = getSearchCursor(cm, state.query, rev ? state.posFrom : state.posTo); if (!cursor.find(rev)) { @@ -144,6 +152,7 @@ cm.setSelection(cursor.from(), cursor.to()); cm.scrollIntoView({from: cursor.from(), to: cursor.to()}, 20); state.posFrom = cursor.from(); state.posTo = cursor.to(); + if (callback) callback(cursor.from(), cursor.to()) });} function clearSearch(cm) {cm.operation(function() { From 7745cb96f1b6cfae9abaf87626a828e3d36f8ace Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Wed, 2 Sep 2015 13:27:29 +0200 Subject: [PATCH 0018/2444] [markdown mode] Allow cross-line code spans Closes #3386 --- mode/gfm/test.js | 4 +- mode/markdown/index.html | 311 +------------------------------------- mode/markdown/markdown.js | 4 +- mode/markdown/test.js | 4 +- 4 files changed, 7 insertions(+), 316 deletions(-) diff --git a/mode/gfm/test.js b/mode/gfm/test.js index c2bc38fd57..54d604880a 100644 --- a/mode/gfm/test.js +++ b/mode/gfm/test.js @@ -152,8 +152,8 @@ MT("notALink", "[comment `foo]", - "[link http://www.example.com/]", - "[comment `foo]", + "[comment&link http://www.example.com/]", + "[comment `] foo", "", "[link http://www.example.com/]"); diff --git a/mode/markdown/index.html b/mode/markdown/index.html index 15660c2618..d56d333aec 100644 --- a/mode/markdown/index.html +++ b/mode/markdown/index.html @@ -31,315 +31,8 @@

    Markdown mode

    -
    +
    + + + + +

    CodeMirror: MscGen mode

    + +
    + + + +

    MIME types defined: text/x-mscgen

    + + diff --git a/mode/mscgen/index_msgenny.html b/mode/mscgen/index_msgenny.html new file mode 100644 index 0000000000..1664f3051e --- /dev/null +++ b/mode/mscgen/index_msgenny.html @@ -0,0 +1,44 @@ + + + + + CodeMirror: msgenny mode + + + + + + +

    CodeMirror: msgenny mode

    + +
    + + + +

    MIME types defined: text/x-msgenny

    + + diff --git a/mode/mscgen/index_xu.html b/mode/mscgen/index_xu.html new file mode 100644 index 0000000000..2f7bf9ec04 --- /dev/null +++ b/mode/mscgen/index_xu.html @@ -0,0 +1,70 @@ + + + + + CodeMirror: xu mode + + + + + + +

    CodeMirror: xù mode

    + +
    + + + +

    MIME types defined: text/x-xu

    + + diff --git a/mode/mscgen/mscgen.js b/mode/mscgen/mscgen.js new file mode 100644 index 0000000000..090a208a78 --- /dev/null +++ b/mode/mscgen/mscgen.js @@ -0,0 +1,186 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: http://codemirror.net/LICENSE + +// mode(s) for the sequence chart dsl's mscgen, xù and msgenny +// For more information on mscgen, see the site of the original author: +// http://www.mcternan.me.uk/mscgen +// +// This mode for mscgen and the two derivative languages were +// originally made for use in the mscgen_js interpreter +// (https://sverweij.github.io/mscgen_js) + +(function(mod) { + if ( typeof exports == "object" && typeof module == "object")// CommonJS + mod(require("../../lib/codemirror")); + else if ( typeof define == "function" && define.amd)// AMD + define(["../../lib/codemirror"], mod); + else// Plain browser env + mod(CodeMirror); +})(function(CodeMirror) { + "use strict"; + + CodeMirror.defineMode("mscgen", function() { + return { + startState : startStateFn, + copyState : copyStateFn, + token : produceTokenFunction({ + "keywords" : ["msc"], + "options" : ["hscale", "width", "arcgradient", "wordwraparcs"], + "attributes" : ["label", "idurl", "id", "url", "linecolor", "linecolour", "textcolor", "textcolour", "textbgcolor", "textbgcolour", "arclinecolor", "arclinecolour", "arctextcolor", "arctextcolour", "arctextbgcolor", "arctextbgcolour", "arcskip"], + "brackets" : ["\\{", "\\}"], // [ and ] are brackets too, but these get handled in with lists + "arcsWords" : ["note", "abox", "rbox", "box"], + "arcsOthers" : ["\\|\\|\\|", "\\.\\.\\.", "---", "--", "<->", "==", "<<=>>", "<=>", "\\.\\.", "<<>>", "::", "<:>", "->", "=>>", "=>", ">>", ":>", "<-", "<<=", "<=", "<<", "<:", "x-", "-x"], + "singlecomment" : ["//", "#"], + "operators" : ["="] + }), + lineComment : "#", + blockCommentStart : "/*", + blockCommentEnd : "*/" + }; + }); + CodeMirror.defineMIME("text/x-mscgen", "mscgen"); + + CodeMirror.defineMode("xu", function() { + return { + startState : startStateFn, + copyState : copyStateFn, + token : produceTokenFunction({ + "keywords" : ["msc"], + "options" : ["hscale", "width", "arcgradient", "wordwraparcs", "watermark"], + "attributes" : ["label", "idurl", "id", "url", "linecolor", "linecolour", "textcolor", "textcolour", "textbgcolor", "textbgcolour", "arclinecolor", "arclinecolour", "arctextcolor", "arctextcolour", "arctextbgcolor", "arctextbgcolour", "arcskip"], + "brackets" : ["\\{", "\\}"], // [ and ] are brackets too, but these get handled in with lists + "arcsWords" : ["note", "abox", "rbox", "box", "alt", "else", "opt", "break", "par", "seq", "strict", "neg", "critical", "ignore", "consider", "assert", "loop", "ref", "exc"], + "arcsOthers" : ["\\|\\|\\|", "\\.\\.\\.", "---", "--", "<->", "==", "<<=>>", "<=>", "\\.\\.", "<<>>", "::", "<:>", "->", "=>>", "=>", ">>", ":>", "<-", "<<=", "<=", "<<", "<:", "x-", "-x"], + "singlecomment" : ["//", "#"], + "operators" : ["="] + }), + lineComment : "#", + blockCommentStart : "/*", + blockCommentEnd : "*/" + }; + }); + CodeMirror.defineMIME("text/x-xu", "xu"); + + CodeMirror.defineMode("msgenny", function() { + return { + startState : startStateFn, + copyState : copyStateFn, + token : produceTokenFunction({ + "keywords" : null, + "options" : ["hscale", "width", "arcgradient", "wordwraparcs", "watermark"], + "attributes" : null, + "brackets" : ["\\{", "\\}"], + "arcsWords" : ["note", "abox", "rbox", "box", "alt", "else", "opt", "break", "par", "seq", "strict", "neg", "critical", "ignore", "consider", "assert", "loop", "ref", "exc"], + "arcsOthers" : ["\\|\\|\\|", "\\.\\.\\.", "---", "--", "<->", "==", "<<=>>", "<=>", "\\.\\.", "<<>>", "::", "<:>", "->", "=>>", "=>", ">>", ":>", "<-", "<<=", "<=", "<<", "<:", "x-", "-x"], + "singlecomment" : ["//", "#"], + "operators" : ["="] + }), + lineComment : "#", + blockCommentStart : "/*", + blockCommentEnd : "*/" + + }; + }); + CodeMirror.defineMIME("text/x-msgenny", "msgenny"); + + function wordRegexpBoundary(pWords) { + return new RegExp("\\b((" + pWords.join(")|(") + "))\\b", "i"); + } + + function wordRegexp(pWords) { + return new RegExp("((" + pWords.join(")|(") + "))", "i"); + } + + function startStateFn() { + return { + inComment : false, + inString : false, + inAttributeList : false, + inScript : false + }; + } + + function copyStateFn(pState) { + return { + inComment : pState.inComment, + inString : pState.inString, + inAttributeList : pState.inAttributeList, + inScript : pState.inScript + }; + } + + function produceTokenFunction(pConfig) { + + return function(pStream, pState) { + if (pStream.match(wordRegexp(pConfig.brackets), true, true)) { + return "bracket"; + } + /* comments */ + if (!pState.inComment) { + if (pStream.match(/\/\*[^\*\/]*/, true, true)) { + pState.inComment = true; + return "comment"; + } + if (pStream.match(wordRegexp(pConfig.singlecomment), true, true)) { + pStream.skipToEnd(); + return "comment"; + } + } + if (pState.inComment) { + if (pStream.match(/[^\*\/]*\*\//, true, true)) { + pState.inComment = false; + } else { + pStream.skipToEnd(); + } + return "comment"; + } + /* strings */ + if (!pState.inString && pStream.match(/\"(\\\"|[^\"])*/, true, true)) { + pState.inString = true; + return "string"; + } + if (pState.inString) { + if (pStream.match(/[^\"]*\"/, true, true)) { + pState.inString = false; + } else { + pStream.skipToEnd(); + } + return "string"; + } + /* keywords & operators */ + if (!!pConfig.keywords && pStream.match(wordRegexpBoundary(pConfig.keywords), true, true)) { + return "keyword"; + } + if (pStream.match(wordRegexpBoundary(pConfig.options), true, true)) { + return "keyword"; + } + if (pStream.match(wordRegexpBoundary(pConfig.arcsWords), true, true)) { + return "keyword"; + } + if (pStream.match(wordRegexp(pConfig.arcsOthers), true, true)) { + return "keyword"; + } + if (!!pConfig.operators && pStream.match(wordRegexp(pConfig.operators), true, true)) { + return "operator"; + } + /* attribute lists */ + if (!pConfig.inAttributeList && !!pConfig.attributes && pStream.match(/\[/, true, true)) { + pConfig.inAttributeList = true; + return "bracket"; + } + if (pConfig.inAttributeList) { + if (pConfig.attributes !== null && pStream.match(wordRegexpBoundary(pConfig.attributes), true, true)) { + return "attribute"; + } + if (pStream.match(/]/, true, true)) { + pConfig.inAttributeList = false; + return "bracket"; + } + } + + pStream.next(); + return "base"; + }; + } + +}); diff --git a/mode/mscgen/mscgen_test.js b/mode/mscgen/mscgen_test.js new file mode 100644 index 0000000000..e319a3997e --- /dev/null +++ b/mode/mscgen/mscgen_test.js @@ -0,0 +1,75 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: http://codemirror.net/LICENSE + +(function() { + var mode = CodeMirror.getMode({indentUnit: 2}, "mscgen"); + function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); } + + MT("empty chart", + "[keyword msc][bracket {]", + "[base ]", + "[bracket }]" + ); + + MT("comments", + "[comment // a single line comment]", + "[comment # another single line comment /* and */ ignored here]", + "[comment /* A multi-line comment even though it contains]", + "[comment msc keywords and \"quoted text\"*/]"); + + MT("strings", + "[string \"// a string\"]", + "[string \"a string running over]", + "[string two lines\"]", + "[string \"with \\\"escaped quote\"]" + ); + + MT("xù/ msgenny keywords classify as 'base'", + "[base watermark]", + "[base alt loop opt ref else break par seq assert]" + ); + + MT("mscgen options classify as keyword", + "[keyword hscale]", "[keyword width]", "[keyword arcgradient]", "[keyword wordwraparcs]" + ); + + MT("mscgen arcs classify as keyword", + "[keyword note]","[keyword abox]","[keyword rbox]","[keyword box]", + "[keyword |||...---]", "[keyword ..--==::]", + "[keyword ->]", "[keyword <-]", "[keyword <->]", + "[keyword =>]", "[keyword <=]", "[keyword <=>]", + "[keyword =>>]", "[keyword <<=]", "[keyword <<=>>]", + "[keyword >>]", "[keyword <<]", "[keyword <<>>]", + "[keyword -x]", "[keyword x-]", "[keyword -X]", "[keyword X-]", + "[keyword :>]", "[keyword <:]", "[keyword <:>]" + ); + + MT("within an attribute list, attributes classify as attribute", + "[bracket [[][attribute label]", + "[attribute id]","[attribute url]","[attribute idurl]", + "[attribute linecolor]","[attribute linecolour]","[attribute textcolor]","[attribute textcolour]","[attribute textbgcolor]","[attribute textbgcolour]", + "[attribute arclinecolor]","[attribute arclinecolour]","[attribute arctextcolor]","[attribute arctextcolour]","[attribute arctextbgcolor]","[attribute arctextbgcolour]", + "[attribute arcskip][bracket ]]]" + ); + + MT("outside an attribute list, attributes classify as base", + "[base label]", + "[base id]","[base url]","[base idurl]", + "[base linecolor]","[base linecolour]","[base textcolor]","[base textcolour]","[base textbgcolor]","[base textbgcolour]", + "[base arclinecolor]","[base arclinecolour]","[base arctextcolor]","[base arctextcolour]","[base arctextbgcolor]","[base arctextbgcolour]", + "[base arcskip]" + ); + + MT("a typical program", + "[comment # typical mscgen program]", + "[keyword msc][base ][bracket {]", + "[keyword wordwraparcs][operator =][string \"true\"][base , ][keyword hscale][operator =][string \"0.8\"][keyword arcgradient][operator =][base 30;]", + "[base a][bracket [[][attribute label][operator =][string \"Entity A\"][bracket ]]][base ,]", + "[base b][bracket [[][attribute label][operator =][string \"Entity B\"][bracket ]]][base ,]", + "[base c][bracket [[][attribute label][operator =][string \"Entity C\"][bracket ]]][base ;]", + "[base a ][keyword =>>][base b][bracket [[][attribute label][operator =][string \"Hello entity B\"][bracket ]]][base ;]", + "[base a ][keyword <<][base b][bracket [[][attribute label][operator =][string \"Here's an answer dude!\"][bracket ]]][base ;]", + "[base c ][keyword :>][base *][bracket [[][attribute label][operator =][string \"What about me?\"][base , ][attribute textcolor][operator =][base red][bracket ]]][base ;]", + "[bracket }]" + ); +})(); diff --git a/mode/mscgen/msgenny_test.js b/mode/mscgen/msgenny_test.js new file mode 100644 index 0000000000..6e9ab16535 --- /dev/null +++ b/mode/mscgen/msgenny_test.js @@ -0,0 +1,71 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: http://codemirror.net/LICENSE + +(function() { + var mode = CodeMirror.getMode({indentUnit: 2}, "msgenny"); + function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); } + + MT("comments", + "[comment // a single line comment]", + "[comment # another single line comment /* and */ ignored here]", + "[comment /* A multi-line comment even though it contains]", + "[comment msc keywords and \"quoted text\"*/]"); + + MT("strings", + "[string \"// a string\"]", + "[string \"a string running over]", + "[string two lines\"]", + "[string \"with \\\"escaped quote\"]" + ); + + MT("xù/ msgenny keywords classify as 'keyword'", + "[keyword watermark]", + "[keyword alt]","[keyword loop]","[keyword opt]","[keyword ref]","[keyword else]","[keyword break]","[keyword par]","[keyword seq]","[keyword assert]" + ); + + MT("mscgen options classify as keyword", + "[keyword hscale]", "[keyword width]", "[keyword arcgradient]", "[keyword wordwraparcs]" + ); + + MT("mscgen arcs classify as keyword", + "[keyword note]","[keyword abox]","[keyword rbox]","[keyword box]", + "[keyword |||...---]", "[keyword ..--==::]", + "[keyword ->]", "[keyword <-]", "[keyword <->]", + "[keyword =>]", "[keyword <=]", "[keyword <=>]", + "[keyword =>>]", "[keyword <<=]", "[keyword <<=>>]", + "[keyword >>]", "[keyword <<]", "[keyword <<>>]", + "[keyword -x]", "[keyword x-]", "[keyword -X]", "[keyword X-]", + "[keyword :>]", "[keyword <:]", "[keyword <:>]" + ); + + MT("within an attribute list, mscgen/ xù attributes classify as base", + "[base [[label]", + "[base idurl id url]", + "[base linecolor linecolour textcolor textcolour textbgcolor textbgcolour]", + "[base arclinecolor arclinecolour arctextcolor arctextcolour arctextbgcolor arctextbgcolour]", + "[base arcskip]]]" + ); + + MT("outside an attribute list, mscgen/ xù attributes classify as base", + "[base label]", + "[base idurl id url]", + "[base linecolor linecolour textcolor textcolour textbgcolor textbgcolour]", + "[base arclinecolor arclinecolour arctextcolor arctextcolour arctextbgcolor arctextbgcolour]", + "[base arcskip]" + ); + + MT("a typical program", + "[comment # typical msgenny program]", + "[keyword wordwraparcs][operator =][string \"true\"][base , ][keyword hscale][operator =][string \"0.8\"][base , ][keyword arcgradient][operator =][base 30;]", + "[base a : ][string \"Entity A\"][base ,]", + "[base b : Entity B,]", + "[base c : Entity C;]", + "[base a ][keyword =>>][base b: ][string \"Hello entity B\"][base ;]", + "[base a ][keyword alt][base c][bracket {]", + "[base a ][keyword <<][base b: ][string \"Here's an answer dude!\"][base ;]", + "[keyword ---][base : ][string \"sorry, won't march - comm glitch\"]", + "[base a ][keyword x-][base b: ][string \"Here's an answer dude! (won't arrive...)\"][base ;]", + "[bracket }]", + "[base c ][keyword :>][base *: What about me?;]" + ); +})(); diff --git a/mode/mscgen/xu_test.js b/mode/mscgen/xu_test.js new file mode 100644 index 0000000000..ada8dd1046 --- /dev/null +++ b/mode/mscgen/xu_test.js @@ -0,0 +1,75 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: http://codemirror.net/LICENSE + +(function() { + var mode = CodeMirror.getMode({indentUnit: 2}, "xu"); + function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); } + + MT("empty chart", + "[keyword msc][bracket {]", + "[base ]", + "[bracket }]" + ); + + MT("comments", + "[comment // a single line comment]", + "[comment # another single line comment /* and */ ignored here]", + "[comment /* A multi-line comment even though it contains]", + "[comment msc keywords and \"quoted text\"*/]"); + + MT("strings", + "[string \"// a string\"]", + "[string \"a string running over]", + "[string two lines\"]", + "[string \"with \\\"escaped quote\"]" + ); + + MT("xù/ msgenny keywords classify as 'keyword'", + "[keyword watermark]", + "[keyword alt]","[keyword loop]","[keyword opt]","[keyword ref]","[keyword else]","[keyword break]","[keyword par]","[keyword seq]","[keyword assert]" + ); + + MT("mscgen options classify as keyword", + "[keyword hscale]", "[keyword width]", "[keyword arcgradient]", "[keyword wordwraparcs]" + ); + + MT("mscgen arcs classify as keyword", + "[keyword note]","[keyword abox]","[keyword rbox]","[keyword box]", + "[keyword |||...---]", "[keyword ..--==::]", + "[keyword ->]", "[keyword <-]", "[keyword <->]", + "[keyword =>]", "[keyword <=]", "[keyword <=>]", + "[keyword =>>]", "[keyword <<=]", "[keyword <<=>>]", + "[keyword >>]", "[keyword <<]", "[keyword <<>>]", + "[keyword -x]", "[keyword x-]", "[keyword -X]", "[keyword X-]", + "[keyword :>]", "[keyword <:]", "[keyword <:>]" + ); + + MT("within an attribute list, attributes classify as attribute", + "[bracket [[][attribute label]", + "[attribute id]","[attribute url]","[attribute idurl]", + "[attribute linecolor]","[attribute linecolour]","[attribute textcolor]","[attribute textcolour]","[attribute textbgcolor]","[attribute textbgcolour]", + "[attribute arclinecolor]","[attribute arclinecolour]","[attribute arctextcolor]","[attribute arctextcolour]","[attribute arctextbgcolor]","[attribute arctextbgcolour]", + "[attribute arcskip][bracket ]]]" + ); + + MT("outside an attribute list, attributes classify as base", + "[base label]", + "[base id]","[base url]","[base idurl]", + "[base linecolor]","[base linecolour]","[base textcolor]","[base textcolour]","[base textbgcolor]","[base textbgcolour]", + "[base arclinecolor]","[base arclinecolour]","[base arctextcolor]","[base arctextcolour]","[base arctextbgcolor]","[base arctextbgcolour]", + "[base arcskip]" + ); + + MT("a typical program", + "[comment # typical mscgen program]", + "[keyword msc][base ][bracket {]", + "[keyword wordwraparcs][operator =][string \"true\"][keyword hscale][operator =][string \"0.8\"][keyword arcgradient][operator =][base 30;]", + "[base a][bracket [[][attribute label][operator =][string \"Entity A\"][bracket ]]][base ,]", + "[base b][bracket [[][attribute label][operator =][string \"Entity B\"][bracket ]]][base ,]", + "[base c][bracket [[][attribute label][operator =][string \"Entity C\"][bracket ]]][base ;]", + "[base a ][keyword =>>][base b][bracket [[][attribute label][operator =][string \"Hello entity B\"][bracket ]]][base ;]", + "[base a ][keyword <<][base b][bracket [[][attribute label][operator =][string \"Here's an answer dude!\"][bracket ]]][base ;]", + "[base c ][keyword :>][base *][bracket [[][attribute label][operator =][string \"What about me?\"][base , ][attribute textcolor][operator =][base red][bracket ]]][base ;]", + "[bracket }]" + ); +})(); diff --git a/test/index.html b/test/index.html index 23d3fa5e57..b0b1fa976b 100644 --- a/test/index.html +++ b/test/index.html @@ -38,6 +38,7 @@ + - - -

    CodeMirror: MscGen mode

    + +CodeMirror: Oz mode + + + + + + + + + +
    +

    MscGen mode

    +

    Kotlin mode

    + +
    + + diff --git a/mode/kotlin/index.html b/mode/kotlin/index.html deleted file mode 100644 index 859e109fb8..0000000000 --- a/mode/kotlin/index.html +++ /dev/null @@ -1,89 +0,0 @@ - - -CodeMirror: Kotlin mode - - - - - - - - - -
    -

    Kotlin mode

    - - -
    - - -

    Mode for Kotlin (http://kotlin.jetbrains.org/)

    -

    Developed by Hadi Hariri (https://github.com/hhariri).

    -

    MIME type defined: text/x-kotlin.

    -
    diff --git a/mode/kotlin/kotlin.js b/mode/kotlin/kotlin.js deleted file mode 100644 index e9a6a94e64..0000000000 --- a/mode/kotlin/kotlin.js +++ /dev/null @@ -1,284 +0,0 @@ -// CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE - -(function(mod) { - if (typeof exports == "object" && typeof module == "object") // CommonJS - mod(require("../../lib/codemirror")); - else if (typeof define == "function" && define.amd) // AMD - define(["../../lib/codemirror"], mod); - else // Plain browser env - mod(CodeMirror); -})(function(CodeMirror) { -"use strict"; - -CodeMirror.defineMode("kotlin", function (config, parserConfig) { - function words(str) { - var obj = {}, words = str.split(" "); - for (var i = 0; i < words.length; ++i) obj[words[i]] = true; - return obj; - } - - var multiLineStrings = parserConfig.multiLineStrings; - - var keywords = words( - "package continue return object while break class data trait interface throw super" + - " when type this else This try val var fun for is in if do as true false null get set"); - var softKeywords = words("import" + - " where by get set abstract enum open annotation override private public internal" + - " protected catch out vararg inline finally final ref"); - var blockKeywords = words("catch class do else finally for if where try while enum"); - var atoms = words("null true false this"); - - var curPunc; - - function tokenBase(stream, state) { - var ch = stream.next(); - if (ch == '"' || ch == "'") { - return startString(ch, stream, state); - } - // Wildcard import w/o trailing semicolon (import smth.*) - if (ch == "." && stream.eat("*")) { - return "word"; - } - if (/[\[\]{}\(\),;\:\.]/.test(ch)) { - curPunc = ch; - return null; - } - if (/\d/.test(ch)) { - if (stream.eat(/eE/)) { - stream.eat(/\+\-/); - stream.eatWhile(/\d/); - } - return "number"; - } - if (ch == "/") { - if (stream.eat("*")) { - state.tokenize.push(tokenComment); - return tokenComment(stream, state); - } - if (stream.eat("/")) { - stream.skipToEnd(); - return "comment"; - } - if (expectExpression(state.lastToken)) { - return startString(ch, stream, state); - } - } - // Commented - if (ch == "-" && stream.eat(">")) { - curPunc = "->"; - return null; - } - if (/[\-+*&%=<>!?|\/~]/.test(ch)) { - stream.eatWhile(/[\-+*&%=<>|~]/); - return "operator"; - } - stream.eatWhile(/[\w\$_]/); - - var cur = stream.current(); - if (atoms.propertyIsEnumerable(cur)) { - return "atom"; - } - if (softKeywords.propertyIsEnumerable(cur)) { - if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement"; - return "softKeyword"; - } - - if (keywords.propertyIsEnumerable(cur)) { - if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement"; - return "keyword"; - } - return "word"; - } - - tokenBase.isBase = true; - - function startString(quote, stream, state) { - var tripleQuoted = false; - if (quote != "/" && stream.eat(quote)) { - if (stream.eat(quote)) tripleQuoted = true; - else return "string"; - } - function t(stream, state) { - var escaped = false, next, end = !tripleQuoted; - - while ((next = stream.next()) != null) { - if (next == quote && !escaped) { - if (!tripleQuoted) { - break; - } - if (stream.match(quote + quote)) { - end = true; - break; - } - } - - if (quote == '"' && next == "$" && !escaped && stream.eat("{")) { - state.tokenize.push(tokenBaseUntilBrace()); - return "string"; - } - - if (next == "$" && !escaped && !stream.eat(" ")) { - state.tokenize.push(tokenBaseUntilSpace()); - return "string"; - } - escaped = !escaped && next == "\\"; - } - if (multiLineStrings) - state.tokenize.push(t); - if (end) state.tokenize.pop(); - return "string"; - } - - state.tokenize.push(t); - return t(stream, state); - } - - function tokenBaseUntilBrace() { - var depth = 1; - - function t(stream, state) { - if (stream.peek() == "}") { - depth--; - if (depth == 0) { - state.tokenize.pop(); - return state.tokenize[state.tokenize.length - 1](stream, state); - } - } else if (stream.peek() == "{") { - depth++; - } - return tokenBase(stream, state); - } - - t.isBase = true; - return t; - } - - function tokenBaseUntilSpace() { - function t(stream, state) { - if (stream.eat(/[\w]/)) { - var isWord = stream.eatWhile(/[\w]/); - if (isWord) { - state.tokenize.pop(); - return "word"; - } - } - state.tokenize.pop(); - return "string"; - } - - t.isBase = true; - return t; - } - - function tokenComment(stream, state) { - var maybeEnd = false, ch; - while (ch = stream.next()) { - if (ch == "/" && maybeEnd) { - state.tokenize.pop(); - break; - } - maybeEnd = (ch == "*"); - } - return "comment"; - } - - function expectExpression(last) { - return !last || last == "operator" || last == "->" || /[\.\[\{\(,;:]/.test(last) || - last == "newstatement" || last == "keyword" || last == "proplabel"; - } - - function Context(indented, column, type, align, prev) { - this.indented = indented; - this.column = column; - this.type = type; - this.align = align; - this.prev = prev; - } - - function pushContext(state, col, type) { - return state.context = new Context(state.indented, col, type, null, state.context); - } - - function popContext(state) { - var t = state.context.type; - if (t == ")" || t == "]" || t == "}") - state.indented = state.context.indented; - return state.context = state.context.prev; - } - - // Interface - - return { - startState: function (basecolumn) { - return { - tokenize: [tokenBase], - context: new Context((basecolumn || 0) - config.indentUnit, 0, "top", false), - indented: 0, - startOfLine: true, - lastToken: null - }; - }, - - token: function (stream, state) { - var ctx = state.context; - if (stream.sol()) { - if (ctx.align == null) ctx.align = false; - state.indented = stream.indentation(); - state.startOfLine = true; - // Automatic semicolon insertion - if (ctx.type == "statement" && !expectExpression(state.lastToken)) { - popContext(state); - ctx = state.context; - } - } - if (stream.eatSpace()) return null; - curPunc = null; - var style = state.tokenize[state.tokenize.length - 1](stream, state); - if (style == "comment") return style; - if (ctx.align == null) ctx.align = true; - if ((curPunc == ";" || curPunc == ":") && ctx.type == "statement") popContext(state); - // Handle indentation for {x -> \n ... } - else if (curPunc == "->" && ctx.type == "statement" && ctx.prev.type == "}") { - popContext(state); - state.context.align = false; - } - else if (curPunc == "{") pushContext(state, stream.column(), "}"); - else if (curPunc == "[") pushContext(state, stream.column(), "]"); - else if (curPunc == "(") pushContext(state, stream.column(), ")"); - else if (curPunc == "}") { - while (ctx.type == "statement") ctx = popContext(state); - if (ctx.type == "}") ctx = popContext(state); - while (ctx.type == "statement") ctx = popContext(state); - } - else if (curPunc == ctx.type) popContext(state); - else if (ctx.type == "}" || ctx.type == "top" || (ctx.type == "statement" && curPunc == "newstatement")) - pushContext(state, stream.column(), "statement"); - state.startOfLine = false; - state.lastToken = curPunc || style; - return style; - }, - - indent: function (state, textAfter) { - if (!state.tokenize[state.tokenize.length - 1].isBase) return 0; - var firstChar = textAfter && textAfter.charAt(0), ctx = state.context; - if (ctx.type == "statement" && !expectExpression(state.lastToken)) ctx = ctx.prev; - var closing = firstChar == ctx.type; - if (ctx.type == "statement") { - return ctx.indented + (firstChar == "{" ? 0 : config.indentUnit); - } - else if (ctx.align) return ctx.column + (closing ? 0 : 1); - else return ctx.indented + (closing ? 0 : config.indentUnit); - }, - - closeBrackets: {triples: "'\""}, - electricChars: "{}", - blockCommentStart: "/*", - blockCommentEnd: "*/", - lineComment: "//" - }; -}); - -CodeMirror.defineMIME("text/x-kotlin", "kotlin"); - -}); From af0ac949bea5fec9ea7121618db14bc8927789b7 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Tue, 22 Sep 2015 13:16:27 +0200 Subject: [PATCH 0062/2444] [kotlin mode] Update/remove references to stand-alone mode --- doc/compress.html | 1 - mode/meta.js | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/doc/compress.html b/doc/compress.html index 218cacc2f0..0b11e1362c 100644 --- a/doc/compress.html +++ b/doc/compress.html @@ -154,7 +154,6 @@

    Script compression helper

    - diff --git a/mode/meta.js b/mode/meta.js index 3a14dfc588..da03716be8 100644 --- a/mode/meta.js +++ b/mode/meta.js @@ -70,7 +70,7 @@ {name: "JSON-LD", mime: "application/ld+json", mode: "javascript", ext: ["jsonld"], alias: ["jsonld"]}, {name: "Jinja2", mime: "null", mode: "jinja2"}, {name: "Julia", mime: "text/x-julia", mode: "julia", ext: ["jl"]}, - {name: "Kotlin", mime: "text/x-kotlin", mode: "kotlin", ext: ["kt"]}, + {name: "Kotlin", mime: "text/x-kotlin", mode: "clike", ext: ["kt"]}, {name: "LESS", mime: "text/x-less", mode: "css", ext: ["less"]}, {name: "LiveScript", mime: "text/x-livescript", mode: "livescript", ext: ["ls"], alias: ["ls"]}, {name: "Lua", mime: "text/x-lua", mode: "lua", ext: ["lua"]}, From b0d525acc5db0eb6cd2fa67c564057d6b89bca37 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Tue, 22 Sep 2015 15:01:45 +0200 Subject: [PATCH 0063/2444] [show-hint addon] Allow hinting functions to support selection Issue #3525 --- addon/hint/show-hint.js | 98 +++++++++++++++++++++++++++++++---------- doc/manual.html | 5 ++- 2 files changed, 79 insertions(+), 24 deletions(-) diff --git a/addon/hint/show-hint.js b/addon/hint/show-hint.js index 980da5235d..649d959e99 100644 --- a/addon/hint/show-hint.js +++ b/addon/hint/show-hint.js @@ -25,8 +25,18 @@ }; CodeMirror.defineExtension("showHint", function(options) { - // We want a single cursor position. - if (this.listSelections().length > 1 || this.somethingSelected()) return; + options = parseOptions(this, options); + var selections = this.listSelections() + if (selections.length > 1) return; + // By default, don't allow completion when something is selected. + // A hint function can have a `supportsSelection` property to + // indicate that it can handle selections. + if (this.somethingSelected()) { + if (!options.hint.supportsSelection) return; + // Don't try with cross-line selections + for (var i = 0; i < selections.length; i++) + if (selections[i].head.line != selections[i].anchor.line) return; + } if (this.state.completionActive) this.state.completionActive.close(); var completion = this.state.completionActive = new Completion(this, options); @@ -38,12 +48,12 @@ function Completion(cm, options) { this.cm = cm; - this.options = this.buildOptions(options); + this.options = options; this.widget = null; this.debounce = 0; this.tick = 0; - this.startPos = this.cm.getCursor(); - this.startLen = this.cm.getLine(this.startPos.line).length; + this.startPos = this.cm.getCursor("start"); + this.startLen = this.cm.getLine(this.startPos.line).length - this.cm.getSelection().length; var self = this; cm.on("cursorActivity", this.activityFunc = function() { self.cursorActivity(); }); @@ -124,20 +134,21 @@ CodeMirror.signal(data, "shown"); } } - }, - - buildOptions: function(options) { - var editor = this.cm.options.hintOptions; - var out = {}; - for (var prop in defaultOptions) out[prop] = defaultOptions[prop]; - if (editor) for (var prop in editor) - if (editor[prop] !== undefined) out[prop] = editor[prop]; - if (options) for (var prop in options) - if (options[prop] !== undefined) out[prop] = options[prop]; - return out; } }; + function parseOptions(cm, pos, options) { + var editor = cm.options.hintOptions; + var out = {}; + for (var prop in defaultOptions) out[prop] = defaultOptions[prop]; + if (editor) for (var prop in editor) + if (editor[prop] !== undefined) out[prop] = editor[prop]; + if (options) for (var prop in options) + if (options[prop] !== undefined) out[prop] = options[prop]; + if (out.hint.resolve) out.hint = out.hint.resolve(cm, pos) + return out; + } + function getText(completion) { if (typeof completion == "string") return completion; else return completion.text; @@ -336,18 +347,59 @@ } }; - CodeMirror.registerHelper("hint", "auto", function(cm, options) { - var helpers = cm.getHelpers(cm.getCursor(), "hint"), words; + function applicableHelpers(cm, helpers) { + if (!cm.somethingSelected()) return helpers + var result = [] + for (var i = 0; i < helpers.length; i++) + if (helpers[i].supportsSelection) result.push(helpers[i]) + return result + } + + function resolveAutoHints(cm, pos) { + var helpers = cm.getHelpers(pos, "hint"), words if (helpers.length) { - for (var i = 0; i < helpers.length; i++) { - var cur = helpers[i](cm, options); - if (cur && cur.list.length) return cur; + var async = false, resolved + for (var i = 0; i < helpers.length; i++) if (helpers[i].async) async = true + if (async) { + resolved = function(cm, callback, options) { + var app = applicableHelpers(cm, helpers) + function run(i, result) { + if (i == app.length) return callback(null) + var helper = app[i] + if (helper.async) { + helper(cm, function(result) { + if (result) callback(result) + else run(i + 1) + }, options) + } else { + var result = helper(cm, options) + if (result) callback(result) + else run(i + 1) + } + } + run(0) + } + resolved.async = true + } else { + resolved = function(cm, options) { + var app = applicableHelpers(cm, helpers) + for (var i = 0; i < app.length; i++) { + var cur = app[i](cm, options) + if (cur && cur.list.length) return cur + } + } } + resolved.supportsSelection = true + return resolved } else if (words = cm.getHelper(cm.getCursor(), "hintWords")) { - if (words) return CodeMirror.hint.fromList(cm, {words: words}); + return function(cm) { return CodeMirror.hint.fromList(cm, {words: words}) } } else if (CodeMirror.hint.anyword) { - return CodeMirror.hint.anyword(cm, options); + return function(cm, options) { return CodeMirror.hint.anyword(cm, options) } } + } + + CodeMirror.registerHelper("hint", "auto", { + resolve: resolveAutoHints }); CodeMirror.registerHelper("hint", "fromList", function(cm, options) { diff --git a/doc/manual.html b/doc/manual.html index 44635b843c..e2a3269d6b 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -2549,7 +2549,10 @@

    Addons

    arguments (cm, callback, ?options), and the completion interface will only be popped up when the hinting function calls the callback, passing it the object holding the - completions. + completions. By default, hinting only works when there is no + selection. You can give a hinting function + a supportsSelection property with a truthy value + to indicate that it supports selections.
    completeSingle: boolean
    Determines whether, when only a single completion is available, it is completed without showing the dialog. From eac558597f753a64940a8e5aaef051de288218bf Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Wed, 23 Sep 2015 09:43:44 +0200 Subject: [PATCH 0064/2444] [show-hint addon] Fix bugs introduced by supportsSelection changes Issue #3525 --- addon/hint/show-hint.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addon/hint/show-hint.js b/addon/hint/show-hint.js index 649d959e99..a1e56c38be 100644 --- a/addon/hint/show-hint.js +++ b/addon/hint/show-hint.js @@ -25,7 +25,7 @@ }; CodeMirror.defineExtension("showHint", function(options) { - options = parseOptions(this, options); + options = parseOptions(this, this.getCursor("start"), options); var selections = this.listSelections() if (selections.length > 1) return; // By default, don't allow completion when something is selected. @@ -395,6 +395,8 @@ return function(cm) { return CodeMirror.hint.fromList(cm, {words: words}) } } else if (CodeMirror.hint.anyword) { return function(cm, options) { return CodeMirror.hint.anyword(cm, options) } + } else { + return function() {} } } From d708748a9c37db8757d06a9baa63b3c3d2ddbae2 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Fri, 25 Sep 2015 11:10:28 +0200 Subject: [PATCH 0065/2444] [hardwrap demo] Make less prone to infinite loops Issue #3548 --- demo/hardwrap.html | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/demo/hardwrap.html b/demo/hardwrap.html index f1a870b41c..84ba0cc0c2 100644 --- a/demo/hardwrap.html +++ b/demo/hardwrap.html @@ -60,11 +60,14 @@

    Hard-wrapping Demo

    "Ctrl-Q": function(cm) { cm.wrapParagraph(cm.getCursor(), options); } } }); -var wait, options = {column: 60}; +var wait, options = {column: 60}, changing = false; editor.on("change", function(cm, change) { + if (changing) return; clearTimeout(wait); wait = setTimeout(function() { - console.log(cm.wrapParagraphsInRange(change.from, CodeMirror.changeEnd(change), options)); + changing = true; + cm.wrapParagraphsInRange(change.from, CodeMirror.changeEnd(change), options); + changing = false; }, 200); }); From edfe2106348c5c251f0f9f4f924dcd7ffd45ec48 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Fri, 25 Sep 2015 11:12:38 +0200 Subject: [PATCH 0066/2444] [hardwrap addon] Don't generate null changes Issue #3548 --- addon/wrap/hardwrap.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addon/wrap/hardwrap.js b/addon/wrap/hardwrap.js index fe9b4dd669..8c1a7436ff 100644 --- a/addon/wrap/hardwrap.js +++ b/addon/wrap/hardwrap.js @@ -86,7 +86,8 @@ if (changes.length) cm.operation(function() { for (var i = 0; i < changes.length; ++i) { var change = changes[i]; - cm.replaceRange(change.text, change.from, change.to); + if (change.text || CodeMirror.cmpPos(change.from, change.to)) + cm.replaceRange(change.text, change.from, change.to); } }); return changes.length ? {from: changes[0].from, to: CodeMirror.changeEnd(changes[changes.length - 1])} : null; From 5c4b8de1f33d7ae5d2a052599245e3f74b0b60b8 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Fri, 25 Sep 2015 13:06:03 +0200 Subject: [PATCH 0067/2444] [merge addon] Use CodeMirror.on to register event handler Closes #3549 --- addon/merge/merge.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addon/merge/merge.js b/addon/merge/merge.js index e99de0b778..b4114a232a 100644 --- a/addon/merge/merge.js +++ b/addon/merge/merge.js @@ -640,7 +640,7 @@ mark.clear(); cm.removeLineClass(from, "wrap", "CodeMirror-merge-collapsed-line"); } - widget.addEventListener("click", clear); + CodeMirror.on(widget, "click", clear); return {mark: mark, clear: clear}; } From cd88422f57c7d00282356c27263a35fe5e3d5629 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Wed, 30 Sep 2015 13:06:21 +0200 Subject: [PATCH 0068/2444] Bring back support for capturing the contextmenu event Which was (possibly accidentally) dropped in the input style overhaul. Closes #3555 --- lib/codemirror.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/codemirror.js b/lib/codemirror.js index 689efa3a78..3605006c7f 100644 --- a/lib/codemirror.js +++ b/lib/codemirror.js @@ -4221,6 +4221,7 @@ // right-click take effect on it. function onContextMenu(cm, e) { if (eventInWidget(cm.display, e) || contextMenuInGutter(cm, e)) return; + if (signalDOMEvent(cm, e, "contextmenu")) return; cm.display.input.onContextMenu(e); } From 2a9bf60c1b068a736d23478e8cc9b1ac9185c255 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Fri, 2 Oct 2015 22:49:24 +0200 Subject: [PATCH 0069/2444] [hardwrap addon] Fix infinite loop in corner case (indented space-less line) Closes #3548 --- addon/wrap/hardwrap.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/addon/wrap/hardwrap.js b/addon/wrap/hardwrap.js index 8c1a7436ff..8806fbe2f2 100644 --- a/addon/wrap/hardwrap.js +++ b/addon/wrap/hardwrap.js @@ -32,11 +32,13 @@ function findBreakPoint(text, column, wrapOn, killTrailingSpace) { for (var at = column; at > 0; --at) if (wrapOn.test(text.slice(at - 1, at + 1))) break; - if (at == 0) at = column; - var endOfText = at; - if (killTrailingSpace) - while (text.charAt(endOfText - 1) == " ") --endOfText; - return {from: endOfText, to: at}; + for (var first = true;; first = false) { + var endOfText = at; + if (killTrailingSpace) + while (text.charAt(endOfText - 1) == " ") --endOfText; + if (endOfText == 0 && first) at = column; + else return {from: endOfText, to: at}; + } } function wrapRange(cm, from, to, options) { From 119c86bad98fa8f874d34fb5253e3a8ed90a7926 Mon Sep 17 00:00:00 2001 From: Tako Schotanus Date: Thu, 1 Oct 2015 18:34:51 +0200 Subject: [PATCH 0070/2444] Added my name to AUTHORS --- AUTHORS | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS b/AUTHORS index 67a8e248c5..78dd06f062 100644 --- a/AUTHORS +++ b/AUTHORS @@ -449,6 +449,7 @@ stoskov Sungho Kim sverweij Taha Jahangir +Tako Schotanus Takuji Shimokawa Tarmil tel From 4255f78cdaa1a2c4bc132a72b192cae52ae37667 Mon Sep 17 00:00:00 2001 From: Tako Schotanus Date: Thu, 1 Oct 2015 18:35:20 +0200 Subject: [PATCH 0071/2444] [ceylon mode] Add --- mode/clike/clike.js | 68 ++++++++++++++++++++++++++++++++++++------- mode/clike/index.html | 54 ++++++++++++++++++++++++++++++++-- mode/index.html | 1 + 3 files changed, 111 insertions(+), 12 deletions(-) diff --git a/mode/clike/clike.js b/mode/clike/clike.js index 91cba89c63..ed4755e9f7 100644 --- a/mode/clike/clike.js +++ b/mode/clike/clike.js @@ -25,8 +25,8 @@ CodeMirror.defineMode("clike", function(config, parserConfig) { multiLineStrings = parserConfig.multiLineStrings, indentStatements = parserConfig.indentStatements !== false, indentSwitch = parserConfig.indentSwitch !== false, - namespaceSeparator = parserConfig.namespaceSeparator; - var isOperatorChar = /[+\-*&%=<>!?|\/]/; + namespaceSeparator = parserConfig.namespaceSeparator, + isOperatorChar = parserConfig.isOperatorChar || /[+\-*&%=<>!?|\/]/; var curPunc, isDefKeyword; @@ -67,17 +67,17 @@ CodeMirror.defineMode("clike", function(config, parserConfig) { stream.eatWhile(/[\w\$_\xa1-\uffff]/); var cur = stream.current(); - if (keywords.propertyIsEnumerable(cur)) { - if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement"; - if (defKeywords.propertyIsEnumerable(cur)) isDefKeyword = true; + if (contains(keywords, cur)) { + if (contains(blockKeywords, cur)) curPunc = "newstatement"; + if (contains(defKeywords, cur)) isDefKeyword = true; return "keyword"; } - if (types.propertyIsEnumerable(cur)) return "variable-3"; - if (builtin.propertyIsEnumerable(cur)) { - if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement"; + if (contains(types, cur)) return "variable-3"; + if (contains(builtin, cur)) { + if (contains(blockKeywords, cur)) curPunc = "newstatement"; return "builtin"; } - if (atoms.propertyIsEnumerable(cur)) return "atom"; + if (contains(atoms, cur)) return "atom"; return "variable"; } @@ -190,7 +190,7 @@ CodeMirror.defineMode("clike", function(config, parserConfig) { pushContext(state, stream.column(), type); } - if (style == "variable" && + if ((style == "variable" || style == "variable-3") && ((state.prevToken == "def" || (parserConfig.typeFirstDefinitions && typeBefore(stream, state) && isTopScope(state.context) && stream.match(/^\s*\(/, false))))) @@ -238,6 +238,13 @@ CodeMirror.defineMode("clike", function(config, parserConfig) { for (var i = 0; i < words.length; ++i) obj[words[i]] = true; return obj; } + function contains(words, word) { + if (typeof words === "function") { + return words(word); + } else { + return words.propertyIsEnumerable(word); + } + } var cKeywords = "auto if break case register continue return default do sizeof " + "static else struct switch extern typedef float union for " + "goto while enum const volatile"; @@ -644,4 +651,45 @@ CodeMirror.defineMode("clike", function(config, parserConfig) { modeProps: {fold: ["brace", "include"]} }); + def("text/x-ceylon", { + name: "clike", + keywords: words("abstracts alias assembly assert assign break case catch class continue dynamic else" + + " exists extends finally for function given if import in interface is let module new" + + " nonempty object of out outer package return satisfies super switch then this throw" + + " try value void while"), + types: function(word) { + // In Ceylon all identifiers that start with an uppercase are types + var first = word.charAt(0); + return (first === first.toUpperCase() && first !== first.toLowerCase()); + }, + blockKeywords: words("case catch class dynamic else finally for function if interface module new object switch try while"), + defKeywords: words("class dynamic function interface module object package value"), + builtin: words("abstract actual aliased annotation by default deprecated doc final formal late license" + + " native optional sealed see serializable shared suppressWarnings tagged throws variable"), + isOperatorChar: /[+\-*&%=<>!?|^~:\/]/, + multiLineStrings: true, + typeFirstDefinitions: true, + atoms: words("true false null larger smaller equal empty finished"), + indentSwitch: false, + hooks: { + "@": function(stream) { + stream.eatWhile(/[\w\$_]/); + return "meta"; + }, + '"': function(stream, state) { + if (!stream.match('""')) return false; + state.tokenize = tokenTripleString; + return state.tokenize(stream, state); + }, + "'": function(stream) { + stream.eatWhile(/[\w\$_\xa1-\uffff]/); + return "atom"; + } + }, + modeProps: { + fold: ["brace", "import"], + closeBrackets: {triples: '"'} + } + }); + }); diff --git a/mode/clike/index.html b/mode/clike/index.html index 5378869a56..45c670ae58 100644 --- a/mode/clike/index.html +++ b/mode/clike/index.html @@ -258,6 +258,50 @@

    Kotlin mode

    } +

    Ceylon mode

    + +
    @@ -305,6 +354,7 @@

    Kotlin mode

    (Java), text/x-csharp (C#), text/x-objectivec (Objective-C), text/x-scala (Scala), text/x-vertex - and x-shader/x-fragment (shader programs), - text/x-squirrel (Squirrel).

    + x-shader/x-fragment (shader programs), + text/x-squirrel (Squirrel) and + text/x-ceylon (Ceylon)

    diff --git a/mode/index.html b/mode/index.html index f63e83684c..3e1230900c 100644 --- a/mode/index.html +++ b/mode/index.html @@ -35,6 +35,7 @@

    Language modes

  • Asterisk dialplan
  • Brainfuck
  • C, C++, C#
  • +
  • Ceylon
  • Clojure
  • Closure Stylesheets (GSS)
  • CMake
  • From acb7e767c116599b80db390a09db0941b752fcec Mon Sep 17 00:00:00 2001 From: idleberg Date: Thu, 24 Sep 2015 15:22:21 +0200 Subject: [PATCH 0072/2444] [nsis mode] Add --- mode/index.html | 1 + mode/nsis/index.html | 62 +++++++++++++++++++++++++++++++++++++++++++ mode/nsis/nsis.js | 63 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 126 insertions(+) create mode 100644 mode/nsis/index.html create mode 100644 mode/nsis/nsis.js diff --git a/mode/index.html b/mode/index.html index 3e1230900c..044dee7fdb 100644 --- a/mode/index.html +++ b/mode/index.html @@ -88,6 +88,7 @@

    Language modes

  • Modelica
  • MUMPS
  • Nginx
  • +
  • NSIS
  • NTriples
  • Objective C
  • OCaml
  • diff --git a/mode/nsis/index.html b/mode/nsis/index.html new file mode 100644 index 0000000000..a1d7aaa586 --- /dev/null +++ b/mode/nsis/index.html @@ -0,0 +1,62 @@ + + +CodeMirror: NSIS mode + + + + + + + + + + + +
    +

    NSIS mode

    + + + + + + +

    MIME types defined: text/x-nsis.

    +
    diff --git a/mode/nsis/nsis.js b/mode/nsis/nsis.js new file mode 100644 index 0000000000..3960b2e451 --- /dev/null +++ b/mode/nsis/nsis.js @@ -0,0 +1,63 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: http://codemirror.net/LICENSE + +// Author: Jan T. Sott (http://github.com/idleberg) + +(function(mod) { + if (typeof exports == "object" && typeof module == "object") // CommonJS + mod(require("../../lib/codemirror"), require("../../addon/mode/simple")); + else if (typeof define == "function" && define.amd) // AMD + define(["../../lib/codemirror", "../../addon/mode/simple"], mod); + else // Plain browser env + mod(CodeMirror); +})(function(CodeMirror) { +"use strict"; + +CodeMirror.defineSimpleMode("nsis",{ + start:[ + // Numbers + {regex: /(?:[+-]?)(?:0x[\d,a-f]+)|(?:0o[0-7]+)|(?:0b[0,1]+)|(?:\d+.?\d*)/, token: "number"}, + // Compile Time Commands + {regex: /(?:\!(include|addincludedir|addplugindir|appendfile|cd|delfile|echo|error|execute|packhdr|finalize|getdllversion|system|tempfile|warning|verbose|define|undef|insertmacro|makensis|searchparse|searchreplace))\b/, token: "keyword"}, + // Conditional Compilation + {regex: /(?:\!(if|ifdef|ifmacrodef|ifmacrondef|ifndef|macro))\b/, token: "keyword", indent: true}, + {regex: /(?:\!(else|endif|macroend))\b/, token: "keyword", dedent: true}, + // Runtime Commands + {regex: /(?:Abort|AddBrandingImage|AddSize|AllowRootDirInstall|AllowSkipFiles|AutoCloseWindow|BGFont|BGGradient|BrandingText|BringToFront|Call|CallInstDLL|Caption|ChangeUI|CheckBitmap|ClearErrors|CompletedText|ComponentText|CopyFiles|CRCCheck|CreateDirectory|CreateFont|CreateShortCut|Delete|DeleteINISec|DeleteINIStr|DeleteRegKey|DeleteRegValue|DetailPrint|DetailsButtonText|DirText|DirVar|DirVerify|EnableWindow|EnumRegKey|EnumRegValue|Exch|Exec|ExecShell|ExecWait|ExpandEnvStrings|File|FileBufSize|FileClose|FileErrorText|FileOpen|FileRead|FileReadByte|FileReadUTF16LE|FileReadWord|FileWriteUTF16LE|FileSeek|FileWrite|FileWriteByte|FileWriteWord|FindClose|FindFirst|FindNext|FindWindow|FlushINI|GetCurInstType|GetCurrentAddress|GetDlgItem|GetDLLVersion|GetDLLVersionLocal|GetErrorLevel|GetFileTime|GetFileTimeLocal|GetFullPathName|GetFunctionAddress|GetInstDirError|GetLabelAddress|GetTempFileName|Goto|HideWindow|Icon|IfAbort|IfErrors|IfFileExists|IfRebootFlag|IfSilent|InitPluginsDir|InstallButtonText|InstallColors|InstallDir|InstallDirRegKey|InstProgressFlags|InstType|InstTypeGetText|InstTypeSetText|IntCmp|IntCmpU|IntFmt|IntOp|IsWindow|LangString|LicenseBkColor|LicenseData|LicenseForceSelection|LicenseLangString|LicenseText|LoadLanguageFile|LockWindow|LogSet|LogText|ManifestDPIAware|ManifestSupportedOS|MessageBox|MiscButtonText|Name|Nop|OutFile|Page|PageCallbacks|Pop|Push|Quit|ReadEnvStr|ReadINIStr|ReadRegDWORD|ReadRegStr|Reboot|RegDLL|Rename|RequestExecutionLevel|ReserveFile|Return|RMDir|SearchPath|SectionGetFlags|SectionGetInstTypes|SectionGetSize|SectionGetText|SectionIn|SectionSetFlags|SectionSetInstTypes|SectionSetSize|SectionSetText|SendMessage|SetAutoClose|SetBrandingImage|SetCompress|SetCompressor|SetCompressorDictSize|SetCtlColors|SetCurInstType|SetDatablockOptimize|SetDateSave|SetDetailsPrint|SetDetailsView|SetErrorLevel|SetErrors|SetFileAttributes|SetFont|SetOutPath|SetOverwrite|SetPluginUnload|SetRebootFlag|SetRegView|SetShellVarContext|SetSilent|ShowInstDetails|ShowUninstDetails|ShowWindow|SilentInstall|SilentUnInstall|Sleep|SpaceTexts|StrCmp|StrCmpS|StrCpy|StrLen|SubCaption|Unicode|UninstallButtonText|UninstallCaption|UninstallIcon|UninstallSubCaption|UninstallText|UninstPage|UnRegDLL|Var|VIAddVersionKey|VIFileVersion|VIProductVersion|WindowIcon|WriteINIStr|WriteRegBin|WriteRegDWORD|WriteRegExpandStr|WriteRegStr|WriteUninstaller|XPStyle)\b/, token: "keyword"}, + {regex: /\b(?:Function|PageEx|Section|SectionGroup)\b/, token: "keyword", indent: true}, + {regex: /\b(?:FunctionEnd|PageExEnd|SectionEnd|SectionGroupEnd)\b/, token: "keyword", dedent: true}, + // Options + {regex: /\b(?:ARCHIVE|FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_NORMAL|FILE_ATTRIBUTE_OFFLINE|FILE_ATTRIBUTE_READONLY|FILE_ATTRIBUTE_SYSTEM|FILE_ATTRIBUTE_TEMPORARY|HIDDEN|HKCC|HKCR|HKCU|HKDD|HKEY_CLASSES_ROOT|HKEY_CURRENT_CONFIG|HKEY_CURRENT_USER|HKEY_DYN_DATA|HKEY_LOCAL_MACHINE|HKEY_PERFORMANCE_DATA|HKEY_USERS|HKLM|HKPD|HKU|IDABORT|IDCANCEL|IDD_DIR|IDD_INST|IDD_INSTFILES|IDD_LICENSE|IDD_SELCOM|IDD_UNINST|IDD_VERIFY|IDIGNORE|IDNO|IDOK|IDRETRY|IDYES|MB_ABORTRETRYIGNORE|MB_DEFBUTTON1|MB_DEFBUTTON2|MB_DEFBUTTON3|MB_DEFBUTTON4|MB_ICONEXCLAMATION|MB_ICONINFORMATION|MB_ICONQUESTION|MB_ICONSTOP|MB_OK|MB_OKCANCEL|MB_RETRYCANCEL|MB_RIGHT|MB_RTLREADING|MB_SETFOREGROUND|MB_TOPMOST|MB_USERICON|MB_YESNO|MB_YESNOCANCEL|NORMAL|OFFLINE|READONLY|SHCTX|SHELL_CONTEXT|SW_HIDE|SW_SHOWDEFAULT|SW_SHOWMAXIMIZED|SW_SHOWMINIMIZED|SW_SHOWNORMAL|SYSTEM|TEMPORARY)\b/, token: "atom"}, + {regex: /\b(?:admin|all|auto|both|bottom|bzip2|components|current|custom|directory|force|hide|highest|ifdiff|ifnewer|instfiles|lastused|leave|left|license|listonly|lzma|nevershow|none|normal|notset|right|show|silent|silentlog|textonly|top|try|un\.components|un\.custom|un\.directory|un\.instfiles|un\.license|uninstConfirm|user|Win10|Win7|Win8|WinVista|zlib)\b/, token: "builtin"}, + + // LogicLib + {regex: /\$\{(?:End(If|Unless|While)|Loop(?:Until)|Next)\}/, token: "variable-2", dedent: true}, + {regex: /\$\{(?:Do(Until|While)|Else(?:If(?:Not)?)?|For(?:Each)?|(?:(?:And|Else|Or)?If(?:Cmd|Not|Then)?|Unless)|While)\}/, token: "variable-2", indent: true}, + + // Line Comment + {regex: /(#|;).*/, token: "comment"}, + // Block Comment + {regex: /\/\*/, token: "comment", next: "comment"}, + // Operator + {regex: /[-+\/*=<>!]+/, token: "operator"}, + // Variable + {regex: /\$[\w]+/, token: "variable"}, + // Constant + {regex: /\${[\w]+}/,token: "variable-2"}, + // Language String + {regex: /\$\([\w]+\)/,token: "variable-3"} + ], + comment: [ + {regex: /.*?\*\//, token: "comment", next: "start"}, + {regex: /.*/, token: "comment"} + ], + meta: { + electricInput: /^\s*(FunctionEnd|PageExEnd|SectionEnd|SectionGroupEnd|(\!(endif|macroend))|\$\{(End(If|Unless|While)|Loop(Until)|Next)\})$/, + blockCommentStart: "/*", + blockCommentEnd: "*/", + lineComment: ["#", ";"] + } +}); + +CodeMirror.defineMIME("text/x-nsis", "nsis"); +}); From b1ad58e9c96c7e25c304fab21cf5641031ccbdf7 Mon Sep 17 00:00:00 2001 From: Wes Cossick Date: Fri, 25 Sep 2015 15:11:34 -0500 Subject: [PATCH 0073/2444] New option: allowDroppedFileTypes --- lib/codemirror.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/codemirror.js b/lib/codemirror.js index 3605006c7f..996978fc67 100644 --- a/lib/codemirror.js +++ b/lib/codemirror.js @@ -3821,6 +3821,9 @@ if (files && files.length && window.FileReader && window.File) { var n = files.length, text = Array(n), read = 0; var loadFile = function(file, i) { + if(this.options.allowDroppedFileTypes !== undefined && this.options.allowDroppedFileTypes.indexOf(file.type) === -1) + return; + var reader = new FileReader; reader.onload = operation(cm, function() { text[i] = reader.result; From 031afdee246f404c8ecaa635a58c457ac899c837 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Fri, 2 Oct 2015 23:46:20 +0200 Subject: [PATCH 0074/2444] Clean up allowDroppedFileTypes implementation, rename to allowDropFileTypes Make it actually work, document it, declare the option, make sure the code runs on pre-ES5 browsers. Issue #3550 --- doc/manual.html | 7 +++++++ lib/codemirror.js | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/doc/manual.html b/doc/manual.html index e2a3269d6b..095a80cd1c 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -421,6 +421,13 @@

    Configuration

    dragDrop: boolean
    Controls whether drag-and-drop is enabled. On by default.
    +
    allowDropFileTypes: array<string>
    +
    When set (default is null) only files whose + type is in the array can be dropped into the editor. The strings + should be MIME types, and will be checked against + the type + of the File object as reported by the browser.
    +
    cursorBlinkRate: number
    Half-period in milliseconds used for cursor blinking. The default blink rate is 530ms. By setting this to zero, blinking can be disabled. A diff --git a/lib/codemirror.js b/lib/codemirror.js index 996978fc67..f0f8837aed 100644 --- a/lib/codemirror.js +++ b/lib/codemirror.js @@ -3821,7 +3821,8 @@ if (files && files.length && window.FileReader && window.File) { var n = files.length, text = Array(n), read = 0; var loadFile = function(file, i) { - if(this.options.allowDroppedFileTypes !== undefined && this.options.allowDroppedFileTypes.indexOf(file.type) === -1) + if (cm.options.allowDropFileTypes && + indexOf(cm.options.allowDropFileTypes, file.type) == -1) return; var reader = new FileReader; @@ -5408,6 +5409,7 @@ }); option("disableInput", false, function(cm, val) {if (!val) cm.display.input.reset();}, true); option("dragDrop", true, dragDropChanged); + option("allowDropFileTypes", null); option("cursorBlinkRate", 530); option("cursorScrollMargin", 0); From 46936dd3129e94be249c457bcef8dbee3beb12e8 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Fri, 2 Oct 2015 23:46:38 +0200 Subject: [PATCH 0075/2444] Refuse to accept dropped binary files Issue #3550 --- lib/codemirror.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/codemirror.js b/lib/codemirror.js index f0f8837aed..1fd68dda24 100644 --- a/lib/codemirror.js +++ b/lib/codemirror.js @@ -3827,7 +3827,9 @@ var reader = new FileReader; reader.onload = operation(cm, function() { - text[i] = reader.result; + var content = reader.result; + if (/[\x00-\x08\x0e-\x1f]{2}/.test(content)) content = ""; + text[i] = content; if (++read == n) { pos = clipPos(cm.doc, pos); var change = {from: pos, to: pos, From 80ba42652018bae1061def23c02e9db81863ca83 Mon Sep 17 00:00:00 2001 From: Anders Nawroth Date: Mon, 28 Sep 2015 11:18:57 +0200 Subject: [PATCH 0076/2444] [cypher mode] Update keywords and builtins * Removes like, ilike. * Adds starts, ends, contains, toString, size, reverse. --- mode/cypher/cypher.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mode/cypher/cypher.js b/mode/cypher/cypher.js index 79048b440c..107e4f6d21 100644 --- a/mode/cypher/cypher.js +++ b/mode/cypher/cypher.js @@ -60,9 +60,9 @@ }; var indentUnit = config.indentUnit; var curPunc; - var funcs = wordRegexp(["abs", "acos", "allShortestPaths", "asin", "atan", "atan2", "avg", "ceil", "coalesce", "collect", "cos", "cot", "count", "degrees", "e", "endnode", "exp", "extract", "filter", "floor", "haversin", "head", "id", "keys", "labels", "last", "left", "length", "log", "log10", "lower", "ltrim", "max", "min", "node", "nodes", "percentileCont", "percentileDisc", "pi", "radians", "rand", "range", "reduce", "rel", "relationship", "relationships", "replace", "right", "round", "rtrim", "shortestPath", "sign", "sin", "split", "sqrt", "startnode", "stdev", "stdevp", "str", "substring", "sum", "tail", "tan", "timestamp", "toFloat", "toInt", "trim", "type", "upper"]); - var preds = wordRegexp(["all", "and", "any", "has", "in", "none", "not", "or", "single", "xor", "like", "ilike", "exists"]); - var keywords = wordRegexp(["as", "asc", "ascending", "assert", "by", "case", "commit", "constraint", "create", "csv", "cypher", "delete", "desc", "descending", "distinct", "drop", "else", "end", "explain", "false", "fieldterminator", "foreach", "from", "headers", "in", "index", "is", "join", "limit", "load", "match", "merge", "null", "on", "optional", "order", "periodic", "profile", "remove", "return", "scan", "set", "skip", "start", "then", "true", "union", "unique", "unwind", "using", "when", "where", "with"]); + var funcs = wordRegexp(["abs", "acos", "allShortestPaths", "asin", "atan", "atan2", "avg", "ceil", "coalesce", "collect", "cos", "cot", "count", "degrees", "e", "endnode", "exp", "extract", "filter", "floor", "haversin", "head", "id", "keys", "labels", "last", "left", "length", "log", "log10", "lower", "ltrim", "max", "min", "node", "nodes", "percentileCont", "percentileDisc", "pi", "radians", "rand", "range", "reduce", "rel", "relationship", "relationships", "replace", "reverse", "right", "round", "rtrim", "shortestPath", "sign", "sin", "size", "split", "sqrt", "startnode", "stdev", "stdevp", "str", "substring", "sum", "tail", "tan", "timestamp", "toFloat", "toInt", "toString", "trim", "type", "upper"]); + var preds = wordRegexp(["all", "and", "any", "contains", "exists", "has", "in", "none", "not", "or", "single", "xor"]); + var keywords = wordRegexp(["as", "asc", "ascending", "assert", "by", "case", "commit", "constraint", "create", "csv", "cypher", "delete", "desc", "descending", "detach", "distinct", "drop", "else", "end", "ends", "explain", "false", "fieldterminator", "foreach", "from", "headers", "in", "index", "is", "join", "limit", "load", "match", "merge", "null", "on", "optional", "order", "periodic", "profile", "remove", "return", "scan", "set", "skip", "start", "starts", "then", "true", "union", "unique", "unwind", "using", "when", "where", "with"]); var operatorChars = /[*+\-<>=&|~%^]/; return { From 52e48afa6d3d508c83115c142c3f8fd0dc477108 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Sat, 3 Oct 2015 00:00:37 +0200 Subject: [PATCH 0077/2444] Only call ensureCursorVisible once in newlineAndIndent --- lib/codemirror.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/codemirror.js b/lib/codemirror.js index 1fd68dda24..63a6229477 100644 --- a/lib/codemirror.js +++ b/lib/codemirror.js @@ -5716,8 +5716,8 @@ var range = cm.listSelections()[i]; cm.replaceRange(cm.doc.lineSeparator(), range.anchor, range.head, "+input"); cm.indentLine(range.from().line + 1, null, true); - ensureCursorVisible(cm); } + ensureCursorVisible(cm); }); }, toggleOverwrite: function(cm) {cm.toggleOverwrite();} From 4f7a6fb37a7f6d879dc6f72f7604e25e75c6487d Mon Sep 17 00:00:00 2001 From: Mark Anderson Date: Mon, 28 Sep 2015 21:27:05 +0100 Subject: [PATCH 0078/2444] [rpm spec mode] Use classes that exist support more arch/preamble/sections and fix clearing control flow state. --- mode/rpm/rpm.js | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/mode/rpm/rpm.js b/mode/rpm/rpm.js index 3bb7cd2f62..87cde591a3 100644 --- a/mode/rpm/rpm.js +++ b/mode/rpm/rpm.js @@ -34,10 +34,10 @@ CodeMirror.defineMIME("text/x-rpm-changes", "rpm-changes"); // Quick and dirty spec file highlighting CodeMirror.defineMode("rpm-spec", function() { - var arch = /^(i386|i586|i686|x86_64|ppc64|ppc|ia64|s390x|s390|sparc64|sparcv9|sparc|noarch|alphaev6|alpha|hppa|mipsel)/; + var arch = /^(i386|i586|i686|x86_64|ppc64le|ppc64|ppc|ia64|s390x|s390|sparc64|sparcv9|sparc|noarch|alphaev6|alpha|hppa|mipsel)/; - var preamble = /^(Name|Version|Release|License|Summary|Url|Group|Source|BuildArch|BuildRequires|BuildRoot|AutoReqProv|Provides|Requires(\(\w+\))?|Obsoletes|Conflicts|Recommends|Source\d*|Patch\d*|ExclusiveArch|NoSource|Supplements):/; - var section = /^%(debug_package|package|description|prep|build|install|files|clean|changelog|preinstall|preun|postinstall|postun|pre|post|triggerin|triggerun|pretrans|posttrans|verifyscript|check|triggerpostun|triggerprein|trigger)/; + var preamble = /^[a-zA-Z0-9()]+:/; + var section = /^%(debug_package|package|description|prep|build|install|files|clean|changelog|preinstall|preun|postinstall|postun|pretrans|posttrans|pre|post|triggerin|triggerun|verifyscript|check|triggerpostun|triggerprein|trigger)/; var control_flow_complex = /^%(ifnarch|ifarch|if)/; // rpm control flow macros var control_flow_simple = /^%(else|endif)/; // rpm control flow macros var operators = /^(\!|\?|\<\=|\<|\>\=|\>|\=\=|\&\&|\|\|)/; // operators in control flow macros @@ -55,8 +55,8 @@ CodeMirror.defineMode("rpm-spec", function() { if (ch == "#") { stream.skipToEnd(); return "comment"; } if (stream.sol()) { - if (stream.match(preamble)) { return "preamble"; } - if (stream.match(section)) { return "section"; } + if (stream.match(preamble)) { return "header"; } + if (stream.match(section)) { return "atom"; } } if (stream.match(/^\$\w+/)) { return "def"; } // Variables like '$RPM_BUILD_ROOT' @@ -73,21 +73,29 @@ CodeMirror.defineMode("rpm-spec", function() { if (stream.eol()) { state.controlFlow = false; } } - if (stream.match(arch)) { return "number"; } + if (stream.match(arch)) { + if (stream.eol()) { state.controlFlow = false; } + return "number"; + } // Macros like '%make_install' or '%attr(0775,root,root)' if (stream.match(/^%[\w]+/)) { if (stream.match(/^\(/)) { state.macroParameters = true; } - return "macro"; + return "keyword"; } if (state.macroParameters) { if (stream.match(/^\d+/)) { return "number";} if (stream.match(/^\)/)) { state.macroParameters = false; - return "macro"; + return "keyword"; } } - if (stream.match(/^%\{\??[\w \-]+\}/)) { return "macro"; } // Macros like '%{defined fedora}' + + // Macros like '%{defined fedora}' + if (stream.match(/^%\{\??[\w \-\:\!]+\}/)) { + if (stream.eol()) { state.controlFlow = false; } + return "def"; + } //TODO: Include bash script sub-parser (CodeMirror supports that) stream.next(); From a24a053df741fea91dac30de16ba56c091164440 Mon Sep 17 00:00:00 2001 From: "amshali@google.com" Date: Tue, 29 Sep 2015 18:10:49 -0700 Subject: [PATCH 0079/2444] [real-world uses] Add Codiad --- doc/realworld.html | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/realworld.html b/doc/realworld.html index 3f72b28c8a..ab33409a64 100644 --- a/doc/realworld.html +++ b/doc/realworld.html @@ -29,6 +29,7 @@

    CodeMirror real-world uses

  • Amber (JavaScript-based Smalltalk system)
  • Apache GUI
  • APEye (tool for testing & documenting APIs)
  • +
  • Appengine Codiad
  • Better Text Viewer (plain text reader app for Chrome)
  • Bitbucket (code hosting)
  • Blogger's template editor
  • From 8a48219a5ec380aacf938cc7d5438dd85a187e31 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Sat, 3 Oct 2015 00:24:12 +0200 Subject: [PATCH 0080/2444] [clike mode] Don't get confused by commas in Java throw clauses Closes #3558 --- mode/clike/clike.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mode/clike/clike.js b/mode/clike/clike.js index ed4755e9f7..77cc203111 100644 --- a/mode/clike/clike.js +++ b/mode/clike/clike.js @@ -26,7 +26,8 @@ CodeMirror.defineMode("clike", function(config, parserConfig) { indentStatements = parserConfig.indentStatements !== false, indentSwitch = parserConfig.indentSwitch !== false, namespaceSeparator = parserConfig.namespaceSeparator, - isOperatorChar = parserConfig.isOperatorChar || /[+\-*&%=<>!?|\/]/; + isOperatorChar = parserConfig.isOperatorChar || /[+\-*&%=<>!?|\/]/, + endStatement = parserConfig.endStatement || /^[;:,]$/; var curPunc, isDefKeyword; @@ -168,8 +169,7 @@ CodeMirror.defineMode("clike", function(config, parserConfig) { if (style == "comment" || style == "meta") return style; if (ctx.align == null) ctx.align = true; - if ((curPunc == ";" || curPunc == ":" || curPunc == ",")) - while (isStatement(state.context.type)) popContext(state); + if (endStatement.test(curPunc)) while (isStatement(state.context.type)) popContext(state); else if (curPunc == "{") pushContext(state, stream.column(), "}"); else if (curPunc == "[") pushContext(state, stream.column(), "]"); else if (curPunc == "(") pushContext(state, stream.column(), ")"); @@ -420,6 +420,7 @@ CodeMirror.defineMode("clike", function(config, parserConfig) { defKeywords: words("class interface package enum"), typeFirstDefinitions: true, atoms: words("true false null"), + endStatement: /^[;:]$/, hooks: { "@": function(stream) { stream.eatWhile(/[\w\$_]/); From 825ca00010c61ae366fb53b78ba633d1c39fc497 Mon Sep 17 00:00:00 2001 From: Markus Bordihn Date: Thu, 1 Oct 2015 11:11:18 +0200 Subject: [PATCH 0081/2444] [coffeescript mode] Remove disabled code Removed possible testing and unreachable code to avoid JavaScript compiler errors: ... codemirror/mode/coffeescript/coffeescript.js:271: WARNING - unreachable code if (false && current === ".") { ... --- mode/coffeescript/coffeescript.js | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/mode/coffeescript/coffeescript.js b/mode/coffeescript/coffeescript.js index 1b96f85d86..adf2184fd7 100644 --- a/mode/coffeescript/coffeescript.js +++ b/mode/coffeescript/coffeescript.js @@ -267,17 +267,6 @@ CodeMirror.defineMode("coffeescript", function(conf, parserConf) { var style = state.tokenize(stream, state); var current = stream.current(); - // Handle "." connected identifiers - if (false && current === ".") { - style = state.tokenize(stream, state); - current = stream.current(); - if (/^\.[\w$]+$/.test(current)) { - return "variable"; - } else { - return ERRORCLASS; - } - } - // Handle scope changes. if (current === "return") { state.dedent = true; From 0e924de982e315ba74ee9e57d6030581dcd43158 Mon Sep 17 00:00:00 2001 From: Martin Laine Date: Sat, 3 Oct 2015 14:34:40 +0100 Subject: [PATCH 0082/2444] Add start and end tokens when highlighting delimiters --- addon/mode/multiplex.js | 6 +++--- addon/mode/multiplex_test.js | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/addon/mode/multiplex.js b/addon/mode/multiplex.js index fe48c7fbd5..3d8b34c452 100644 --- a/addon/mode/multiplex.js +++ b/addon/mode/multiplex.js @@ -51,7 +51,7 @@ CodeMirror.multiplexingMode = function(outer /*, others */) { if (!other.parseDelimiters) stream.match(other.open); state.innerActive = other; state.inner = CodeMirror.startState(other.mode, outer.indent ? outer.indent(state.outer, "") : 0); - return other.delimStyle; + return other.delimStyle && (other.delimStyle + " " + other.delimStyle + "-open"); } else if (found != -1 && found < cutOff) { cutOff = found; } @@ -70,7 +70,7 @@ CodeMirror.multiplexingMode = function(outer /*, others */) { if (found == stream.pos && !curInner.parseDelimiters) { stream.match(curInner.close); state.innerActive = state.inner = null; - return curInner.delimStyle; + return curInner.delimStyle && (curInner.delimStyle + " " + curInner.delimStyle + "-close"); } if (found > -1) stream.string = oldContent.slice(0, found); var innerToken = curInner.mode.token(stream, state.inner); @@ -80,7 +80,7 @@ CodeMirror.multiplexingMode = function(outer /*, others */) { state.innerActive = state.inner = null; if (curInner.innerStyle) { - if (innerToken) innerToken = innerToken + ' ' + curInner.innerStyle; + if (innerToken) innerToken = innerToken + " " + curInner.innerStyle; else innerToken = curInner.innerStyle; } diff --git a/addon/mode/multiplex_test.js b/addon/mode/multiplex_test.js index d33943420e..24e5e670de 100644 --- a/addon/mode/multiplex_test.js +++ b/addon/mode/multiplex_test.js @@ -29,5 +29,5 @@ MT( "stexInsideMarkdown", - "[strong **Equation:**] [delim $][inner&tag \\pi][delim $]"); + "[strong **Equation:**] [delim&delim-open $][inner&tag \\pi][delim&delim-close $]"); })(); From 1011199245705e8e05447dd47e835caf0abba817 Mon Sep 17 00:00:00 2001 From: Martin Laine Date: Sat, 3 Oct 2015 16:25:06 +0100 Subject: [PATCH 0083/2444] Update docs --- doc/manual.html | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/manual.html b/doc/manual.html index 095a80cd1c..75875ff2bd 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -2488,7 +2488,9 @@

    Addons

    Pass "\n" for open or close if you want to switch on a blank line.
    • When delimStyle is specified, it will be the token - style returned for the delimiter tokens.
    • + style returned for the delimiter tokens (as well as + [delimStyle]-open on the opening token and + [delimStyle]-close on the closing token).
    • When innerStyle is specified, it will be the token style added for each inner mode token.
    • When parseDelimiters is true, the content of From d8237c8f1d377d13bd5593712c1d8e703b8139eb Mon Sep 17 00:00:00 2001 From: Tako Schotanus Date: Mon, 5 Oct 2015 18:43:13 +0200 Subject: [PATCH 0084/2444] [clike mode] Make punctuation and number chars configurable --- mode/clike/clike.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/mode/clike/clike.js b/mode/clike/clike.js index 77cc203111..e1502437bc 100644 --- a/mode/clike/clike.js +++ b/mode/clike/clike.js @@ -26,6 +26,8 @@ CodeMirror.defineMode("clike", function(config, parserConfig) { indentStatements = parserConfig.indentStatements !== false, indentSwitch = parserConfig.indentSwitch !== false, namespaceSeparator = parserConfig.namespaceSeparator, + isPunctuationChar = parserConfig.isPunctuationChar || /[\[\]{}\(\),;\:\.]/, + isNumberChar = parserConfig.isNumberChar || /\d/, isOperatorChar = parserConfig.isOperatorChar || /[+\-*&%=<>!?|\/]/, endStatement = parserConfig.endStatement || /^[;:,]$/; @@ -41,11 +43,11 @@ CodeMirror.defineMode("clike", function(config, parserConfig) { state.tokenize = tokenString(ch); return state.tokenize(stream, state); } - if (/[\[\]{}\(\),;\:\.]/.test(ch)) { + if (isPunctuationChar.test(ch)) { curPunc = ch; return null; } - if (/\d/.test(ch)) { + if (isNumberChar.test(ch)) { stream.eatWhile(/[\w\.]/); return "number"; } @@ -667,7 +669,9 @@ CodeMirror.defineMode("clike", function(config, parserConfig) { defKeywords: words("class dynamic function interface module object package value"), builtin: words("abstract actual aliased annotation by default deprecated doc final formal late license" + " native optional sealed see serializable shared suppressWarnings tagged throws variable"), + isPunctuationChar: /[\[\]{}\(\),;\:\.`]/, isOperatorChar: /[+\-*&%=<>!?|^~:\/]/, + isNumberChar: /[\d#$]/, multiLineStrings: true, typeFirstDefinitions: true, atoms: words("true false null larger smaller equal empty finished"), From 84d5f64006822fd2213ca09cb0fcb93ca85d1b0e Mon Sep 17 00:00:00 2001 From: Tako Schotanus Date: Mon, 5 Oct 2015 18:44:02 +0200 Subject: [PATCH 0085/2444] [clike mode] Support string interpolation and members in Ceylon mode --- mode/clike/clike.js | 49 +++++++++++++++++++++++++++++++++++++++------ 1 file changed, 43 insertions(+), 6 deletions(-) diff --git a/mode/clike/clike.js b/mode/clike/clike.js index e1502437bc..e2900d8014 100644 --- a/mode/clike/clike.js +++ b/mode/clike/clike.js @@ -192,7 +192,7 @@ CodeMirror.defineMode("clike", function(config, parserConfig) { pushContext(state, stream.column(), type); } - if ((style == "variable" || style == "variable-3") && + if (style == "variable" && ((state.prevToken == "def" || (parserConfig.typeFirstDefinitions && typeBefore(stream, state) && isTopScope(state.context) && stream.match(/^\s*\(/, false))))) @@ -654,6 +654,31 @@ CodeMirror.defineMode("clike", function(config, parserConfig) { modeProps: {fold: ["brace", "include"]} }); + // Ceylon Strings need to deal with interpolation + var stringTokenizer = null; + function tokenCeylonString(type) { + return function(stream, state) { + var escaped = false, next, end = false; + while (!stream.eol()) { + if (!escaped && stream.match('"') && + (type == "single" || stream.match('""'))) { + end = true; + break; + } + if (!escaped && stream.match('``')) { + stringTokenizer = tokenCeylonString(type); + end = true; + break; + } + next = stream.next(); + escaped = type == "single" && !escaped && next == "\\"; + } + if (end) + state.tokenize = null; + return "string"; + } + } + def("text/x-ceylon", { name: "clike", keywords: words("abstracts alias assembly assert assign break case catch class continue dynamic else" + @@ -676,20 +701,32 @@ CodeMirror.defineMode("clike", function(config, parserConfig) { typeFirstDefinitions: true, atoms: words("true false null larger smaller equal empty finished"), indentSwitch: false, + styleDefs: false, hooks: { "@": function(stream) { stream.eatWhile(/[\w\$_]/); return "meta"; }, '"': function(stream, state) { - if (!stream.match('""')) return false; - state.tokenize = tokenTripleString; - return state.tokenize(stream, state); - }, + state.tokenize = tokenCeylonString(stream.match('""') ? "triple" : "single"); + return state.tokenize(stream, state); + }, + '`': function(stream, state) { + if (!stringTokenizer || !stream.match('`')) return false; + state.tokenize = stringTokenizer; + stringTokenizer = null; + return state.tokenize(stream, state); + }, "'": function(stream) { stream.eatWhile(/[\w\$_\xa1-\uffff]/); return "atom"; - } + }, + token: function(_stream, state, style) { + if ((style == "variable" || style == "variable-3") && + state.prevToken == ".") { + return "variable-2"; + } + } }, modeProps: { fold: ["brace", "import"], From b62924237dce61ba5f8e799a434b2d82747876ac Mon Sep 17 00:00:00 2001 From: "amshali@google.com" Date: Wed, 30 Sep 2015 18:15:22 -0700 Subject: [PATCH 0086/2444] [abcdef theme] Change link color to blueviolet ...because the original blue on black background is difficult to read. --- theme/abcdef.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/theme/abcdef.css b/theme/abcdef.css index 142d813703..7f9d788704 100644 --- a/theme/abcdef.css +++ b/theme/abcdef.css @@ -27,6 +27,6 @@ .cm-s-abcdef span.cm-attribute { color: #DDFF00; } .cm-s-abcdef span.cm-error { color: #FF0000; } .cm-s-abcdef span.cm-header { color: aquamarine; font-weight: bold; } -.cm-s-abcdef span.cm-link { color: blue; } +.cm-s-abcdef span.cm-link { color: blueviolet; } .cm-s-abcdef .CodeMirror-activeline-background { background: #314151; } From 61e9389610df5f944b82e3a24edd564614427ff6 Mon Sep 17 00:00:00 2001 From: "amshali@google.com" Date: Wed, 30 Sep 2015 13:56:33 -0700 Subject: [PATCH 0087/2444] [liquibyte theme] Fix css file to have more complete selectors Including liquibyte theme with other themes causes other themes(when in use) to not look right. For example there will be underline text decorations when a text is selected in default theme. --- theme/liquibyte.css | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/theme/liquibyte.css b/theme/liquibyte.css index c64c25c743..9db8bde739 100644 --- a/theme/liquibyte.css +++ b/theme/liquibyte.css @@ -4,17 +4,17 @@ line-height: 1.2em; font-size: 1em; } -.CodeMirror-focused .cm-matchhighlight { +.cm-s-liquibyte .CodeMirror-focused .cm-matchhighlight { text-decoration: underline; text-decoration-color: #0f0; text-decoration-style: wavy; } -.cm-trailingspace { +.cm-s-liquibyte .cm-trailingspace { text-decoration: line-through; text-decoration-color: #f00; text-decoration-style: dotted; } -.cm-tab { +.cm-s-liquibyte .cm-tab { text-decoration: line-through; text-decoration-color: #404040; text-decoration-style: dotted; @@ -54,42 +54,42 @@ .cm-s-liquibyte .CodeMirror-activeline-background { background-color: rgba(0, 255, 0, 0.15); } /* Default styles for common addons */ -div.CodeMirror span.CodeMirror-matchingbracket { color: #0f0; font-weight: bold; } -div.CodeMirror span.CodeMirror-nonmatchingbracket { color: #f00; font-weight: bold; } +.cm-s-liquibyte .CodeMirror span.CodeMirror-matchingbracket { color: #0f0; font-weight: bold; } +.cm-s-liquibyte .CodeMirror span.CodeMirror-nonmatchingbracket { color: #f00; font-weight: bold; } .CodeMirror-matchingtag { background-color: rgba(150, 255, 0, .3); } /* Scrollbars */ /* Simple */ -div.CodeMirror-simplescroll-horizontal div:hover, div.CodeMirror-simplescroll-vertical div:hover { +.cm-s-liquibyte div.CodeMirror-simplescroll-horizontal div:hover, div.CodeMirror-simplescroll-vertical div:hover { background-color: rgba(80, 80, 80, .7); } -div.CodeMirror-simplescroll-horizontal div, div.CodeMirror-simplescroll-vertical div { +.cm-s-liquibyte div.CodeMirror-simplescroll-horizontal div, div.CodeMirror-simplescroll-vertical div { background-color: rgba(80, 80, 80, .3); border: 1px solid #404040; border-radius: 5px; } -div.CodeMirror-simplescroll-vertical div { +.cm-s-liquibyte div.CodeMirror-simplescroll-vertical div { border-top: 1px solid #404040; border-bottom: 1px solid #404040; } -div.CodeMirror-simplescroll-horizontal div { +.cm-s-liquibyte div.CodeMirror-simplescroll-horizontal div { border-left: 1px solid #404040; border-right: 1px solid #404040; } -div.CodeMirror-simplescroll-vertical { +.cm-s-liquibyte div.CodeMirror-simplescroll-vertical { background-color: #262626; } -div.CodeMirror-simplescroll-horizontal { +.cm-s-liquibyte div.CodeMirror-simplescroll-horizontal { background-color: #262626; border-top: 1px solid #404040; } /* Overlay */ -div.CodeMirror-overlayscroll-horizontal div, div.CodeMirror-overlayscroll-vertical div { +.cm-s-liquibyte div.CodeMirror-overlayscroll-horizontal div, div.CodeMirror-overlayscroll-vertical div { background-color: #404040; border-radius: 5px; } -div.CodeMirror-overlayscroll-vertical div { +.cm-s-liquibyte div.CodeMirror-overlayscroll-vertical div { border: 1px solid #404040; } -div.CodeMirror-overlayscroll-horizontal div { +.cm-s-liquibyte div.CodeMirror-overlayscroll-horizontal div { border: 1px solid #404040; } From d16f4d81ff576b93f7db37d11ec5f73babbccd88 Mon Sep 17 00:00:00 2001 From: idleberg Date: Wed, 7 Oct 2015 12:44:45 +0200 Subject: [PATCH 0088/2444] [nsis mode] Shorten some regular expressions --- mode/nsis/nsis.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mode/nsis/nsis.js b/mode/nsis/nsis.js index 3960b2e451..93dd7421e8 100644 --- a/mode/nsis/nsis.js +++ b/mode/nsis/nsis.js @@ -20,12 +20,12 @@ CodeMirror.defineSimpleMode("nsis",{ // Compile Time Commands {regex: /(?:\!(include|addincludedir|addplugindir|appendfile|cd|delfile|echo|error|execute|packhdr|finalize|getdllversion|system|tempfile|warning|verbose|define|undef|insertmacro|makensis|searchparse|searchreplace))\b/, token: "keyword"}, // Conditional Compilation - {regex: /(?:\!(if|ifdef|ifmacrodef|ifmacrondef|ifndef|macro))\b/, token: "keyword", indent: true}, + {regex: /(?:\!(if(?:n?def)?|ifmacron?def|macro))\b/, token: "keyword", indent: true}, {regex: /(?:\!(else|endif|macroend))\b/, token: "keyword", dedent: true}, // Runtime Commands {regex: /(?:Abort|AddBrandingImage|AddSize|AllowRootDirInstall|AllowSkipFiles|AutoCloseWindow|BGFont|BGGradient|BrandingText|BringToFront|Call|CallInstDLL|Caption|ChangeUI|CheckBitmap|ClearErrors|CompletedText|ComponentText|CopyFiles|CRCCheck|CreateDirectory|CreateFont|CreateShortCut|Delete|DeleteINISec|DeleteINIStr|DeleteRegKey|DeleteRegValue|DetailPrint|DetailsButtonText|DirText|DirVar|DirVerify|EnableWindow|EnumRegKey|EnumRegValue|Exch|Exec|ExecShell|ExecWait|ExpandEnvStrings|File|FileBufSize|FileClose|FileErrorText|FileOpen|FileRead|FileReadByte|FileReadUTF16LE|FileReadWord|FileWriteUTF16LE|FileSeek|FileWrite|FileWriteByte|FileWriteWord|FindClose|FindFirst|FindNext|FindWindow|FlushINI|GetCurInstType|GetCurrentAddress|GetDlgItem|GetDLLVersion|GetDLLVersionLocal|GetErrorLevel|GetFileTime|GetFileTimeLocal|GetFullPathName|GetFunctionAddress|GetInstDirError|GetLabelAddress|GetTempFileName|Goto|HideWindow|Icon|IfAbort|IfErrors|IfFileExists|IfRebootFlag|IfSilent|InitPluginsDir|InstallButtonText|InstallColors|InstallDir|InstallDirRegKey|InstProgressFlags|InstType|InstTypeGetText|InstTypeSetText|IntCmp|IntCmpU|IntFmt|IntOp|IsWindow|LangString|LicenseBkColor|LicenseData|LicenseForceSelection|LicenseLangString|LicenseText|LoadLanguageFile|LockWindow|LogSet|LogText|ManifestDPIAware|ManifestSupportedOS|MessageBox|MiscButtonText|Name|Nop|OutFile|Page|PageCallbacks|Pop|Push|Quit|ReadEnvStr|ReadINIStr|ReadRegDWORD|ReadRegStr|Reboot|RegDLL|Rename|RequestExecutionLevel|ReserveFile|Return|RMDir|SearchPath|SectionGetFlags|SectionGetInstTypes|SectionGetSize|SectionGetText|SectionIn|SectionSetFlags|SectionSetInstTypes|SectionSetSize|SectionSetText|SendMessage|SetAutoClose|SetBrandingImage|SetCompress|SetCompressor|SetCompressorDictSize|SetCtlColors|SetCurInstType|SetDatablockOptimize|SetDateSave|SetDetailsPrint|SetDetailsView|SetErrorLevel|SetErrors|SetFileAttributes|SetFont|SetOutPath|SetOverwrite|SetPluginUnload|SetRebootFlag|SetRegView|SetShellVarContext|SetSilent|ShowInstDetails|ShowUninstDetails|ShowWindow|SilentInstall|SilentUnInstall|Sleep|SpaceTexts|StrCmp|StrCmpS|StrCpy|StrLen|SubCaption|Unicode|UninstallButtonText|UninstallCaption|UninstallIcon|UninstallSubCaption|UninstallText|UninstPage|UnRegDLL|Var|VIAddVersionKey|VIFileVersion|VIProductVersion|WindowIcon|WriteINIStr|WriteRegBin|WriteRegDWORD|WriteRegExpandStr|WriteRegStr|WriteUninstaller|XPStyle)\b/, token: "keyword"}, - {regex: /\b(?:Function|PageEx|Section|SectionGroup)\b/, token: "keyword", indent: true}, - {regex: /\b(?:FunctionEnd|PageExEnd|SectionEnd|SectionGroupEnd)\b/, token: "keyword", dedent: true}, + {regex: /\b(?:Function|PageEx|Section(?:Group)?)\b/, token: "keyword", indent: true}, + {regex: /\b(?:(Function|PageEx|Section(?:Group)?)End)\b/, token: "keyword", dedent: true}, // Options {regex: /\b(?:ARCHIVE|FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_NORMAL|FILE_ATTRIBUTE_OFFLINE|FILE_ATTRIBUTE_READONLY|FILE_ATTRIBUTE_SYSTEM|FILE_ATTRIBUTE_TEMPORARY|HIDDEN|HKCC|HKCR|HKCU|HKDD|HKEY_CLASSES_ROOT|HKEY_CURRENT_CONFIG|HKEY_CURRENT_USER|HKEY_DYN_DATA|HKEY_LOCAL_MACHINE|HKEY_PERFORMANCE_DATA|HKEY_USERS|HKLM|HKPD|HKU|IDABORT|IDCANCEL|IDD_DIR|IDD_INST|IDD_INSTFILES|IDD_LICENSE|IDD_SELCOM|IDD_UNINST|IDD_VERIFY|IDIGNORE|IDNO|IDOK|IDRETRY|IDYES|MB_ABORTRETRYIGNORE|MB_DEFBUTTON1|MB_DEFBUTTON2|MB_DEFBUTTON3|MB_DEFBUTTON4|MB_ICONEXCLAMATION|MB_ICONINFORMATION|MB_ICONQUESTION|MB_ICONSTOP|MB_OK|MB_OKCANCEL|MB_RETRYCANCEL|MB_RIGHT|MB_RTLREADING|MB_SETFOREGROUND|MB_TOPMOST|MB_USERICON|MB_YESNO|MB_YESNOCANCEL|NORMAL|OFFLINE|READONLY|SHCTX|SHELL_CONTEXT|SW_HIDE|SW_SHOWDEFAULT|SW_SHOWMAXIMIZED|SW_SHOWMINIMIZED|SW_SHOWNORMAL|SYSTEM|TEMPORARY)\b/, token: "atom"}, {regex: /\b(?:admin|all|auto|both|bottom|bzip2|components|current|custom|directory|force|hide|highest|ifdiff|ifnewer|instfiles|lastused|leave|left|license|listonly|lzma|nevershow|none|normal|notset|right|show|silent|silentlog|textonly|top|try|un\.components|un\.custom|un\.directory|un\.instfiles|un\.license|uninstConfirm|user|Win10|Win7|Win8|WinVista|zlib)\b/, token: "builtin"}, @@ -52,7 +52,7 @@ CodeMirror.defineSimpleMode("nsis",{ {regex: /.*/, token: "comment"} ], meta: { - electricInput: /^\s*(FunctionEnd|PageExEnd|SectionEnd|SectionGroupEnd|(\!(endif|macroend))|\$\{(End(If|Unless|While)|Loop(Until)|Next)\})$/, + electricInput: /^\s*((Function|PageEx|Section|Section(Group)?)End|(\!(endif|macroend))|\$\{(End(If|Unless|While)|Loop(Until)|Next)\})$/, blockCommentStart: "/*", blockCommentEnd: "*/", lineComment: ["#", ";"] From 897586c0ad1bec7226c7109b0c8a0e3aae35d333 Mon Sep 17 00:00:00 2001 From: Stephen Lavelle Date: Sun, 6 Sep 2015 08:17:48 +0100 Subject: [PATCH 0089/2444] [haxe mode] Add support for globalVars --- mode/haxe/haxe.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/mode/haxe/haxe.js b/mode/haxe/haxe.js index 73cd6213ac..00be2962b5 100644 --- a/mode/haxe/haxe.js +++ b/mode/haxe/haxe.js @@ -192,12 +192,20 @@ CodeMirror.defineMode("haxe", function(config, parserConfig) { return true; } function register(varname) { + function inList(list) { + for (var v = list; v; v = v.next) + if (v.name == varname) return true; + return false; + } var state = cx.state; if (state.context) { cx.marked = "def"; - for (var v = state.localVars; v; v = v.next) - if (v.name == varname) return; + if (inList(state.localVars)) return; state.localVars = {name: varname, next: state.localVars}; + } else { + if (inList(state.globalVars)) return; + if (parserConfig.globalVars) + state.globalVars = {name: varname, next: state.globalVars}; } } @@ -380,11 +388,10 @@ CodeMirror.defineMode("haxe", function(config, parserConfig) { } // Interface - return { startState: function(basecolumn) { var defaulttypes = ["Int", "Float", "String", "Void", "Std", "Bool", "Dynamic", "Array"]; - return { + var state = { tokenize: haxeTokenBase, reAllowed: true, kwAllowed: true, @@ -395,6 +402,9 @@ CodeMirror.defineMode("haxe", function(config, parserConfig) { context: parserConfig.localVars && {vars: parserConfig.localVars}, indented: 0 }; + if (parserConfig.globalVars && typeof parserConfig.globalVars == "object") + state.globalVars = parserConfig.globalVars; + return state; }, token: function(stream, state) { From a039316c74253b6176b8fd9517a93295033f8ec5 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Wed, 7 Oct 2015 12:59:10 +0200 Subject: [PATCH 0090/2444] [haxe mode] Tweak previous patch --- mode/haxe/haxe.js | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/mode/haxe/haxe.js b/mode/haxe/haxe.js index 00be2962b5..a9573dd71b 100644 --- a/mode/haxe/haxe.js +++ b/mode/haxe/haxe.js @@ -191,21 +191,20 @@ CodeMirror.defineMode("haxe", function(config, parserConfig) { pass.apply(null, arguments); return true; } + function inList(name, list) { + for (var v = list; v; v = v.next) + if (v.name == name) return true; + return false; + } function register(varname) { - function inList(list) { - for (var v = list; v; v = v.next) - if (v.name == varname) return true; - return false; - } var state = cx.state; if (state.context) { cx.marked = "def"; - if (inList(state.localVars)) return; + if (inList(varname, state.localVars)) return; state.localVars = {name: varname, next: state.localVars}; - } else { - if (inList(state.globalVars)) return; - if (parserConfig.globalVars) - state.globalVars = {name: varname, next: state.globalVars}; + } else if (state.globalVars) { + if (inList(varname, state.globalVars)) return; + state.globalVars = {name: varname, next: state.globalVars}; } } From 5fafcf837480430b614085d62d884098ccd53297 Mon Sep 17 00:00:00 2001 From: "S. Chris Colbert" Date: Wed, 7 Oct 2015 13:41:25 -0400 Subject: [PATCH 0091/2444] Fix vertical scroll jitter on OSX trackpads --- lib/codemirror.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/codemirror.js b/lib/codemirror.js index 63a6229477..4b1fc4f769 100644 --- a/lib/codemirror.js +++ b/lib/codemirror.js @@ -3971,8 +3971,9 @@ var display = cm.display, scroll = display.scroller; // Quit if there's nothing to scroll here - if (!(dx && scroll.scrollWidth > scroll.clientWidth || - dy && scroll.scrollHeight > scroll.clientHeight)) return; + var canScrollX = scroll.scrollWidth > scroll.clientWidth; + var canScrollY = scroll.scrollHeight > scroll.clientHeight; + if (!(dx && canScrollX || dy && canScrollY)) return; // Webkit browsers on OS X abort momentum scrolls when the target // of the scroll event is removed from the scrollable element. @@ -3996,10 +3997,15 @@ // scrolling entirely here. It'll be slightly off from native, but // better than glitching out. if (dx && !gecko && !presto && wheelPixelsPerUnit != null) { - if (dy) + if (dy && canScrollY) setScrollTop(cm, Math.max(0, Math.min(scroll.scrollTop + dy * wheelPixelsPerUnit, scroll.scrollHeight - scroll.clientHeight))); setScrollLeft(cm, Math.max(0, Math.min(scroll.scrollLeft + dx * wheelPixelsPerUnit, scroll.scrollWidth - scroll.clientWidth))); - e_preventDefault(e); + // Only prevent default scrolling if vertical scrolling is + // actually possible. Otherwise, it causes vertical scroll + // jitter on OSX trackpads when deltaX is small and deltaY + // is large (issue #3579) + if (!dy || (dy && canScrollY)) + e_preventDefault(e); display.wheelStartX = null; // Abort measurement, if in progress return; } From 4a0c9c3e23f886065d44b4ad29c8dce13d8306b4 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Thu, 8 Oct 2015 16:28:38 +0200 Subject: [PATCH 0092/2444] [javascript mode] Also style global definitions as 'def' --- mode/javascript/javascript.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mode/javascript/javascript.js b/mode/javascript/javascript.js index 8869c9b08e..de7b5abe91 100644 --- a/mode/javascript/javascript.js +++ b/mode/javascript/javascript.js @@ -281,8 +281,8 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { return false; } var state = cx.state; + cx.marked = "def"; if (state.context) { - cx.marked = "def"; if (inList(state.localVars)) return; state.localVars = {name: varname, next: state.localVars}; } else { From 55f3f3a086c7080ce0c27aed39a90174796e1035 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Thu, 8 Oct 2015 16:45:41 +0200 Subject: [PATCH 0093/2444] [javascript modes] Update tests for changed highlighting of toplevel defs --- mode/javascript/test.js | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/mode/javascript/test.js b/mode/javascript/test.js index 452de5fd6b..de71d8c95d 100644 --- a/mode/javascript/test.js +++ b/mode/javascript/test.js @@ -6,7 +6,7 @@ function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); } MT("locals", - "[keyword function] [variable foo]([def a], [def b]) { [keyword var] [def c] [operator =] [number 10]; [keyword return] [variable-2 a] [operator +] [variable-2 c] [operator +] [variable d]; }"); + "[keyword function] [def foo]([def a], [def b]) { [keyword var] [def c] [operator =] [number 10]; [keyword return] [variable-2 a] [operator +] [variable-2 c] [operator +] [variable d]; }"); MT("comma-and-binop", "[keyword function](){ [keyword var] [def x] [operator =] [number 1] [operator +] [number 2], [def y]; }"); @@ -18,7 +18,7 @@ "})();"); MT("class_body", - "[keyword class] [variable Foo] {", + "[keyword class] [def Foo] {", " [property constructor]() {}", " [property sayName]() {", " [keyword return] [string-2 `foo${][variable foo][string-2 }oo`];", @@ -26,7 +26,7 @@ "}"); MT("class", - "[keyword class] [variable Point] [keyword extends] [variable SuperThing] {", + "[keyword class] [def Point] [keyword extends] [variable SuperThing] {", " [property get] [property prop]() { [keyword return] [number 24]; }", " [property constructor]([def x], [def y]) {", " [keyword super]([string 'something']);", @@ -35,44 +35,44 @@ "}"); MT("import", - "[keyword function] [variable foo]() {", + "[keyword function] [def foo]() {", " [keyword import] [def $] [keyword from] [string 'jquery'];", " [keyword import] { [def encrypt], [def decrypt] } [keyword from] [string 'crypto'];", "}"); MT("const", - "[keyword function] [variable f]() {", + "[keyword function] [def f]() {", " [keyword const] [[ [def a], [def b] ]] [operator =] [[ [number 1], [number 2] ]];", "}"); MT("for/of", - "[keyword for]([keyword let] [variable of] [keyword of] [variable something]) {}"); + "[keyword for]([keyword let] [def of] [keyword of] [variable something]) {}"); MT("generator", - "[keyword function*] [variable repeat]([def n]) {", + "[keyword function*] [def repeat]([def n]) {", " [keyword for]([keyword var] [def i] [operator =] [number 0]; [variable-2 i] [operator <] [variable-2 n]; [operator ++][variable-2 i])", " [keyword yield] [variable-2 i];", "}"); MT("quotedStringAddition", - "[keyword let] [variable f] [operator =] [variable a] [operator +] [string 'fatarrow'] [operator +] [variable c];"); + "[keyword let] [def f] [operator =] [variable a] [operator +] [string 'fatarrow'] [operator +] [variable c];"); MT("quotedFatArrow", - "[keyword let] [variable f] [operator =] [variable a] [operator +] [string '=>'] [operator +] [variable c];"); + "[keyword let] [def f] [operator =] [variable a] [operator +] [string '=>'] [operator +] [variable c];"); MT("fatArrow", "[variable array].[property filter]([def a] [operator =>] [variable-2 a] [operator +] [number 1]);", "[variable a];", // No longer in scope - "[keyword let] [variable f] [operator =] ([[ [def a], [def b] ]], [def c]) [operator =>] [variable-2 a] [operator +] [variable-2 c];", + "[keyword let] [def f] [operator =] ([[ [def a], [def b] ]], [def c]) [operator =>] [variable-2 a] [operator +] [variable-2 c];", "[variable c];"); MT("spread", - "[keyword function] [variable f]([def a], [meta ...][def b]) {", + "[keyword function] [def f]([def a], [meta ...][def b]) {", " [variable something]([variable-2 a], [meta ...][variable-2 b]);", "}"); MT("comprehension", - "[keyword function] [variable f]() {", + "[keyword function] [def f]() {", " [[([variable x] [operator +] [number 1]) [keyword for] ([keyword var] [def x] [keyword in] [variable y]) [keyword if] [variable pred]([variable-2 x]) ]];", " ([variable u] [keyword for] ([keyword var] [def u] [keyword of] [variable generateValues]()) [keyword if] ([variable-2 u].[property color] [operator ===] [string 'blue']));", "}"); @@ -84,7 +84,7 @@ "[variable x] [operator =] [string-2 `fofdlakj${][variable x] [operator +] [string-2 `foo`] [operator +] [number 1][string-2 }fdsa`] [operator +] [number 2]"); MT("indent_statement", - "[keyword var] [variable x] [operator =] [number 10]", + "[keyword var] [def x] [operator =] [number 10]", "[variable x] [operator +=] [variable y] [operator +]", " [atom Infinity]", "[keyword debugger];"); @@ -105,14 +105,14 @@ "}"); MT("indent_for", - "[keyword for] ([keyword var] [variable i] [operator =] [number 0];", + "[keyword for] ([keyword var] [def i] [operator =] [number 0];", " [variable i] [operator <] [number 100];", " [variable i][operator ++])", " [variable doSomething]([variable i]);", "[keyword debugger];"); MT("indent_c_style", - "[keyword function] [variable foo]()", + "[keyword function] [def foo]()", "{", " [keyword debugger];", "}"); @@ -140,21 +140,21 @@ "[number 2];"); MT("multilinestring", - "[keyword var] [variable x] [operator =] [string 'foo\\]", + "[keyword var] [def x] [operator =] [string 'foo\\]", "[string bar'];"); MT("scary_regexp", "[string-2 /foo[[/]]bar/];"); MT("indent_strange_array", - "[keyword var] [variable x] [operator =] [[", + "[keyword var] [def x] [operator =] [[", " [number 1],,", " [number 2],", "]];", "[number 10];"); MT("param_default", - "[keyword function] [variable foo]([def x] [operator =] [string-2 `foo${][number 10][string-2 }bar`]) {", + "[keyword function] [def foo]([def x] [operator =] [string-2 `foo${][number 10][string-2 }bar`]) {", " [keyword return] [variable-2 x];", "}"); From 8fbf049ab7c0591d91687ccc8c74dc5940ac6317 Mon Sep 17 00:00:00 2001 From: idleberg Date: Fri, 9 Oct 2015 13:12:17 +0200 Subject: [PATCH 0094/2444] [base64 themes] Fix URL in comment --- theme/base16-dark.css | 2 +- theme/base16-light.css | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/theme/base16-dark.css b/theme/base16-dark.css index 81dac03923..026a816890 100644 --- a/theme/base16-dark.css +++ b/theme/base16-dark.css @@ -3,7 +3,7 @@ Name: Base16 Default Dark Author: Chris Kempson (http://chriskempson.com) - CodeMirror template by Jan T. Sott (https://github.com/idleberg/base16-chrome-devtools) + CodeMirror template by Jan T. Sott (https://github.com/idleberg/base16-codemirror) Original Base16 color scheme by Chris Kempson (https://github.com/chriskempson/base16) */ diff --git a/theme/base16-light.css b/theme/base16-light.css index e645678f8a..474e0ca9d1 100644 --- a/theme/base16-light.css +++ b/theme/base16-light.css @@ -3,7 +3,7 @@ Name: Base16 Default Light Author: Chris Kempson (http://chriskempson.com) - CodeMirror template by Jan T. Sott (https://github.com/idleberg/base16-chrome-devtools) + CodeMirror template by Jan T. Sott (https://github.com/idleberg/base16-codemirror) Original Base16 color scheme by Chris Kempson (https://github.com/chriskempson/base16) */ From de7b15f97f6a2f85ae0b09dea8c649f5d3c29159 Mon Sep 17 00:00:00 2001 From: peter Date: Fri, 9 Oct 2015 17:42:39 +0800 Subject: [PATCH 0095/2444] Refactor local variable name to save file size when minified --- lib/codemirror.js | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/lib/codemirror.js b/lib/codemirror.js index 4b1fc4f769..8801a44cb7 100644 --- a/lib/codemirror.js +++ b/lib/codemirror.js @@ -21,27 +21,29 @@ // Kludges for bugs and behavior differences that can't be feature // detected are enabled based on userAgent etc sniffing. + var userAgent = navigator.userAgent; + var platform = navigator.platform; - var gecko = /gecko\/\d/i.test(navigator.userAgent); - var ie_upto10 = /MSIE \d/.test(navigator.userAgent); - var ie_11up = /Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent); + var gecko = /gecko\/\d/i.test(userAgent); + var ie_upto10 = /MSIE \d/.test(userAgent); + var ie_11up = /Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(userAgent); var ie = ie_upto10 || ie_11up; var ie_version = ie && (ie_upto10 ? document.documentMode || 6 : ie_11up[1]); - var webkit = /WebKit\//.test(navigator.userAgent); - var qtwebkit = webkit && /Qt\/\d+\.\d+/.test(navigator.userAgent); - var chrome = /Chrome\//.test(navigator.userAgent); - var presto = /Opera\//.test(navigator.userAgent); + var webkit = /WebKit\//.test(userAgent); + var qtwebkit = webkit && /Qt\/\d+\.\d+/.test(userAgent); + var chrome = /Chrome\//.test(userAgent); + var presto = /Opera\//.test(userAgent); var safari = /Apple Computer/.test(navigator.vendor); - var mac_geMountainLion = /Mac OS X 1\d\D([8-9]|\d\d)\D/.test(navigator.userAgent); - var phantom = /PhantomJS/.test(navigator.userAgent); + var mac_geMountainLion = /Mac OS X 1\d\D([8-9]|\d\d)\D/.test(userAgent); + var phantom = /PhantomJS/.test(userAgent); - var ios = /AppleWebKit/.test(navigator.userAgent) && /Mobile\/\w+/.test(navigator.userAgent); + var ios = /AppleWebKit/.test(userAgent) && /Mobile\/\w+/.test(userAgent); // This is woefully incomplete. Suggestions for alternative methods welcome. - var mobile = ios || /Android|webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(navigator.userAgent); - var mac = ios || /Mac/.test(navigator.platform); - var windows = /win/i.test(navigator.platform); + var mobile = ios || /Android|webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(userAgent); + var mac = ios || /Mac/.test(platform); + var windows = /win/i.test(platform); - var presto_version = presto && navigator.userAgent.match(/Version\/(\d*\.\d*)/); + var presto_version = presto && userAgent.match(/Version\/(\d*\.\d*)/); if (presto_version) presto_version = Number(presto_version[1]); if (presto_version && presto_version >= 15) { presto = false; webkit = true; } // Some browsers use the wrong event properties to signal cmd/ctrl on OS X From 0ca9fc878df2ecc2f9d2a279de9d5c3786f9a2f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elis=C3=A9e?= Date: Sun, 11 Oct 2015 00:58:06 +0200 Subject: [PATCH 0096/2444] [javascript mode] Fix TypeScript mode to highlight "boolean" not "bool" --- mode/javascript/javascript.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mode/javascript/javascript.js b/mode/javascript/javascript.js index de7b5abe91..106111d837 100644 --- a/mode/javascript/javascript.js +++ b/mode/javascript/javascript.js @@ -56,7 +56,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { "static": kw("static"), // types - "string": type, "number": type, "bool": type, "any": type + "string": type, "number": type, "boolean": type, "any": type }; for (var attr in tsKeywords) { From eedb58faa301551d530b34e5c765a90607232a31 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Wed, 14 Oct 2015 18:09:56 +0200 Subject: [PATCH 0097/2444] [htmlmixed mode] Check for own properties when looking up defined tags Closes #3596 --- mode/htmlmixed/htmlmixed.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mode/htmlmixed/htmlmixed.js b/mode/htmlmixed/htmlmixed.js index 670fd62bf1..21e74f163d 100644 --- a/mode/htmlmixed/htmlmixed.js +++ b/mode/htmlmixed/htmlmixed.js @@ -89,8 +89,8 @@ tags.script.unshift(["type", configScript[i].matches, configScript[i].mode]) function html(stream, state) { - var tagName = state.htmlState.tagName; - var tagInfo = tagName && tags[tagName.toLowerCase()]; + var tagName = state.htmlState.tagName && state.htmlState.tagName.toLowerCase(); + var tagInfo = tagName && tags.hasOwnProperty(tagName) && tags[tagName]; var style = htmlMode.token(stream, state.htmlState), modeSpec; From bc5a4939b2603f587c2358a8b13063862660bcdf Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Thu, 15 Oct 2015 09:46:18 +0200 Subject: [PATCH 0098/2444] Allow the type of a marker created by markText to be overridden ... using the type option. Closes #3600 --- lib/codemirror.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/codemirror.js b/lib/codemirror.js index 8801a44cb7..c13f954352 100644 --- a/lib/codemirror.js +++ b/lib/codemirror.js @@ -7558,7 +7558,7 @@ removeLineWidget: function(widget) { widget.clear(); }, markText: function(from, to, options) { - return markText(this, clipPos(this, from), clipPos(this, to), options, "range"); + return markText(this, clipPos(this, from), clipPos(this, to), options, options && options.type || "range"); }, setBookmark: function(pos, options) { var realOpts = {replacedWith: options && (options.nodeType == null ? options.widget : options), From caf1323d81cfc446db0e77129a26bd95ab9322b8 Mon Sep 17 00:00:00 2001 From: Michael Goderbauer Date: Thu, 15 Oct 2015 10:56:55 -0700 Subject: [PATCH 0099/2444] [dart mode] support for triple-quoted strings and string interpolation - Previously, triple-quoted multi-line strings could be closed with a single quote, e.g. CodeMirror thought the following was a legal string literal: '''This string literal is not terminated correctly'. Also reported here: dart-lang/dart-pad#667 - String interpolation with $identifier and ${expression} now works --- mode/dart/dart.js | 82 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 81 insertions(+), 1 deletion(-) diff --git a/mode/dart/dart.js b/mode/dart/dart.js index a49e218c3b..3132c21e71 100644 --- a/mode/dart/dart.js +++ b/mode/dart/dart.js @@ -26,10 +26,21 @@ return obj; } + function pushInterpolationStack(state) { + (state.interpolationStack || (state.interpolationStack = [])).push(state.tokenize); + } + + function popInterpolationStack(state) { + return (state.interpolationStack || (state.interpolationStack = [])).pop(); + } + + function sizeInterpolationStack(state) { + return (state.interpolationStack || (state.interpolationStack = [])).length; + } + CodeMirror.defineMIME("application/dart", { name: "clike", keywords: set(keywords), - multiLineStrings: true, blockKeywords: set(blockKeywords), builtin: set(builtins), atoms: set(atoms), @@ -37,10 +48,79 @@ "@": function(stream) { stream.eatWhile(/[\w\$_]/); return "meta"; + }, + + // custom string handling to deal with triple-quoted strings and string interpolation + "'": function(stream, state) { + return tokenString("'", stream, state, false); + }, + "\"": function(stream, state) { + return tokenString("\"", stream, state, false); + }, + "r": function(stream, state) { + var peek = stream.peek(); + if (peek == "'" || peek == "\"") { + return tokenString(stream.next(), stream, state, true); + } + return false; + }, + + "}": function(_stream, state) { + // "}" is end of interpolation, if interpolation stack is non-empty + if (sizeInterpolationStack(state) > 0) { + state.tokenize = popInterpolationStack(state); + return null; + } + return false; } } }); + function tokenString(quote, stream, state, raw) { + var tripleQuoted = false; + if (stream.eat(quote)) { + if (stream.eat(quote)) tripleQuoted = true; + else return "string"; //empty string + } + function tokenStringHelper(stream, state) { + var escaped = false; + while (!stream.eol()) { + if (!raw && !escaped && stream.peek() == "$") { + pushInterpolationStack(state); + state.tokenize = tokenInterpolation; + return "string"; + } + var next = stream.next(); + if (next == quote && !escaped && (!tripleQuoted || stream.match(quote + quote))) { + state.tokenize = null; + break; + } + escaped = !escaped && next == "\\"; + } + return "string"; + } + state.tokenize = tokenStringHelper; + return tokenStringHelper(stream, state); + } + + function tokenInterpolation(stream, state) { + stream.eat("$"); + if (stream.eat("{")) { + // let clike handle the content of ${...}, + // we take over again when "}" appears (see hooks). + state.tokenize = null; + } else { + state.tokenize = tokenInterpolationIdentifier; + } + return null; + } + + function tokenInterpolationIdentifier(stream, state) { + stream.eatWhile(/[\w_]/); + state.tokenize = popInterpolationStack(state); + return "variable"; + } + CodeMirror.registerHelper("hintWords", "application/dart", keywords.concat(atoms).concat(builtins)); // This is needed to make loading through meta.js work. From b3619febb82a792450c3a0f8d61512f2217d6d60 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Thu, 15 Oct 2015 22:33:29 +0200 Subject: [PATCH 0100/2444] [dart mode] Avoid unneccesary adding of state property Issue #3601 --- mode/dart/dart.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mode/dart/dart.js b/mode/dart/dart.js index 3132c21e71..7d6e5abd96 100644 --- a/mode/dart/dart.js +++ b/mode/dart/dart.js @@ -35,7 +35,7 @@ } function sizeInterpolationStack(state) { - return (state.interpolationStack || (state.interpolationStack = [])).length; + return state.interpolationStack ? state.interpolationStack.length : 0; } CodeMirror.defineMIME("application/dart", { From 356f2a1ad385283b9d4de8e4dcc09bd90c995681 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Thu, 15 Oct 2015 23:19:23 +0200 Subject: [PATCH 0101/2444] [css mode] Support interpolation in @block context Closes #3585 --- mode/css/css.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mode/css/css.js b/mode/css/css.js index 7300850399..d07426473b 100644 --- a/mode/css/css.js +++ b/mode/css/css.js @@ -275,6 +275,8 @@ CodeMirror.defineMode("css", function(config, parserConfig) { if (type == "}" || type == ";") return popAndPass(type, stream, state); if (type == "{") return popContext(state) && pushContext(state, stream, allowNested ? "block" : "top"); + if (type == "interpolation") return pushContext(state, stream, "interpolation"); + if (type == "word") { var word = stream.current().toLowerCase(); if (word == "only" || word == "not" || word == "and" || word == "or") From 8fd466fba5d47176d7b3c26ddc5edf2a8f4b1292 Mon Sep 17 00:00:00 2001 From: Vincent Woo Date: Fri, 9 Oct 2015 18:24:59 -0700 Subject: [PATCH 0102/2444] [comment addon] Smarter indenting in multiline linecommenting --- addon/comment/comment.js | 9 ++++++++- test/comment_test.js | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/addon/comment/comment.js b/addon/comment/comment.js index 2dd114d332..1c7aaae1e1 100644 --- a/addon/comment/comment.js +++ b/addon/comment/comment.js @@ -57,7 +57,14 @@ self.operation(function() { if (options.indent) { - var baseString = firstLine.slice(0, firstNonWS(firstLine)); + var baseString = null; + for (var i = from.line; i < end; ++i) { + var line = self.getLine(i); + var whitespace = line.slice(0, firstNonWS(line)); + if (baseString == null || baseString.length > whitespace.length) { + baseString = whitespace; + } + } for (var i = from.line; i < end; ++i) { var line = self.getLine(i), cut = baseString.length; if (!blankLines && !nonWS.test(line)) continue; diff --git a/test/comment_test.js b/test/comment_test.js index 8bd3959ee9..26e474493b 100644 --- a/test/comment_test.js +++ b/test/comment_test.js @@ -79,7 +79,7 @@ namespace = "comment_"; test("indented", "javascript", function(cm) { cm.lineComment(Pos(1, 0), Pos(2), {indent: true}); - }, simpleProg, "function foo() {\n // return bar;\n // }"); + }, simpleProg, "function foo() {\n// return bar;\n// }"); test("singleEmptyLine", "javascript", function(cm) { cm.setCursor(1); From 872bb73403998d14e2994fbefee43df01e828470 Mon Sep 17 00:00:00 2001 From: John Engler Date: Wed, 7 Oct 2015 18:34:34 -0700 Subject: [PATCH 0103/2444] [clike mode] Remove false from Scala keyword list So that both true and false highlight as atoms --- mode/clike/clike.js | 2 +- mode/javascript/javascript.js | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/mode/clike/clike.js b/mode/clike/clike.js index e2900d8014..d4b7438b9d 100644 --- a/mode/clike/clike.js +++ b/mode/clike/clike.js @@ -478,7 +478,7 @@ CodeMirror.defineMode("clike", function(config, parserConfig) { keywords: words( /* scala */ - "abstract case catch class def do else extends false final finally for forSome if " + + "abstract case catch class def do else extends final finally for forSome if " + "implicit import lazy match new null object override package private protected return " + "sealed super this throw trait try type val var while with yield _ : = => <- <: " + "<% >: # @ " + diff --git a/mode/javascript/javascript.js b/mode/javascript/javascript.js index 106111d837..07281b7959 100644 --- a/mode/javascript/javascript.js +++ b/mode/javascript/javascript.js @@ -670,6 +670,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { lexical = lexical.prev; var type = lexical.type, closing = firstChar == type; + console.log(firstChar, type) if (type == "vardef") return lexical.indented + (state.lastType == "operator" || state.lastType == "," ? lexical.info + 1 : 0); else if (type == "form" && firstChar == "{") return lexical.indented; else if (type == "form") return lexical.indented + indentUnit; From 4096f2da64c0af8c744b5e3e7a4a6c047073e354 Mon Sep 17 00:00:00 2001 From: darealshinji Date: Wed, 14 Oct 2015 19:58:13 +0200 Subject: [PATCH 0104/2444] [shell mode] add `PKGBUILD' as a file name `A PKGBUILD is a shell script containing the build information required by Arch Linux packages.` https://wiki.archlinux.org/index.php/PKGBUILD --- mode/meta.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mode/meta.js b/mode/meta.js index da03716be8..7d6a6e1bf4 100644 --- a/mode/meta.js +++ b/mode/meta.js @@ -109,7 +109,7 @@ {name: "Scala", mime: "text/x-scala", mode: "clike", ext: ["scala"]}, {name: "Scheme", mime: "text/x-scheme", mode: "scheme", ext: ["scm", "ss"]}, {name: "SCSS", mime: "text/x-scss", mode: "css", ext: ["scss"]}, - {name: "Shell", mime: "text/x-sh", mode: "shell", ext: ["sh", "ksh", "bash"], alias: ["bash", "sh", "zsh"]}, + {name: "Shell", mime: "text/x-sh", mode: "shell", ext: ["sh", "ksh", "bash"], alias: ["bash", "sh", "zsh"], file: /^PKGBUILD$/}, {name: "Sieve", mime: "application/sieve", mode: "sieve", ext: ["siv", "sieve"]}, {name: "Slim", mimes: ["text/x-slim", "application/x-slim"], mode: "slim", ext: ["slim"]}, {name: "Smalltalk", mime: "text/x-stsrc", mode: "smalltalk", ext: ["st"]}, From 8a012c0ae93654c911e029f82f92d5e21c1f389d Mon Sep 17 00:00:00 2001 From: Vincent Woo Date: Fri, 9 Oct 2015 17:35:59 -0700 Subject: [PATCH 0105/2444] Allow passing options to toggleComment --- addon/comment/comment.js | 18 ++++++++++++------ doc/manual.html | 9 ++++++--- keymap/sublime.js | 4 +++- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/addon/comment/comment.js b/addon/comment/comment.js index 1c7aaae1e1..3aa468089e 100644 --- a/addon/comment/comment.js +++ b/addon/comment/comment.js @@ -21,22 +21,28 @@ } CodeMirror.commands.toggleComment = function(cm) { - var minLine = Infinity, ranges = cm.listSelections(), mode = null; + cm.toggleComment(); + }; + + CodeMirror.defineExtension("toggleComment", function(options) { + if (!options) options = noOptions; + var cm = this; + var minLine = Infinity, ranges = this.listSelections(), mode = null; for (var i = ranges.length - 1; i >= 0; i--) { var from = ranges[i].from(), to = ranges[i].to(); if (from.line >= minLine) continue; if (to.line >= minLine) to = Pos(minLine, 0); minLine = from.line; if (mode == null) { - if (cm.uncomment(from, to)) mode = "un"; - else { cm.lineComment(from, to); mode = "line"; } + if (cm.uncomment(from, to, options)) mode = "un"; + else { cm.lineComment(from, to, options); mode = "line"; } } else if (mode == "un") { - cm.uncomment(from, to); + cm.uncomment(from, to, options); } else { - cm.lineComment(from, to); + cm.lineComment(from, to, options); } } - }; + }); CodeMirror.defineExtension("lineComment", function(from, to, options) { if (!options) options = noOptions; diff --git a/doc/manual.html b/doc/manual.html index 75875ff2bd..4cc4a39c25 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -2313,9 +2313,12 @@

      Addons

      demo.
    comment/comment.js
    -
    Addon for commenting and uncommenting code. Adds three +
    Addon for commenting and uncommenting code. Adds four methods to CodeMirror instances:
    +
    toggleComment(from: {line, ch}, to: {line, ch}, ?options: object)
    +
    Tries to uncomment the current selection, and if that + fails, line-comments it.
    lineComment(from: {line, ch}, to: {line, ch}, ?options: object)
    Set the lines in the given range to be line comments. Will fall back to blockComment when no line comment @@ -2353,8 +2356,8 @@

    Addons

    The addon also defines a toggleComment command, - which will try to uncomment the current selection, and if that - fails, line-comments it.
    + which is a shorthand command for calling + toggleComment with no options.
    fold/foldcode.js
    Helps with code folding. Adds a foldCode method diff --git a/keymap/sublime.js b/keymap/sublime.js index 44e812a248..a0ca41ea2a 100644 --- a/keymap/sublime.js +++ b/keymap/sublime.js @@ -240,7 +240,9 @@ }); }; - map[ctrl + "/"] = "toggleComment"; + map[ctrl + "/"] = function(cm) { + cm.toggleComment({ indent: true }); + } cmds[map[ctrl + "J"] = "joinLines"] = function(cm) { var ranges = cm.listSelections(), joined = []; From e07f8fcf7087b6b87fb8aa9884d14bb158485a1e Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Fri, 16 Oct 2015 09:44:21 +0200 Subject: [PATCH 0106/2444] [javascript mode] Remove accidentally committed debug statement --- mode/javascript/javascript.js | 1 - 1 file changed, 1 deletion(-) diff --git a/mode/javascript/javascript.js b/mode/javascript/javascript.js index 07281b7959..106111d837 100644 --- a/mode/javascript/javascript.js +++ b/mode/javascript/javascript.js @@ -670,7 +670,6 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { lexical = lexical.prev; var type = lexical.type, closing = firstChar == type; - console.log(firstChar, type) if (type == "vardef") return lexical.indented + (state.lastType == "operator" || state.lastType == "," ? lexical.info + 1 : 0); else if (type == "form" && firstChar == "{") return lexical.indented; else if (type == "form") return lexical.indented + indentUnit; From 770a7719494119dc90ed16c848d3e2399da1c263 Mon Sep 17 00:00:00 2001 From: Barret Rennie Date: Thu, 1 Oct 2015 12:55:53 -0600 Subject: [PATCH 0107/2444] [markdown mode] Allow styles to be overridden The `markdown` mode now supports styling overrides. The configuration object passed to the class now accepts a `tokenTypeOverrides` object, which allows the user to sepcify different CSS classes for elements. This is useful for the case where the default CSS classes are reused for multiple elements (e.g. `list1` maps to `variable-2` by default) and more customized styling is desired. Unit tests have been added to cover all types of styling overrides. --- mode/markdown/markdown.js | 105 +++++++++++++++++++++----------------- mode/markdown/test.js | 99 +++++++++++++++++++++++++++++++++++ 2 files changed, 157 insertions(+), 47 deletions(-) diff --git a/mode/markdown/markdown.js b/mode/markdown/markdown.js index 9d40368180..2349ddf22b 100644 --- a/mode/markdown/markdown.js +++ b/mode/markdown/markdown.js @@ -51,24 +51,36 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) { if (modeCfg.strikethrough === undefined) modeCfg.strikethrough = false; + // Allow token types to be overridden by user-provided token types. + if (modeCfg.tokenTypeOverrides === undefined) + modeCfg.tokenTypeOverrides = {}; + var codeDepth = 0; - var header = 'header' - , code = 'comment' - , quote = 'quote' - , list1 = 'variable-2' - , list2 = 'variable-3' - , list3 = 'keyword' - , hr = 'hr' - , image = 'tag' - , formatting = 'formatting' - , linkinline = 'link' - , linkemail = 'link' - , linktext = 'link' - , linkhref = 'string' - , em = 'em' - , strong = 'strong' - , strikethrough = 'strikethrough'; + var tokenTypes = { + header: "header", + code: "comment", + quote: "quote", + list1: "variable-2", + list2: "variable-3", + list3: "keyword", + hr: "hr", + image: "tag", + formatting: "formatting", + linkInline: "link", + linkEmail: "link", + linkText: "link", + linkHref: "string", + em: "em", + strong: "strong", + strikethrough: "strikethrough" + }; + + for (var tokenType in tokenTypes) { + if (tokenTypes.hasOwnProperty(tokenType) && modeCfg.tokenTypeOverrides[tokenType]) { + tokenTypes[tokenType] = modeCfg.tokenTypeOverrides[tokenType]; + } + } var hrRE = /^([*\-_])(?:\s*\1){2,}\s*$/ , ulRE = /^[*\-+]\s+/ @@ -152,7 +164,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) { if (prevLineIsIndentedCode || lineIsEmpty(state.prevLine)) { state.indentation -= 4; state.indentedCode = true; - return code; + return tokenTypes.code; } else { return null; } @@ -178,7 +190,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) { return switchInline(stream, state, footnoteLink); } else if (stream.match(hrRE, true)) { state.hr = true; - return hr; + return tokenTypes.hr; } else if ((lineIsEmpty(state.prevLine) || prevLineIsList) && (stream.match(ulRE, false) || stream.match(olRE, false))) { var listType = null; if (stream.match(ulRE, true)) { @@ -231,7 +243,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) { return state.localMode.token(stream, state.localState); } else { stream.skipToEnd(); - return code; + return tokenTypes.code; } } @@ -252,22 +264,22 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) { var styles = []; if (state.formatting) { - styles.push(formatting); + styles.push(tokenTypes.formatting); if (typeof state.formatting === "string") state.formatting = [state.formatting]; for (var i = 0; i < state.formatting.length; i++) { - styles.push(formatting + "-" + state.formatting[i]); + styles.push(tokenTypes.formatting + "-" + state.formatting[i]); if (state.formatting[i] === "header") { - styles.push(formatting + "-" + state.formatting[i] + "-" + state.header); + styles.push(tokenTypes.formatting + "-" + state.formatting[i] + "-" + state.header); } // Add `formatting-quote` and `formatting-quote-#` for blockquotes // Add `error` instead if the maximum blockquote nesting depth is passed if (state.formatting[i] === "quote") { if (!modeCfg.maxBlockquoteDepth || modeCfg.maxBlockquoteDepth >= state.quote) { - styles.push(formatting + "-" + state.formatting[i] + "-" + state.quote); + styles.push(tokenTypes.formatting + "-" + state.formatting[i] + "-" + state.quote); } else { styles.push("error"); } @@ -285,38 +297,36 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) { } if (state.linkHref) { - styles.push(linkhref, "url"); + styles.push(tokenTypes.linkHref, "url"); } else { // Only apply inline styles to non-url text - if (state.strong) { styles.push(strong); } - if (state.em) { styles.push(em); } - if (state.strikethrough) { styles.push(strikethrough); } - - if (state.linkText) { styles.push(linktext); } - - if (state.code) { styles.push(code); } + if (state.strong) { styles.push(tokenTypes.strong); } + if (state.em) { styles.push(tokenTypes.em); } + if (state.strikethrough) { styles.push(tokenTypes.strikethrough); } + if (state.linkText) { styles.push(tokenTypes.linkText); } + if (state.code) { styles.push(tokenTypes.code); } } - if (state.header) { styles.push(header); styles.push(header + "-" + state.header); } + if (state.header) { styles.push(tokenTypes.header, tokenTypes.header + "-" + state.header); } if (state.quote) { - styles.push(quote); + styles.push(tokenTypes.quote); // Add `quote-#` where the maximum for `#` is modeCfg.maxBlockquoteDepth if (!modeCfg.maxBlockquoteDepth || modeCfg.maxBlockquoteDepth >= state.quote) { - styles.push(quote + "-" + state.quote); + styles.push(tokenTypes.quote + "-" + state.quote); } else { - styles.push(quote + "-" + modeCfg.maxBlockquoteDepth); + styles.push(tokenTypes.quote + "-" + modeCfg.maxBlockquoteDepth); } } if (state.list !== false) { var listMod = (state.listDepth - 1) % 3; if (!listMod) { - styles.push(list1); + styles.push(tokenTypes.list1); } else if (listMod === 1) { - styles.push(list2); + styles.push(tokenTypes.list2); } else { - styles.push(list3); + styles.push(tokenTypes.list3); } } @@ -372,7 +382,8 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) { stream.next(); if (modeCfg.highlightFormatting) { var type = getType(state); - return type ? type + " formatting-escape" : "formatting-escape"; + var formattingEscape = tokenTypes.formatting + "-escape"; + return type ? type + " " + formattingEscape : formattingEscape; } } @@ -386,7 +397,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) { matchCh = (matchCh+'').replace(/([.?*+^$[\]\\(){}|-])/g, "\\$1"); var regex = '^\\s*(?:[^' + matchCh + '\\\\]+|\\\\\\\\|\\\\.)' + matchCh; if (stream.match(new RegExp(regex), true)) { - return linkhref; + return tokenTypes.linkHref; } } @@ -417,7 +428,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) { if (ch === '!' && stream.match(/\[[^\]]*\] ?(?:\(|\[)/, false)) { stream.match(/\[[^\]]*\]/); state.inline = state.f = linkHref; - return image; + return tokenTypes.image; } if (ch === '[' && stream.match(/.*\](\(.*\)| ?\[.*\])/, false)) { @@ -443,7 +454,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) { } else { type = ""; } - return type + linkinline; + return type + tokenTypes.linkInline; } if (ch === '<' && stream.match(/^[^> \\]+@(?:[^\\>]|\\.)+>/, false)) { @@ -455,7 +466,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) { } else { type = ""; } - return type + linkemail; + return type + tokenTypes.linkEmail; } if (ch === '<' && stream.match(/^(!--|\w)/, false)) { @@ -564,12 +575,12 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) { } else { type = ""; } - return type + linkinline; + return type + tokenTypes.linkInline; } stream.match(/^[^>]+/, true); - return linkinline; + return tokenTypes.linkInline; } function linkHref(stream, state) { @@ -630,7 +641,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) { stream.match(/^[^\]]+/, true); - return linktext; + return tokenTypes.linkText; } function footnoteUrl(stream, state) { @@ -647,7 +658,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) { stream.match(/^(?:\s+(?:"(?:[^"\\]|\\\\|\\.)+"|'(?:[^'\\]|\\\\|\\.)+'|\((?:[^)\\]|\\\\|\\.)+\)))?/, true); } state.f = state.inline = inlineNormal; - return linkhref + " url"; + return tokenTypes.linkHref + " url"; } var savedInlineRE = []; diff --git a/mode/markdown/test.js b/mode/markdown/test.js index 78b6c685af..f9cc27c3b4 100644 --- a/mode/markdown/test.js +++ b/mode/markdown/test.js @@ -10,6 +10,35 @@ function AtxNoSpaceTest(name) { test.mode(name, modeAtxNoSpace, Array.prototype.slice.call(arguments, 1)); } var modeFenced = CodeMirror.getMode({tabSize: 4}, {name: "markdown", fencedCodeBlocks: true}); function FencedTest(name) { test.mode(name, modeFenced, Array.prototype.slice.call(arguments, 1)); } + var modeOverrideClasses = CodeMirror.getMode({tabsize: 4}, { + name: "markdown", + strikethrough: true, + tokenTypeOverrides: { + "header" : "override-header", + "code" : "override-code", + "quote" : "override-quote", + "list1" : "override-list1", + "list2" : "override-list2", + "list3" : "override-list3", + "hr" : "override-hr", + "image" : "override-image", + "linkInline" : "override-link-inline", + "linkEmail" : "override-link-email", + "linkText" : "override-link-text", + "linkHref" : "override-link-href", + "em" : "override-em", + "strong" : "override-strong", + "strikethrough" : "override-strikethrough" + }}); + function TokenTypeOverrideTest(name) { test.mode(name, modeOverrideClasses, Array.prototype.slice.call(arguments, 1)); } + var modeFormattingOverride = CodeMirror.getMode({tabsize: 4}, { + name: "markdown", + highlightFormatting: true, + tokenTypeOverrides: { + "formatting" : "override-formatting" + }}); + function FormatTokenTypeOverrideTest(name) { test.mode(name, modeFormattingOverride, Array.prototype.slice.call(arguments, 1)); } + FT("formatting_emAsterisk", "[em&formatting&formatting-em *][em foo][em&formatting&formatting-em *]"); @@ -774,6 +803,76 @@ "\\", "[em *foo*]"); + // Class override tests + TokenTypeOverrideTest("overrideHeader1", + "[override-header&override-header-1 # Foo]"); + + TokenTypeOverrideTest("overrideHeader2", + "[override-header&override-header-2 ## Foo]"); + + TokenTypeOverrideTest("overrideHeader3", + "[override-header&override-header-3 ### Foo]"); + + TokenTypeOverrideTest("overrideHeader4", + "[override-header&override-header-4 #### Foo]"); + + TokenTypeOverrideTest("overrideHeader5", + "[override-header&override-header-5 ##### Foo]"); + + TokenTypeOverrideTest("overrideHeader6", + "[override-header&override-header-6 ###### Foo]"); + + TokenTypeOverrideTest("overrideCode", + "[override-code `foo`]"); + + TokenTypeOverrideTest("overrideCodeBlock", + "[override-code ```]", + "[override-code foo]", + "[override-code ```]"); + + TokenTypeOverrideTest("overrideQuote", + "[override-quote&override-quote-1 > foo]", + "[override-quote&override-quote-1 > bar]"); + + TokenTypeOverrideTest("overrideQuoteNested", + "[override-quote&override-quote-1 > foo]", + "[override-quote&override-quote-1 >][override-quote&override-quote-2 > bar]", + "[override-quote&override-quote-1 >][override-quote&override-quote-2 >][override-quote&override-quote-3 > baz]"); + + TokenTypeOverrideTest("overrideLists", + "[override-list1 - foo]", + "", + " [override-list2 + bar]", + "", + " [override-list3 * baz]", + "", + " [override-list1 1. qux]", + "", + " [override-list2 - quux]"); + + TokenTypeOverrideTest("overrideHr", + "[override-hr * * *]"); + + TokenTypeOverrideTest("overrideImage", + "[override-image ![[foo]]][override-link-href&url (http://example.com/)]") + + TokenTypeOverrideTest("overrideLinkText", + "[override-link-text [[foo]]][override-link-href&url (http://example.com)]"); + + TokenTypeOverrideTest("overrideLinkEmailAndInline", + "[override-link-email <][override-link-inline foo@example.com>]"); + + TokenTypeOverrideTest("overrideEm", + "[override-em *foo*]"); + + TokenTypeOverrideTest("overrideStrong", + "[override-strong **foo**]"); + + TokenTypeOverrideTest("overrideStrikethrough", + "[override-strikethrough ~~foo~~]"); + + FormatTokenTypeOverrideTest("overrideFormatting", + "[override-formatting-escape \\*]"); // Tests to make sure GFM-specific things aren't getting through From bc008c070f19ee1e6902384a69317f84774d17de Mon Sep 17 00:00:00 2001 From: "Jan T. Sott" Date: Fri, 9 Oct 2015 22:15:35 +0200 Subject: [PATCH 0108/2444] [bespin, hopskotch, isotope, and railscasts themes] Add --- theme/bespin.css | 33 +++++++++++++++++++++++++++++++++ theme/hopscotch.css | 33 +++++++++++++++++++++++++++++++++ theme/isotope.css | 33 +++++++++++++++++++++++++++++++++ theme/railscasts.css | 33 +++++++++++++++++++++++++++++++++ 4 files changed, 132 insertions(+) create mode 100644 theme/bespin.css create mode 100644 theme/hopscotch.css create mode 100644 theme/isotope.css create mode 100644 theme/railscasts.css diff --git a/theme/bespin.css b/theme/bespin.css new file mode 100644 index 0000000000..1265a672b1 --- /dev/null +++ b/theme/bespin.css @@ -0,0 +1,33 @@ +/* + + Name: Bespin + Author: Mozilla / Jan T. Sott + + CodeMirror template by Jan T. Sott (https://github.com/idleberg/base16-codemirror) + Original Base16 color scheme by Chris Kempson (https://github.com/chriskempson/base16) + +*/ + +.cm-s-bespin.CodeMirror {background: #28211c; color: #9d9b97;} +.cm-s-bespin div.CodeMirror-selected {background: #36312e !important;} +.cm-s-bespin .CodeMirror-gutters {background: #28211c; border-right: 0px;} +.cm-s-bespin .CodeMirror-linenumber {color: #666666;} +.cm-s-bespin .CodeMirror-cursor {border-left: 1px solid #797977 !important;} + +.cm-s-bespin span.cm-comment {color: #937121;} +.cm-s-bespin span.cm-atom {color: #9b859d;} +.cm-s-bespin span.cm-number {color: #9b859d;} + +.cm-s-bespin span.cm-property, .cm-s-bespin span.cm-attribute {color: #54be0d;} +.cm-s-bespin span.cm-keyword {color: #cf6a4c;} +.cm-s-bespin span.cm-string {color: #f9ee98;} + +.cm-s-bespin span.cm-variable {color: #54be0d;} +.cm-s-bespin span.cm-variable-2 {color: #5ea6ea;} +.cm-s-bespin span.cm-def {color: #cf7d34;} +.cm-s-bespin span.cm-error {background: #cf6a4c; color: #797977;} +.cm-s-bespin span.cm-bracket {color: #9d9b97;} +.cm-s-bespin span.cm-tag {color: #cf6a4c;} +.cm-s-bespin span.cm-link {color: #9b859d;} + +.cm-s-bespin .CodeMirror-matchingbracket { text-decoration: underline; color: white !important;} diff --git a/theme/hopscotch.css b/theme/hopscotch.css new file mode 100644 index 0000000000..dd1d2add47 --- /dev/null +++ b/theme/hopscotch.css @@ -0,0 +1,33 @@ +/* + + Name: Hopscotch + Author: Jan T. Sott + + CodeMirror template by Jan T. Sott (https://github.com/idleberg/base16-codemirror) + Original Base16 color scheme by Chris Kempson (https://github.com/chriskempson/base16) + +*/ + +.cm-s-hopscotch.CodeMirror {background: #322931; color: #d5d3d5;} +.cm-s-hopscotch div.CodeMirror-selected {background: #433b42 !important;} +.cm-s-hopscotch .CodeMirror-gutters {background: #322931; border-right: 0px;} +.cm-s-hopscotch .CodeMirror-linenumber {color: #797379;} +.cm-s-hopscotch .CodeMirror-cursor {border-left: 1px solid #989498 !important;} + +.cm-s-hopscotch span.cm-comment {color: #b33508;} +.cm-s-hopscotch span.cm-atom {color: #c85e7c;} +.cm-s-hopscotch span.cm-number {color: #c85e7c;} + +.cm-s-hopscotch span.cm-property, .cm-s-hopscotch span.cm-attribute {color: #8fc13e;} +.cm-s-hopscotch span.cm-keyword {color: #dd464c;} +.cm-s-hopscotch span.cm-string {color: #fdcc59;} + +.cm-s-hopscotch span.cm-variable {color: #8fc13e;} +.cm-s-hopscotch span.cm-variable-2 {color: #1290bf;} +.cm-s-hopscotch span.cm-def {color: #fd8b19;} +.cm-s-hopscotch span.cm-error {background: #dd464c; color: #989498;} +.cm-s-hopscotch span.cm-bracket {color: #d5d3d5;} +.cm-s-hopscotch span.cm-tag {color: #dd464c;} +.cm-s-hopscotch span.cm-link {color: #c85e7c;} + +.cm-s-hopscotch .CodeMirror-matchingbracket { text-decoration: underline; color: white !important;} diff --git a/theme/isotope.css b/theme/isotope.css new file mode 100644 index 0000000000..1fe8ce08d5 --- /dev/null +++ b/theme/isotope.css @@ -0,0 +1,33 @@ +/* + + Name: Isotope + Author: David Desandro / Jan T. Sott + + CodeMirror template by Jan T. Sott (https://github.com/idleberg/base16-codemirror) + Original Base16 color scheme by Chris Kempson (https://github.com/chriskempson/base16) + +*/ + +.cm-s-isotope.CodeMirror {background: #000000; color: #e0e0e0;} +.cm-s-isotope div.CodeMirror-selected {background: #404040 !important;} +.cm-s-isotope .CodeMirror-gutters {background: #000000; border-right: 0px;} +.cm-s-isotope .CodeMirror-linenumber {color: #808080;} +.cm-s-isotope .CodeMirror-cursor {border-left: 1px solid #c0c0c0 !important;} + +.cm-s-isotope span.cm-comment {color: #3300ff;} +.cm-s-isotope span.cm-atom {color: #cc00ff;} +.cm-s-isotope span.cm-number {color: #cc00ff;} + +.cm-s-isotope span.cm-property, .cm-s-isotope span.cm-attribute {color: #33ff00;} +.cm-s-isotope span.cm-keyword {color: #ff0000;} +.cm-s-isotope span.cm-string {color: #ff0099;} + +.cm-s-isotope span.cm-variable {color: #33ff00;} +.cm-s-isotope span.cm-variable-2 {color: #0066ff;} +.cm-s-isotope span.cm-def {color: #ff9900;} +.cm-s-isotope span.cm-error {background: #ff0000; color: #c0c0c0;} +.cm-s-isotope span.cm-bracket {color: #e0e0e0;} +.cm-s-isotope span.cm-tag {color: #ff0000;} +.cm-s-isotope span.cm-link {color: #cc00ff;} + +.cm-s-isotope .CodeMirror-matchingbracket { text-decoration: underline; color: white !important;} diff --git a/theme/railscasts.css b/theme/railscasts.css new file mode 100644 index 0000000000..34fc951eab --- /dev/null +++ b/theme/railscasts.css @@ -0,0 +1,33 @@ +/* + + Name: Railscasts + Author: Ryan Bates (http://railscasts.com) + + CodeMirror template by Jan T. Sott (https://github.com/idleberg/base16-codemirror) + Original Base16 color scheme by Chris Kempson (https://github.com/chriskempson/base16) + +*/ + +.cm-s-railscasts.CodeMirror {background: #2b2b2b; color: #f4f1ed;} +.cm-s-railscasts div.CodeMirror-selected {background: #272935 !important;} +.cm-s-railscasts .CodeMirror-gutters {background: #2b2b2b; border-right: 0px;} +.cm-s-railscasts .CodeMirror-linenumber {color: #5a647e;} +.cm-s-railscasts .CodeMirror-cursor {border-left: 1px solid #d4cfc9 !important;} + +.cm-s-railscasts span.cm-comment {color: #bc9458;} +.cm-s-railscasts span.cm-atom {color: #b6b3eb;} +.cm-s-railscasts span.cm-number {color: #b6b3eb;} + +.cm-s-railscasts span.cm-property, .cm-s-railscasts span.cm-attribute {color: #a5c261;} +.cm-s-railscasts span.cm-keyword {color: #da4939;} +.cm-s-railscasts span.cm-string {color: #ffc66d;} + +.cm-s-railscasts span.cm-variable {color: #a5c261;} +.cm-s-railscasts span.cm-variable-2 {color: #6d9cbe;} +.cm-s-railscasts span.cm-def {color: #cc7833;} +.cm-s-railscasts span.cm-error {background: #da4939; color: #d4cfc9;} +.cm-s-railscasts span.cm-bracket {color: #f4f1ed;} +.cm-s-railscasts span.cm-tag {color: #da4939;} +.cm-s-railscasts span.cm-link {color: #b6b3eb;} + +.cm-s-railscasts .CodeMirror-matchingbracket { text-decoration: underline; color: white !important;} From 960bacc91e8faeec9372b12a5645035a9405762e Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Fri, 16 Oct 2015 16:20:21 +0200 Subject: [PATCH 0109/2444] [bespin, hopskotch, isotop, railscasts themes] Integrate Issue #3586 --- demo/theme.html | 8 ++++++++ theme/bespin.css | 1 + theme/hopscotch.css | 1 + theme/isotope.css | 1 + theme/railscasts.css | 1 + 5 files changed, 12 insertions(+) diff --git a/demo/theme.html b/demo/theme.html index 3c6b1c07de..300e2625e3 100644 --- a/demo/theme.html +++ b/demo/theme.html @@ -10,6 +10,7 @@ + @@ -18,7 +19,9 @@ + + @@ -32,6 +35,7 @@ + @@ -89,6 +93,7 @@

    Theme Demo

    + @@ -96,7 +101,9 @@

    Theme Demo

    + + @@ -110,6 +117,7 @@

    Theme Demo

    + diff --git a/theme/bespin.css b/theme/bespin.css index 1265a672b1..60913ba938 100644 --- a/theme/bespin.css +++ b/theme/bespin.css @@ -31,3 +31,4 @@ .cm-s-bespin span.cm-link {color: #9b859d;} .cm-s-bespin .CodeMirror-matchingbracket { text-decoration: underline; color: white !important;} +.cm-s-bespin .CodeMirror-activeline-background { background: #404040; } diff --git a/theme/hopscotch.css b/theme/hopscotch.css index dd1d2add47..7d05431bdc 100644 --- a/theme/hopscotch.css +++ b/theme/hopscotch.css @@ -31,3 +31,4 @@ .cm-s-hopscotch span.cm-link {color: #c85e7c;} .cm-s-hopscotch .CodeMirror-matchingbracket { text-decoration: underline; color: white !important;} +.cm-s-hopscotch .CodeMirror-activeline-background { background: #302020; } diff --git a/theme/isotope.css b/theme/isotope.css index 1fe8ce08d5..d0d6263cf4 100644 --- a/theme/isotope.css +++ b/theme/isotope.css @@ -31,3 +31,4 @@ .cm-s-isotope span.cm-link {color: #cc00ff;} .cm-s-isotope .CodeMirror-matchingbracket { text-decoration: underline; color: white !important;} +.cm-s-isotope .CodeMirror-activeline-background { background: #202020; } diff --git a/theme/railscasts.css b/theme/railscasts.css index 34fc951eab..aeff0449d5 100644 --- a/theme/railscasts.css +++ b/theme/railscasts.css @@ -31,3 +31,4 @@ .cm-s-railscasts span.cm-link {color: #b6b3eb;} .cm-s-railscasts .CodeMirror-matchingbracket { text-decoration: underline; color: white !important;} +.cm-s-railscasts .CodeMirror-activeline-background { background: #303040; } From 0073840889e3b50af08aafa3b06348f024d7ae2c Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Mon, 19 Oct 2015 13:34:26 +0200 Subject: [PATCH 0110/2444] [merge addon] Stop trying to require diff_match_patch Issue #3593 --- addon/merge/merge.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addon/merge/merge.js b/addon/merge/merge.js index b4114a232a..3ee75e751a 100644 --- a/addon/merge/merge.js +++ b/addon/merge/merge.js @@ -5,7 +5,7 @@ (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS - mod(require("../../lib/codemirror"), require("diff_match_patch")); + mod(require("../../lib/codemirror")); // Note non-packaged dependency diff_match_patch else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror", "diff_match_patch"], mod); else // Plain browser env From a06e2e1e08b6788f044c486f4772c3dc909a4956 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Mon, 19 Oct 2015 13:47:53 +0200 Subject: [PATCH 0111/2444] [clike mode] Support indent hook, use it to improve @property indent in objc Closes #3592 --- mode/clike/clike.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/mode/clike/clike.js b/mode/clike/clike.js index d4b7438b9d..603e48ce46 100644 --- a/mode/clike/clike.js +++ b/mode/clike/clike.js @@ -214,6 +214,10 @@ CodeMirror.defineMode("clike", function(config, parserConfig) { if (state.tokenize != tokenBase && state.tokenize != null) return CodeMirror.Pass; var ctx = state.context, firstChar = textAfter && textAfter.charAt(0); if (isStatement(ctx.type) && firstChar == "}") ctx = ctx.prev; + if (hooks.indent) { + var hook = hooks.indent(state, ctx, textAfter); + if (typeof hook == "number") return hook + } var closing = firstChar == ctx.type; var switchBlock = ctx.prev && ctx.prev.type == "switchstatement"; if (isStatement(ctx.type)) @@ -636,7 +640,10 @@ CodeMirror.defineMode("clike", function(config, parserConfig) { stream.eatWhile(/[\w\$]/); return "keyword"; }, - "#": cppHook + "#": cppHook, + indent: function(_state, ctx, textAfter) { + if (ctx.type == "statement" && /^@\w/.test(textAfter)) return ctx.indented + } }, modeProps: {fold: "brace"} }); From 71ac921c4385c7bfcbaa6c83ab105172a0049728 Mon Sep 17 00:00:00 2001 From: Caitlin Potter Date: Tue, 20 Oct 2015 02:48:10 -0400 Subject: [PATCH 0112/2444] [javascript mode] Add a test for new.target --- mode/javascript/test.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mode/javascript/test.js b/mode/javascript/test.js index de71d8c95d..252e064dcc 100644 --- a/mode/javascript/test.js +++ b/mode/javascript/test.js @@ -158,6 +158,14 @@ " [keyword return] [variable-2 x];", "}"); + MT("new_target", + "[keyword function] [def F]([def target]) {", + " [keyword if] ([variable-2 target] [operator &&] [keyword new].[keyword target].[property name]) {", + " [keyword return] [keyword new]", + " .[keyword target];", + " }", + "}"); + var jsonld_mode = CodeMirror.getMode( {indentUnit: 2}, {name: "javascript", jsonld: true} From 457468315e8175befd7464d55f4c5eeabf76186e Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Tue, 20 Oct 2015 10:01:40 +0200 Subject: [PATCH 0113/2444] [javascript mode] Implement new.target Issue #3607 --- mode/javascript/javascript.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/mode/javascript/javascript.js b/mode/javascript/javascript.js index 106111d837..b961b89011 100644 --- a/mode/javascript/javascript.js +++ b/mode/javascript/javascript.js @@ -30,7 +30,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { var jsKeywords = { "if": kw("if"), "while": A, "with": A, "else": B, "do": B, "try": B, "finally": B, - "return": C, "break": C, "continue": C, "new": C, "delete": C, "throw": C, "debugger": C, + "return": C, "break": C, "continue": C, "new": kw("new"), "delete": C, "throw": C, "debugger": C, "var": kw("var"), "const": kw("var"), "let": kw("var"), "async": kw("async"), "function": kw("function"), "catch": kw("catch"), "for": kw("for"), "switch": kw("switch"), "case": kw("case"), "default": kw("default"), @@ -122,7 +122,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { stream.skipToEnd(); return ret("comment", "comment"); } else if (state.lastType == "operator" || state.lastType == "keyword c" || - state.lastType == "sof" || /^[\[{}\(,;:]$/.test(state.lastType)) { + state.lastType == "sof" || /^[\[{}\(,;:]$/.test(state.lastType)) { readRegexp(stream); stream.match(/^\b(([gimyu])(?![gimyu]*\2))+\b/); return ret("regexp", "string-2"); @@ -380,7 +380,8 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { if (type == "operator" || type == "spread") return cont(noComma ? expressionNoComma : expression); if (type == "[") return cont(pushlex("]"), arrayLiteral, poplex, maybeop); if (type == "{") return contCommasep(objprop, "}", null, maybeop); - if (type == "quasi") { return pass(quasi, maybeop); } + if (type == "quasi") return pass(quasi, maybeop); + if (type == "new") return cont(maybeTarget(noComma)); return cont(); } function maybeexpression(type) { @@ -431,6 +432,18 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { findFatArrow(cx.stream, cx.state); return pass(type == "{" ? statement : expressionNoComma); } + function maybeTarget(noComma) { + return function(type) { + if (type == ".") return cont(noComma ? targetNoComma : target); + else return pass(noComma ? expressionNoComma : expression); + }; + } + function target(_, value) { + if (value == "target") { cx.marked = "keyword"; return cont(maybeoperatorComma); } + } + function targetNoComma(_, value) { + if (value == "target") { cx.marked = "keyword"; return cont(maybeoperatorNoComma); } + } function maybelabel(type) { if (type == ":") return cont(poplex, statement); return pass(maybeoperatorComma, expect(";"), poplex); From 4df95b1501ff4ad66d2d65d0c065ff7623a50fae Mon Sep 17 00:00:00 2001 From: Basarat Ali Syed Date: Tue, 20 Oct 2015 09:26:12 +1100 Subject: [PATCH 0114/2444] :memo: `+input` origin documentation --- doc/manual.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/manual.html b/doc/manual.html index 4cc4a39c25..6221e04790 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -1311,7 +1311,7 @@

    Cursor and selection methods

    collapsed or both non-collapsed), the new one will replace the old one. When it starts with *, it will always replace the previous event (if that had the same origin). - Built-in motion uses the "+move" origin.
    + Built-in motion uses the "+move" origin. User input uses the "+input" origin.
    bias: number
    Determine the direction into which the selection endpoints should be adjusted when they fall inside From d71a32856823c047b995b7178c28c9ce9dce20f0 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Tue, 20 Oct 2015 11:08:21 +0200 Subject: [PATCH 0115/2444] [merge addon] Don't suppress highlight updates when collapsing code Since collapsing might move previously hidden code into the viewport Issue #3599 --- addon/merge/merge.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/addon/merge/merge.js b/addon/merge/merge.js index 3ee75e751a..830a5f027a 100644 --- a/addon/merge/merge.js +++ b/addon/merge/merge.js @@ -471,13 +471,10 @@ if (left) left.init(leftPane, origLeft, options); if (right) right.init(rightPane, origRight, options); - if (options.collapseIdentical) { - updating = true; + if (options.collapseIdentical) this.editor().operation(function() { collapseIdenticalStretches(self, options.collapseIdentical); }); - updating = false; - } if (options.connect == "align") { this.aligners = []; alignChunks(this.left || this.right, true); From c7274043fd9db6e48524e41c5f60c8aa5f731768 Mon Sep 17 00:00:00 2001 From: idleberg Date: Tue, 20 Oct 2015 10:58:05 +0200 Subject: [PATCH 0116/2444] [mode meta] List NSIS mode --- mode/meta.js | 1 + 1 file changed, 1 insertion(+) diff --git a/mode/meta.js b/mode/meta.js index 7d6a6e1bf4..7af51c1ec5 100644 --- a/mode/meta.js +++ b/mode/meta.js @@ -83,6 +83,7 @@ {name: "MS SQL", mime: "text/x-mssql", mode: "sql"}, {name: "MySQL", mime: "text/x-mysql", mode: "sql"}, {name: "Nginx", mime: "text/x-nginx-conf", mode: "nginx", file: /nginx.*\.conf$/i}, + {name: "NSIS", mime: "text/x-nsis", mode: "nsis", ext: ["nsh", "nsi"]}, {name: "NTriples", mime: "text/n-triples", mode: "ntriples", ext: ["nt"]}, {name: "Objective C", mime: "text/x-objectivec", mode: "clike", ext: ["m", "mm"]}, {name: "OCaml", mime: "text/x-ocaml", mode: "mllike", ext: ["ml", "mli", "mll", "mly"]}, From 300e65942c0f93f37f80cab26f6b79bc0ad7001b Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Tue, 20 Oct 2015 11:29:22 +0200 Subject: [PATCH 0117/2444] Mark release 5.8 --- AUTHORS | 13 +++++++++++++ doc/compress.html | 1 + doc/manual.html | 2 +- doc/releases.html | 15 ++++++++++++++- index.html | 2 +- lib/codemirror.js | 2 +- package.json | 2 +- 7 files changed, 32 insertions(+), 5 deletions(-) diff --git a/AUTHORS b/AUTHORS index 78dd06f062..1e3ece23e0 100644 --- a/AUTHORS +++ b/AUTHORS @@ -27,6 +27,7 @@ Alex Piggott Aliaksei Chapyzhenka Allen Sarkisyan Amin Shali +amshali@google.com Amsul amuntean Amy @@ -63,6 +64,8 @@ as3boyan AtomicPages LLC Atul Bhouraskar Aurelian Oancea +Barret Rennie +Basarat Ali Syed Bastian Müller belhaj Bem Jones-Bey @@ -86,6 +89,7 @@ Brett Zamir Brian Grinstead Brian Sletten Bruce Mitchener +Caitlin Potter Calin Barbat Chandra Sekhar Pydi Charles Skelton @@ -144,6 +148,7 @@ duralog eborden edsharp ekhaled +Elisée Enam Mijbah Noor Eric Allam eustas @@ -196,6 +201,7 @@ Ian Wehrman Ian Wetherbee Ice White ICHIKAWA, Yuji +idleberg ilvalle Ingo Richter Irakli Gozalishvili @@ -230,6 +236,7 @@ Jeremy Parmenter Jochen Berger Johan Ask John Connor +John Engler John Lees-Miller John Snelson John Van Der Loo @@ -296,12 +303,15 @@ Marek Rudnicki Marijn Haverbeke Mário Gonçalves Mario Pietsch +Mark Anderson Mark Lentczner Marko Bonaci +Markus Bordihn Martin Balek Martín Gaitán Martin Hasoň Martin Hunt +Martin Laine Martin Zagora Mason Malone Mateusz Paprocki @@ -327,6 +337,7 @@ melpon Metatheos Micah Dubinko Michael +Michael Goderbauer Michael Grey Michael Kaminsky Michael Lehenbauer @@ -386,6 +397,7 @@ Pavel Feldman Pavel Strashkin Paweł Bartkiewicz peteguhl +peter Peter Flynn peterkroon Peter Kroon @@ -420,6 +432,7 @@ Sascha Peilicke satamas satchmorun sathyamoorthi +S. Chris Colbert SCLINIC\jdecker Scott Aikin Scott Goodhew diff --git a/doc/compress.html b/doc/compress.html index 0b11e1362c..6a183ca528 100644 --- a/doc/compress.html +++ b/doc/compress.html @@ -36,6 +36,7 @@

    Script compression helper

    Version:

    Version: (Use line:column or scroll% syntax)'; + + function jumpToLine(cm) { + var cur = cm.getCursor(); + dialog(cm, jumpDialog, 'Jump to line:', (cur.line+1)+':'+(cur.ch+1), function(posStr) { + if (!posStr) return; + + var clnMatch = /^\s*([\+\-]?\d+)\s*\:\s*(\d+)\s*$/.exec(posStr); + var prcMatch = /^\s*([\+\-]?\d+(\.\d+)?)\%\s*/.exec(posStr); + var lnMatch = /^\s*\:?\s*([\+\-]?\d+)\s*/.exec(posStr); + if (clnMatch) { + try { + var line = parseInt(clnMatch[1]); + var ch = parseInt(clnMatch[2]); + if ('+-'.indexOf(clnMatch[1].charAt(0))>=0) + line = cur.line+line+1; + } + catch (error) { return; } + cm.setCursor(line-1, ch-1); + } + else if (prcMatch) { + try { + var prc = parseFloat(prcMatch[1]); + var line = Math.round(cm.lineCount()*prc/100); + if ('+-'.indexOf(prcMatch[1].charAt(0))>=0) + line = cur.line+line+1; + } + catch (error) { return; } + cm.setCursor(line-1, cur.ch); + } + else if (lnMatch) { + try { + var line = parseInt(lnMatch[1]); + if ('+-'.indexOf(lnMatch[1].charAt(0))>=0) + line = cur.line+line+1; + } + catch (error) { return; } + cm.setCursor(line-1, cur.ch); + } + }) + } + + CodeMirror.commands.jumpToLine = jumpToLine; + CodeMirror.keyMap.default["Alt-G"] = "jumpToLine"; +}); diff --git a/demo/search.html b/demo/search.html index 21c34251e2..fd445db290 100644 --- a/demo/search.html +++ b/demo/search.html @@ -14,6 +14,7 @@ + - - -

    CodeMirror: msgenny mode

    - -
    - - - -

    MIME types defined: text/x-msgenny

    - - diff --git a/mode/mscgen/index_xu.html b/mode/mscgen/index_xu.html deleted file mode 100644 index 2f7bf9ec04..0000000000 --- a/mode/mscgen/index_xu.html +++ /dev/null @@ -1,70 +0,0 @@ - - - - - CodeMirror: xu mode - - - - - - -

    CodeMirror: xù mode

    - -
    - - - -

    MIME types defined: text/x-xu

    - - From 382f51d257112027d147f583d14d6880618fd3da Mon Sep 17 00:00:00 2001 From: sverweij Date: Sat, 5 Dec 2015 19:55:08 +0100 Subject: [PATCH 0180/2444] [mscgen mode] simplifies the regexps to recognize keywords for our purposes (=>|<=|...) works just as well as ((<=)|(=>)|...) --- mode/mscgen/mscgen.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mode/mscgen/mscgen.js b/mode/mscgen/mscgen.js index 3cf4eb0897..d61b470652 100644 --- a/mode/mscgen/mscgen.js +++ b/mode/mscgen/mscgen.js @@ -69,11 +69,11 @@ CodeMirror.defineMIME("text/x-msgenny", {name: "mscgen", language: "msgenny"}); function wordRegexpBoundary(pWords) { - return new RegExp("\\b((" + pWords.join(")|(") + "))\\b", "i"); + return new RegExp("\\b(" + pWords.join("|") + ")\\b", "i"); } function wordRegexp(pWords) { - return new RegExp("((" + pWords.join(")|(") + "))", "i"); + return new RegExp("(" + pWords.join("|") + ")", "i"); } function startStateFn() { From 764022a60ee7c092e18c9a45f3678d6b52852a00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Sat, 5 Dec 2015 22:05:27 +0100 Subject: [PATCH 0181/2444] [javascript mode] Recognize regex inside template literal Closes gh-3687 --- mode/javascript/javascript.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mode/javascript/javascript.js b/mode/javascript/javascript.js index e97593a212..d4ae668794 100644 --- a/mode/javascript/javascript.js +++ b/mode/javascript/javascript.js @@ -126,7 +126,8 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { } else if (stream.eat("/")) { stream.skipToEnd(); return ret("comment", "comment"); - } else if (/^(?:operator|sof|keyword c|case|new|[\[{}\(,;:])$/.test(state.lastType)) { + } else if (/^(?:operator|sof|keyword c|case|new|[\[{}\(,;:])$/.test(state.lastType) || + (state.lastType == "quasi" && /\{\s*$/.test(stream.string.slice(0, stream.pos - 1)))) { readRegexp(stream); stream.match(/^\b(([gimyu])(?![gimyu]*\2))+\b/); return ret("regexp", "string-2"); From 9399b1cdee43d648fd8649c15220afdc33fc3ec0 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Mon, 7 Dec 2015 15:43:13 +0100 Subject: [PATCH 0182/2444] [vim bindings] Use a simpler way to handle splitting on dashes --- keymap/vim.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/keymap/vim.js b/keymap/vim.js index 02ed53af30..c1532a179a 100644 --- a/keymap/vim.js +++ b/keymap/vim.js @@ -292,12 +292,7 @@ // Keypress character binding of format "'a'" return key.charAt(1); } - var pieces = key.split('-'); - if (/-$/.test(key)) { - // If the - key was typed, split will result in 2 extra empty strings - // in the array. Replace them with 1 '-'. - pieces.splice(-2, 2, '-'); - } + var pieces = key.split(/-(?!$)/); var lastPiece = pieces[pieces.length - 1]; if (pieces.length == 1 && pieces[0].length == 1) { // No-modifier bindings use literal character bindings above. Skip. From 4bdf6440429bc455f4ce39486d424fba0be7fa14 Mon Sep 17 00:00:00 2001 From: mihailik Date: Sat, 28 Nov 2015 15:55:34 +0000 Subject: [PATCH 0183/2444] Fixing hidding keyboard on arrow keys on mobile Makes sure the selection is not entirely cleared, which causs the on-screen keyboard to get hidden. Disabled for Firefox, where this causes other problems. Issue #3653 --- lib/codemirror.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/codemirror.js b/lib/codemirror.js index 88c47bba46..5bfa91d6c2 100644 --- a/lib/codemirror.js +++ b/lib/codemirror.js @@ -1688,8 +1688,13 @@ try { var rng = range(start.node, start.offset, end.offset, end.node); } catch(e) {} // Our model of the DOM might be outdated, in which case the range we try to set can be impossible if (rng) { - sel.removeAllRanges(); - sel.addRange(rng); + if (!gecko && this.cm.state.focused) { + sel.collapse(start.node, start.offset); + if (!rng.collapsed) sel.addRange(rng); + } else { + sel.removeAllRanges(); + sel.addRange(rng); + } if (old && sel.anchorNode == null) sel.addRange(old); else if (gecko) this.startGracePeriod(); } From b3010eddf829821ef279ce80a73047b6e6db6011 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Sun, 13 Dec 2015 00:07:29 +0100 Subject: [PATCH 0184/2444] [css mode] Clean up handling of inline option --- mode/css/css.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/mode/css/css.js b/mode/css/css.js index b20b4907ec..2673074ab9 100644 --- a/mode/css/css.js +++ b/mode/css/css.js @@ -12,9 +12,8 @@ "use strict"; CodeMirror.defineMode("css", function(config, parserConfig) { - var provided = parserConfig; + var inline = parserConfig.inline if (!parserConfig.propertyKeywords) parserConfig = CodeMirror.resolveMode("text/css"); - parserConfig.inline = provided.inline; var indentUnit = config.indentUnit, tokenHooks = parserConfig.tokenHooks, @@ -368,9 +367,9 @@ CodeMirror.defineMode("css", function(config, parserConfig) { return { startState: function(base) { return {tokenize: null, - state: parserConfig.inline ? "block" : "top", + state: inline ? "block" : "top", stateArg: null, - context: new Context(parserConfig.inline ? "block" : "top", base || 0, null)}; + context: new Context(inline ? "block" : "top", base || 0, null)}; }, token: function(stream, state) { From 0dbe0ef55d50734818325bbbc211f47c21c3c0ed Mon Sep 17 00:00:00 2001 From: TDaglis Date: Tue, 15 Dec 2015 11:39:14 +0000 Subject: [PATCH 0185/2444] [django mode] better highlighting of in/and/or/not Currently operators in most themes look like normal text because cm-operator doesn't usually get special styling. This patch highlights word operators (in/and/or/not) to make them stand out better. --- mode/django/django.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/mode/django/django.js b/mode/django/django.js index 7fae876c16..eb8d65914e 100644 --- a/mode/django/django.js +++ b/mode/django/django.js @@ -35,11 +35,13 @@ "truncatechars_html", "truncatewords", "truncatewords_html", "unordered_list", "upper", "urlencode", "urlize", "urlizetrunc", "wordcount", "wordwrap", "yesno"], - operators = ["==", "!=", "<", ">", "<=", ">=", "in", "not", "or", "and"]; + operators = ["==", "!=", "<", ">", "<=", ">="], + wordOperators = ["in", "not", "or", "and"]; keywords = new RegExp("^\\b(" + keywords.join("|") + ")\\b"); filters = new RegExp("^\\b(" + filters.join("|") + ")\\b"); operators = new RegExp("^\\b(" + operators.join("|") + ")\\b"); + wordOperators = new RegExp("^\\b(" + wordOperators.join("|") + ")\\b"); // We have to return "null" instead of null, in order to avoid string // styling as the default, when using Django templates inside HTML @@ -270,6 +272,11 @@ return "operator"; } + // Attempt to match a word operator + if (stream.match(wordOperators)) { + return "keyword"; + } + // Attempt to match a keyword var keywordMatch = stream.match(keywords); if (keywordMatch) { From 07207dd57c351b7ce9861960c1fba03caf301a99 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Tue, 15 Dec 2015 22:13:51 +0100 Subject: [PATCH 0186/2444] [show-hint addon] Use mouseover rather than mousemove to change selection So that tiny mouse motions don't keep resetting the selected item Closes #3698 --- addon/hint/show-hint.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/addon/hint/show-hint.js b/addon/hint/show-hint.js index 7eefad8b5b..204e136fe8 100644 --- a/addon/hint/show-hint.js +++ b/addon/hint/show-hint.js @@ -296,10 +296,10 @@ }); if (completion.options.completeOnSingleClick) - CodeMirror.on(hints, "mousemove", function(e) { - var elt = getHintElement(hints, e.target || e.srcElement); - if (elt && elt.hintId != null) - widget.changeActive(elt.hintId); + CodeMirror.on(hints, "mouseover", function(e) { + var target = e.target || e.srcElement + if (target.hintId != null && !target.contains(e.relatedTarget || e.fromElement)) + widget.changeActive(target.hintId); }); CodeMirror.signal(data, "select", completions[0], hints.firstChild); From 9951761dc3e690cb958b4f11f7a84092466c9c56 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Tue, 15 Dec 2015 22:36:46 +0100 Subject: [PATCH 0187/2444] Fall back to putting CodeMirror in window if this is undefined Issue #3708 --- lib/codemirror.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/codemirror.js b/lib/codemirror.js index 5bfa91d6c2..07a23f1b80 100644 --- a/lib/codemirror.js +++ b/lib/codemirror.js @@ -13,7 +13,7 @@ else if (typeof define == "function" && define.amd) // AMD return define([], mod); else // Plain browser env - this.CodeMirror = mod(); + (this || window).CodeMirror = mod(); })(function() { "use strict"; From b7f07850a9339b85a97fe0c261b5d3929c31d835 Mon Sep 17 00:00:00 2001 From: Cole R Lawrence Date: Mon, 14 Dec 2015 11:59:30 -0600 Subject: [PATCH 0188/2444] Link text runmode script in the correct location --- demo/runmode.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demo/runmode.html b/demo/runmode.html index 257f03d6b6..ab8938d8d3 100644 --- a/demo/runmode.html +++ b/demo/runmode.html @@ -43,7 +43,7 @@

    Mode Runner Demo

    Running a CodeMirror mode outside of the editor. The CodeMirror.runMode function, defined - in lib/runmode.js takes the following arguments:

    + in addon/runmode/runmode.js takes the following arguments:

    text (string)
    From 4c66400caefe1dbaf959b30ed835feec6942aa86 Mon Sep 17 00:00:00 2001 From: Jim Date: Mon, 14 Dec 2015 11:47:37 -0800 Subject: [PATCH 0189/2444] Correct typo in codemirror.css (`actuall` vs `actual`) There was a typo in one of the comments (`actuall` vs `actual`). --- lib/codemirror.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/codemirror.css b/lib/codemirror.css index 3543523e64..1067b3ee6b 100644 --- a/lib/codemirror.css +++ b/lib/codemirror.css @@ -165,7 +165,7 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;} } /* The fake, visible scrollbars. Used to force redraw during scrolling - before actuall scrolling happens, thus preventing shaking and + before actual scrolling happens, thus preventing shaking and flickering artifacts. */ .CodeMirror-vscrollbar, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler { position: absolute; From 188ae75e0154ba68d918ab21939163d8bf2d9f87 Mon Sep 17 00:00:00 2001 From: McBrainy Date: Mon, 14 Dec 2015 17:49:23 -0600 Subject: [PATCH 0190/2444] Fix typo in manual It took me forever to figure out why vim mode wasn't working, and all because the manual said to set the "keymap" option and not the "keyMap" option. I also added quotes to make it clear that "vim" is a string. --- doc/manual.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/manual.html b/doc/manual.html index 22d32df0ad..8812a1713d 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -3251,8 +3251,8 @@

    VIM Mode API

    CodeMirror has a robust VIM mode that attempts to faithfully emulate VIM's most useful features. It can be enabled by including keymap/vim.js - and setting the keymap option to - vim.

    + and setting the keyMap option to + "vim".

    Configuration

    From 7e35f03ad1639d92735c8dee1e1b5c86a727c873 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Tue, 15 Dec 2015 22:48:56 +0100 Subject: [PATCH 0191/2444] [runmode addon] Treat everything with an appendChild property as a DOM output node Closes #3703 --- addon/runmode/runmode.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addon/runmode/runmode.js b/addon/runmode/runmode.js index 07d2279f74..a51c6d0d52 100644 --- a/addon/runmode/runmode.js +++ b/addon/runmode/runmode.js @@ -16,7 +16,7 @@ CodeMirror.runMode = function(string, modespec, callback, options) { var ie = /MSIE \d/.test(navigator.userAgent); var ie_lt9 = ie && (document.documentMode == null || document.documentMode < 9); - if (callback.nodeType == 1) { + if (callback.appendChild) { var tabSize = (options && options.tabSize) || CodeMirror.defaults.tabSize; var node = callback, col = 0; node.innerHTML = ""; From bae907609a698e0da4579f69d13f84eccc252833 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Wed, 16 Dec 2015 09:09:22 +0100 Subject: [PATCH 0192/2444] [sublime bindings] Give ctrl-/ command a name Closes #3689 --- keymap/sublime.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/keymap/sublime.js b/keymap/sublime.js index e0640b7639..e0d0e92b91 100644 --- a/keymap/sublime.js +++ b/keymap/sublime.js @@ -243,7 +243,7 @@ }); }; - map[ctrl + "/"] = function(cm) { + cmds[map[ctrl + "/"] = "toggleCommentIndented"] = function(cm) { cm.toggleComment({ indent: true }); } From 06e83fd66ebe639038eb64013891a1535ed07f25 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Wed, 16 Dec 2015 09:15:52 +0100 Subject: [PATCH 0193/2444] [show-hint addon] Revert select-on-mouse behavior Issue #3636 Issue #3698 --- addon/hint/show-hint.js | 7 ------- 1 file changed, 7 deletions(-) diff --git a/addon/hint/show-hint.js b/addon/hint/show-hint.js index 204e136fe8..cbe3b39a30 100644 --- a/addon/hint/show-hint.js +++ b/addon/hint/show-hint.js @@ -295,13 +295,6 @@ setTimeout(function(){cm.focus();}, 20); }); - if (completion.options.completeOnSingleClick) - CodeMirror.on(hints, "mouseover", function(e) { - var target = e.target || e.srcElement - if (target.hintId != null && !target.contains(e.relatedTarget || e.fromElement)) - widget.changeActive(target.hintId); - }); - CodeMirror.signal(data, "select", completions[0], hints.firstChild); return true; } From 463797fb5ed003bacd64b69fc0910fbdb2cd0ca5 Mon Sep 17 00:00:00 2001 From: mihailik Date: Wed, 16 Dec 2015 09:55:27 +0000 Subject: [PATCH 0194/2444] [jump-to-line addon] Quote `default` property To avoid IE8 parser issue. --- addon/search/jump-to-line.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addon/search/jump-to-line.js b/addon/search/jump-to-line.js index 49f3df4efe..8b599cbc17 100644 --- a/addon/search/jump-to-line.js +++ b/addon/search/jump-to-line.js @@ -45,5 +45,5 @@ }); }; - CodeMirror.keyMap.default["Alt-G"] = "jumpToLine"; + CodeMirror.keyMap["default"]["Alt-G"] = "jumpToLine"; }); From ab78fe07c459a56d92c6c4c9b50b3be86c314534 Mon Sep 17 00:00:00 2001 From: nightwing Date: Fri, 11 Dec 2015 00:49:09 +0400 Subject: [PATCH 0195/2444] [vim] fix autoindent of S command --- keymap/vim.js | 20 ++++++++++++++------ test/vim_test.js | 15 ++++++++++++--- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/keymap/vim.js b/keymap/vim.js index c1532a179a..59815957ca 100644 --- a/keymap/vim.js +++ b/keymap/vim.js @@ -1954,13 +1954,21 @@ text = text.slice(0, - match[0].length); } } - var wasLastLine = head.line - 1 == cm.lastLine(); - cm.replaceRange('', anchor, head); - if (args.linewise && !wasLastLine) { + var prevLineEnd = new Pos(anchor.line - 1, Number.MAX_VALUE); + var wasLastLine = cm.firstLine() == cm.lastLine(); + if (head.line > cm.lastLine() && args.linewise && !wasLastLine) { + cm.replaceRange('', prevLineEnd, head); + } else { + cm.replaceRange('', anchor, head); + } + if (args.linewise) { // Push the next line back down, if there is a next line. - CodeMirror.commands.newlineAndIndent(cm); - // null ch so setCursor moves to end of line. - anchor.ch = null; + if (!wasLastLine) { + cm.setCursor(prevLineEnd); + CodeMirror.commands.newlineAndIndent(cm); + } + // make sure cursor ends up at the end of the line. + anchor.ch = Number.MAX_VALUE; } finalHead = anchor; } else { diff --git a/test/vim_test.js b/test/vim_test.js index 855cb8825e..74c6a95071 100644 --- a/test/vim_test.js +++ b/test/vim_test.js @@ -2148,9 +2148,18 @@ testVim('S_normal', function(cm, vim, helpers) { cm.setCursor(0, 1); helpers.doKeys('j', 'S'); helpers.doKeys(''); - helpers.assertCursorAt(1, 0); - eq('aa\n\ncc', cm.getValue()); -}, { value: 'aa\nbb\ncc'}); + helpers.assertCursorAt(1, 1); + eq('aa{\n \ncc', cm.getValue()); + helpers.doKeys('j', 'S'); + eq('aa{\n \n ', cm.getValue()); + helpers.assertCursorAt(2, 2); + helpers.doKeys(''); + helpers.doKeys('d', 'd', 'd', 'd'); + helpers.assertCursorAt(0, 0); + helpers.doKeys('S'); + is(vim.insertMode); + eq('', cm.getValue()); +}, { value: 'aa{\nbb\ncc'}); testVim('blockwise_paste', function(cm, vim, helpers) { cm.setCursor(0, 0); helpers.doKeys('', '3', 'j', 'l', 'y'); From 78e3ac3520aec44b19a47d7c43232813a0e28f39 Mon Sep 17 00:00:00 2001 From: Justin Andresen Date: Thu, 17 Dec 2015 19:58:16 +0100 Subject: [PATCH 0196/2444] Update manual entry of extendSelectionsBy. --- doc/manual.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/manual.html b/doc/manual.html index 8812a1713d..2d8d618a19 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -1350,7 +1350,7 @@

    Cursor and selection methods

    An equivalent of extendSelection that acts on all selections at once.
    -
    doc.extendSelectionsBy(f: function(range: {anchor, head}) → {anchor, head}), ?options: object)
    +
    doc.extendSelectionsBy(f: function(range: {anchor, head}) → {line, ch}), ?options: object)
    Applies the given function to all existing selections, and calls extendSelections on the result.
    From 3e88446bb59cacf133e7db1ae2221a85728b5bcc Mon Sep 17 00:00:00 2001 From: Drini Cami Date: Sat, 19 Dec 2015 02:50:21 -0500 Subject: [PATCH 0197/2444] [sparql mode] Add lineComment property --- mode/sparql/sparql.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mode/sparql/sparql.js b/mode/sparql/sparql.js index bbf8a76a0d..0cf40f58bc 100644 --- a/mode/sparql/sparql.js +++ b/mode/sparql/sparql.js @@ -165,7 +165,9 @@ CodeMirror.defineMode("sparql", function(config) { return context.col + (closing ? 0 : 1); else return context.indent + (closing ? 0 : indentUnit); - } + }, + + lineComment: "#" }; }); From d9042e78013f3377580966bf5a3092ccfa7848c0 Mon Sep 17 00:00:00 2001 From: Justin Andresen Date: Thu, 17 Dec 2015 18:58:45 +0100 Subject: [PATCH 0198/2444] Fix options of extendSelections. --- lib/codemirror.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/codemirror.js b/lib/codemirror.js index 07a23f1b80..c7c507d979 100644 --- a/lib/codemirror.js +++ b/lib/codemirror.js @@ -7454,7 +7454,7 @@ extendSelection(this, clipPos(this, head), other && clipPos(this, other), options); }), extendSelections: docMethodOp(function(heads, options) { - extendSelections(this, clipPosArray(this, heads, options)); + extendSelections(this, clipPosArray(this, heads), options); }), extendSelectionsBy: docMethodOp(function(f, options) { extendSelections(this, map(this.sel.ranges, f), options); From c39008a728e3172b196546eb7c22bb3d8a7d50f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Sch=C3=A4r?= Date: Wed, 16 Dec 2015 21:10:11 +0100 Subject: [PATCH 0199/2444] [markdown mode] fix escaped brackets in link def Example: `[foo\[bar\]foo]: https://example.com` --- mode/markdown/markdown.js | 4 ++-- mode/markdown/test.js | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/mode/markdown/markdown.js b/mode/markdown/markdown.js index 97dfb7464a..70889205d3 100644 --- a/mode/markdown/markdown.js +++ b/mode/markdown/markdown.js @@ -620,7 +620,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) { } function footnoteLink(stream, state) { - if (stream.match(/^[^\]]*\]:/, false)) { + if (stream.match(/^([^\]\\]|\\.)*\]:/, false)) { state.f = footnoteLinkInside; stream.next(); // Consume [ if (modeCfg.highlightFormatting) state.formatting = "link"; @@ -639,7 +639,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) { return returnType; } - stream.match(/^[^\]]+/, true); + stream.match(/^([^\]\\]|\\.)+/, true); return tokenTypes.linkText; } diff --git a/mode/markdown/test.js b/mode/markdown/test.js index f9cc27c3b4..6d7829fa57 100644 --- a/mode/markdown/test.js +++ b/mode/markdown/test.js @@ -696,6 +696,15 @@ "[link [[foo]]:] [string&url http://example.com/]", "(bar\" hello"); + MT("labelEscape", + "[link [[foo \\]] ]]:] [string&url http://example.com/]"); + + MT("labelEscapeColon", + "[link [[foo \\]]: bar]]:] [string&url http://example.com/]"); + + MT("labelEscapeEnd", + "[[foo\\]]: http://example.com/"); + MT("linkWeb", "[link ] foo"); From 420cefd50bb4f62db4217c709064b39f55976650 Mon Sep 17 00:00:00 2001 From: Justin Andresen Date: Thu, 17 Dec 2015 19:02:41 +0100 Subject: [PATCH 0200/2444] Clip extended ranges. --- lib/codemirror.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/codemirror.js b/lib/codemirror.js index c7c507d979..dde88b4f9b 100644 --- a/lib/codemirror.js +++ b/lib/codemirror.js @@ -7457,7 +7457,8 @@ extendSelections(this, clipPosArray(this, heads), options); }), extendSelectionsBy: docMethodOp(function(f, options) { - extendSelections(this, map(this.sel.ranges, f), options); + var heads = map(this.sel.ranges, f); + extendSelections(this, clipPosArray(this, heads), options); }), setSelections: docMethodOp(function(ranges, primary, options) { if (!ranges.length) return; From fec88d280e1c0bf0f09b6b1db50318f39a74f172 Mon Sep 17 00:00:00 2001 From: Justin Andresen Date: Thu, 17 Dec 2015 19:02:41 +0100 Subject: [PATCH 0201/2444] Add an origin field to beforeSelectionChange event objects Issue #3723 --- doc/manual.html | 8 +++++--- lib/codemirror.js | 7 ++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/doc/manual.html b/doc/manual.html index 2d8d618a19..bda852a72f 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -582,15 +582,17 @@

    Events

    mode's electric patterns, and this caused the line's indentation to change.
    -
    "beforeSelectionChange" (instance: CodeMirror, obj: {ranges, update})
    +
    "beforeSelectionChange" (instance: CodeMirror, obj: {ranges, origin, update})
    This event is fired before the selection is moved. Its handler may inspect the set of selection ranges, present as an array of {anchor, head} objects in the ranges property of the obj argument, and optionally change them by calling the update method on this object, passing an array - of ranges in the same format. Handlers for this event have the - same restriction + of ranges in the same format. The object also contains + an origin property holding the origin string passed + to the selection-changing method, if any. Handlers for this + event have the same restriction as "beforeChange" handlers — they should not do anything to directly update the state of the editor.
    diff --git a/lib/codemirror.js b/lib/codemirror.js index dde88b4f9b..2141cda197 100644 --- a/lib/codemirror.js +++ b/lib/codemirror.js @@ -2155,7 +2155,7 @@ // Give beforeSelectionChange handlers a change to influence a // selection update. - function filterSelectionChange(doc, sel) { + function filterSelectionChange(doc, sel, options) { var obj = { ranges: sel.ranges, update: function(ranges) { @@ -2163,7 +2163,8 @@ for (var i = 0; i < ranges.length; i++) this.ranges[i] = new Range(clipPos(doc, ranges[i].anchor), clipPos(doc, ranges[i].head)); - } + }, + origin: options && options.origin }; signal(doc, "beforeSelectionChange", doc, obj); if (doc.cm) signal(doc.cm, "beforeSelectionChange", doc.cm, obj); @@ -2189,7 +2190,7 @@ function setSelectionNoUndo(doc, sel, options) { if (hasHandler(doc, "beforeSelectionChange") || doc.cm && hasHandler(doc.cm, "beforeSelectionChange")) - sel = filterSelectionChange(doc, sel); + sel = filterSelectionChange(doc, sel, options); var bias = options && options.bias || (cmp(sel.primary().head, doc.sel.primary().head) < 0 ? -1 : 1); From ca8fb83d48ebb9fe2d24b8f08abfe204f706dcad Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Sun, 20 Dec 2015 21:50:47 +0100 Subject: [PATCH 0202/2444] Fire DOM events for paste --- doc/manual.html | 2 +- lib/codemirror.js | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/doc/manual.html b/doc/manual.html index bda852a72f..695a7ed25d 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -654,7 +654,7 @@

    Events

    "mousedown", "dblclick", "contextmenu", "keydown", "keypress", - "keyup", "dragstart", "dragenter", + "keyup", "paste", "dragstart", "dragenter", "dragover", "drop" (instance: CodeMirror, event: Event)
    Fired when CodeMirror is handling a DOM event of this type. diff --git a/lib/codemirror.js b/lib/codemirror.js index 2141cda197..6305cafdc2 100644 --- a/lib/codemirror.js +++ b/lib/codemirror.js @@ -1251,7 +1251,7 @@ }); on(te, "paste", function(e) { - if (handlePaste(e, cm)) return true; + if (signalDOMEvent(cm, e) || handlePaste(e, cm)) return cm.state.pasteIncoming = true; input.fastPoll(); @@ -1285,7 +1285,7 @@ on(te, "copy", prepareCopyCut); on(display.scroller, "paste", function(e) { - if (eventInWidget(display, e)) return; + if (eventInWidget(display, e) || signalDOMEvent(cm, e)) return; cm.state.pasteIncoming = true; input.focus(); }); @@ -1570,7 +1570,9 @@ var div = input.div = display.lineDiv; disableBrowserMagic(div); - on(div, "paste", function(e) { handlePaste(e, cm); }) + on(div, "paste", function(e) { + if (!signalDOMEvent(cm, e)) handlePaste(e, cm); + }) on(div, "compositionstart", function(e) { var data = e.data; From a4e987079517e1ff23d73c5a572f69d15ec4ff55 Mon Sep 17 00:00:00 2001 From: Chunliang Lyu Date: Sat, 19 Dec 2015 22:39:10 +0800 Subject: [PATCH 0203/2444] Add mode for GitHub Flavored Markdown with YAML front matter --- mode/yaml-markdown/index.html | 114 ++++++++++++++++++++++++++++ mode/yaml-markdown/yaml-markdown.js | 64 ++++++++++++++++ 2 files changed, 178 insertions(+) create mode 100644 mode/yaml-markdown/index.html create mode 100644 mode/yaml-markdown/yaml-markdown.js diff --git a/mode/yaml-markdown/index.html b/mode/yaml-markdown/index.html new file mode 100644 index 0000000000..ad610da8f9 --- /dev/null +++ b/mode/yaml-markdown/index.html @@ -0,0 +1,114 @@ + + +CodeMirror: GitHub Flavored Markdown with YAML front matter mode + + + + + + + + + + + + + +
    +

    GitHub Flavored Markdown with YAML front matter mode

    +
    + + +
    diff --git a/mode/yaml-markdown/yaml-markdown.js b/mode/yaml-markdown/yaml-markdown.js new file mode 100644 index 0000000000..a1af80f3ec --- /dev/null +++ b/mode/yaml-markdown/yaml-markdown.js @@ -0,0 +1,64 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: http://codemirror.net/LICENSE + +(function (mod) { + if (typeof exports == "object" && typeof module == "object") // CommonJS + mod(require("../../lib/codemirror"), require("../gfm/gfm"), require("../yaml/yaml")); + else if (typeof define == "function" && define.amd) // AMD + define(["../../lib/codemirror", "../gfm/gfm", "../yaml/yaml"], mod); + else // Plain browser env + mod(CodeMirror); +})(function (CodeMirror) { + + // a mixed mode for Markdown text with an optional YAML front matter + CodeMirror.defineMode("yaml-markdown", function (config) { + var gfmMode = CodeMirror.getMode(config, {name: "gfm"}); + var yamlMode = CodeMirror.getMode(config, {name: "yaml"}); + + return { + startState: function () { + var gfmState = gfmMode.startState(); + var yamlState = yamlMode.startState(); + return { + firstLine: true, + mode: gfmMode, + gfmState: gfmState, + yamlState: yamlState + }; + }, + copyState: function (state) { + return { + mode: state.mode, + gfmState: gfmMode.copyState(state.gfmState), + yamlState: state.yamlState + }; + }, + token: function (stream, state) { + if (state.firstLine && stream.match(/---/, false)) { + state.firstLine = false; + state.mode = yamlMode; + return yamlMode.token(stream, state.yamlState); + } else if (state.mode == yamlMode && stream.match(/---/, false)) { + state.mode = gfmMode; + return yamlMode.token(stream, state.yamlState); + } else if (state.mode == yamlMode) { + return state.mode.token(stream, state.yamlState); + } else { + return state.mode.token(stream, state.gfmState); + } + }, + innerMode: function (state) { + if (state.mode == gfmMode) { + return gfmMode.innerMode(state.gfmState); + } else { + return {mode: yamlMode, state: state}; + } + }, + blankLine: function (state) { + if (state.mode == gfmMode) { + return gfmMode.blankLine(state.gfmState) + } + } + }; + }); +}); From d6212b9216e4a3add9df636726d0c59dfd62ca74 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Sun, 20 Dec 2015 22:15:16 +0100 Subject: [PATCH 0204/2444] [yaml-frontmatter mode] Repurpose yaml-markdown mode to a general yaml-frontmatter mode Issue #3722 --- doc/compress.html | 1 + mode/index.html | 1 + .../index.html | 17 +++-- mode/yaml-frontmatter/yaml-frontmatter.js | 68 +++++++++++++++++++ mode/yaml-markdown/yaml-markdown.js | 64 ----------------- 5 files changed, 82 insertions(+), 69 deletions(-) rename mode/{yaml-markdown => yaml-frontmatter}/index.html (83%) create mode 100644 mode/yaml-frontmatter/yaml-frontmatter.js delete mode 100644 mode/yaml-markdown/yaml-markdown.js diff --git a/doc/compress.html b/doc/compress.html index f7c511c78c..fe8260ad64 100644 --- a/doc/compress.html +++ b/doc/compress.html @@ -219,6 +219,7 @@

    Script compression helper

    + diff --git a/mode/index.html b/mode/index.html index 477ca2c18c..724192413a 100644 --- a/mode/index.html +++ b/mode/index.html @@ -148,6 +148,7 @@

    Language modes

  • XML/HTML
  • XQuery
  • YAML
  • +
  • YAML frontmatter
  • Z80
  • diff --git a/mode/yaml-markdown/index.html b/mode/yaml-frontmatter/index.html similarity index 83% rename from mode/yaml-markdown/index.html rename to mode/yaml-frontmatter/index.html index ad610da8f9..30bed2f855 100644 --- a/mode/yaml-markdown/index.html +++ b/mode/yaml-frontmatter/index.html @@ -1,6 +1,6 @@ -CodeMirror: GitHub Flavored Markdown with YAML front matter mode +CodeMirror: YAML front matter mode @@ -10,7 +10,7 @@ - +
    -

    GitHub Flavored Markdown with YAML front matter mode

    +

    YAML front matter mode

    + +

    Defines a mode that parses +a YAML frontmatter +at the start of a file, switching to a base mode at the end of that. +Takes a mode configuration option base to configure the +base mode, which defaults to "gfm".

    +
    diff --git a/mode/yaml-frontmatter/yaml-frontmatter.js b/mode/yaml-frontmatter/yaml-frontmatter.js new file mode 100644 index 0000000000..5b65dffbf7 --- /dev/null +++ b/mode/yaml-frontmatter/yaml-frontmatter.js @@ -0,0 +1,68 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: http://codemirror.net/LICENSE + +(function (mod) { + if (typeof exports == "object" && typeof module == "object") // CommonJS + mod(require("../../lib/codemirror"), require("../yaml/yaml")) + else if (typeof define == "function" && define.amd) // AMD + define(["../../lib/codemirror", "../yaml/yaml"], mod) + else // Plain browser env + mod(CodeMirror) +})(function (CodeMirror) { + + var START = 0, FRONTMATTER = 1, BODY = 2 + + // a mixed mode for Markdown text with an optional YAML front matter + CodeMirror.defineMode("yaml-frontmatter", function (config, parserConfig) { + var yamlMode = CodeMirror.getMode(config, "yaml") + var innerMode = CodeMirror.getMode(config, parserConfig && parserConfig.base || "gfm") + + function curMode(state) { + return state.state == BODY ? innerMode : yamlMode + } + + return { + startState: function () { + return { + state: START, + inner: CodeMirror.startState(yamlMode) + } + }, + copyState: function (state) { + return { + state: state.state, + inner: CodeMirror.copyState(curMode(state), state.inner) + } + }, + token: function (stream, state) { + if (state.state == START) { + if (stream.match(/---/, false)) { + state.state = FRONTMATTER + return yamlMode.token(stream, state.inner) + } else { + stream.state = BODY + state.inner = CodeMirror.startState(innerMode) + return innerMode.token(stream, state.inner) + } + } else if (state.state == FRONTMATTER) { + var end = stream.sol() && stream.match(/---/, false) + var style = yamlMode.token(stream, state.inner) + if (end) { + state.state = BODY + state.inner = CodeMirror.startState(innerMode) + } + return style + } else { + return innerMode.token(stream, state.inner) + } + }, + innerMode: function (state) { + return {mode: curMode(state), state: state.inner} + }, + blankLine: function (state) { + var mode = curMode(state) + if (mode.blankLine) return mode.blankLine(state.inner) + } + } + }) +}) diff --git a/mode/yaml-markdown/yaml-markdown.js b/mode/yaml-markdown/yaml-markdown.js deleted file mode 100644 index a1af80f3ec..0000000000 --- a/mode/yaml-markdown/yaml-markdown.js +++ /dev/null @@ -1,64 +0,0 @@ -// CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE - -(function (mod) { - if (typeof exports == "object" && typeof module == "object") // CommonJS - mod(require("../../lib/codemirror"), require("../gfm/gfm"), require("../yaml/yaml")); - else if (typeof define == "function" && define.amd) // AMD - define(["../../lib/codemirror", "../gfm/gfm", "../yaml/yaml"], mod); - else // Plain browser env - mod(CodeMirror); -})(function (CodeMirror) { - - // a mixed mode for Markdown text with an optional YAML front matter - CodeMirror.defineMode("yaml-markdown", function (config) { - var gfmMode = CodeMirror.getMode(config, {name: "gfm"}); - var yamlMode = CodeMirror.getMode(config, {name: "yaml"}); - - return { - startState: function () { - var gfmState = gfmMode.startState(); - var yamlState = yamlMode.startState(); - return { - firstLine: true, - mode: gfmMode, - gfmState: gfmState, - yamlState: yamlState - }; - }, - copyState: function (state) { - return { - mode: state.mode, - gfmState: gfmMode.copyState(state.gfmState), - yamlState: state.yamlState - }; - }, - token: function (stream, state) { - if (state.firstLine && stream.match(/---/, false)) { - state.firstLine = false; - state.mode = yamlMode; - return yamlMode.token(stream, state.yamlState); - } else if (state.mode == yamlMode && stream.match(/---/, false)) { - state.mode = gfmMode; - return yamlMode.token(stream, state.yamlState); - } else if (state.mode == yamlMode) { - return state.mode.token(stream, state.yamlState); - } else { - return state.mode.token(stream, state.gfmState); - } - }, - innerMode: function (state) { - if (state.mode == gfmMode) { - return gfmMode.innerMode(state.gfmState); - } else { - return {mode: yamlMode, state: state}; - } - }, - blankLine: function (state) { - if (state.mode == gfmMode) { - return gfmMode.blankLine(state.gfmState) - } - } - }; - }); -}); From 237a6b69baab3c5d0c4dedc00ad70ceb436d6d13 Mon Sep 17 00:00:00 2001 From: Erik Welander Date: Sat, 12 Dec 2015 01:56:34 -0800 Subject: [PATCH 0205/2444] [vim] Correct the scroll position for zt & zb. zt was placing 40% of the line above the visible area, and zb was placing it too high. --- keymap/vim.js | 4 +--- test/vim_test.js | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/keymap/vim.js b/keymap/vim.js index 59815957ca..0548b75be7 100644 --- a/keymap/vim.js +++ b/keymap/vim.js @@ -2147,9 +2147,7 @@ switch (actionArgs.position) { case 'center': y = y - (height / 2) + lineHeight; break; - case 'bottom': y = y - height + lineHeight*1.4; - break; - case 'top': y = y + lineHeight*0.4; + case 'bottom': y = y - height + lineHeight; break; } cm.scrollTo(null, y); diff --git a/test/vim_test.js b/test/vim_test.js index 74c6a95071..25f7e75e90 100644 --- a/test/vim_test.js +++ b/test/vim_test.js @@ -3119,6 +3119,25 @@ forEach(['zb','zz','zt','z-','z.','z'], function(e, idx){ return new Array(500).join('\n'); })()}); }); +testVim('zb_to_bottom', function(cm, vim, helpers){ + var lineNum = 250; + cm.setSize(600, 35*cm.defaultTextHeight()); + cm.setCursor(lineNum, 0); + helpers.doKeys('z', 'b'); + var scrollInfo = cm.getScrollInfo(); + eq(scrollInfo.top + scrollInfo.clientHeight, cm.charCoords(Pos(lineNum, 0), 'local').bottom); +}, { value: (function(){ + return new Array(500).join('\n'); +})()}); +testVim('zt_to_top', function(cm, vim, helpers){ + var lineNum = 250; + cm.setSize(600, 35*cm.defaultTextHeight()); + cm.setCursor(lineNum, 0); + helpers.doKeys('z', 't'); + eq(cm.getScrollInfo().top, cm.charCoords(Pos(lineNum, 0), 'local').top); +}, { value: (function(){ + return new Array(500).join('\n'); +})()}); testVim('zb Date: Mon, 21 Dec 2015 10:05:31 +0100 Subject: [PATCH 0206/2444] [clike mode] Highlight comments in preprocessor lines Closes #3709 --- mode/clike/clike.js | 25 ++++++++++++------------- mode/clike/test.js | 9 +++++++++ 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/mode/clike/clike.js b/mode/clike/clike.js index 0cbe2faea2..3766209c28 100644 --- a/mode/clike/clike.js +++ b/mode/clike/clike.js @@ -262,21 +262,20 @@ CodeMirror.defineMode("clike", function(config, parserConfig) { var cTypes = "int long char short double float unsigned signed void size_t ptrdiff_t"; function cppHook(stream, state) { - if (!state.startOfLine) return false; - for (;;) { - if (stream.skipTo("\\")) { - stream.next(); - if (stream.eol()) { - state.tokenize = cppHook; - break; - } - } else { - stream.skipToEnd(); - state.tokenize = null; - break; + if (!state.startOfLine) return false + for (var ch, next = null; ch = stream.peek();) { + if (!ch) { + break + } else if (ch == "\\" && stream.match(/^.$/)) { + next = cppHook + break + } else if (ch == "/" && stream.match(/^\/[\/\*]/, false)) { + break } + stream.next() } - return "meta"; + state.tokenize = next + return "meta" } function pointerHook(_stream, state) { diff --git a/mode/clike/test.js b/mode/clike/test.js index c84d22e185..c26003266c 100644 --- a/mode/clike/test.js +++ b/mode/clike/test.js @@ -31,6 +31,15 @@ " [variable x][operator ++];", "[keyword return];"); + MT("preprocessor", + "[meta #define FOO 3]", + "[variable-3 int] [variable foo];", + "[meta #define BAR\\]", + "[meta 4]", + "[variable-3 unsigned] [variable-3 int] [variable bar] [operator =] [number 8];", + "[meta #include ][comment // comment]") + + var mode_cpp = CodeMirror.getMode({indentUnit: 2}, "text/x-c++src"); function MTCPP(name) { test.mode(name, mode_cpp, Array.prototype.slice.call(arguments, 1)); } From c7b64ca080df3657f5094a51a976a167176a4178 Mon Sep 17 00:00:00 2001 From: TSUYUSATO Kitsune Date: Thu, 17 Dec 2015 00:12:45 +0900 Subject: [PATCH 0207/2444] [crystal mode] Add --- mode/crystal/crystal.js | 391 ++++++++++++++++++++++++++++++++++++++++ mode/crystal/index.html | 119 ++++++++++++ mode/index.html | 1 + mode/meta.js | 1 + 4 files changed, 512 insertions(+) create mode 100644 mode/crystal/crystal.js create mode 100644 mode/crystal/index.html diff --git a/mode/crystal/crystal.js b/mode/crystal/crystal.js new file mode 100644 index 0000000000..8fd65a5f0b --- /dev/null +++ b/mode/crystal/crystal.js @@ -0,0 +1,391 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: http://codemirror.net/LICENSE + +(function(mod) { + if (typeof exports == "object" && typeof module == "object") // CommonJS + mod(require("../../lib/codemirror")); + else if (typeof define == "function" && define.amd) // AMD + define(["../../lib/codemirror"], mod); + else // Plain browser env + mod(CodeMirror); +})(function(CodeMirror) { + "use strict"; + + CodeMirror.defineMode("crystal", function(config) { + function wordRegExp(words, end) { + return new RegExp((end ? "" : "^") + "(?:" + words.join("|") + ")" + (end ? "$" : "\\b")); + } + + function chain(tokenize, stream, state) { + state.tokenize.push(tokenize); + return tokenize(stream, state); + } + + var operators = /^(?:[-+/%|&^]|\*\*?|[<>]{2})/; + var conditionalOperators = /^(?:[=!]~|===|<=>|[<>=!]=?|[|&]{2}|~)/; + var indexingOperators = /^(?:\[\][?=]?)/; + var anotherOperators = /^(?:\.(?:\.{2})?|->|[?:])/; + var idents = /^[a-z_\u009F-\uFFFF][a-zA-Z0-9_\u009F-\uFFFF]*/; + var types = /^[A-Z_\u009F-\uFFFF][a-zA-Z0-9_\u009F-\uFFFF]*/; + var keywords = wordRegExp([ + "abstract", "alias", "as", "asm", "begin", "break", "case", "class", "def", "do", + "else", "elsif", "end", "ensure", "enum", "extend", "for", "fun", "if", "ifdef", + "include", "instance_sizeof", "lib", "macro", "module", "next", "of", "out", "pointerof", + "private", "protected", "rescue", "return", "require", "sizeof", "struct", + "super", "then", "type", "typeof", "union", "unless", "until", "when", "while", "with", + "yield", "__DIR__", "__FILE__", "__LINE__" + ]); + var atomWords = wordRegExp(["true", "false", "nil", "self"]); + var indentKeywordsArray = [ + "def", "fun", "macro", + "class", "module", "struct", "lib", "enum", "union", + "if", "unless", "case", "while", "until", "begin", "then", + "do", + "for", "ifdef" + ]; + var indentKeywords = wordRegExp(indentKeywordsArray); + var dedentKeywordsArray = [ + "end", + "else", "elsif", + "rescue", "ensure" + ]; + var dedentKeywords = wordRegExp(dedentKeywordsArray); + var dedentPunctualsArray = ["\\)", "\\}", "\\]"]; + var dedentPunctuals = new RegExp("^(?:" + dedentPunctualsArray.join("|") + ")$"); + var nextTokenizer = { + "def": tokenFollowIdent, "fun": tokenFollowIdent, "macro": tokenMacroDef, + "class": tokenFollowType, "module": tokenFollowType, "struct": tokenFollowType, + "lib": tokenFollowType, "enum": tokenFollowType, "union": tokenFollowType + }; + var matching = {"[": "]", "{": "}", "(": ")", "<": ">"}; + + function tokenBase(stream, state) { + if (stream.eatSpace()) { + return null; + } + + // Macros + if (state.lastToken != "\\" && stream.match("{%", false)) { + return chain(tokenMacro("%", "%"), stream, state); + } + + if (state.lastToken != "\\" && stream.match("{{", false)) { + return chain(tokenMacro("{", "}"), stream, state); + } + + // Comments + if (stream.peek() == "#") { + stream.skipToEnd(); + return "comment"; + } + + // Variables and keywords + var matched; + if (matched = stream.match(idents)) { + stream.eat(/[?!]/); + + matched = stream.current(); + if (stream.eat(":")) { + return "atom"; + } else if (state.lastToken == ".") { + return "property"; + } else if (keywords.test(matched)) { + if (state.lastToken != "abstract" && indentKeywords.test(matched)) { + if (!(matched == "fun" && state.blocks.indexOf("lib") >= 0)) { + state.blocks.push(matched); + state.currentIndent += 1; + } + } else if (dedentKeywords.test(matched)) { + state.blocks.pop(); + state.currentIndent -= 1; + } + + if (nextTokenizer.hasOwnProperty(matched)) { + state.tokenize.push(nextTokenizer[matched]); + } + + return "keyword"; + } else if (atomWords.test(matched)) { + return "atom"; + } + + return "variable"; + } + + // Class variables and instance variables + // or attributes + if (stream.eat("@")) { + if (stream.peek() == "[") { + return chain(tokenNest("[", "]", "meta"), stream, state); + } + + stream.eat("@"); + stream.match(idents) || stream.match(types); + return "variable-2"; + } + + // Global variables + if (stream.eat("$")) { + stream.eat(/[0-9]+|\?/) || stream.match(idents) || stream.match(types); + return "variable-3"; + } + + // Constants and types + if (stream.match(types)) { + return "tag"; + } + + // Symbols or ':' operator + if (stream.eat(":")) { + if (stream.eat("\"")) { + return chain(tokenQuote("\"", "atom", false), stream, state); + } else if (stream.match(idents) || stream.match(types) || + stream.match(operators) || stream.match(conditionalOperators) || stream.match(indexingOperators)) { + return "atom"; + } + stream.eat(":"); + return "operator"; + } + + // Strings + if (stream.eat("\"")) { + return chain(tokenQuote("\"", "string", true), stream, state); + } + + // Strings or regexps or macro variables or '%' operator + if (stream.peek() == "%") { + var style = "string"; + var embed = true; + var delim; + + if (stream.match("%r")) { + // Regexps + style = "string-2"; + delim = stream.next(); + } else if (stream.match("%w")) { + embed = false; + delim = stream.next(); + } else { + if(delim = stream.match(/^%([^\w\s=])/)) { + delim = delim[1]; + } else if (stream.match(/^%[a-zA-Z0-9_\u009F-\uFFFF]*/)) { + // Macro variables + return "meta"; + } else { + // '%' operator + return "operator"; + } + } + + if (matching.hasOwnProperty(delim)) { + delim = matching[delim]; + } + return chain(tokenQuote(delim, style, embed), stream, state); + } + + // Characters + if (stream.eat("'")) { + stream.match(/^(?:[^']|\\(?:[befnrtv0'"]|[0-7]{3}|u(?:[0-9a-fA-F]{4}|\{[0-9a-fA-F]{1,6}\})))/); + stream.eat("'"); + return "atom"; + } + + // Numbers + if (stream.eat("0")) { + if (stream.eat("x")) { + stream.match(/^[0-9a-fA-F]+/); + } else if (stream.eat("o")) { + stream.match(/^[0-7]+/); + } else if (stream.eat("b")) { + stream.match(/^[01]+/); + } + return "number"; + } + + if (stream.eat(/\d/)) { + stream.match(/^\d*(?:\.\d+)?(?:[eE][+-]?\d+)?/); + return "number"; + } + + // Operators + if (stream.match(operators)) { + stream.eat("="); // Operators can follow assigin symbol. + return "operator"; + } + + if (stream.match(conditionalOperators) || stream.match(anotherOperators)) { + return "operator"; + } + + // Parens and braces + if (matched = stream.match(/[({[]/, false)) { + matched = matched[0]; + return chain(tokenNest(matched, matching[matched], null), stream, state); + } + + // Escapes + if (stream.eat("\\")) { + stream.next(); + return "meta"; + } + + stream.next(); + return null; + } + + function tokenNest(begin, end, style, started) { + return function (stream, state) { + if (!started && stream.match(begin)) { + state.tokenize[state.tokenize.length - 1] = tokenNest(begin, end, style, true); + state.currentIndent += 1; + return style; + } + + var nextStyle = tokenBase(stream, state); + if (stream.current() === end) { + state.tokenize.pop(); + state.currentIndent -= 1; + nextStyle = style; + } + + return nextStyle; + }; + } + + function tokenMacro(begin, end, started) { + return function (stream, state) { + if (!started && stream.match("{" + begin)) { + state.currentIndent += 1; + state.tokenize[state.tokenize.length - 1] = tokenMacro(begin, end, true); + return "meta"; + } + + if (stream.match(end + "}")) { + state.currentIndent -= 1; + state.tokenize.pop(); + return "meta"; + } + + return tokenBase(stream, state); + }; + } + + function tokenMacroDef(stream, state) { + if (stream.eatSpace()) { + return null; + } + + var matched; + if (matched = stream.match(idents)) { + if (matched == "def") { + return "keyword"; + } + stream.eat(/[?!]/); + } + + state.tokenize.pop(); + return "def"; + } + + function tokenFollowIdent(stream, state) { + if (stream.eatSpace()) { + return null; + } + + if (stream.match(idents)) { + stream.eat(/[!?]/); + } else { + stream.match(operators) || stream.match(conditionalOperators) || stream.match(indexingOperators); + } + state.tokenize.pop(); + return "def"; + } + + function tokenFollowType(stream, state) { + if (stream.eatSpace()) { + return null; + } + + stream.match(types); + state.tokenize.pop(); + return "def"; + } + + function tokenQuote(end, style, embed) { + return function (stream, state) { + var escaped = false; + + while (stream.peek()) { + if (!escaped) { + if (stream.match("{%", false)) { + state.tokenize.push(tokenMacro("%", "%")); + return style; + } + + if (stream.match("{{", false)) { + state.tokenize.push(tokenMacro("{", "}")); + return style; + } + + if (embed && stream.match("#{", false)) { + state.tokenize.push(tokenNest("#{", "}", "meta")); + return style; + } + + var ch = stream.next(); + + if (ch == end) { + state.tokenize.pop(); + return style; + } + + escaped = ch == "\\"; + } else { + stream.next(); + escaped = false; + } + } + + return style; + }; + } + + return { + startState: function () { + return { + tokenize: [tokenBase], + currentIndent: 0, + lastToken: null, + blocks: [] + }; + }, + + token: function (stream, state) { + var style = state.tokenize[state.tokenize.length - 1](stream, state); + var token = stream.current(); + + if (style && style != "comment") { + state.lastToken = token; + } + + return style; + }, + + indent: function (state, textAfter) { + textAfter = textAfter.replace(/^\s*(?:\{%)?\s*|\s*(?:%\})?\s*$/g, ""); + + if (dedentKeywords.test(textAfter) || dedentPunctuals.test(textAfter)) { + return config.indentUnit * (state.currentIndent - 1); + } + + return config.indentUnit * state.currentIndent; + }, + + fold: "indent", + electricInput: wordRegExp(dedentPunctualsArray.concat(dedentKeywordsArray), true), + lineComment: '#' + }; + }); + + CodeMirror.defineMIME("text/x-crystal", "crystal"); +}); diff --git a/mode/crystal/index.html b/mode/crystal/index.html new file mode 100644 index 0000000000..4bd0399f0c --- /dev/null +++ b/mode/crystal/index.html @@ -0,0 +1,119 @@ + + +CodeMirror: Ruby mode + + + + + + + + + + + +
    +

    Crystal mode

    +
    + + +

    MIME types defined: text/x-crystal.

    +
    diff --git a/mode/index.html b/mode/index.html index 724192413a..072b89bdaa 100644 --- a/mode/index.html +++ b/mode/index.html @@ -42,6 +42,7 @@

    Language modes

  • COBOL
  • CoffeeScript
  • Common Lisp
  • +
  • Crystal
  • CSS
  • Cypher
  • Cython
  • diff --git a/mode/meta.js b/mode/meta.js index 7af51c1ec5..69e2a3ef69 100644 --- a/mode/meta.js +++ b/mode/meta.js @@ -28,6 +28,7 @@ {name: "Common Lisp", mime: "text/x-common-lisp", mode: "commonlisp", ext: ["cl", "lisp", "el"], alias: ["lisp"]}, {name: "Cypher", mime: "application/x-cypher-query", mode: "cypher", ext: ["cyp", "cypher"]}, {name: "Cython", mime: "text/x-cython", mode: "python", ext: ["pyx", "pxd", "pxi"]}, + {name: "Crystal", mime: "text/x-crystal", mode: "crystal", ext: ["cr"]}, {name: "CSS", mime: "text/css", mode: "css", ext: ["css"]}, {name: "CQL", mime: "text/x-cassandra", mode: "sql", ext: ["cql"]}, {name: "D", mime: "text/x-d", mode: "d", ext: ["d"]}, From 09e20bce214c2bd849667783365a7283b803d8eb Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Mon, 21 Dec 2015 10:42:29 +0100 Subject: [PATCH 0208/2444] [crystal mode] Integrate --- doc/compress.html | 1 + mode/crystal/crystal.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/compress.html b/doc/compress.html index fe8260ad64..74c6834768 100644 --- a/doc/compress.html +++ b/doc/compress.html @@ -122,6 +122,7 @@

    Script compression helper

    + diff --git a/mode/crystal/crystal.js b/mode/crystal/crystal.js index 8fd65a5f0b..2e74bee436 100644 --- a/mode/crystal/crystal.js +++ b/mode/crystal/crystal.js @@ -81,7 +81,7 @@ // Variables and keywords var matched; - if (matched = stream.match(idents)) { + if (stream.match(idents)) { stream.eat(/[?!]/); matched = stream.current(); From 6bc4c5a082be035ecf1c2bc66c0237df7c94850f Mon Sep 17 00:00:00 2001 From: TSUYUSATO Kitsune Date: Mon, 21 Dec 2015 18:55:12 +0900 Subject: [PATCH 0209/2444] [crystal mode] Crystal looks like Ruby but not Ruby --- mode/crystal/index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mode/crystal/index.html b/mode/crystal/index.html index 4bd0399f0c..ec03e25094 100644 --- a/mode/crystal/index.html +++ b/mode/crystal/index.html @@ -1,6 +1,6 @@ -CodeMirror: Ruby mode +CodeMirror: Crystal mode @@ -23,7 +23,7 @@ From fcfe83818aaee069c932be21cffeb855d7ac6cb0 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Mon, 21 Dec 2015 11:16:41 +0100 Subject: [PATCH 0210/2444] Fix assignment of end styles when there are multiple active marks We can't check for nextChange until all marks have been looked at See https://discuss.codemirror.net/t/marktext-endstyle-appearing-multiple-times/568/5 --- lib/codemirror.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/codemirror.js b/lib/codemirror.js index 6305cafdc2..a90b9b5940 100644 --- a/lib/codemirror.js +++ b/lib/codemirror.js @@ -7089,7 +7089,7 @@ if (nextChange == pos) { // Update current marker set spanStyle = spanEndStyle = spanStartStyle = title = css = ""; collapsed = null; nextChange = Infinity; - var foundBookmarks = []; + var foundBookmarks = [], endStyles for (var j = 0; j < spans.length; ++j) { var sp = spans[j], m = sp.marker; if (m.type == "bookmark" && sp.from == pos && m.widgetNode) { @@ -7102,7 +7102,7 @@ if (m.className) spanStyle += " " + m.className; if (m.css) css = (css ? css + ";" : "") + m.css; if (m.startStyle && sp.from == pos) spanStartStyle += " " + m.startStyle; - if (m.endStyle && sp.to == nextChange) spanEndStyle += " " + m.endStyle; + if (m.endStyle && sp.to == nextChange) (endStyles || (endStyles = [])).push(m.endStyle, sp.to) if (m.title && !title) title = m.title; if (m.collapsed && (!collapsed || compareCollapsedMarkers(collapsed.marker, m) < 0)) collapsed = sp; @@ -7110,6 +7110,9 @@ nextChange = sp.from; } } + if (endStyles) for (var j = 0; j < endStyles.length; j += 2) + if (endStyles[j + 1] == nextChange) spanEndStyle += " " + endStyles[j] + if (collapsed && (collapsed.from || 0) == pos) { buildCollapsedSpan(builder, (collapsed.to == null ? len + 1 : collapsed.to) - pos, collapsed.marker, collapsed.from == null); From 8a3e59cb49b05da385639c350858c2a2a07e60c1 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Mon, 21 Dec 2015 11:30:25 +0100 Subject: [PATCH 0211/2444] Mark release 5.10.0 --- AUTHORS | 11 +++++++++++ doc/compress.html | 1 + doc/manual.html | 2 +- doc/releases.html | 19 ++++++++++++++++--- index.html | 2 +- lib/codemirror.js | 2 +- package.json | 2 +- 7 files changed, 32 insertions(+), 7 deletions(-) diff --git a/AUTHORS b/AUTHORS index 4f06064129..830a968c27 100644 --- a/AUTHORS +++ b/AUTHORS @@ -105,9 +105,11 @@ Christian Petrov Christopher Brown Christopher Mitchell Christopher Pfohl +Chunliang Lyu ciaranj CodeAnimal coderaiser +Cole R Lawrence ComFreek Curtis Gagliardi dagsta @@ -144,6 +146,7 @@ Doug Wikle Drew Bratcher Drew Hintz Drew Khoury +Drini Cami Dror BG duralog eborden @@ -152,6 +155,7 @@ ekhaled Elisée Enam Mijbah Noor Eric Allam +Erik Welander eustas Fabien O'Carroll Fabio Zendhi Nagao @@ -219,6 +223,7 @@ Jan Jongboom jankeromnes Jan Keromnes Jan Odvarko +Jan Schär Jan T. Sott Jared Forsyth Jason @@ -234,7 +239,9 @@ jeffkenton Jeff Pickhardt jem (graphite) Jeremy Parmenter +Jim JobJob +jochenberger Jochen Berger Johan Ask John Connor @@ -258,6 +265,7 @@ ju1ius Juan Benavides Romero Jucovschi Constantin Juho Vuori +Justin Andresen Justin Hileman jwallers@gmail.com kaniga @@ -337,6 +345,7 @@ Max Kirsch Max Schaefer Max Xiantu mbarkhau +McBrainy melpon Metatheos Micah Dubinko @@ -376,6 +385,7 @@ Nicholas Bollweg Nicholas Bollweg (Nick) Nick Kreeger Nick Small +Nicolò Ribaudo Niels van Groningen nightwing Nikita Beloglazov @@ -492,6 +502,7 @@ Tom MacWright Tony Jian Travis Heppe Triangle717 +TSUYUSATO Kitsune twifkak Vestimir Markov vf diff --git a/doc/compress.html b/doc/compress.html index 74c6834768..1f1d0f0764 100644 --- a/doc/compress.html +++ b/doc/compress.html @@ -36,6 +36,7 @@

    Script compression helper

    Version: + + + + +

    From 07bcf88d8606b6aa75951862abe504fcf83f64b0 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Tue, 29 Dec 2015 09:32:54 +0100 Subject: [PATCH 0224/2444] [haskell-literate mode] Integrate Issue #3730 --- doc/compress.html | 1 + mode/haskell-literate/haskell-literate.js | 27 ++++++++++++++--------- mode/haskell-literate/index.html | 6 +++++ mode/index.html | 2 +- mode/meta.js | 1 + 5 files changed, 25 insertions(+), 12 deletions(-) diff --git a/doc/compress.html b/doc/compress.html index 1f1d0f0764..2537978290 100644 --- a/doc/compress.html +++ b/doc/compress.html @@ -149,6 +149,7 @@

    Script compression helper

    + diff --git a/mode/haskell-literate/haskell-literate.js b/mode/haskell-literate/haskell-literate.js index f50d2fb100..f51e96b604 100644 --- a/mode/haskell-literate/haskell-literate.js +++ b/mode/haskell-literate/haskell-literate.js @@ -9,30 +9,35 @@ else // Plain browser env mod(CodeMirror) })(function (CodeMirror) { - CodeMirror.defineMode("haskell-literate", function (config) { - var haskellMode = CodeMirror.getMode(config, "haskell") + "use strict" + + CodeMirror.defineMode("haskell-literate", function (config, parserConfig) { + var baseMode = CodeMirror.getMode(config, (parserConfig && parserConfig.base) || "haskell") + return { startState: function () { return { - haskellCode: false, - haskellState: CodeMirror.startState(haskellMode) + inCode: false, + baseState: CodeMirror.startState(baseMode) } }, token: function (stream, state) { - if ((stream.sol() && stream.next() == '>') || state.haskellCode) { - state.haskellCode = true - return haskellMode.token(stream, state.haskellState) + if (stream.sol()) { + if (state.inCode = stream.eat(">")) + return "meta" + } + if (state.inCode) { + return baseMode.token(stream, state.baseState) } else { stream.skipToEnd() return "comment" } }, - blankLine: function (state) { - state.haskellCode = false - }, innerMode: function (state) { - return {state: state.haskellState, mode: haskellMode}; + return state.inCode ? {state: state.baseState, mode: baseMode} : null } } }) + + CodeMirror.defineMIME("text/x-literate-haskell", "haskell-literate") }) diff --git a/mode/haskell-literate/index.html b/mode/haskell-literate/index.html index 051724776b..8c9bc60d15 100644 --- a/mode/haskell-literate/index.html +++ b/mode/haskell-literate/index.html @@ -269,6 +269,12 @@

    Haskell literate mode

    +

    MIME types + defined: text/x-literate-haskell.

    + +

    Parser configuration parameters recognized: base to + set the base mode (defaults to "haskell").

    + diff --git a/mode/index.html b/mode/index.html index 072b89bdaa..2a159ec53f 100644 --- a/mode/index.html +++ b/mode/index.html @@ -68,7 +68,7 @@

    Language modes

  • Groovy
  • HAML
  • Handlebars
  • -
  • Haskell
  • +
  • Haskell (Literate)
  • Haxe
  • HTML embedded (JSP, ASP.NET)
  • HTML mixed-mode
  • diff --git a/mode/meta.js b/mode/meta.js index 69e2a3ef69..e4b97360c3 100644 --- a/mode/meta.js +++ b/mode/meta.js @@ -56,6 +56,7 @@ {name: "Groovy", mime: "text/x-groovy", mode: "groovy", ext: ["groovy"]}, {name: "HAML", mime: "text/x-haml", mode: "haml", ext: ["haml"]}, {name: "Haskell", mime: "text/x-haskell", mode: "haskell", ext: ["hs"]}, + {name: "Haskell (Literate)", mime: "text/x-literate-haskell", mode: "haskell-literate", ext: ["lhs"]}, {name: "Haxe", mime: "text/x-haxe", mode: "haxe", ext: ["hx"]}, {name: "HXML", mime: "text/x-hxml", mode: "haxe", ext: ["hxml"]}, {name: "ASP.NET", mime: "application/x-aspx", mode: "htmlembedded", ext: ["aspx"], alias: ["asp", "aspx"]}, From b3f9487046e37facd64196380ebdd8639efc57b5 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Tue, 29 Dec 2015 13:33:29 +0100 Subject: [PATCH 0225/2444] [jsx mode] Add Closes #3742 Closes #3744 --- doc/compress.html | 2 +- mode/index.html | 2 +- mode/javascript/javascript.js | 16 +++++-- mode/jsx/index.html | 89 +++++++++++++++++++++++++++++++++++ mode/jsx/jsx.js | 85 +++++++++++++++++++++++++++++++++ mode/jsx/test.js | 35 ++++++++++++++ mode/meta.js | 1 + mode/xml/xml.js | 25 ++++++---- test/index.html | 2 + 9 files changed, 243 insertions(+), 14 deletions(-) create mode 100644 mode/jsx/index.html create mode 100644 mode/jsx/jsx.js create mode 100644 mode/jsx/test.js diff --git a/doc/compress.html b/doc/compress.html index 2537978290..a79b3097a3 100644 --- a/doc/compress.html +++ b/doc/compress.html @@ -159,7 +159,7 @@

    Script compression helper

    - + diff --git a/mode/index.html b/mode/index.html index 2a159ec53f..a6c293ec28 100644 --- a/mode/index.html +++ b/mode/index.html @@ -76,7 +76,7 @@

    Language modes

  • IDL
  • Java
  • Jade
  • -
  • JavaScript
  • +
  • JavaScript (JSX)
  • Jinja2
  • Julia
  • Kotlin
  • diff --git a/mode/javascript/javascript.js b/mode/javascript/javascript.js index d4ae668794..c851547775 100644 --- a/mode/javascript/javascript.js +++ b/mode/javascript/javascript.js @@ -13,6 +13,11 @@ })(function(CodeMirror) { "use strict"; +function expressionAllowed(stream, state, backUp) { + return /^(?:operator|sof|keyword c|case|new|[\[{}\(,;:])$/.test(state.lastType) || + (state.lastType == "quasi" && /\{\s*$/.test(stream.string.slice(0, stream.pos - (backUp || 0)))) +} + CodeMirror.defineMode("javascript", function(config, parserConfig) { var indentUnit = config.indentUnit; var statementIndent = parserConfig.statementIndent; @@ -126,8 +131,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { } else if (stream.eat("/")) { stream.skipToEnd(); return ret("comment", "comment"); - } else if (/^(?:operator|sof|keyword c|case|new|[\[{}\(,;:])$/.test(state.lastType) || - (state.lastType == "quasi" && /\{\s*$/.test(stream.string.slice(0, stream.pos - 1)))) { + } else if (expressionAllowed(stream, state, 1)) { readRegexp(stream); stream.match(/^\b(([gimyu])(?![gimyu]*\2))+\b/); return ret("regexp", "string-2"); @@ -711,7 +715,13 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { helperType: jsonMode ? "json" : "javascript", jsonldMode: jsonldMode, - jsonMode: jsonMode + jsonMode: jsonMode, + + expressionAllowed: expressionAllowed, + skipExpression: function(state) { + var top = state.cc[state.cc.length - 1] + if (top == expression || top == expressionNoComma) state.cc.pop() + } }; }); diff --git a/mode/jsx/index.html b/mode/jsx/index.html new file mode 100644 index 0000000000..cb51edb364 --- /dev/null +++ b/mode/jsx/index.html @@ -0,0 +1,89 @@ + + +CodeMirror: JSX mode + + + + + + + + + + + +
    +

    JSX mode

    + +
    + + + +

    JSX Mode for React's +JavaScript syntax extension.

    + +

    MIME types defined: text/jsx.

    + +
    diff --git a/mode/jsx/jsx.js b/mode/jsx/jsx.js new file mode 100644 index 0000000000..c3d227a882 --- /dev/null +++ b/mode/jsx/jsx.js @@ -0,0 +1,85 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: http://codemirror.net/LICENSE + +(function(mod) { + if (typeof exports == "object" && typeof module == "object") // CommonJS + mod(require("../../lib/codemirror"), require("../xml/xml"), require("../javascript/javascript")) + else if (typeof define == "function" && define.amd) // AMD + define(["../../lib/codemirror", "../xml/xml", "../javascript/javascript"], mod) + else // Plain browser env + mod(CodeMirror) +})(function(CodeMirror) { + "use strict" + + function copyContext(context) { + return {state: CodeMirror.copyState(context.mode, context.state), + mode: context.mode, + depth: context.depth, + prev: context.prev && copyContext(context.prev)} + } + + CodeMirror.defineMode("jsx", function(config) { + var xmlMode = CodeMirror.getMode(config, "xml") + var jsMode = CodeMirror.getMode(config, "javascript") + + return { + startState: function() { + return {context: {state: CodeMirror.startState(jsMode), mode: jsMode}} + }, + + copyState: function(state) { + return {context: copyContext(state.context)} + }, + + token: function(stream, state) { + var cx = state.context + if (cx.mode == xmlMode) { + if (stream.peek() == "{") { + xmlMode.skipAttribute(cx.state) + state.context = {state: CodeMirror.startState(jsMode, xmlMode.indent(cx.state, "")), + mode: jsMode, + depth: 1, + prev: state.context} + return jsMode.token(stream, state.context.state) + } else { // FIXME skip attribute + var style = xmlMode.token(stream, cx.state), cur, brace + if (/\btag\b/.test(style) && !cx.state.context && /^\/?>$/.test(stream.current())) + state.context = state.context.prev + else if (!style && (brace = (cur = stream.current()).indexOf("{")) > -1) + stream.backUp(cur.length - brace) + return style + } + } else { // jsMode + if (stream.peek() == "<" && jsMode.expressionAllowed(stream, cx.state)) { + jsMode.skipExpression(cx.state) + state.context = {state: CodeMirror.startState(xmlMode, jsMode.indent(cx.state, "")), + mode: xmlMode, + prev: state.context} + return xmlMode.token(stream, state.context.state) + } else { + var style = jsMode.token(stream, cx.state) + if (!style && cx.depth != null) { + var cur = stream.current() + if (cur == "{") { + cx.depth++ + } else if (cur == "}") { + if (--cx.depth == 0) state.context = state.context.prev + } + } + return style + } + } + }, + + indent: function(state, textAfter, fullLine) { + return state.context.mode.indent(state.context.state, textAfter, fullLine) + }, + + innerMode: function(state) { + return state.context[state.context.length - 1] + } + } + }, "xml", "javascript") + + CodeMirror.defineMIME("text/jsx", "jsx") +}) diff --git a/mode/jsx/test.js b/mode/jsx/test.js new file mode 100644 index 0000000000..63fafb27c1 --- /dev/null +++ b/mode/jsx/test.js @@ -0,0 +1,35 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: http://codemirror.net/LICENSE + +(function() { + var mode = CodeMirror.getMode({indentUnit: 2}, "jsx") + function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)) } + + MT("selfclose", + "[keyword var] [def x] [operator =] [bracket&tag <] [tag foo] [bracket&tag />] [operator +] [number 1];") + + MT("openclose", + "([bracket&tag <][tag foo][bracket&tag >]hello [atom &][bracket&tag ][operator ++])") + + MT("attr", + "([bracket&tag <][tag foo] [attribute abc]=[string 'value'][bracket&tag >]hello [atom &][bracket&tag ][operator ++])") + + MT("braced_attr", + "([bracket&tag <][tag foo] [attribute abc]={[number 10]}[bracket&tag >]hello [atom &][bracket&tag ][operator ++])") + + MT("braced_text", + "([bracket&tag <][tag foo][bracket&tag >]hello {[number 10]} [atom &][bracket&tag ][operator ++])") + + MT("nested_tag", + "([bracket&tag <][tag foo][bracket&tag ><][tag bar][bracket&tag >][operator ++])") + + MT("nested_jsx", + "[keyword return] (", + " [bracket&tag <][tag foo][bracket&tag >]", + " say {[number 1] [operator +] [bracket&tag <][tag bar] [attribute attr]={[number 10]}[bracket&tag />]}!", + " [bracket&tag ][operator ++]", + ")") + + MT("preserve_js_context", + "[variable x] [operator =] [string-2 `quasi${][bracket&tag <][tag foo][bracket&tag />][string-2 }quoted`]") +})() diff --git a/mode/meta.js b/mode/meta.js index e4b97360c3..49520717fd 100644 --- a/mode/meta.js +++ b/mode/meta.js @@ -70,6 +70,7 @@ mode: "javascript", ext: ["js"], alias: ["ecmascript", "js", "node"]}, {name: "JSON", mimes: ["application/json", "application/x-json"], mode: "javascript", ext: ["json", "map"], alias: ["json5"]}, {name: "JSON-LD", mime: "application/ld+json", mode: "javascript", ext: ["jsonld"], alias: ["jsonld"]}, + {name: "JSX", mime: "text/jsx", mode: "jsx", ext: ["jsx"]}, {name: "Jinja2", mime: "null", mode: "jinja2"}, {name: "Julia", mime: "text/x-julia", mode: "julia", ext: ["jl"]}, {name: "Kotlin", mime: "text/x-kotlin", mode: "clike", ext: ["kt"]}, diff --git a/mode/xml/xml.js b/mode/xml/xml.js index 5ad21720fb..92808e1478 100644 --- a/mode/xml/xml.js +++ b/mode/xml/xml.js @@ -297,12 +297,14 @@ CodeMirror.defineMode("xml", function(config, parserConfig) { } return { - startState: function() { - return {tokenize: inText, - state: baseState, - indented: 0, - tagName: null, tagStart: null, - context: null}; + startState: function(baseIndent) { + var state = {tokenize: inText, + state: baseState, + indented: baseIndent || 0, + tagName: null, tagStart: null, + context: null} + if (baseIndent != null) state.baseIndent = baseIndent + return state }, token: function(stream, state) { @@ -362,10 +364,10 @@ CodeMirror.defineMode("xml", function(config, parserConfig) { break; } } - while (context && !context.startOfLine) + while (context && context.prev && !context.startOfLine) context = context.prev; if (context) return context.indent + indentUnit; - else return 0; + else return state.baseIndent || 0; }, electricInput: /<\/[\s\w:]+>$/, @@ -373,7 +375,12 @@ CodeMirror.defineMode("xml", function(config, parserConfig) { blockCommentEnd: "-->", configuration: parserConfig.htmlMode ? "html" : "xml", - helperType: parserConfig.htmlMode ? "html" : "xml" + helperType: parserConfig.htmlMode ? "html" : "xml", + + skipAttribute: function(state) { + if (state.state == attrValueState) + state.state = attrState + } }; }); diff --git a/test/index.html b/test/index.html index b0b1fa976b..3e227a061d 100644 --- a/test/index.html +++ b/test/index.html @@ -23,6 +23,7 @@ + @@ -107,6 +108,7 @@

    Test Suite

    + From b42563cadcfb6a490732090757dae38569ba6068 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Tue, 29 Dec 2015 22:16:37 +0100 Subject: [PATCH 0226/2444] [jsx mode] Support JS comments Issue #3745 --- mode/jsx/jsx.js | 43 +++++++++++++++++++++++++++---------------- mode/jsx/test.js | 9 +++++++++ 2 files changed, 36 insertions(+), 16 deletions(-) diff --git a/mode/jsx/jsx.js b/mode/jsx/jsx.js index c3d227a882..ebae784455 100644 --- a/mode/jsx/jsx.js +++ b/mode/jsx/jsx.js @@ -11,11 +11,15 @@ })(function(CodeMirror) { "use strict" + function Context(state, mode, depth, prev) { + this.state = state; this.mode = mode; this.depth = depth; this.prev = prev + } + function copyContext(context) { - return {state: CodeMirror.copyState(context.mode, context.state), - mode: context.mode, - depth: context.depth, - prev: context.prev && copyContext(context.prev)} + return new Context(CodeMirror.copyState(context.mode, context.state), + context.mode, + context.depth, + context.prev && copyContext(context.prev)) } CodeMirror.defineMode("jsx", function(config) { @@ -24,7 +28,7 @@ return { startState: function() { - return {context: {state: CodeMirror.startState(jsMode), mode: jsMode}} + return {context: new Context(CodeMirror.startState(jsMode), jsMode)} }, copyState: function(state) { @@ -34,27 +38,34 @@ token: function(stream, state) { var cx = state.context if (cx.mode == xmlMode) { - if (stream.peek() == "{") { + if (cx.depth) { // Inside a JS /* */ comment + if (stream.match(/^.*?\*\//)) cx.depth = 0 + else stream.skipToEnd() + return "comment" + } else if (stream.peek() == "{") { xmlMode.skipAttribute(cx.state) - state.context = {state: CodeMirror.startState(jsMode, xmlMode.indent(cx.state, "")), - mode: jsMode, - depth: 1, - prev: state.context} + state.context = new Context(CodeMirror.startState(jsMode, xmlMode.indent(cx.state, "")), + jsMode, 1, state.context) return jsMode.token(stream, state.context.state) + } else if (stream.match("//")) { + stream.skipToEnd() + return "comment" + } else if (stream.match("/*")) { + cx.depth = 1 + return this.token(stream, state) } else { // FIXME skip attribute - var style = xmlMode.token(stream, cx.state), cur, brace + var style = xmlMode.token(stream, cx.state), cur, stop if (/\btag\b/.test(style) && !cx.state.context && /^\/?>$/.test(stream.current())) state.context = state.context.prev - else if (!style && (brace = (cur = stream.current()).indexOf("{")) > -1) - stream.backUp(cur.length - brace) + else if (!style && (stop = (cur = stream.current()).search(/\{|\/[*\/]/)) > -1) + stream.backUp(cur.length - stop) return style } } else { // jsMode if (stream.peek() == "<" && jsMode.expressionAllowed(stream, cx.state)) { jsMode.skipExpression(cx.state) - state.context = {state: CodeMirror.startState(xmlMode, jsMode.indent(cx.state, "")), - mode: xmlMode, - prev: state.context} + state.context = new Context(CodeMirror.startState(xmlMode, jsMode.indent(cx.state, "")), + xmlMode, 0, state.context) return xmlMode.token(stream, state.context.state) } else { var style = jsMode.token(stream, cx.state) diff --git a/mode/jsx/test.js b/mode/jsx/test.js index 63fafb27c1..e45f67cdcd 100644 --- a/mode/jsx/test.js +++ b/mode/jsx/test.js @@ -32,4 +32,13 @@ MT("preserve_js_context", "[variable x] [operator =] [string-2 `quasi${][bracket&tag <][tag foo][bracket&tag />][string-2 }quoted`]") + + MT("line_comment", + "([bracket&tag <][tag foo][bracket&tag >] [comment // hello]", + " [bracket&tag ][operator ++])") + + MT("block_comment", + "([bracket&tag <][tag foo][bracket&tag >] [comment /* hello]", + "[comment line 2]", + "[comment line 3 */] [bracket&tag ][operator ++])") })() From e8ad6773ba672017a50af029b260eafbc93c5f46 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Tue, 29 Dec 2015 22:30:28 +0100 Subject: [PATCH 0227/2444] [xml mode] Allow more direct access to configuration Use it to enable value-less attributes in the JSX mode Issue #3745 --- mode/jsx/jsx.js | 2 +- mode/jsx/test.js | 4 ++ mode/xml/xml.js | 124 ++++++++++++++++++++++++----------------------- 3 files changed, 68 insertions(+), 62 deletions(-) diff --git a/mode/jsx/jsx.js b/mode/jsx/jsx.js index ebae784455..d38d16c898 100644 --- a/mode/jsx/jsx.js +++ b/mode/jsx/jsx.js @@ -23,7 +23,7 @@ } CodeMirror.defineMode("jsx", function(config) { - var xmlMode = CodeMirror.getMode(config, "xml") + var xmlMode = CodeMirror.getMode(config, {name: "xml", allowMissing: true}) var jsMode = CodeMirror.getMode(config, "javascript") return { diff --git a/mode/jsx/test.js b/mode/jsx/test.js index e45f67cdcd..c0032a4ce0 100644 --- a/mode/jsx/test.js +++ b/mode/jsx/test.js @@ -41,4 +41,8 @@ "([bracket&tag <][tag foo][bracket&tag >] [comment /* hello]", "[comment line 2]", "[comment line 3 */] [bracket&tag ][operator ++])") + + MT("missing_attr", + "([bracket&tag <][tag foo] [attribute selected][bracket&tag />][operator ++])") + })() diff --git a/mode/xml/xml.js b/mode/xml/xml.js index 92808e1478..014f7d846d 100644 --- a/mode/xml/xml.js +++ b/mode/xml/xml.js @@ -11,54 +11,56 @@ })(function(CodeMirror) { "use strict"; -CodeMirror.defineMode("xml", function(config, parserConfig) { - var indentUnit = config.indentUnit; - var multilineTagIndentFactor = parserConfig.multilineTagIndentFactor || 1; - var multilineTagIndentPastTag = parserConfig.multilineTagIndentPastTag; - if (multilineTagIndentPastTag == null) multilineTagIndentPastTag = true; +var htmlConfig = { + autoSelfClosers: {'area': true, 'base': true, 'br': true, 'col': true, 'command': true, + 'embed': true, 'frame': true, 'hr': true, 'img': true, 'input': true, + 'keygen': true, 'link': true, 'meta': true, 'param': true, 'source': true, + 'track': true, 'wbr': true, 'menuitem': true}, + implicitlyClosed: {'dd': true, 'li': true, 'optgroup': true, 'option': true, 'p': true, + 'rp': true, 'rt': true, 'tbody': true, 'td': true, 'tfoot': true, + 'th': true, 'tr': true}, + contextGrabbers: { + 'dd': {'dd': true, 'dt': true}, + 'dt': {'dd': true, 'dt': true}, + 'li': {'li': true}, + 'option': {'option': true, 'optgroup': true}, + 'optgroup': {'optgroup': true}, + 'p': {'address': true, 'article': true, 'aside': true, 'blockquote': true, 'dir': true, + 'div': true, 'dl': true, 'fieldset': true, 'footer': true, 'form': true, + 'h1': true, 'h2': true, 'h3': true, 'h4': true, 'h5': true, 'h6': true, + 'header': true, 'hgroup': true, 'hr': true, 'menu': true, 'nav': true, 'ol': true, + 'p': true, 'pre': true, 'section': true, 'table': true, 'ul': true}, + 'rp': {'rp': true, 'rt': true}, + 'rt': {'rp': true, 'rt': true}, + 'tbody': {'tbody': true, 'tfoot': true}, + 'td': {'td': true, 'th': true}, + 'tfoot': {'tbody': true}, + 'th': {'td': true, 'th': true}, + 'thead': {'tbody': true, 'tfoot': true}, + 'tr': {'tr': true} + }, + doNotIndent: {"pre": true}, + allowUnquoted: true, + allowMissing: true, + caseFold: true +} - var Kludges = parserConfig.htmlMode ? { - autoSelfClosers: {'area': true, 'base': true, 'br': true, 'col': true, 'command': true, - 'embed': true, 'frame': true, 'hr': true, 'img': true, 'input': true, - 'keygen': true, 'link': true, 'meta': true, 'param': true, 'source': true, - 'track': true, 'wbr': true, 'menuitem': true}, - implicitlyClosed: {'dd': true, 'li': true, 'optgroup': true, 'option': true, 'p': true, - 'rp': true, 'rt': true, 'tbody': true, 'td': true, 'tfoot': true, - 'th': true, 'tr': true}, - contextGrabbers: { - 'dd': {'dd': true, 'dt': true}, - 'dt': {'dd': true, 'dt': true}, - 'li': {'li': true}, - 'option': {'option': true, 'optgroup': true}, - 'optgroup': {'optgroup': true}, - 'p': {'address': true, 'article': true, 'aside': true, 'blockquote': true, 'dir': true, - 'div': true, 'dl': true, 'fieldset': true, 'footer': true, 'form': true, - 'h1': true, 'h2': true, 'h3': true, 'h4': true, 'h5': true, 'h6': true, - 'header': true, 'hgroup': true, 'hr': true, 'menu': true, 'nav': true, 'ol': true, - 'p': true, 'pre': true, 'section': true, 'table': true, 'ul': true}, - 'rp': {'rp': true, 'rt': true}, - 'rt': {'rp': true, 'rt': true}, - 'tbody': {'tbody': true, 'tfoot': true}, - 'td': {'td': true, 'th': true}, - 'tfoot': {'tbody': true}, - 'th': {'td': true, 'th': true}, - 'thead': {'tbody': true, 'tfoot': true}, - 'tr': {'tr': true} - }, - doNotIndent: {"pre": true}, - allowUnquoted: true, - allowMissing: true, - caseFold: true - } : { - autoSelfClosers: {}, - implicitlyClosed: {}, - contextGrabbers: {}, - doNotIndent: {}, - allowUnquoted: false, - allowMissing: false, - caseFold: false - }; - var alignCDATA = parserConfig.alignCDATA; +var xmlConfig = { + autoSelfClosers: {}, + implicitlyClosed: {}, + contextGrabbers: {}, + doNotIndent: {}, + allowUnquoted: false, + allowMissing: false, + caseFold: false +} + +CodeMirror.defineMode("xml", function(editorConf, config_) { + var indentUnit = editorConf.indentUnit + var config = {} + var defaults = config_.htmlMode ? htmlConfig : xmlConfig + for (var prop in defaults) config[prop] = defaults[prop] + for (var prop in config_) config[prop] = config_[prop] // Return variables for tokenizers var type, setStyle; @@ -188,7 +190,7 @@ CodeMirror.defineMode("xml", function(config, parserConfig) { this.tagName = tagName; this.indent = state.indented; this.startOfLine = startOfLine; - if (Kludges.doNotIndent.hasOwnProperty(tagName) || (state.context && state.context.noIndent)) + if (config.doNotIndent.hasOwnProperty(tagName) || (state.context && state.context.noIndent)) this.noIndent = true; } function popContext(state) { @@ -201,8 +203,8 @@ CodeMirror.defineMode("xml", function(config, parserConfig) { return; } parentTagName = state.context.tagName; - if (!Kludges.contextGrabbers.hasOwnProperty(parentTagName) || - !Kludges.contextGrabbers[parentTagName].hasOwnProperty(nextTagName)) { + if (!config.contextGrabbers.hasOwnProperty(parentTagName) || + !config.contextGrabbers[parentTagName].hasOwnProperty(nextTagName)) { return; } popContext(state); @@ -233,7 +235,7 @@ CodeMirror.defineMode("xml", function(config, parserConfig) { if (type == "word") { var tagName = stream.current(); if (state.context && state.context.tagName != tagName && - Kludges.implicitlyClosed.hasOwnProperty(state.context.tagName)) + config.implicitlyClosed.hasOwnProperty(state.context.tagName)) popContext(state); if (state.context && state.context.tagName == tagName) { setStyle = "tag"; @@ -269,7 +271,7 @@ CodeMirror.defineMode("xml", function(config, parserConfig) { var tagName = state.tagName, tagStart = state.tagStart; state.tagName = state.tagStart = null; if (type == "selfcloseTag" || - Kludges.autoSelfClosers.hasOwnProperty(tagName)) { + config.autoSelfClosers.hasOwnProperty(tagName)) { maybePopContext(state, tagName); } else { maybePopContext(state, tagName); @@ -282,12 +284,12 @@ CodeMirror.defineMode("xml", function(config, parserConfig) { } function attrEqState(type, stream, state) { if (type == "equals") return attrValueState; - if (!Kludges.allowMissing) setStyle = "error"; + if (!config.allowMissing) setStyle = "error"; return attrState(type, stream, state); } function attrValueState(type, stream, state) { if (type == "string") return attrContinuedState; - if (type == "word" && Kludges.allowUnquoted) {setStyle = "string"; return attrState;} + if (type == "word" && config.allowUnquoted) {setStyle = "string"; return attrState;} setStyle = "error"; return attrState(type, stream, state); } @@ -337,19 +339,19 @@ CodeMirror.defineMode("xml", function(config, parserConfig) { return fullLine ? fullLine.match(/^(\s*)/)[0].length : 0; // Indent the starts of attribute names. if (state.tagName) { - if (multilineTagIndentPastTag) + if (config.multilineTagIndentPastTag !== false) return state.tagStart + state.tagName.length + 2; else - return state.tagStart + indentUnit * multilineTagIndentFactor; + return state.tagStart + indentUnit * (config.multilineTagIndentFactor || 1); } - if (alignCDATA && /", - configuration: parserConfig.htmlMode ? "html" : "xml", - helperType: parserConfig.htmlMode ? "html" : "xml", + configuration: config.htmlMode ? "html" : "xml", + helperType: config.htmlMode ? "html" : "xml", skipAttribute: function(state) { if (state.state == attrValueState) From e3dc9731678b2f4b33b5faf9ffb90332d3c97c96 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Tue, 29 Dec 2015 22:49:02 +0100 Subject: [PATCH 0228/2444] [jsx mode] Improve indentation of nested JavaScript Kludge the xml indentation to ignore inside-tag positions, and properly set start indentation state in javascript mode. Issue #3745 --- mode/javascript/javascript.js | 2 +- mode/jsx/jsx.js | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/mode/javascript/javascript.js b/mode/javascript/javascript.js index c851547775..ee6e4016df 100644 --- a/mode/javascript/javascript.js +++ b/mode/javascript/javascript.js @@ -659,7 +659,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { lexical: new JSLexical((basecolumn || 0) - indentUnit, 0, "block", false), localVars: parserConfig.localVars, context: parserConfig.localVars && {vars: parserConfig.localVars}, - indented: 0 + indented: basecolumn || 0 }; if (parserConfig.globalVars && typeof parserConfig.globalVars == "object") state.globalVars = parserConfig.globalVars; diff --git a/mode/jsx/jsx.js b/mode/jsx/jsx.js index d38d16c898..ccf2ee742f 100644 --- a/mode/jsx/jsx.js +++ b/mode/jsx/jsx.js @@ -44,8 +44,11 @@ return "comment" } else if (stream.peek() == "{") { xmlMode.skipAttribute(cx.state) + var tagName = cx.state.tagName + cx.state.tagName = null state.context = new Context(CodeMirror.startState(jsMode, xmlMode.indent(cx.state, "")), jsMode, 1, state.context) + cx.state.tagName = tagName return jsMode.token(stream, state.context.state) } else if (stream.match("//")) { stream.skipToEnd() @@ -87,7 +90,7 @@ }, innerMode: function(state) { - return state.context[state.context.length - 1] + return state.context } } }, "xml", "javascript") From d103ebfc453193406d3d01c8fbf638cadd00793d Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Tue, 29 Dec 2015 22:54:28 +0100 Subject: [PATCH 0229/2444] [jsx mode] Add test case for spread syntax --- mode/jsx/test.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/mode/jsx/test.js b/mode/jsx/test.js index c0032a4ce0..1d2fe4984b 100644 --- a/mode/jsx/test.js +++ b/mode/jsx/test.js @@ -44,5 +44,14 @@ MT("missing_attr", "([bracket&tag <][tag foo] [attribute selected][bracket&tag />][operator ++])") - + + MT("indent_js", + "([bracket&tag <][tag foo][bracket&tag >]", + " [bracket&tag <][tag bar] [attribute baz]={[keyword function]() {", + " [keyword return] [number 10]", + " }}[bracket&tag />]", + " [bracket&tag ])") + + MT("spread", + "([bracket&tag <][tag foo] [attribute bar]={[meta ...][variable baz] [operator /][number 2]}[bracket&tag />])") })() From bec6669991a226de6c8b8f6046f2296ac346b68c Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Wed, 30 Dec 2015 11:52:33 +0100 Subject: [PATCH 0230/2444] [jsx mode] Only recognize comments inside of tags Issue #3745 --- mode/jsx/jsx.js | 35 ++++++++++++++++++++++------------- mode/jsx/test.js | 17 +++++++++++++---- 2 files changed, 35 insertions(+), 17 deletions(-) diff --git a/mode/jsx/jsx.js b/mode/jsx/jsx.js index ccf2ee742f..6b7b6c2487 100644 --- a/mode/jsx/jsx.js +++ b/mode/jsx/jsx.js @@ -11,6 +11,9 @@ })(function(CodeMirror) { "use strict" + // Depth means the amount of open braces in JS context, in XML + // context 0 means not in tag, 1 means in tag, and 2 means in tag + // and js block comment. function Context(state, mode, depth, prev) { this.state = state; this.mode = mode; this.depth = depth; this.prev = prev } @@ -23,7 +26,7 @@ } CodeMirror.defineMode("jsx", function(config) { - var xmlMode = CodeMirror.getMode(config, {name: "xml", allowMissing: true}) + var xmlMode = CodeMirror.getMode(config, {name: "xml", allowMissing: true, multilineTagIndentPastTag: false}) var jsMode = CodeMirror.getMode(config, "javascript") return { @@ -38,8 +41,8 @@ token: function(stream, state) { var cx = state.context if (cx.mode == xmlMode) { - if (cx.depth) { // Inside a JS /* */ comment - if (stream.match(/^.*?\*\//)) cx.depth = 0 + if (cx.depth == 2) { // Inside a JS /* */ comment + if (stream.match(/^.*?\*\//)) cx.depth = 1 else stream.skipToEnd() return "comment" } else if (stream.peek() == "{") { @@ -47,21 +50,27 @@ var tagName = cx.state.tagName cx.state.tagName = null state.context = new Context(CodeMirror.startState(jsMode, xmlMode.indent(cx.state, "")), - jsMode, 1, state.context) + jsMode, 0, state.context) cx.state.tagName = tagName - return jsMode.token(stream, state.context.state) - } else if (stream.match("//")) { + return this.token(stream, state) + } else if (cx.depth == 1 && stream.match("//")) { stream.skipToEnd() return "comment" - } else if (stream.match("/*")) { - cx.depth = 1 + } else if (cx.depth == 1 && stream.match("/*")) { + cx.depth = 2 return this.token(stream, state) } else { // FIXME skip attribute - var style = xmlMode.token(stream, cx.state), cur, stop - if (/\btag\b/.test(style) && !cx.state.context && /^\/?>$/.test(stream.current())) - state.context = state.context.prev - else if (!style && (stop = (cur = stream.current()).search(/\{|\/[*\/]/)) > -1) + var style = xmlMode.token(stream, cx.state), cur = stream.current(), stop + if (/\btag\b/.test(style)) { + if (/>$/.test(cur)) { + if (cx.state.context) cx.depth = 0 + else state.context = state.context.prev + } else if (/^ -1) { stream.backUp(cur.length - stop) + } return style } } else { // jsMode @@ -69,7 +78,7 @@ jsMode.skipExpression(cx.state) state.context = new Context(CodeMirror.startState(xmlMode, jsMode.indent(cx.state, "")), xmlMode, 0, state.context) - return xmlMode.token(stream, state.context.state) + return this.token(stream, state) } else { var style = jsMode.token(stream, cx.state) if (!style && cx.depth != null) { diff --git a/mode/jsx/test.js b/mode/jsx/test.js index 1d2fe4984b..ee601651d8 100644 --- a/mode/jsx/test.js +++ b/mode/jsx/test.js @@ -34,13 +34,22 @@ "[variable x] [operator =] [string-2 `quasi${][bracket&tag <][tag foo][bracket&tag />][string-2 }quoted`]") MT("line_comment", - "([bracket&tag <][tag foo][bracket&tag >] [comment // hello]", + "([bracket&tag <][tag foo] [comment // hello]", + " [bracket&tag >][operator ++])") + + MT("line_comment_not_in_tag", + "([bracket&tag <][tag foo][bracket&tag >] // hello", " [bracket&tag ][operator ++])") MT("block_comment", - "([bracket&tag <][tag foo][bracket&tag >] [comment /* hello]", - "[comment line 2]", - "[comment line 3 */] [bracket&tag ][operator ++])") + "([bracket&tag <][tag foo] [comment /* hello]", + "[comment line 2]", + "[comment line 3 */] [bracket&tag >][operator ++])") + + MT("block_comment_not_in_tag", + "([bracket&tag <][tag foo][bracket&tag >]/* hello", + " line 2", + " line 3 */ [bracket&tag ][operator ++])") MT("missing_attr", "([bracket&tag <][tag foo] [attribute selected][bracket&tag />][operator ++])") From 8870302a3f2efec00e68d32f6a9d5af959210241 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Wed, 30 Dec 2015 12:02:21 +0100 Subject: [PATCH 0231/2444] [jsx mode] Support tag attributes Issue #3745 --- mode/jsx/jsx.js | 134 ++++++++++++++++++++++++++++------------------- mode/jsx/test.js | 3 ++ 2 files changed, 82 insertions(+), 55 deletions(-) diff --git a/mode/jsx/jsx.js b/mode/jsx/jsx.js index 6b7b6c2487..5f6afc1832 100644 --- a/mode/jsx/jsx.js +++ b/mode/jsx/jsx.js @@ -29,6 +29,84 @@ var xmlMode = CodeMirror.getMode(config, {name: "xml", allowMissing: true, multilineTagIndentPastTag: false}) var jsMode = CodeMirror.getMode(config, "javascript") + function flatXMLIndent(state) { + var tagName = state.tagName + state.tagName = null + var result = xmlMode.indent(state, "") + state.tagName = tagName + return result + } + + function token(stream, state) { + if (state.context.mode == xmlMode) + return xmlToken(stream, state, state.context) + else + return jsToken(stream, state, state.context) + } + + function xmlToken(stream, state, cx) { + if (cx.depth == 2) { // Inside a JS /* */ comment + if (stream.match(/^.*?\*\//)) cx.depth = 1 + else stream.skipToEnd() + return "comment" + } + + if (stream.peek() == "{") { + xmlMode.skipAttribute(cx.state) + state.context = new Context(CodeMirror.startState(jsMode, flatXMLIndent(cx.state)), + jsMode, 0, state.context) + return token(stream, state) + } + + if (cx.depth == 1) { // Inside of tag + if (stream.peek() == "<") { // Tag inside of tag + xmlMode.skipAttribute(cx.state) + state.context = new Context(CodeMirror.startState(xmlMode, flatXMLIndent(cx.state)), + xmlMode, 0, state.context) + return token(stream, state) + } else if (stream.match("//")) { + stream.skipToEnd() + return "comment" + } else if (stream.match("/*")) { + cx.depth = 2 + return token(stream, state) + } + } + + var style = xmlMode.token(stream, cx.state), cur = stream.current(), stop + if (/\btag\b/.test(style)) { + if (/>$/.test(cur)) { + if (cx.state.context) cx.depth = 0 + else state.context = state.context.prev + } else if (/^ -1) { + stream.backUp(cur.length - stop) + } + return style + } + + function jsToken(stream, state, cx) { + if (stream.peek() == "<" && jsMode.expressionAllowed(stream, cx.state)) { + jsMode.skipExpression(cx.state) + state.context = new Context(CodeMirror.startState(xmlMode, jsMode.indent(cx.state, "")), + xmlMode, 0, state.context) + return token(stream, state) + } + + var style = jsMode.token(stream, cx.state) + if (!style && cx.depth != null) { + var cur = stream.current() + if (cur == "{") { + cx.depth++ + } else if (cur == "}") { + if (--cx.depth == 0) state.context = state.context.prev + } + } + return style + } + return { startState: function() { return {context: new Context(CodeMirror.startState(jsMode), jsMode)} @@ -38,61 +116,7 @@ return {context: copyContext(state.context)} }, - token: function(stream, state) { - var cx = state.context - if (cx.mode == xmlMode) { - if (cx.depth == 2) { // Inside a JS /* */ comment - if (stream.match(/^.*?\*\//)) cx.depth = 1 - else stream.skipToEnd() - return "comment" - } else if (stream.peek() == "{") { - xmlMode.skipAttribute(cx.state) - var tagName = cx.state.tagName - cx.state.tagName = null - state.context = new Context(CodeMirror.startState(jsMode, xmlMode.indent(cx.state, "")), - jsMode, 0, state.context) - cx.state.tagName = tagName - return this.token(stream, state) - } else if (cx.depth == 1 && stream.match("//")) { - stream.skipToEnd() - return "comment" - } else if (cx.depth == 1 && stream.match("/*")) { - cx.depth = 2 - return this.token(stream, state) - } else { // FIXME skip attribute - var style = xmlMode.token(stream, cx.state), cur = stream.current(), stop - if (/\btag\b/.test(style)) { - if (/>$/.test(cur)) { - if (cx.state.context) cx.depth = 0 - else state.context = state.context.prev - } else if (/^ -1) { - stream.backUp(cur.length - stop) - } - return style - } - } else { // jsMode - if (stream.peek() == "<" && jsMode.expressionAllowed(stream, cx.state)) { - jsMode.skipExpression(cx.state) - state.context = new Context(CodeMirror.startState(xmlMode, jsMode.indent(cx.state, "")), - xmlMode, 0, state.context) - return this.token(stream, state) - } else { - var style = jsMode.token(stream, cx.state) - if (!style && cx.depth != null) { - var cur = stream.current() - if (cur == "{") { - cx.depth++ - } else if (cur == "}") { - if (--cx.depth == 0) state.context = state.context.prev - } - } - return style - } - } - }, + token: token, indent: function(state, textAfter, fullLine) { return state.context.mode.indent(state.context.state, textAfter, fullLine) diff --git a/mode/jsx/test.js b/mode/jsx/test.js index ee601651d8..0ea9901784 100644 --- a/mode/jsx/test.js +++ b/mode/jsx/test.js @@ -63,4 +63,7 @@ MT("spread", "([bracket&tag <][tag foo] [attribute bar]={[meta ...][variable baz] [operator /][number 2]}[bracket&tag />])") + + MT("tag_attribute", + "([bracket&tag <][tag foo] [attribute bar]=[bracket&tag <][tag foo][bracket&tag />/>][operator ++])") })() From 78aba6492cb31e1b3ab680af47896e1a0b8a2156 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Wed, 30 Dec 2015 12:09:05 +0100 Subject: [PATCH 0232/2444] [javascript mode] Allow expressions after fat arrow Issue #3745 --- mode/javascript/javascript.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mode/javascript/javascript.js b/mode/javascript/javascript.js index ee6e4016df..f4e7ed6daf 100644 --- a/mode/javascript/javascript.js +++ b/mode/javascript/javascript.js @@ -14,7 +14,7 @@ "use strict"; function expressionAllowed(stream, state, backUp) { - return /^(?:operator|sof|keyword c|case|new|[\[{}\(,;:])$/.test(state.lastType) || + return /^(?:operator|sof|keyword c|case|new|[\[{}\(,;:]|=>)$/.test(state.lastType) || (state.lastType == "quasi" && /\{\s*$/.test(stream.string.slice(0, stream.pos - (backUp || 0)))) } From 5c53fe7c7f97147650bac3f20c1518a7b5cdd16e Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Wed, 30 Dec 2015 14:09:47 +0100 Subject: [PATCH 0233/2444] [nginx mode] Fix MIME declaration Closes #3746 --- mode/nginx/nginx.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mode/nginx/nginx.js b/mode/nginx/nginx.js index 135b9cc7f8..00a3224922 100644 --- a/mode/nginx/nginx.js +++ b/mode/nginx/nginx.js @@ -173,6 +173,6 @@ CodeMirror.defineMode("nginx", function(config) { }; }); -CodeMirror.defineMIME("text/nginx", "text/x-nginx-conf"); +CodeMirror.defineMIME("text/x-nginx-conf", "nginx"); }); From 5f228475fd7059c3d712da96c441496fccd25081 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Mon, 4 Jan 2016 10:34:49 +0100 Subject: [PATCH 0234/2444] Signal touchstart event, signal mousedown even during touch Issue #3736 --- doc/manual.html | 3 ++- lib/codemirror.js | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/doc/manual.html b/doc/manual.html index a33b77aef4..5087df9061 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -653,7 +653,8 @@

    Events

    should not try to change the state of the editor.
    "mousedown", - "dblclick", "contextmenu", "keydown", "keypress", + "dblclick", "touchstart", "contextmenu", + "keydown", "keypress", "keyup", "cut", "copy", "paste", "dragstart", "dragenter", "dragover", "drop" diff --git a/lib/codemirror.js b/lib/codemirror.js index c4f5a0008f..55412ae72a 100644 --- a/lib/codemirror.js +++ b/lib/codemirror.js @@ -3435,7 +3435,7 @@ return dx * dx + dy * dy > 20 * 20; } on(d.scroller, "touchstart", function(e) { - if (!isMouseLikeTouchEvent(e)) { + if (!signalDOMEvent(cm, e) && !isMouseLikeTouchEvent(e)) { clearTimeout(touchFinished); var now = +new Date; d.activeTouch = {start: now, moved: false, @@ -3564,7 +3564,7 @@ // not interfere with, such as a scrollbar or widget. function onMouseDown(e) { var cm = this, display = cm.display; - if (display.activeTouch && display.input.supportsTouch() || signalDOMEvent(cm, e)) return; + if (signalDOMEvent(cm, e) || display.activeTouch && display.input.supportsTouch()) return; display.shift = e.shiftKey; if (eventInWidget(display, e)) { From 0d73c4bf947efccfb43b534ca2f78c513f43cdb5 Mon Sep 17 00:00:00 2001 From: Devin Abbott Date: Wed, 30 Dec 2015 12:35:43 -0800 Subject: [PATCH 0235/2444] [javascript mode] Allow trailing comma in object destructure Issue #3745 --- mode/javascript/javascript.js | 1 + mode/javascript/test.js | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/mode/javascript/javascript.js b/mode/javascript/javascript.js index f4e7ed6daf..fa5721d5d0 100644 --- a/mode/javascript/javascript.js +++ b/mode/javascript/javascript.js @@ -537,6 +537,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { } if (type == "variable") cx.marked = "property"; if (type == "spread") return cont(pattern); + if (type == "}") return pass(); return cont(expect(":"), pattern, maybeAssign); } function maybeAssign(_type, value) { diff --git a/mode/javascript/test.js b/mode/javascript/test.js index 252e064dcc..cb43d0894d 100644 --- a/mode/javascript/test.js +++ b/mode/javascript/test.js @@ -17,6 +17,10 @@ " [[[variable-2 c], [variable y] ]] [operator =] [variable-2 c];", "})();"); + MT("destructure_trailing_comma", + "[keyword let] {[def a], [def b],} [operator =] [variable foo];", + "[keyword let] [def c];"); // Parser still in good state? + MT("class_body", "[keyword class] [def Foo] {", " [property constructor]() {}", From 65950ad0acb3d3014077d9bfe0defc8bd468b11c Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Mon, 4 Jan 2016 10:45:34 +0100 Subject: [PATCH 0236/2444] [jsx mode] Return empty token when switching inner modes So that addModeClass sees the right mode for the token Issue #3745 --- mode/jsx/jsx.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mode/jsx/jsx.js b/mode/jsx/jsx.js index 5f6afc1832..af0e26338a 100644 --- a/mode/jsx/jsx.js +++ b/mode/jsx/jsx.js @@ -55,7 +55,7 @@ xmlMode.skipAttribute(cx.state) state.context = new Context(CodeMirror.startState(jsMode, flatXMLIndent(cx.state)), jsMode, 0, state.context) - return token(stream, state) + return null } if (cx.depth == 1) { // Inside of tag @@ -63,7 +63,7 @@ xmlMode.skipAttribute(cx.state) state.context = new Context(CodeMirror.startState(xmlMode, flatXMLIndent(cx.state)), xmlMode, 0, state.context) - return token(stream, state) + return null } else if (stream.match("//")) { stream.skipToEnd() return "comment" @@ -92,7 +92,7 @@ jsMode.skipExpression(cx.state) state.context = new Context(CodeMirror.startState(xmlMode, jsMode.indent(cx.state, "")), xmlMode, 0, state.context) - return token(stream, state) + return null } var style = jsMode.token(stream, cx.state) From 8f2149c2d5861842883f078003d055546951aec4 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Mon, 4 Jan 2016 11:03:46 +0100 Subject: [PATCH 0237/2444] Draw bookmarks next to a collapsed span See https://discuss.codemirror.net/t/inserting-a-boomark-immediately-before-a-textmarker/590/1 --- lib/codemirror.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/codemirror.js b/lib/codemirror.js index 55412ae72a..aa5664a173 100644 --- a/lib/codemirror.js +++ b/lib/codemirror.js @@ -7115,14 +7115,14 @@ if (endStyles) for (var j = 0; j < endStyles.length; j += 2) if (endStyles[j + 1] == nextChange) spanEndStyle += " " + endStyles[j] + if (!collapsed || collapsed.from == pos) for (var j = 0; j < foundBookmarks.length; ++j) + buildCollapsedSpan(builder, 0, foundBookmarks[j]); if (collapsed && (collapsed.from || 0) == pos) { buildCollapsedSpan(builder, (collapsed.to == null ? len + 1 : collapsed.to) - pos, collapsed.marker, collapsed.from == null); if (collapsed.to == null) return; if (collapsed.to == pos) collapsed = false; } - if (!collapsed && foundBookmarks.length) for (var j = 0; j < foundBookmarks.length; ++j) - buildCollapsedSpan(builder, 0, foundBookmarks[j]); } if (pos >= len) break; From f923adb268043880178ab17dcaeaeacaf5d5fdd5 Mon Sep 17 00:00:00 2001 From: Will Dean Date: Fri, 1 Jan 2016 11:50:16 +0000 Subject: [PATCH 0238/2444] Various HTML cleanups --- demo/btree.html | 4 +--- demo/tern.html | 4 ++-- demo/xmlcomplete.html | 4 ++-- doc/internals.html | 3 ++- doc/manual.html | 4 ++-- doc/releases.html | 4 ++-- mode/asn.1/index.html | 3 +-- mode/handlebars/index.html | 5 ++--- mode/mumps/index.html | 4 ++-- mode/nginx/index.html | 4 ++-- mode/pig/index.html | 4 +--- mode/tiki/tiki.css | 2 +- 12 files changed, 20 insertions(+), 25 deletions(-) diff --git a/demo/btree.html b/demo/btree.html index fc4997f4f5..ba07bc74f4 100644 --- a/demo/btree.html +++ b/demo/btree.html @@ -1,4 +1,4 @@ - + CodeMirror: B-Tree visualization @@ -26,9 +26,7 @@

    B-Tree visualization

    -
    - - - +

    Handlebars syntax highlighting for CodeMirror.

    MIME types defined: text/x-handlebars-template

    diff --git a/mode/mumps/index.html b/mode/mumps/index.html index bd1f69aef5..b1f92c213f 100644 --- a/mode/mumps/index.html +++ b/mode/mumps/index.html @@ -1,4 +1,4 @@ - + CodeMirror: MUMPS mode @@ -73,7 +73,7 @@

    MUMPS mode

    IF '$LENGTH($PIECE(XUSER(1),U,2)) QUIT 21 ;p419, p434 Q 0 ; - + + +
    Fired when CodeMirror is handling a DOM event of this type. You can preventDefault the event, or give it a diff --git a/lib/codemirror.js b/lib/codemirror.js index d1599c99e9..372020d873 100644 --- a/lib/codemirror.js +++ b/lib/codemirror.js @@ -3495,7 +3495,7 @@ over: function(e) {if (!signalDOMEvent(cm, e)) { onDragOver(cm, e); e_stop(e); }}, start: function(e){onDragStart(cm, e);}, drop: operation(cm, onDrop), - leave: function() {clearDragCursor(cm);} + leave: function(e) {if (!signalDOMEvent(cm, e)) { clearDragCursor(cm); }} }; var inp = d.input.getField(); From ecaa8914751ad5472f315bce5f0c49c232aa5c26 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Mon, 21 Mar 2016 11:18:29 +0100 Subject: [PATCH 0335/2444] Make sure gutters are never left higher than the view height Closes #3884 --- lib/codemirror.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/codemirror.js b/lib/codemirror.js index 372020d873..c736708ee4 100644 --- a/lib/codemirror.js +++ b/lib/codemirror.js @@ -747,6 +747,7 @@ function postUpdateDisplay(cm, update) { var viewport = update.viewport; + for (var first = true;; first = false) { if (!first || !cm.options.lineWrapping || update.oldDisplayWidth == displayWidth(cm)) { // Clip forced viewport to actual scrollable area. @@ -766,6 +767,9 @@ updateScrollbars(cm, barMeasure); } + if (parseInt(cm.display.gutters.style.height) > cm.display.scroller.clientHeight) + cm.display.gutters.style.height = cm.display.scroller.clientHeight + "px" + update.signal(cm, "update", cm); if (cm.display.viewFrom != cm.display.reportedViewFrom || cm.display.viewTo != cm.display.reportedViewTo) { update.signal(cm, "viewportChange", cm, cm.display.viewFrom, cm.display.viewTo); From 8e6158c94c79797d9aa818d0572f6f2ac8c6113d Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Mon, 21 Mar 2016 11:37:00 +0100 Subject: [PATCH 0336/2444] Mark release 5.13.0 --- AUTHORS | 10 ++++++++++ CHANGELOG.md | 28 ++++++++++++++++++++++++++++ doc/compress.html | 1 + doc/manual.html | 2 +- doc/releases.html | 21 +++++++++++++++++++-- index.html | 2 +- lib/codemirror.js | 2 +- package.json | 2 +- 8 files changed, 62 insertions(+), 6 deletions(-) diff --git a/AUTHORS b/AUTHORS index 741ba1e35e..c3680eb4d8 100644 --- a/AUTHORS +++ b/AUTHORS @@ -75,6 +75,7 @@ benbro Beni Cherniavsky-Paskin Benjamin DeCoste Ben Keen +Ben Mosher Bernhard Sirlinger Bert Chang Billy Moon @@ -137,6 +138,7 @@ David Barnett David Mignot David Pathakjee David Vázquez +David Whittington deebugger Deep Thought Devin Abbott @@ -184,6 +186,7 @@ galambalazs Gautam Mehta Gavin Douglas gekkoe +geowarin Gerard Braad Gergely Hegykozi Giovanni Calò @@ -198,6 +201,7 @@ greengiant Gregory Koberger Guillaume Massé Guillaume Massé +guraga Gustavo Rodrigues Hakan Tunc Hans Engel @@ -274,6 +278,7 @@ ju1ius Juan Benavides Romero Jucovschi Constantin Juho Vuori +Julien Rebetez Justin Andresen Justin Hileman jwallers@gmail.com @@ -281,6 +286,7 @@ kaniga karevn Kayur Patel Ken Newman +ken restivo Ken Rockot Kevin Earls Kevin Sawicki @@ -426,7 +432,9 @@ peter Peter Flynn peterkroon Peter Kroon +Philipp A Philip Stadermann +Pierre Gerold Piët Delport prasanthj Prasanth J @@ -476,6 +484,7 @@ Shiv Deepak Shmuel Englard Shubham Jain silverwind +sinkuu snasa soliton4 sonson @@ -518,6 +527,7 @@ Tom MacWright Tony Jian Travis Heppe Triangle717 +Tristan Tarrant TSUYUSATO Kitsune twifkak Vestimir Markov diff --git a/CHANGELOG.md b/CHANGELOG.md index fe78c71d5e..60ec9df51b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,31 @@ +## 5.13.0 (2016-03-21) + +### New features + +New DOM event forwarded: [`"dragleave"`](http://codemirror.net/doc/manual.html#event_dom). + +[protobuf mode](http://codemirror.net/mode/protobuf/index.html): Newly added. + +### Bugfixes + +Fix problem where [`findMarks`](http://codemirror.net/doc/manual.html#findMarks) sometimes failed to find multi-line marks. + +Fix crash that showed up when atomic ranges and bidi text were combined. + +[show-hint addon](http://codemirror.net/demo/complete.html): Completion widgets no longer close when the line indented or dedented. + +[merge addon](http://codemirror.net/demo/merge.html): Fix bug when merging chunks at the end of the file. + +[placeholder addon](http://codemirror.net/doc/manual.html#addon_placeholder): No longer gets confused by [`swapDoc`](http://codemirror.net/doc/manual.html#swapDoc). + +[simplescrollbars addon](http://codemirror.net/doc/manual.html#addon_simplescrollbars): Fix invalid state when deleting at end of document. + +[clike mode](http://codemirror.net/mode/clike/index.html): No longer gets confused when a comment starts after an operator. + +[markdown mode](http://codemirror.net/mode/markdown/index.html): Now supports CommonMark-style flexible list indentation. + +[dylan mode](http://codemirror.net/mode/dylan/index.html): Several improvements and fixes. + ## 5.12.0 (2016-02-19) ### New features diff --git a/doc/compress.html b/doc/compress.html index 302890c477..a0d4364a3e 100644 --- a/doc/compress.html +++ b/doc/compress.html @@ -36,6 +36,7 @@

    Script compression helper

    Version:

    Version: + + + +

    MIME types defined: text/x-powershell.

    + + diff --git a/mode/powershell/powershell.js b/mode/powershell/powershell.js new file mode 100644 index 0000000000..944088fbbe --- /dev/null +++ b/mode/powershell/powershell.js @@ -0,0 +1,191 @@ +CodeMirror.defineMode("powershell", function() { + var ERRORCLASS = 'error'; + + function wordRegexp(words) { + return new RegExp("^((" + words.join(")|(") + "))\\b"); + } + + var wordOperators = wordRegexp(['-eq', '-ne', '-gt', '-lt', '-le', '-ge']); + var commonkeywords = ['begin', 'break', 'continue', 'do', 'default', 'else', 'elseif', + 'end', 'filter', 'for', 'foreach', 'function', 'if', 'in', 'param', + 'process', 'return', 'switch', 'until', 'where', 'while']; + + var isOperatorChar = /[+\-*&^%:=<>!|\/]/; + var isString = /("|')(\`?.)*?\1/; + + var keywords = wordRegexp(commonkeywords); + //var builtins = wordRegexp(commonBuiltins); + + var indentInfo = null; + + // tokenizers + function tokenBase(stream, state) { + + + + // Handle Comments + //var ch = stream.peek(); + + if (stream.match(keywords)) { + return('variable-2'); + } + + if (stream.match(isString)) { + return('string'); + } + + if (stream.match(wordOperators)) { + return('variable-2'); + } + if (stream.match(isOperatorChar)) { + return('variable-1'); + } + + + // Handle Variables + + + // Handle Number Literals + if (stream.match(/^[0-9\.]/, false)) { + var floatLiteral = false; + // Floats + if (stream.match(/^\d*\.\d+(e[\+\-]?\d+)?/i)) { floatLiteral = true; } + if (stream.match(/^\d+\.\d*/)) { floatLiteral = true; } + if (stream.match(/^\.\d+/)) { floatLiteral = true; } + if (floatLiteral) { + // Float literals may be "imaginary" + stream.eat(/J/i); + return 'number'; + } + // Integers + var intLiteral = false; + // Hex + if (stream.match(/^0x[0-9a-f]+/i)) { intLiteral = true; } + // Binary + if (stream.match(/^0b[01]+/i)) { intLiteral = true; } + // Octal + if (stream.match(/^0o[0-7]+/i)) { intLiteral = true; } + // Decimal + if (stream.match(/^[1-9]\d*(e[\+\-]?\d+)?/)) { + // Decimal literals may be "imaginary" + stream.eat(/J/i); + // TODO - Can you have imaginary longs? + intLiteral = true; + } + // Zero by itself with no other piece of number. + if (stream.match(/^0(?![\dx])/i)) { intLiteral = true; } + if (intLiteral) { + // Integer literals may be "long" + stream.eat(/L/i); + return 'number'; + } + } + + var ch = stream.next(); + + if (ch === '$') { + if (stream.eat('{')) { + state.tokenize = tokenVariable; + return tokenVariable(stream, state); + } else { + stream.eatWhile(/[\w\\\-]/); + return 'variable-2'; + } + } + + if (ch === '<' && stream.eat('#')) { + state.tokenize = tokenComment; + return tokenComment(stream, state); + } + + if (ch === '#') { + stream.skipToEnd(); + return 'comment'; + } + + if (ch === '@' && stream.eat('\"')) { + state.tokenize = tokenMultiString; + return tokenMultiString(stream, state); + } + + //if (isOperatorChar.test(ch)) { + // stream.eat; + //stream.next; + // return("variable-1"); + // } + + stream.next(); + return ERRORCLASS; + } + + + function tokenComment(stream, state) { + var maybeEnd = false, ch; + while ((ch = stream.next()) != null) { + if (maybeEnd && ch == ">") { + state.tokenize = tokenBase; + break; + } + maybeEnd = (ch === '#'); + } + return("comment"); + } + + function tokenVariable(stream, state) { + while ((ch = stream.next()) != null) { + if (ch == "}") { + state.tokenize = tokenBase; + break; + } + } + return("variable-2"); + } + + function tokenMultiString(stream, state) { + var maybeEnd = false, ch; + while ((ch = stream.next()) != null) { + if (maybeEnd && ch == "@") { + state.tokenize = tokenBase; + break; + } + maybeEnd = (ch === '"'); + } + return("string"); + } + + function tokenLexer(stream, state) { + //indentInfo = null; + var style = state.tokenize(stream, state); + //var current = stream.current(); + return style; + } + + var external = { + startState: function(basecolumn) { + return { + tokenize: tokenBase, + scopes: [{offset:basecolumn || 0, type:'py'}], + lastToken: null, + lambda: false, + dedent: 0 + }; + }, + + token: function(stream, state) { + var style = tokenLexer(stream, state); + state.lastToken = {style:style, content: stream.current()}; + if (stream.eol() && stream.lambda) { + state.lambda = false; + } + + return style; + }, + + blockCommentStart: "<#", + blockCommentEnd: "#>", + lineComment: "#" + }; + return external; +}); + +CodeMirror.defineMIME("text/x-powershell", "powershell"); From 20641be6a4973f7914d4a7ef4261f78ebe969411 Mon Sep 17 00:00:00 2001 From: Andrey Shchekin Date: Mon, 30 Jun 2014 00:20:00 +1200 Subject: [PATCH 0350/2444] [powershell mode] Implement actual PowerShell syntax. --- mode/powershell/index.html | 231 +++++++++++------ mode/powershell/powershell.js | 462 ++++++++++++++++++++++------------ 2 files changed, 464 insertions(+), 229 deletions(-) diff --git a/mode/powershell/index.html b/mode/powershell/index.html index 940840c3b6..bc0f9c486c 100644 --- a/mode/powershell/index.html +++ b/mode/powershell/index.html @@ -3,97 +3,179 @@ CodeMirror: Powershell mode - - - - + + + - -

    CodeMirror: Powershell mode

    - -
    +# Built-in functions +A: +Add-Computer Add-Content Add-History Add-Member Add-PSSnapin Add-Type +B: +C: +Checkpoint-Computer Clear-Content Clear-EventLog Clear-History Clear-Host Clear-Item +Clear-ItemProperty Clear-Variable Compare-Object Complete-Transaction Connect-PSSession +ConvertFrom-Csv ConvertFrom-Json ConvertFrom-SecureString ConvertFrom-StringData +Convert-Path ConvertTo-Csv ConvertTo-Html ConvertTo-Json ConvertTo-SecureString +ConvertTo-Xml Copy-Item Copy-ItemProperty +D: +Debug-Process Disable-ComputerRestore Disable-PSBreakpoint Disable-PSRemoting +Disable-PSSessionConfiguration Disconnect-PSSession +E: +Enable-ComputerRestore Enable-PSBreakpoint Enable-PSRemoting Enable-PSSessionConfiguration +Enter-PSSession Exit-PSSession Export-Alias Export-Clixml Export-Console Export-Counter +Export-Csv Export-FormatData Export-ModuleMember Export-PSSession +F: +ForEach-Object Format-Custom Format-List Format-Table Format-Wide +G: +Get-Acl Get-Alias Get-AuthenticodeSignature Get-ChildItem Get-Command Get-ComputerRestorePoint +Get-Content Get-ControlPanelItem Get-Counter Get-Credential Get-Culture Get-Date +Get-Event Get-EventLog Get-EventSubscriber Get-ExecutionPolicy Get-FormatData Get-Help +Get-History Get-Host Get-HotFix Get-Item Get-ItemProperty Get-Job Get-Location Get-Member +Get-Module Get-PfxCertificate Get-Process Get-PSBreakpoint Get-PSCallStack Get-PSDrive +Get-PSProvider Get-PSSession Get-PSSessionConfiguration Get-PSSnapin Get-Random Get-Service +Get-TraceSource Get-Transaction Get-TypeData Get-UICulture Get-Unique Get-Variable Get-Verb +Get-WinEvent Get-WmiObject Group-Object +H: +help +I: +Import-Alias Import-Clixml Import-Counter Import-Csv Import-LocalizedData Import-Module +Import-PSSession ImportSystemModules Invoke-Command Invoke-Expression Invoke-History +Invoke-Item Invoke-RestMethod Invoke-WebRequest Invoke-WmiMethod +J: +Join-Path +K: +L: +Limit-EventLog +M: +Measure-Command Measure-Object mkdir more Move-Item Move-ItemProperty +N: +New-Alias New-Event New-EventLog New-Item New-ItemProperty New-Module New-ModuleManifest +New-Object New-PSDrive New-PSSession New-PSSessionConfigurationFile New-PSSessionOption +New-PSTransportOption New-Service New-TimeSpan New-Variable New-WebServiceProxy +New-WinEvent +O: +oss Out-Default Out-File Out-GridView Out-Host Out-Null Out-Printer Out-String +P: +Pause Pop-Location prompt Push-Location +Q: +R: +Read-Host Receive-Job Receive-PSSession Register-EngineEvent Register-ObjectEvent +Register-PSSessionConfiguration Register-WmiEvent Remove-Computer Remove-Event +Remove-EventLog Remove-Item Remove-ItemProperty Remove-Job Remove-Module +Remove-PSBreakpoint Remove-PSDrive Remove-PSSession Remove-PSSnapin Remove-TypeData +Remove-Variable Remove-WmiObject Rename-Computer Rename-Item Rename-ItemProperty +Reset-ComputerMachinePassword Resolve-Path Restart-Computer Restart-Service +Restore-Computer Resume-Job Resume-Service +S: +Save-Help Select-Object Select-String Select-Xml Send-MailMessage Set-Acl Set-Alias +Set-AuthenticodeSignature Set-Content Set-Date Set-ExecutionPolicy Set-Item +Set-ItemProperty Set-Location Set-PSBreakpoint Set-PSDebug +Set-PSSessionConfiguration Set-Service Set-StrictMode Set-TraceSource Set-Variable +Set-WmiInstance Show-Command Show-ControlPanelItem Show-EventLog Sort-Object +Split-Path Start-Job Start-Process Start-Service Start-Sleep Start-Transaction +Start-Transcript Stop-Computer Stop-Job Stop-Process Stop-Service Stop-Transcript +Suspend-Job Suspend-Service +T: +TabExpansion2 Tee-Object Test-ComputerSecureChannel Test-Connection +Test-ModuleManifest Test-Path Test-PSSessionConfigurationFile Trace-Command +U: +Unblock-File Undo-Transaction Unregister-Event Unregister-PSSessionConfiguration +Update-FormatData Update-Help Update-List Update-TypeData Use-Transaction +V: +W: +Wait-Event Wait-Job Wait-Process Where-Object Write-Debug Write-Error Write-EventLog +Write-Host Write-Output Write-Progress Write-Verbose Write-Warning +X: +Y: +Z: -

    MIME types defined: text/x-powershell.

    diff --git a/mode/powershell/powershell.js b/mode/powershell/powershell.js index 944088fbbe..f63111b2c8 100644 --- a/mode/powershell/powershell.js +++ b/mode/powershell/powershell.js @@ -1,191 +1,345 @@ -CodeMirror.defineMode("powershell", function() { - var ERRORCLASS = 'error'; +// Initially based on CodeMirror Python mode, copyright (c) by Marijn Haverbeke and others +// PowerShell mode, copyright (c) Andrey Shchekin, VapidWorx and others +// Distributed under an MIT license: http://codemirror.net/LICENSE - function wordRegexp(words) { - return new RegExp("^((" + words.join(")|(") + "))\\b"); +(function(mod) { + 'use strict'; + if (typeof exports == 'object' && typeof module == 'object') // CommonJS + mod(require('codemirror')); + else if (typeof define == 'function' && define.amd) // AMD + define(['codemirror'], mod); + else // Plain browser env + mod(window.CodeMirror); +})(function(CodeMirror) { +'use strict'; + +CodeMirror.defineMode('powershell', function() { + function buildRegexp(patterns, options) { + options = options || {}; + var prefix = options.prefix !== undefined ? options.prefix : '^'; + var suffix = options.suffix !== undefined ? options.suffix : '\\b'; + + for (var i = 0; i < patterns.length; i++) { + if (patterns[i] instanceof RegExp) { + patterns[i] = patterns[i].source; + } + else { + patterns[i] = patterns[i].replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'); + } + } + + return new RegExp(prefix + '(' + patterns.join('|') + ')' + suffix, 'i'); } - var wordOperators = wordRegexp(['-eq', '-ne', '-gt', '-lt', '-le', '-ge']); - var commonkeywords = ['begin', 'break', 'continue', 'do', 'default', 'else', 'elseif', - 'end', 'filter', 'for', 'foreach', 'function', 'if', 'in', 'param', - 'process', 'return', 'switch', 'until', 'where', 'while']; + var notCharacterOrDash = '(?=[^A-Z\\d\\-_]|$)'; + var keywords = buildRegexp([ + /begin|break|catch|continue|data|default|do|dynamicparam/, + /else|elseif|end|exit|filter|finally|for|foreach|from|function|if|in/, + /param|process|return|switch|throw|trap|try|until|where|while/ + ], { suffix: notCharacterOrDash }); + + var punctuation = /[\[\]{},;`\.]|@[({]/; + var wordOperators = buildRegexp([ + 'f', + /b?not/, + /[ic]?split/, 'join', + /is(not)?/, 'as', + /[ic]?(eq|ne|[gl][te])/, + /[ic]?(not)?(like|match|contains)/, + /[ic]?replace/, + /b?(and|or|xor)/ + ], { prefix: '-' }); + var symbolOperators = /[+\-*\/%]=|\+\+|--|\.\.|[+\-*&^%:=<>!|\/]/; + var operators = buildRegexp([wordOperators, symbolOperators], { suffix: '' }); + + var numbers = /^[+-]?(0x[\da-f]+|(\d+(\.\d+)?|\.\d*)(e[\+\-]?\d+)?)[ld]?([kmgtp]b)?/i; - var isOperatorChar = /[+\-*&^%:=<>!|\/]/; - var isString = /("|')(\`?.)*?\1/; - - var keywords = wordRegexp(commonkeywords); - //var builtins = wordRegexp(commonBuiltins); + var identifiers = /^[A-Za-z\_][A-Za-z\-\_\d]*\b/; - var indentInfo = null; + var symbolBuiltins = /[A-Z]:|%|\?/i; + var namedBuiltins = buildRegexp([ + /Add-(Computer|Content|History|Member|PSSnapin|Type)/, + /Checkpoint-Computer/, + /Clear-(Content|EventLog|History|Host|Item(Property)?|Variable)/, + /Compare-Object/, + /Complete-Transaction/, + /Connect-PSSession/, + /ConvertFrom-(Csv|Json|SecureString|StringData)/, + /Convert-Path/, + /ConvertTo-(Csv|Html|Json|SecureString|Xml)/, + /Copy-Item(Property)?/, + /Debug-Process/, + /Disable-(ComputerRestore|PSBreakpoint|PSRemoting|PSSessionConfiguration)/, + /Disconnect-PSSession/, + /Enable-(ComputerRestore|PSBreakpoint|PSRemoting|PSSessionConfiguration)/, + /(Enter|Exit)-PSSession/, + /Export-(Alias|Clixml|Console|Counter|Csv|FormatData|ModuleMember|PSSession)/, + /ForEach-Object/, + /Format-(Custom|List|Table|Wide)/, + new RegExp('Get-(Acl|Alias|AuthenticodeSignature|ChildItem|Command|ComputerRestorePoint|Content|ControlPanelItem|Counter|Credential' + + '|Culture|Date|Event|EventLog|EventSubscriber|ExecutionPolicy|FormatData|Help|History|Host|HotFix|Item|ItemProperty|Job' + + '|Location|Member|Module|PfxCertificate|Process|PSBreakpoint|PSCallStack|PSDrive|PSProvider|PSSession|PSSessionConfiguration' + + '|PSSnapin|Random|Service|TraceSource|Transaction|TypeData|UICulture|Unique|Variable|Verb|WinEvent|WmiObject)'), + /Group-Object/, + /Import-(Alias|Clixml|Counter|Csv|LocalizedData|Module|PSSession)/, + /ImportSystemModules/, + /Invoke-(Command|Expression|History|Item|RestMethod|WebRequest|WmiMethod)/, + /Join-Path/, + /Limit-EventLog/, + /Measure-(Command|Object)/, + /Move-Item(Property)?/, + new RegExp('New-(Alias|Event|EventLog|Item(Property)?|Module|ModuleManifest|Object|PSDrive|PSSession|PSSessionConfigurationFile' + + '|PSSessionOption|PSTransportOption|Service|TimeSpan|Variable|WebServiceProxy|WinEvent)'), + /Out-(Default|File|GridView|Host|Null|Printer|String)/, + /Pause/, + /(Pop|Push)-Location/, + /Read-Host/, + /Receive-(Job|PSSession)/, + /Register-(EngineEvent|ObjectEvent|PSSessionConfiguration|WmiEvent)/, + /Remove-(Computer|Event|EventLog|Item(Property)?|Job|Module|PSBreakpoint|PSDrive|PSSession|PSSnapin|TypeData|Variable|WmiObject)/, + /Rename-(Computer|Item(Property)?)/, + /Reset-ComputerMachinePassword/, + /Resolve-Path/, + /Restart-(Computer|Service)/, + /Restore-Computer/, + /Resume-(Job|Service)/, + /Save-Help/, + /Select-(Object|String|Xml)/, + /Send-MailMessage/, + new RegExp('Set-(Acl|Alias|AuthenticodeSignature|Content|Date|ExecutionPolicy|Item(Property)?|Location|PSBreakpoint|PSDebug' + + '|PSSessionConfiguration|Service|StrictMode|TraceSource|Variable|WmiInstance)'), + /Show-(Command|ControlPanelItem|EventLog)/, + /Sort-Object/, + /Split-Path/, + /Start-(Job|Process|Service|Sleep|Transaction|Transcript)/, + /Stop-(Computer|Job|Process|Service|Transcript)/, + /Suspend-(Job|Service)/, + /TabExpansion2/, + /Tee-Object/, + /Test-(ComputerSecureChannel|Connection|ModuleManifest|Path|PSSessionConfigurationFile)/, + /Trace-Command/, + /Unblock-File/, + /Undo-Transaction/, + /Unregister-(Event|PSSessionConfiguration)/, + /Update-(FormatData|Help|List|TypeData)/, + /Use-Transaction/, + /Wait-(Event|Job|Process)/, + /Where-Object/, + /Write-(Debug|Error|EventLog|Host|Output|Progress|Verbose|Warning)/, + /cd|help|mkdir|more|oss|prompt/, + /ac|asnp|cat|cd|chdir|clc|clear|clhy|cli|clp|cls|clv|cnsn|compare|copy|cp|cpi|cpp|cvpa|dbp|del|diff|dir|dnsn|ebp/, + /echo|epal|epcsv|epsn|erase|etsn|exsn|fc|fl|foreach|ft|fw|gal|gbp|gc|gci|gcm|gcs|gdr|ghy|gi|gjb|gl|gm|gmo|gp|gps/, + /group|gsn|gsnp|gsv|gu|gv|gwmi|h|history|icm|iex|ihy|ii|ipal|ipcsv|ipmo|ipsn|irm|ise|iwmi|iwr|kill|lp|ls|man|md/, + /measure|mi|mount|move|mp|mv|nal|ndr|ni|nmo|npssc|nsn|nv|ogv|oh|popd|ps|pushd|pwd|r|rbp|rcjb|rcsn|rd|rdr|ren|ri/, + /rjb|rm|rmdir|rmo|rni|rnp|rp|rsn|rsnp|rujb|rv|rvpa|rwmi|sajb|sal|saps|sasv|sbp|sc|select|set|shcm|si|sl|sleep|sls/, + /sort|sp|spjb|spps|spsv|start|sujb|sv|swmi|tee|trcm|type|where|wjb|write/, + ], { prefix: '', suffix: '' }); + var variableBuiltins = buildRegexp([ + /[$?^_]|Args|ConfirmPreference|ConsoleFileName|DebugPreference|Error|ErrorActionPreference|ErrorView|ExecutionContext/, + /FormatEnumerationLimit|Home|Host|Input|MaximumAliasCount|MaximumDriveCount|MaximumErrorCount|MaximumFunctionCount/, + /MaximumHistoryCount|MaximumVariableCount|MyInvocation|NestedPromptLevel|OutputEncoding|Pid|Profile|ProgressPreference/, + /PSBoundParameters|PSCommandPath|PSCulture|PSDefaultParameterValues|PSEmailServer|PSHome|PSScriptRoot|PSSessionApplicationName/, + /PSSessionConfigurationName|PSSessionOption|PSUICulture|PSVersionTable|Pwd|ShellId|StackTrace|VerbosePreference/, + /WarningPreference|WhatIfPreference/, + + /Event|EventArgs|EventSubscriber|Sender/, + /Matches|Ofs|ForEach|LastExitCode|PSCmdlet|PSItem|PSSenderInfo|This/, + /true|false|null/ + ], { prefix: '\\$', suffix: '' }); + + var builtins = buildRegexp([ symbolBuiltins, namedBuiltins, variableBuiltins ], { suffix: notCharacterOrDash }); + + var grammar = { + keyword: keywords, + number: numbers, + operator: operators, + builtin: builtins, + punctuation: punctuation, + indetifier: identifiers + }; // tokenizers function tokenBase(stream, state) { - - - - // Handle Comments - //var ch = stream.peek(); - - if (stream.match(keywords)) { - return('variable-2'); - } - - if (stream.match(isString)) { - return('string'); - } - - if (stream.match(wordOperators)) { - return('variable-2'); - } - if (stream.match(isOperatorChar)) { - return('variable-1'); - } - - - // Handle Variables - - - // Handle Number Literals - if (stream.match(/^[0-9\.]/, false)) { - var floatLiteral = false; - // Floats - if (stream.match(/^\d*\.\d+(e[\+\-]?\d+)?/i)) { floatLiteral = true; } - if (stream.match(/^\d+\.\d*/)) { floatLiteral = true; } - if (stream.match(/^\.\d+/)) { floatLiteral = true; } - if (floatLiteral) { - // Float literals may be "imaginary" - stream.eat(/J/i); - return 'number'; - } - // Integers - var intLiteral = false; - // Hex - if (stream.match(/^0x[0-9a-f]+/i)) { intLiteral = true; } - // Binary - if (stream.match(/^0b[01]+/i)) { intLiteral = true; } - // Octal - if (stream.match(/^0o[0-7]+/i)) { intLiteral = true; } - // Decimal - if (stream.match(/^[1-9]\d*(e[\+\-]?\d+)?/)) { - // Decimal literals may be "imaginary" - stream.eat(/J/i); - // TODO - Can you have imaginary longs? - intLiteral = true; - } - // Zero by itself with no other piece of number. - if (stream.match(/^0(?![\dx])/i)) { intLiteral = true; } - if (intLiteral) { - // Integer literals may be "long" - stream.eat(/L/i); - return 'number'; + // Handle Comments + //var ch = stream.peek(); + + if (stream.eatSpace()) { + return null; + } + + var parent = state.returnStack[state.returnStack.length - 1]; + if (parent && parent.shouldReturnFrom(state)) { + state.tokenize = parent.tokenize; + state.returnStack.pop(); + return state.tokenize(stream, state); + } + + if (stream.eat('(')) { + state.bracketNesting += 1; + return 'punctuation'; + } + + if (stream.eat(')')) { + state.bracketNesting -= 1; + return 'punctuation'; + } + + for (var key in grammar) { + if (stream.match(grammar[key])) { + return key; } } - var ch = stream.next(); + // single-quote string + if (stream.match(/'([^']|'')+'/)) { + return 'string'; + } + + var ch = stream.next(); + if (ch === '$') { + return tokenVariable(stream, state); + } + + // double-quote string + if (ch === '"') { + return tokenDoubleQuoteString(stream, state); + } - if (ch === '$') { - if (stream.eat('{')) { - state.tokenize = tokenVariable; - return tokenVariable(stream, state); - } else { - stream.eatWhile(/[\w\\\-]/); - return 'variable-2'; - } - } - if (ch === '<' && stream.eat('#')) { - state.tokenize = tokenComment; - return tokenComment(stream, state); - } - - if (ch === '#') { + state.tokenize = tokenComment; + return tokenComment(stream, state); + } + + if (ch === '#') { stream.skipToEnd(); return 'comment'; } - if (ch === '@' && stream.eat('\"')) { - state.tokenize = tokenMultiString; - return tokenMultiString(stream, state); - } - - //if (isOperatorChar.test(ch)) { - // stream.eat; - //stream.next; - // return("variable-1"); - // } + if (ch === '@') { + var quoteMatch = stream.eat(/["']/); + if (quoteMatch && stream.eol()) { + state.tokenize = tokenMultiString; + state.startQuote = quoteMatch[0]; + return tokenMultiString(stream, state); + } + } stream.next(); - return ERRORCLASS; + return 'error'; + } + + function tokenDoubleQuoteString(stream, state) { + var ch; + while((ch = stream.peek()) != null) { + if (ch === '$') { + state.tokenize = tokenInterpolation; + return 'string'; + } + + stream.next(); + if (ch === '`') { + stream.next(); + continue; + } + + if (ch === '"' && !stream.eat('"')) { + state.tokenize = tokenBase; + return 'string'; + } + } + + return 'error'; + } + + function tokenInterpolation(stream, state) { + if (stream.match('$(')) { + var savedBracketNesting = state.bracketNesting; + state.returnStack.push({ + /*jshint loopfunc:true */ + shouldReturnFrom: function(state) { + return state.bracketNesting === savedBracketNesting; + }, + tokenize: tokenDoubleQuoteString + }); + state.tokenize = tokenBase; + state.bracketNesting += 1; + return 'punctuation'; + } else { + stream.next(); + state.returnStack.push({ + shouldReturnFrom: function() { return true; }, + tokenize: tokenDoubleQuoteString + }); + state.tokenize = tokenVariable; + return state.tokenize(stream, state); + } } - - function tokenComment(stream, state) { - var maybeEnd = false, ch; - while ((ch = stream.next()) != null) { - if (maybeEnd && ch == ">") { - state.tokenize = tokenBase; - break; - } - maybeEnd = (ch === '#'); + function tokenComment(stream, state) { + var maybeEnd = false, ch; + while ((ch = stream.next()) != null) { + if (maybeEnd && ch == '>') { + state.tokenize = tokenBase; + break; + } + maybeEnd = (ch === '#'); + } + return 'comment'; } - return("comment"); - } - - function tokenVariable(stream, state) { - while ((ch = stream.next()) != null) { - if (ch == "}") { - state.tokenize = tokenBase; - break; - } + + function tokenVariable(stream, state) { + if (stream.eat('{')) { + state.tokenize = tokenVariableWithBraces; + return tokenVariableWithBraces(stream, state); + } else { + stream.eatWhile(/[\w\\\-:]/); + state.tokenize = tokenBase; + return 'variable-2'; + } } - return("variable-2"); - } - - function tokenMultiString(stream, state) { - var maybeEnd = false, ch; - while ((ch = stream.next()) != null) { - if (maybeEnd && ch == "@") { - state.tokenize = tokenBase; - break; - } - maybeEnd = (ch === '"'); + + function tokenVariableWithBraces(stream, state) { + var ch; + while ((ch = stream.next()) != null) { + if (ch === '}') { + state.tokenize = tokenBase; + break; + } + } + return 'variable-2'; } - return("string"); - } - - function tokenLexer(stream, state) { - //indentInfo = null; - var style = state.tokenize(stream, state); - //var current = stream.current(); - return style; + + function tokenMultiString(stream, state) { + var quote = state.startQuote; + if (stream.sol() && stream.match(new RegExp(quote + '@'))) { + state.tokenize = tokenBase; + } + else { + stream.skipToEnd(); + } + + return 'string'; } var external = { - startState: function(basecolumn) { + startState: function() { return { - tokenize: tokenBase, - scopes: [{offset:basecolumn || 0, type:'py'}], - lastToken: null, - lambda: false, - dedent: 0 - }; + returnStack: [], + bracketNesting: 0, + tokenize: tokenBase + }; }, token: function(stream, state) { - var style = tokenLexer(stream, state); - state.lastToken = {style:style, content: stream.current()}; - if (stream.eol() && stream.lambda) { - state.lambda = false; - } - - return style; + return state.tokenize(stream, state); }, - blockCommentStart: "<#", - blockCommentEnd: "#>", - lineComment: "#" + blockCommentStart: '<#', + blockCommentEnd: '#>', + lineComment: '#' }; return external; }); -CodeMirror.defineMIME("text/x-powershell", "powershell"); +CodeMirror.defineMIME('text/x-powershell', 'powershell'); +}); \ No newline at end of file From d0e82a76f88a1e359447da39df2cb68c31067f6a Mon Sep 17 00:00:00 2001 From: Ben Miller Date: Thu, 24 Sep 2015 15:48:23 +1200 Subject: [PATCH 0351/2444] [powershell mode] Improve corrected angle bracket matching in operators (fixes block comments) corrected digit matching regex corrected spelling of 'identifier' in grammar dictionary notCharacterOrDash explicitly includes lowercase characters improved variable matching splatted variables now match bare '$' and '@' are errors, not variables moved single-quoted string processing into tokenSingleQuoteString incomplete strings are errors now empty strings are no longer errors added support for here-string interpolation with nesting support added highlighting for splatted vars removed arbitrary stream advancement prior to default error in tokenBase enabled folding braces --- mode/powershell/powershell.js | 104 ++++++++++++++++++++++++++-------- 1 file changed, 80 insertions(+), 24 deletions(-) diff --git a/mode/powershell/powershell.js b/mode/powershell/powershell.js index f63111b2c8..8295635a6f 100644 --- a/mode/powershell/powershell.js +++ b/mode/powershell/powershell.js @@ -1,6 +1,9 @@ -// Initially based on CodeMirror Python mode, copyright (c) by Marijn Haverbeke and others -// PowerShell mode, copyright (c) Andrey Shchekin, VapidWorx and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +/** + * @license + * Initially based on CodeMirror Python mode, copyright (c) by Marijn Haverbeke and others + * PowerShell mode, copyright (c) Andrey Shchekin, VapidWorx and others + * Distributed under an MIT license: http://codemirror.net/LICENSE + */ (function(mod) { 'use strict'; @@ -31,7 +34,8 @@ CodeMirror.defineMode('powershell', function() { return new RegExp(prefix + '(' + patterns.join('|') + ')' + suffix, 'i'); } - var notCharacterOrDash = '(?=[^A-Z\\d\\-_]|$)'; + var notCharacterOrDash = '(?=[^A-Za-z\\d\\-_]|$)'; + var varNames = /[\w\-:]/ var keywords = buildRegexp([ /begin|break|catch|continue|data|default|do|dynamicparam/, /else|elseif|end|exit|filter|finally|for|foreach|from|function|if|in/, @@ -49,10 +53,10 @@ CodeMirror.defineMode('powershell', function() { /[ic]?replace/, /b?(and|or|xor)/ ], { prefix: '-' }); - var symbolOperators = /[+\-*\/%]=|\+\+|--|\.\.|[+\-*&^%:=<>!|\/]/; + var symbolOperators = /[+\-*\/%]=|\+\+|--|\.\.|[+\-*&^%:=!|\/]|<(?!#)|(?!#)>/; var operators = buildRegexp([wordOperators, symbolOperators], { suffix: '' }); - var numbers = /^[+-]?(0x[\da-f]+|(\d+(\.\d+)?|\.\d*)(e[\+\-]?\d+)?)[ld]?([kmgtp]b)?/i; + var numbers = /^[+-]?((0x[\da-f]+)|((\d+\.\d+|\d\.|\.\d+|\d+)(e[\+\-]?\d+)?))[ld]?([kmgtp]b)?/i; var identifiers = /^[A-Za-z\_][A-Za-z\-\_\d]*\b/; @@ -106,8 +110,8 @@ CodeMirror.defineMode('powershell', function() { /Save-Help/, /Select-(Object|String|Xml)/, /Send-MailMessage/, - new RegExp('Set-(Acl|Alias|AuthenticodeSignature|Content|Date|ExecutionPolicy|Item(Property)?|Location|PSBreakpoint|PSDebug' - + '|PSSessionConfiguration|Service|StrictMode|TraceSource|Variable|WmiInstance)'), + new RegExp('Set-(Acl|Alias|AuthenticodeSignature|Content|Date|ExecutionPolicy|Item(Property)?|Location|PSBreakpoint|PSDebug' + + '|PSSessionConfiguration|Service|StrictMode|TraceSource|Variable|WmiInstance)'), /Show-(Command|ControlPanelItem|EventLog)/, /Sort-Object/, /Split-Path/, @@ -132,7 +136,7 @@ CodeMirror.defineMode('powershell', function() { /group|gsn|gsnp|gsv|gu|gv|gwmi|h|history|icm|iex|ihy|ii|ipal|ipcsv|ipmo|ipsn|irm|ise|iwmi|iwr|kill|lp|ls|man|md/, /measure|mi|mount|move|mp|mv|nal|ndr|ni|nmo|npssc|nsn|nv|ogv|oh|popd|ps|pushd|pwd|r|rbp|rcjb|rcsn|rd|rdr|ren|ri/, /rjb|rm|rmdir|rmo|rni|rnp|rp|rsn|rsnp|rujb|rv|rvpa|rwmi|sajb|sal|saps|sasv|sbp|sc|select|set|shcm|si|sl|sleep|sls/, - /sort|sp|spjb|spps|spsv|start|sujb|sv|swmi|tee|trcm|type|where|wjb|write/, + /sort|sp|spjb|spps|spsv|start|sujb|sv|swmi|tee|trcm|type|where|wjb|write/ ], { prefix: '', suffix: '' }); var variableBuiltins = buildRegexp([ /[$?^_]|Args|ConfirmPreference|ConsoleFileName|DebugPreference|Error|ErrorActionPreference|ErrorView|ExecutionContext/, @@ -147,7 +151,7 @@ CodeMirror.defineMode('powershell', function() { /true|false|null/ ], { prefix: '\\$', suffix: '' }); - var builtins = buildRegexp([ symbolBuiltins, namedBuiltins, variableBuiltins ], { suffix: notCharacterOrDash }); + var builtins = buildRegexp([symbolBuiltins, namedBuiltins, variableBuiltins], { suffix: notCharacterOrDash }); var grammar = { keyword: keywords, @@ -155,7 +159,7 @@ CodeMirror.defineMode('powershell', function() { operator: operators, builtin: builtins, punctuation: punctuation, - indetifier: identifiers + identifier: identifiers }; // tokenizers @@ -190,12 +194,13 @@ CodeMirror.defineMode('powershell', function() { } } + var ch = stream.next(); + // single-quote string - if (stream.match(/'([^']|'')+'/)) { - return 'string'; + if (ch === "'") { + return tokenSingleQuoteString(stream, state); } - var ch = stream.next(); if (ch === '$') { return tokenVariable(stream, state); } @@ -221,18 +226,35 @@ CodeMirror.defineMode('powershell', function() { state.tokenize = tokenMultiString; state.startQuote = quoteMatch[0]; return tokenMultiString(stream, state); + } else if (stream.peek().match(/[({]/)) { + return 'punctuation'; + } else if (stream.match(varNames)) { + // splatted variable + return tokenVariable(stream, state); + } + } + return 'error'; + } + + function tokenSingleQuoteString(stream, state) { + var ch; + while ((ch = stream.peek()) != null) { + stream.next(); + + if (ch === "'" && !stream.eat("'")) { + state.tokenize = tokenBase; + return 'string'; } } - stream.next(); return 'error'; } function tokenDoubleQuoteString(stream, state) { var ch; - while((ch = stream.peek()) != null) { + while ((ch = stream.peek()) != null) { if (ch === '$') { - state.tokenize = tokenInterpolation; + state.tokenize = tokenStringInterpolation; return 'string'; } @@ -251,7 +273,22 @@ CodeMirror.defineMode('powershell', function() { return 'error'; } - function tokenInterpolation(stream, state) { + function tokenStringInterpolation(stream, state) { + return tokenInterpolation(stream, state, tokenDoubleQuoteString); + } + + function tokenMultiStringReturn(stream, state) { + state.tokenize = tokenMultiString; + state.startQuote = '"' + return tokenMultiString(stream, state); + } + + function tokenHereStringInterpolation(stream, state) { + var saved; + return tokenInterpolation(stream, state, tokenMultiStringReturn); + } + + function tokenInterpolation(stream, state, parentTokenize) { if (stream.match('$(')) { var savedBracketNesting = state.bracketNesting; state.returnStack.push({ @@ -259,7 +296,7 @@ CodeMirror.defineMode('powershell', function() { shouldReturnFrom: function(state) { return state.bracketNesting === savedBracketNesting; }, - tokenize: tokenDoubleQuoteString + tokenize: parentTokenize }); state.tokenize = tokenBase; state.bracketNesting += 1; @@ -268,7 +305,7 @@ CodeMirror.defineMode('powershell', function() { stream.next(); state.returnStack.push({ shouldReturnFrom: function() { return true; }, - tokenize: tokenDoubleQuoteString + tokenize: parentTokenize }); state.tokenize = tokenVariable; return state.tokenize(stream, state); @@ -288,13 +325,17 @@ CodeMirror.defineMode('powershell', function() { } function tokenVariable(stream, state) { + var ch = stream.peek(); if (stream.eat('{')) { state.tokenize = tokenVariableWithBraces; return tokenVariableWithBraces(stream, state); - } else { - stream.eatWhile(/[\w\\\-:]/); + } else if (ch != undefined && ch.match(varNames)) { + stream.eatWhile(varNames); state.tokenize = tokenBase; return 'variable-2'; + } else { + state.tokenize = tokenBase; + return 'error'; } } @@ -314,6 +355,20 @@ CodeMirror.defineMode('powershell', function() { if (stream.sol() && stream.match(new RegExp(quote + '@'))) { state.tokenize = tokenBase; } + else if (quote === '"') { + while (!stream.eol()) { + var ch = stream.peek(); + if (ch === '$') { + state.tokenize = tokenHereStringInterpolation; + return 'string'; + } + + stream.next(); + if (ch === '`') { + stream.next(); + } + } + } else { stream.skipToEnd(); } @@ -336,10 +391,11 @@ CodeMirror.defineMode('powershell', function() { blockCommentStart: '<#', blockCommentEnd: '#>', - lineComment: '#' + lineComment: '#', + fold: 'brace' }; return external; }); CodeMirror.defineMIME('text/x-powershell', 'powershell'); -}); \ No newline at end of file +}); From 95f6840611f8b7025de3783f8408e9f353a830cc Mon Sep 17 00:00:00 2001 From: Andrey Shchekin Date: Sun, 27 Mar 2016 22:11:07 +1300 Subject: [PATCH 0352/2444] [powershell mode] Prepare for merge into CodeMirror repository Added tests and fixed some issues uncovered by testing. --- mode/powershell/index.html | 46 ++- mode/powershell/powershell.js | 697 +++++++++++++++++----------------- mode/powershell/test.js | 72 ++++ test/index.html | 2 + 4 files changed, 451 insertions(+), 366 deletions(-) create mode 100644 mode/powershell/test.js diff --git a/mode/powershell/index.html b/mode/powershell/index.html index bc0f9c486c..6b235df8f1 100644 --- a/mode/powershell/index.html +++ b/mode/powershell/index.html @@ -3,15 +3,30 @@ CodeMirror: Powershell mode - - - + + + + -

    CodeMirror: Powershell mode

    +
    CodeMirror.defineDocExtension(name: string, value: any)
    -
    Like defineExtension, +
    Like defineExtension, but the method will be added to the interface for Doc objects instead.
    diff --git a/index.html b/index.html index 1f775abc69..da5a06c49d 100644 --- a/index.html +++ b/index.html @@ -106,7 +106,7 @@

    This is CodeMirror

    maintainers need to subsist.
    Current funding status =
    You can help per month or - once. + once.
    diff --git a/keymap/vim.js b/keymap/vim.js index b7e8d85889..7f2fb62743 100644 --- a/keymap/vim.js +++ b/keymap/vim.js @@ -26,7 +26,7 @@ * 2. Variable declarations and short basic helpers * 3. Instance (External API) implementation * 4. Internal state tracking objects (input state, counter) implementation - * and instanstiation + * and instantiation * 5. Key handler (the main command dispatcher) implementation * 6. Motion, operator, and action implementations * 7. Helper functions for the key handler, motions, operators, and actions @@ -642,7 +642,7 @@ jumpList: createCircularJumpList(), macroModeState: new MacroModeState, // Recording latest f, t, F or T motion command. - lastChararacterSearch: {increment:0, forward:true, selectedCharacter:''}, + lastCharacterSearch: {increment:0, forward:true, selectedCharacter:''}, registerController: new RegisterController({}), // search history buffer searchHistoryController: new HistoryController({}), @@ -1373,7 +1373,7 @@ } }, evalInput: function(cm, vim) { - // If the motion comand is set, execute both the operator and motion. + // If the motion command is set, execute both the operator and motion. // Otherwise return. var inputState = vim.inputState; var motion = inputState.motion; @@ -1910,7 +1910,7 @@ }, repeatLastCharacterSearch: function(cm, head, motionArgs) { - var lastSearch = vimGlobalState.lastChararacterSearch; + var lastSearch = vimGlobalState.lastCharacterSearch; var repeat = motionArgs.repeat; var forward = motionArgs.forward === lastSearch.forward; var increment = (lastSearch.increment ? 1 : 0) * (forward ? -1 : 1); @@ -3089,9 +3089,9 @@ } function recordLastCharacterSearch(increment, args) { - vimGlobalState.lastChararacterSearch.increment = increment; - vimGlobalState.lastChararacterSearch.forward = args.forward; - vimGlobalState.lastChararacterSearch.selectedCharacter = args.selectedCharacter; + vimGlobalState.lastCharacterSearch.increment = increment; + vimGlobalState.lastCharacterSearch.forward = args.forward; + vimGlobalState.lastCharacterSearch.selectedCharacter = args.selectedCharacter; } var symbolToMode = { @@ -3451,7 +3451,7 @@ } // TODO: perhaps this finagling of start and end positions belonds - // in codmirror/replaceRange? + // in codemirror/replaceRange? function selectCompanionObject(cm, head, symb, inclusive) { var cur = head, start, end; diff --git a/mode/clike/clike.js b/mode/clike/clike.js index 34d3a5afd3..695d5ceff3 100644 --- a/mode/clike/clike.js +++ b/mode/clike/clike.js @@ -667,7 +667,7 @@ CodeMirror.defineMode("clike", function(config, parserConfig) { def("text/x-objectivec", { name: "clike", - keywords: words(cKeywords + "inline restrict _Bool _Complex _Imaginery BOOL Class bycopy byref id IMP in " + + keywords: words(cKeywords + "inline restrict _Bool _Complex _Imaginary BOOL Class bycopy byref id IMP in " + "inout nil oneway out Protocol SEL self super atomic nonatomic retain copy readwrite readonly"), types: words(cTypes), atoms: words("YES NO NULL NILL ON OFF true false"), diff --git a/mode/crystal/crystal.js b/mode/crystal/crystal.js index 2e74bee436..e63627cee8 100644 --- a/mode/crystal/crystal.js +++ b/mode/crystal/crystal.js @@ -209,7 +209,7 @@ // Operators if (stream.match(operators)) { - stream.eat("="); // Operators can follow assigin symbol. + stream.eat("="); // Operators can follow assign symbol. return "operator"; } diff --git a/mode/django/django.js b/mode/django/django.js index a8a7d8311d..7b4ef3b566 100644 --- a/mode/django/django.js +++ b/mode/django/django.js @@ -66,11 +66,11 @@ } // A string can be included in either single or double quotes (this is - // the delimeter). Mark everything as a string until the start delimeter + // the delimiter). Mark everything as a string until the start delimiter // occurs again. - function inString (delimeter, previousTokenizer) { + function inString (delimiter, previousTokenizer) { return function (stream, state) { - if (!state.escapeNext && stream.eat(delimeter)) { + if (!state.escapeNext && stream.eat(delimiter)) { state.tokenize = previousTokenizer; } else { if (state.escapeNext) { @@ -80,7 +80,7 @@ var ch = stream.next(); // Take into account the backslash for escaping characters, such as - // the string delimeter. + // the string delimiter. if (ch == "\\") { state.escapeNext = true; } @@ -100,7 +100,7 @@ return "null"; } - // Dot folowed by a non-word character should be considered an error. + // Dot followed by a non-word character should be considered an error. if (stream.match(/\.\W+/)) { return "error"; } else if (stream.eat(".")) { @@ -119,7 +119,7 @@ return "null"; } - // Pipe folowed by a non-word character should be considered an error. + // Pipe followed by a non-word character should be considered an error. if (stream.match(/\.\W+/)) { return "error"; } else if (stream.eat("|")) { @@ -199,7 +199,7 @@ return "null"; } - // Dot folowed by a non-word character should be considered an error. + // Dot followed by a non-word character should be considered an error. if (stream.match(/\.\W+/)) { return "error"; } else if (stream.eat(".")) { @@ -218,7 +218,7 @@ return "null"; } - // Pipe folowed by a non-word character should be considered an error. + // Pipe followed by a non-word character should be considered an error. if (stream.match(/\.\W+/)) { return "error"; } else if (stream.eat("|")) { diff --git a/mode/gfm/index.html b/mode/gfm/index.html index 7e38c52d60..24c90c068e 100644 --- a/mode/gfm/index.html +++ b/mode/gfm/index.html @@ -47,7 +47,7 @@

    GFM mode

    GFM adds syntax to strikethrough text, which is missing from standard Markdown. ~~Mistaken text.~~ -~~**works with other fomatting**~~ +~~**works with other formatting**~~ ~~spans across lines~~ diff --git a/mode/haml/haml.js b/mode/haml/haml.js index 03ce83355c..86def73ebb 100644 --- a/mode/haml/haml.js +++ b/mode/haml/haml.js @@ -11,7 +11,7 @@ })(function(CodeMirror) { "use strict"; - // full haml mode. This handled embeded ruby and html fragments too + // full haml mode. This handled embedded ruby and html fragments too CodeMirror.defineMode("haml", function(config) { var htmlMode = CodeMirror.getMode(config, {name: "htmlmixed"}); var rubyMode = CodeMirror.getMode(config, "ruby"); diff --git a/mode/htmlembedded/index.html b/mode/htmlembedded/index.html index 365ef8f366..f27582ef86 100644 --- a/mode/htmlembedded/index.html +++ b/mode/htmlembedded/index.html @@ -52,7 +52,7 @@

    Html Embedded Scripts mode

    Mode for html embedded scripts like JSP and ASP.NET. Depends on HtmlMixed which in turn depends on - JavaScript, CSS and XML.
    Other dependancies include those of the scriping language chosen.

    + JavaScript, CSS and XML.
    Other dependencies include those of the scripting language chosen.

    MIME types defined: application/x-aspx (ASP.NET), application/x-ejs (Embedded Javascript), application/x-jsp (JavaServer Pages)

    diff --git a/mode/markdown/test.js b/mode/markdown/test.js index a48d153107..e2b3a81527 100644 --- a/mode/markdown/test.js +++ b/mode/markdown/test.js @@ -647,7 +647,7 @@ MT("linkReferenceEmStrong", "[link [[][link&strong **][link&em&strong *foo**][link&em *][link ]]][string&url [[bar]]] hello"); - // Reference-style links with optional space separator (per docuentation) + // Reference-style links with optional space separator (per documentation) // "You can optionally use a space to separate the sets of brackets" MT("linkReferenceSpace", "[link [[foo]]] [string&url [[bar]]] hello"); @@ -683,7 +683,7 @@ MT("labelTitleSingleQuotes", "[link [[foo]]:] [string&url http://example.com/ 'bar']"); - MT("labelTitleParenthese", + MT("labelTitleParentheses", "[link [[foo]]:] [string&url http://example.com/ (bar)]"); MT("labelTitleInvalid", @@ -700,7 +700,7 @@ "[link [[foo]]:] [string&url http://example.com/]", "[string 'bar'] hello"); - MT("labelTitleNextParenthese", + MT("labelTitleNextParentheses", "[link [[foo]]:] [string&url http://example.com/]", "[string (bar)] hello"); diff --git a/mode/octave/index.html b/mode/octave/index.html index 79df581199..3490ee6371 100644 --- a/mode/octave/index.html +++ b/mode/octave/index.html @@ -65,7 +65,7 @@

    Octave mode

    %one line comment %{ multi -line commment %} +line comment %} + + + + + +
    +

    yacas mode

    + + + + + + +

    MIME types defined: text/x-yacas (yacas).

    +
    diff --git a/mode/yacas/yacas.js b/mode/yacas/yacas.js new file mode 100644 index 0000000000..2967382b43 --- /dev/null +++ b/mode/yacas/yacas.js @@ -0,0 +1,138 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: http://codemirror.net/LICENSE + +// Yacas mode copyright (c) 2015 by Grzegorz Mazur +// Loosely based on mathematica mode by Calin Barbat + +(function(mod) { + if (typeof exports == "object" && typeof module == "object") // CommonJS + mod(require("../../lib/codemirror")); + else if (typeof define == "function" && define.amd) // AMD + define(["../../lib/codemirror"], mod); + else // Plain browser env + mod(CodeMirror); +})(function(CodeMirror) { +"use strict"; + +CodeMirror.defineMode('yacas', function(_config, _parserConfig) { + + // patterns + var pFloatForm = "(?:(?:\\.\\d+|\\d+\\.\\d*|\\d+)(?:[eE][+-]?\\d+)?)"; + var pIdentifier = "(?:[a-zA-Z\\$'][a-zA-Z0-9\\$']*)"; + + // regular expressions + var reFloatForm = new RegExp(pFloatForm); + var reIdentifier = new RegExp(pIdentifier); + var rePattern = new RegExp(pIdentifier + "?_" + pIdentifier); + var reFunctionLike = new RegExp(pIdentifier + "\\s*\\("); + + function tokenBase(stream, state) { + var ch; + + // get next character + ch = stream.next(); + + // string + if (ch === '"') { + state.tokenize = tokenString; + return state.tokenize(stream, state); + } + + // comment + if (ch === '/') { + if (stream.eat('*')) { + state.tokenize = tokenComment; + return state.tokenize(stream, state); + } + if (stream.eat("/")) { + stream.skipToEnd(); + return "comment"; + } + } + + // go back one character + stream.backUp(1); + + // look for ordered rules + if (stream.match(/\d+ *#/, true, false)) { + return 'qualifier'; + } + + // look for numbers + if (stream.match(reFloatForm, true, false)) { + return 'number'; + } + + // look for placeholders + if (stream.match(rePattern, true, false)) { + return 'variable-3'; + } + + // match all braces separately + if (stream.match(/(?:\[|\]|{|}|\(|\))/, true, false)) { + return 'bracket'; + } + + // literals looking like function calls + if (stream.match(reFunctionLike, true, false)) { + stream.backUp(1); + return 'variable'; + } + + // all other identifiers + if (stream.match(reIdentifier, true, false)) { + return 'variable-2'; + } + + // operators; note that operators like @@ or /; are matched separately for each symbol. + if (stream.match(/(?:\\|\+|\-|\*|\/|,|;|\.|:|@|~|=|>|<|&|\||_|`|'|\^|\?|!|%)/, true, false)) { + return 'operator'; + } + + // everything else is an error + return 'error'; + } + + function tokenString(stream, state) { + var next, end = false, escaped = false; + while ((next = stream.next()) != null) { + if (next === '"' && !escaped) { + end = true; + break; + } + escaped = !escaped && next === '\\'; + } + if (end && !escaped) { + state.tokenize = tokenBase; + } + return 'string'; + }; + + function tokenComment(stream, state) { + var prev, next; + while((next = stream.next()) != null) { + if (prev === '*' && next === '/') + break; + prev = next; + } + state.tokenize = tokenBase; + return 'comment'; + } + + return { + startState: function() {return {tokenize: tokenBase, commentLevel: 0};}, + token: function(stream, state) { + if (stream.eatSpace()) return null; + return state.tokenize(stream, state); + }, + blockCommentStart: "/*", + blockCommentEnd: "*/", + lineComment: "//" + }; +}); + +CodeMirror.defineMIME('text/x-yacas', { + name: 'yacas' +}); + +}); From 66fd40ff072151a1a451e2f1b80e34340d293d38 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Wed, 6 Apr 2016 10:25:46 +0200 Subject: [PATCH 0369/2444] [manual] Explain the way fromTextArea can leak memory Issue #3938 --- doc/manual.html | 45 ++++++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/doc/manual.html b/doc/manual.html index 59419027c0..ce03bd30c3 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -1,4 +1,4 @@ - + CodeMirror: User Manual @@ -2064,26 +2064,29 @@

    Static properties

    else (usually one) for dev snapshots.
    CodeMirror.fromTextArea(textArea: TextAreaElement, ?config: object)
    -
    - The method provides another way to initialize an editor. It - takes a textarea DOM node as first argument and an optional - configuration object as second. It will replace the textarea - with a CodeMirror instance, and wire up the form of that - textarea (if any) to make sure the editor contents are put - into the textarea when the form is submitted. The text in the - textarea will provide the content for the editor. A CodeMirror - instance created this way has three additional methods: -
    -
    cm.save()
    -
    Copy the content of the editor into the textarea.
    - -
    cm.toTextArea()
    -
    Remove the editor, and restore the original textarea (with - the editor's current content).
    - -
    cm.getTextArea() → TextAreaElement
    -
    Returns the textarea that the instance was based on.
    -
    +
    This method provides another way to initialize an editor. It + takes a textarea DOM node as first argument and an optional + configuration object as second. It will replace the textarea + with a CodeMirror instance, and wire up the form of that + textarea (if any) to make sure the editor contents are put into + the textarea when the form is submitted. The text in the + textarea will provide the content for the editor. A CodeMirror + instance created this way has three additional methods: +
    +
    cm.save()
    +
    Copy the content of the editor into the textarea.
    + +
    cm.toTextArea()
    +
    Remove the editor, and restore the original textarea (with + the editor's current content). If you dynamically create and + destroy editors made with `fromTextArea`, without destroying + the form they are part of, you should make sure to call + `toTextArea` to remove the editor, or its `"submit"` handler + on the form will cause a memory leak.
    + +
    cm.getTextArea() → TextAreaElement
    +
    Returns the textarea that the instance was based on.
    +
    CodeMirror.defaults: object
    From 225a35fc4a107fc0027c544743fe6c10d86f9f52 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Wed, 6 Apr 2016 21:55:28 +0200 Subject: [PATCH 0370/2444] Bump version number to 5.13.5 5.13.4 was a trivial release restoring a LICENSE file. --- doc/manual.html | 2 +- lib/codemirror.js | 2 +- package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/manual.html b/doc/manual.html index ce03bd30c3..b513bf9408 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -69,7 +69,7 @@

    User manual and reference guide - version 5.13.3 + version 5.13.5

    CodeMirror is a code-editor component that can be embedded in diff --git a/lib/codemirror.js b/lib/codemirror.js index 22186b45ad..19baf0098f 100644 --- a/lib/codemirror.js +++ b/lib/codemirror.js @@ -8890,7 +8890,7 @@ // THE END - CodeMirror.version = "5.13.3"; + CodeMirror.version = "5.13.5"; return CodeMirror; }); diff --git a/package.json b/package.json index 11551de2d6..ca0d787e49 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "codemirror", - "version":"5.13.3", + "version":"5.13.5", "main": "lib/codemirror.js", "description": "In-browser code editing made bearable", "license": "MIT", From d6e8f34ae926f782379e96a1d911e74363a6a416 Mon Sep 17 00:00:00 2001 From: Matt Pass Date: Wed, 6 Apr 2016 23:20:39 +0100 Subject: [PATCH 0371/2444] [icecoder theme] Warmer background and fixed matchingbracket --- theme/icecoder.css | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/theme/icecoder.css b/theme/icecoder.css index d70d26e820..ffebaf2f0b 100644 --- a/theme/icecoder.css +++ b/theme/icecoder.css @@ -2,7 +2,7 @@ ICEcoder default theme by Matt Pass, used in code editor available at https://icecoder.net */ -.cm-s-icecoder { color: #666; background: #141612; } +.cm-s-icecoder { color: #666; background: #1d1d1b; } .cm-s-icecoder span.cm-keyword { color: #eee; font-weight:bold; } /* off-white 1 */ .cm-s-icecoder span.cm-atom { color: #e1c76e; } /* yellow */ @@ -37,7 +37,7 @@ ICEcoder default theme by Matt Pass, used in code editor available at https://ic .cm-s-icecoder .CodeMirror-cursor { border-left: 1px solid white; } .cm-s-icecoder div.CodeMirror-selected { color: #fff; background: #037; } -.cm-s-icecoder .CodeMirror-gutters { background: #141612; min-width: 41px; border-right: 0; } +.cm-s-icecoder .CodeMirror-gutters { background: #1d1d1b; min-width: 41px; border-right: 0; } .cm-s-icecoder .CodeMirror-linenumber { color: #555; cursor: default; } -.cm-s-icecoder .CodeMirror-matchingbracket { border: 1px solid grey; color: black !important; } -.cm-s-icecoder .CodeMirror-activeline-background { background: #000; } \ No newline at end of file +.cm-s-icecoder .CodeMirror-matchingbracket { color: #fff !important; background: #555 !important; } +.cm-s-icecoder .CodeMirror-activeline-background { background: #000; } From adb73ffa1810807bfedf4a218e8cd1462425df14 Mon Sep 17 00:00:00 2001 From: Timothy Gu Date: Sat, 2 Apr 2016 20:25:41 -0700 Subject: [PATCH 0372/2444] [webidl mode] Add --- doc/compress.html | 1 + mode/index.html | 1 + mode/meta.js | 1 + mode/webidl/index.html | 71 +++++++++++++++ mode/webidl/webidl.js | 197 +++++++++++++++++++++++++++++++++++++++++ 5 files changed, 271 insertions(+) create mode 100644 mode/webidl/index.html create mode 100644 mode/webidl/webidl.js diff --git a/doc/compress.html b/doc/compress.html index 538ecbe5f0..44e6fea828 100644 --- a/doc/compress.html +++ b/doc/compress.html @@ -226,6 +226,7 @@

    Script compression helper

    + diff --git a/mode/index.html b/mode/index.html index efb64143a1..822f04fc61 100644 --- a/mode/index.html +++ b/mode/index.html @@ -149,6 +149,7 @@

    Language modes

  • Verilog/SystemVerilog
  • VHDL
  • Vue.js app
  • +
  • Web IDL
  • XML/HTML
  • XQuery
  • Yacas
  • diff --git a/mode/meta.js b/mode/meta.js index 3539beaa17..dcdcdab9c0 100644 --- a/mode/meta.js +++ b/mode/meta.js @@ -145,6 +145,7 @@ {name: "Turtle", mime: "text/turtle", mode: "turtle", ext: ["ttl"]}, {name: "TypeScript", mime: "application/typescript", mode: "javascript", ext: ["ts"], alias: ["ts"]}, {name: "Twig", mime: "text/x-twig", mode: "twig"}, + {name: "Web IDL", mime: "text/x-webidl", mode: "webidl", ext: ["webidl"]}, {name: "VB.NET", mime: "text/x-vb", mode: "vb", ext: ["vb"]}, {name: "VBScript", mime: "text/vbscript", mode: "vbscript", ext: ["vbs"]}, {name: "Velocity", mime: "text/velocity", mode: "velocity", ext: ["vtl"]}, diff --git a/mode/webidl/index.html b/mode/webidl/index.html new file mode 100644 index 0000000000..1d4112e1c3 --- /dev/null +++ b/mode/webidl/index.html @@ -0,0 +1,71 @@ + + +CodeMirror: Web IDL mode + + + + + + + + + + +
    +

    Web IDL mode

    + +
    + +
    + + + +

    MIME type defined: text/x-webidl.

    +
    diff --git a/mode/webidl/webidl.js b/mode/webidl/webidl.js new file mode 100644 index 0000000000..6a60fa23ef --- /dev/null +++ b/mode/webidl/webidl.js @@ -0,0 +1,197 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: http://codemirror.net/LICENSE + +(function(mod) { + if (typeof exports == "object" && typeof module == "object") // CommonJS + mod(require("../../lib/codemirror")); + else if (typeof define == "function" && define.amd) // AMD + define(["../../lib/codemirror"], mod); + else // Plain browser env + mod(CodeMirror); +})(function(CodeMirror) { +"use strict"; + +function wordRegexp(words) { + return new RegExp("^((" + words.join(")|(") + "))\\b"); +}; + +var builtinArray = [ + "Clamp", + "Constructor", + "EnforceRange", + "Exposed", + "ImplicitThis", + "Global", "PrimaryGlobal", + "LegacyArrayClass", + "LegacyUnenumerableNamedProperties", + "LenientThis", + "NamedConstructor", + "NewObject", + "NoInterfaceObject", + "OverrideBuiltins", + "PutForwards", + "Replaceable", + "SameObject", + "TreatNonObjectAsNull", + "TreatNullAs", + "EmptyString", + "Unforgeable", + "Unscopeable" +]; +var builtins = wordRegexp(builtinArray); + +var typeArray = [ + "unsigned", "short", "long", // UnsignedIntegerType + "unrestricted", "float", "double", // UnrestrictedFloatType + "boolean", "byte", "octet", // Rest of PrimitiveType + "Promise", // PromiseType + "ArrayBuffer", "DataView", "Int8Array", "Int16Array", "Int32Array", + "Uint8Array", "Uint16Array", "Uint32Array", "Uint8ClampedArray", + "Float32Array", "Float64Array", // BufferRelatedType + "ByteString", "DOMString", "USVString", "sequence", "object", "RegExp", + "Error", "DOMException", "FrozenArray", // Rest of NonAnyType + "any", // Rest of SingleType + "void" // Rest of ReturnType +]; +var types = wordRegexp(typeArray); + +var keywordArray = [ + "attribute", "callback", "const", "deleter", "dictionary", "enum", "getter", + "implements", "inherit", "interface", "iterable", "legacycaller", "maplike", + "partial", "required", "serializer", "setlike", "setter", "static", + "stringifier", "typedef", // ArgumentNameKeyword except + // "unrestricted" + "optional", "readonly", "or" +]; +var keywords = wordRegexp(keywordArray); + +var atomArray = [ + "true", "false", // BooleanLiteral + "Infinity", "NaN", // FloatLiteral + "null" // Rest of ConstValue +]; +var atoms = wordRegexp(atomArray); + +CodeMirror.registerHelper("hintWords", "webidl", + builtinArray.concat(typeArray).concat(keywordArray).concat(atomArray)); + +var startDefArray = ["callback", "dictionary", "enum", "interface"]; +var startDefs = wordRegexp(startDefArray); + +var endDefArray = ["typedef"]; +var endDefs = wordRegexp(endDefArray); + +var singleOperators = /^[:<=>?]/; +var integers = /^-?([1-9][0-9]*|0[Xx][0-9A-Fa-f]+|0[0-7]*)/; +var floats = /^-?(([0-9]+\.[0-9]*|[0-9]*\.[0-9]+)([Ee][+-]?[0-9]+)?|[0-9]+[Ee][+-]?[0-9]+)/; +var identifiers = /^_?[A-Za-z][0-9A-Z_a-z-]*/; +var strings = /^"[^"]*"/; +var multilineComments = /^\/\*.*?\*\//; +var multilineCommentsStart = /^\/\*.*/; +var multilineCommentsEnd = /^.*?\*\//; + +function readToken(stream, state) { + // whitespace + if (stream.eatSpace()) return null; + + // comment + if (state.inComment) { + if (stream.match(multilineCommentsEnd)) { + state.inComment = false; + return "comment"; + } + stream.skipToEnd(); + return "comment"; + } + if (stream.match("//")) { + stream.skipToEnd(); + return "comment"; + } + if (stream.match(multilineComments)) return "comment"; + if (stream.match(multilineCommentsStart)) { + state.inComment = true; + return "comment"; + } + + // integer and float + if (stream.match(/^-?[0-9\.]/, false)) { + if (stream.match(integers) || stream.match(floats)) return "number"; + } + + // string + if (stream.match(strings)) return "string"; + + // identifier + var pos = stream.pos; + if (stream.match(identifiers)) { + if (state.startDef) return "def"; + if (state.endDef && stream.match(/^\s*;/, false)) { + state.endDef = false; + return "def"; + } + stream.pos = pos; + } + + if (stream.match(keywords)) return "keyword"; + + if (stream.match(types)) { + var lastToken = state.lastToken; + var nextToken = (stream.match(/^\s*(.+?)\b/, false) || [])[1]; + + if (lastToken === ":" || lastToken === "implements" || + nextToken === "implements" || nextToken === "=") { + // Used as identifier + return "builtin"; + } else { + // Used as type + return "variable-3"; + } + } + + if (stream.match(builtins)) return "builtin"; + if (stream.match(atoms)) return "atom"; + if (stream.match(identifiers)) return "variable"; + + // other + if (stream.match(singleOperators)) return "operator"; + + // unrecognized + stream.next(); + return null; +}; + +CodeMirror.defineMode("webidl", function() { + return { + startState: function() { + return { + // Is in multiline comment + inComment: false, + // Last non-whitespace, matched token + lastToken: "", + // Next token is a definition + startDef: false, + // Last token of the statement is a definition + endDef: false + }; + }, + token: function(stream, state) { + var style = readToken(stream, state); + + if (style) { + var cur = stream.current(); + state.lastToken = cur; + if (style === "keyword") { + state.startDef = startDefs.test(cur); + state.endDef = state.endDef || endDefs.test(cur); + } else { + state.startDef = false; + } + } + + return style; + } + }; +}); + +CodeMirror.defineMIME("text/x-webidl", "webidl"); +}); From def70631ca7a50cfb5bf414c27df4db53f899a15 Mon Sep 17 00:00:00 2001 From: Timothy Gu Date: Thu, 7 Apr 2016 06:36:38 -0700 Subject: [PATCH 0373/2444] [webidl mode] Remove unnecessary pos saving --- mode/webidl/webidl.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/mode/webidl/webidl.js b/mode/webidl/webidl.js index 6a60fa23ef..6f024c63f8 100644 --- a/mode/webidl/webidl.js +++ b/mode/webidl/webidl.js @@ -122,14 +122,12 @@ function readToken(stream, state) { if (stream.match(strings)) return "string"; // identifier - var pos = stream.pos; if (stream.match(identifiers)) { if (state.startDef) return "def"; if (state.endDef && stream.match(/^\s*;/, false)) { state.endDef = false; return "def"; } - stream.pos = pos; } if (stream.match(keywords)) return "keyword"; From 300f7f8eb885fa5ff5cdbf0a43126849a7881095 Mon Sep 17 00:00:00 2001 From: Kris Ciccarello Date: Thu, 7 Apr 2016 13:35:42 -0400 Subject: [PATCH 0374/2444] [docs] `doc.getSelections` returns an array of strings. --- doc/manual.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/manual.html b/doc/manual.html index b513bf9408..8b600eac54 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -1254,7 +1254,7 @@

    Cursor and selection methods

    separator to put between the lines in the output. When multiple selections are present, they are concatenated with instances of lineSep in between. -
    doc.getSelections(?lineSep: string) → string
    +
    doc.getSelections(?lineSep: string) → array<string>
    Returns an array containing a string for each selection, representing the content of the selections.
    From bef7e37a093a55ca7f14e1cd823431db07326200 Mon Sep 17 00:00:00 2001 From: Michael Zhou Date: Thu, 7 Apr 2016 17:10:23 -0400 Subject: [PATCH 0375/2444] [mode/meta] Recognize Bazel, Buck and Pants build files as Python in mode/meta.js BUCK, BUILD, *.BUILD and *.bzl files are build files for the three build systems mentioned, and they are all valid Python files. --- mode/meta.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mode/meta.js b/mode/meta.js index dcdcdab9c0..20ebe0ae22 100644 --- a/mode/meta.js +++ b/mode/meta.js @@ -105,7 +105,7 @@ {name: "PowerShell", mime: "application/x-powershell", mode: "powershell", ext: ["ps1", "psd1", "psm1"]}, {name: "Properties files", mime: "text/x-properties", mode: "properties", ext: ["properties", "ini", "in"], alias: ["ini", "properties"]}, {name: "ProtoBuf", mime: "text/x-protobuf", mode: "protobuf", ext: ["proto"]}, - {name: "Python", mime: "text/x-python", mode: "python", ext: ["py", "pyw"]}, + {name: "Python", mime: "text/x-python", mode: "python", ext: ["BUILD", "bzl", "py", "pyw"], file: /^(BUCK|BUILD)$/}, {name: "Puppet", mime: "text/x-puppet", mode: "puppet", ext: ["pp"]}, {name: "Q", mime: "text/x-q", mode: "q", ext: ["q"]}, {name: "R", mime: "text/x-rsrc", mode: "r", ext: ["r"], alias: ["rscript"]}, From 44e4bd42c7ecbd67a48d1c005bdde6140f8475cd Mon Sep 17 00:00:00 2001 From: Gary Sheng Date: Thu, 7 Apr 2016 17:07:17 -0400 Subject: [PATCH 0376/2444] [sql mode] Add __key__ keyword to GQL MIME definition --- mode/sql/sql.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mode/sql/sql.js b/mode/sql/sql.js index c90918b7f2..daec60ce6f 100644 --- a/mode/sql/sql.js +++ b/mode/sql/sql.js @@ -376,7 +376,7 @@ CodeMirror.defineMode("sql", function(config, parserConfig) { name: "sql", keywords: set("ancestor and asc by contains desc descendant distinct from group has in is limit offset on order select superset where"), atoms: set("false true"), - builtin: set("blob datetime first key string integer double boolean null"), + builtin: set("blob datetime first key __key__ string integer double boolean null"), operatorChars: /^[*+\-%<>!=]/ }); }()); From 7fa0cdc493e48571e163317d27b58483f5c8d464 Mon Sep 17 00:00:00 2001 From: Jared Dean Date: Fri, 1 Apr 2016 11:37:36 -0400 Subject: [PATCH 0377/2444] [sas mode] Add --- AUTHORS | 1 + mode/meta.js | 1 + mode/sas/index.html | 87 ++++++++++ mode/sas/sas.js | 381 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 470 insertions(+) create mode 100644 mode/sas/index.html create mode 100755 mode/sas/sas.js diff --git a/AUTHORS b/AUTHORS index 03b1ac5b0a..2c8a9bf3d1 100644 --- a/AUTHORS +++ b/AUTHORS @@ -238,6 +238,7 @@ Jan Keromnes Jan Odvarko Jan Schär Jan T. Sott +Jared Dean Jared Forsyth Jason Jason Barnabe diff --git a/mode/meta.js b/mode/meta.js index 20ebe0ae22..f93078c00b 100644 --- a/mode/meta.js +++ b/mode/meta.js @@ -114,6 +114,7 @@ {name: "RPM Spec", mime: "text/x-rpm-spec", mode: "rpm", ext: ["spec"]}, {name: "Ruby", mime: "text/x-ruby", mode: "ruby", ext: ["rb"], alias: ["jruby", "macruby", "rake", "rb", "rbx"]}, {name: "Rust", mime: "text/x-rustsrc", mode: "rust", ext: ["rs"]}, + {name: "SAS", mime: "text/x-sas", mode: "sas", ext: ["sas"]}, {name: "Sass", mime: "text/x-sass", mode: "sass", ext: ["sass"]}, {name: "Scala", mime: "text/x-scala", mode: "clike", ext: ["scala"]}, {name: "Scheme", mime: "text/x-scheme", mode: "scheme", ext: ["scm", "ss"]}, diff --git a/mode/sas/index.html b/mode/sas/index.html new file mode 100644 index 0000000000..80957403d5 --- /dev/null +++ b/mode/sas/index.html @@ -0,0 +1,87 @@ + + +CodeMirror: SAS mode + + + + + + + + + + + +
    +

    SAS mode

    + + + + + +

    MIME types defined: text/x-sas.

    + + +
    diff --git a/mode/sas/sas.js b/mode/sas/sas.js new file mode 100755 index 0000000000..4043bc7027 --- /dev/null +++ b/mode/sas/sas.js @@ -0,0 +1,381 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: http://codemirror.net/LICENSE + + +// SAS mode copyright (c) 2016 Jared Dean, SAS Institute +// Created by Jared Dean + +// TODO +// indent and de-indent +// identify macro variables + + +//Definitions +// comment -- text withing * ; or /* */ +// keyword -- SAS language variable +// variable -- macro variables starts with '&' or variable formats +// variable-2 -- DATA Step, proc, or macro names +// string -- text within ' ' or " " +// operator -- numeric operator + / - * ** le eq ge ... and so on +// builtin -- proc %macro data run mend +// atom +// def + + +(function (mod) { + if (typeof exports == "object" && typeof module == "object") { // CommonJS + mod(require("../../lib/codemirror")); + } + else if (typeof define == "function" && define.amd) {// AMD + define(["../../lib/codemirror"], mod); + } + else {// Plain browser env + mod(CodeMirror); + } +})(function (CodeMirror) { + "use strict"; + + CodeMirror.defineMode("sas", function () { + var words = {}; + var isDoubleOperatorSym = { + eq: 'operator', + lt: 'operator', + le: 'operator', + gt: 'operator', + ge: 'operator', + in: 'operator', + ne: 'operator', + or: 'operator' + }; + var isDoubleOperatorChar = /(<=|>=|!=|<>)/; + var isSingleOperatorChar = /[=\(:\),{}.*<>+\-\/^\[\]]/; + + // Takes a string of words separated by spaces and adds them as + // keys with the value of the first argument 'style' + var define = function (style, string, context) { + if (context) { + var split = string.split(' '); + for (var i = 0; i < split.length; i++) { + words[split[i]] = {style: style, state: context}; + } + } + }; + //datastep + define('def', 'stack pgm view source debug nesting nolist', ['inDataStep']); + define('def', 'if while until for do do; end end; then else cancel', ['inDataStep']); + define('def', 'label format _n_ _error_', ['inDataStep']); + define('def', 'ALTER BUFNO BUFSIZE CNTLLEV COMPRESS DLDMGACTION ENCRYPT ENCRYPTKEY EXTENDOBSCOUNTER GENMAX GENNUM INDEX LABEL OBSBUF OUTREP PW PWREQ READ REPEMPTY REPLACE REUSE ROLE SORTEDBY SPILL TOBSNO TYPE WRITE FILECLOSE FIRSTOBS IN OBS POINTOBS WHERE WHEREUP IDXNAME IDXWHERE DROP KEEP RENAME', ['inDataStep']); + define('def', 'filevar finfo finv fipname fipnamel fipstate first firstobs floor', ['inDataStep']); + define('def', 'varfmt varinfmt varlabel varlen varname varnum varray varrayx vartype verify vformat vformatd vformatdx vformatn vformatnx vformatw vformatwx vformatx vinarray vinarrayx vinformat vinformatd vinformatdx vinformatn vinformatnx vinformatw vinformatwx vinformatx vlabel vlabelx vlength vlengthx vname vnamex vnferr vtype vtypex weekday', ['inDataStep']); + define('def', 'zipfips zipname zipnamel zipstate', ['inDataStep']); + define('def', 'put putc putn', ['inDataStep']); + define('builtin', 'data run', ['inDataStep']); + + + //proc + define('def', 'data', ['inProc']); + + // flow control for macros + define('def', '%if %end %end; %else %else; %do %do; %then', ['inMacro']); + + //everywhere + define('builtin', 'proc run; quit; libname filename %macro %mend option options', ['ALL']); + + define('def', 'footnote title libname ods', ['ALL']); + define('def', '%let %put %global %sysfunc %eval ', ['ALL']); + // automatic macro variables http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/viewer.htm#a003167023.htm + define('variable', '&sysbuffr &syscc &syscharwidth &syscmd &sysdate &sysdate9 &sysday &sysdevic &sysdmg &sysdsn &sysencoding &sysenv &syserr &syserrortext &sysfilrc &syshostname &sysindex &sysinfo &sysjobid &syslast &syslckrc &syslibrc &syslogapplname &sysmacroname &sysmenv &sysmsg &sysncpu &sysodspath &sysparm &syspbuff &sysprocessid &sysprocessname &sysprocname &sysrc &sysscp &sysscpl &sysscpl &syssite &sysstartid &sysstartname &systcpiphostname &systime &sysuserid &sysver &sysvlong &sysvlong4 &syswarningtext', ['ALL']); + + //footnote[1-9]? title[1-9]? + + //options statement + define('def', 'source2 nosource2 page pageno pagesize', ['ALL']); + + //proc and datastep + define('def', '_all_ _character_ _cmd_ _freq_ _i_ _infile_ _last_ _msg_ _null_ _numeric_ _temporary_ _type_ abort abs addr adjrsq airy alpha alter altlog altprint and arcos array arsin as atan attrc attrib attrn authserver autoexec awscontrol awsdef awsmenu awsmenumerge awstitle backward band base betainv between blocksize blshift bnot bor brshift bufno bufsize bxor by byerr byline byte calculated call cards cards4 catcache cbufno cdf ceil center cexist change chisq cinv class cleanup close cnonct cntllev coalesce codegen col collate collin column comamid comaux1 comaux2 comdef compbl compound compress config continue convert cos cosh cpuid create cross crosstab css curobs cv daccdb daccdbsl daccsl daccsyd dacctab dairy datalines datalines4 datejul datepart datetime day dbcslang dbcstype dclose ddm delete delimiter depdb depdbsl depsl depsyd deptab dequote descending descript design= device dflang dhms dif digamma dim dinfo display distinct dkricond dkrocond dlm dnum do dopen doptname doptnum dread drop dropnote dsname dsnferr echo else emaildlg emailid emailpw emailserver emailsys encrypt end endsas engine eof eov erf erfc error errorcheck errors exist exp fappend fclose fcol fdelete feedback fetch fetchobs fexist fget file fileclose fileexist filefmt filename fileref fmterr fmtsearch fnonct fnote font fontalias fopen foptname foptnum force formatted formchar formdelim formdlim forward fpoint fpos fput fread frewind frlen from fsep fuzz fwrite gaminv gamma getoption getvarc getvarn go goto group gwindow hbar hbound helpenv helploc hms honorappearance hosthelp hostprint hour hpct html hvar ibessel ibr id if index indexc indexw initcmd initstmt inner input inputc inputn inr insert int intck intnx into intrr invaliddata irr is jbessel join juldate keep kentb kurtosis label lag last lbound leave left length levels lgamma lib library libref line linesize link list log log10 log2 logpdf logpmf logsdf lostcard lowcase lrecl ls macro macrogen maps mautosource max maxdec maxr mdy mean measures median memtype merge merror min minute missing missover mlogic mod mode model modify month mopen mort mprint mrecall msglevel msymtabmax mvarsize myy n nest netpv new news nmiss no nobatch nobs nocaps nocardimage nocenter nocharcode nocmdmac nocol nocum nodate nodbcs nodetails nodmr nodms nodmsbatch nodup nodupkey noduplicates noechoauto noequals noerrorabend noexitwindows nofullstimer noicon noimplmac noint nolist noloadlist nomiss nomlogic nomprint nomrecall nomsgcase nomstored nomultenvappl nonotes nonumber noobs noovp nopad nopercent noprint noprintinit normal norow norsasuser nosetinit nosplash nosymbolgen note notes notitle notitles notsorted noverbose noxsync noxwait npv null number numkeys nummousekeys nway obs on open order ordinal otherwise out outer outp= output over ovp p(1 5 10 25 50 75 90 95 99) pad pad2 paired parm parmcards path pathdll pathname pdf peek peekc pfkey pmf point poisson poke position printer probbeta probbnml probchi probf probgam probhypr probit probnegb probnorm probsig probt procleave prt ps pw pwreq qtr quote r ranbin rancau ranexp rangam range ranks rannor ranpoi rantbl rantri ranuni read recfm register regr remote remove rename repeat replace resolve retain return reuse reverse rewind right round rsquare rtf rtrace rtraceloc s s2 samploc sasautos sascontrol sasfrscr sasmsg sasmstore sasscript sasuser saving scan sdf second select selection separated seq serror set setcomm setot sign simple sin sinh siteinfo skewness skip sle sls sortedby sortpgm sortseq sortsize soundex spedis splashlocation split spool sqrt start std stderr stdin stfips stimer stname stnamel stop stopover subgroup subpopn substr sum sumwgt symbol symbolgen symget symput sysget sysin sysleave sysmsg sysparm sysprint sysprintfont sysprod sysrc system t table tables tan tanh tapeclose tbufsize terminal test then timepart tinv tnonct to today tol tooldef totper transformout translate trantab tranwrd trigamma trim trimn trunc truncover type unformatted uniform union until upcase update user usericon uss validate value var weight when where while wincharset window work workinit workterm write wsum xsync xwait yearcutoff yes yyq min max', ['inDataStep', 'inProc']); + define('operator', 'and not ', ['inDataStep', 'inProc']); + + // Main function + function tokenize(stream, state) { + // Finally advance the stream + var ch = stream.next(); + + // BLOCKCOMMENT + if (ch === '/' && stream.eat('*')) { + state.continueComment = true; + return "comment"; + } + // in comment block + else if (state.continueComment === true) { + //comment ends at the beginning of the line + if (ch === '*' && stream.peek() === '/') { + stream.next(); + state.continueComment = false; + } + //comment is potentially later in line + else if (stream.skipTo('*')) { + stream.skipTo('*'); + stream.next(); + if (stream.eat('/')) { + state.continueComment = false; + } + } + else { + stream.skipToEnd(); + } + return "comment"; + } + + // DoubleOperator match + var doubleOperator = ch + stream.peek(); + + // Match all line comments. + var myString = stream.string; + var myRegexp = /(?:^\s*|[;]\s*)(\*.*?);/ig; + var match = myRegexp.exec(myString); + if (match !== null) + { + if (match.index === 0 && (stream.column() !== (match.index + match[0].length - 1))) { + stream.backUp(stream.column()); + stream.skipTo(';'); + stream.next(); + return 'comment'; + } + // the ';' triggers the match so move one past it to start + // the comment block that is why match.index+1 + else if (match.index + 1 < stream.column() && stream.column() < match.index + match[0].length - 1) { + stream.backUp(stream.column() - match.index - 1); + stream.skipTo(';'); + stream.next(); + return 'comment'; + } + } + // Have we found a string? + else + if (!state.continueString && (ch === '"' || ch === "'")) { + state.continueString = ch; //save the matching quote in the state + return "string"; + } + else if (state.continueString !== null) { + if (stream.skipTo(state.continueString)) { + // quote found on this line + stream.next(); + state.continueString = null; + } + else { + stream.skipToEnd(); + } + return "string"; + } + else if (state.continueString !== null && stream.eol()) { + stream.skipTo(state.continueString) || stream.skipToEnd(); + return "string"; + } + //find numbers + else if (/[\d\.]/.test(ch)) { + if (ch === ".") { + stream.match(/^[0-9]+([eE][\-+]?[0-9]+)?/); + } else if (ch === "0") { + stream.match(/^[xX][0-9a-fA-F]+/) || stream.match(/^0[0-7]+/); + } else { + stream.match(/^[0-9]*\.?[0-9]*([eE][\-+]?[0-9]+)?/); + } + return "number"; + } + // TWO SYMBOL TOKENS + else if (isDoubleOperatorChar.test(ch + stream.peek())) { + stream.next(); + state.tokenize = null; + return "operator"; + } + else if (isDoubleOperatorSym.hasOwnProperty(doubleOperator)) { + stream.next(); + if (stream.peek() === ' ') { + return isDoubleOperatorSym[doubleOperator.toLowerCase()]; + } + + } + // SINGLE SYMBOL TOKENS + else if (isSingleOperatorChar.test(ch)) { + state.tokenize = null; + return "operator"; + } + + // Matches one whole word -- even if the word is a character + var word; + if (stream.match(/[%&;\w]+/, false) != null) { + word = ch + stream.match(/[%&;\w]+/, true); + if (/&/.test(word)) { + return 'variable' + } + } + else { + + word = ch; + } + // the word after DATA PROC or MACRO + if (state.nextword) { + stream.match(/[\w]+/); + // match memname.libname + if (stream.peek() === '.') { + stream.skipTo(' '); + } + state.nextword = false; + return 'variable-2'; + + } + + // Are we in a DATA Step? + if (state.inDataStep) { + if (word.toLowerCase() === 'run;' || stream.match(/run\s;/)) { + state.inDataStep = false; + return 'builtin'; + } + // variable formats + if ((word) && stream.next() === '.') { + //either a format or libname.memname + if (/\w/.test(stream.peek())) { + //libname.memname + return 'variable-2'; + } + else { + //format + return 'variable'; + } + } + // do we have a DATA Step keyword + if (word && words.hasOwnProperty(word.toLowerCase()) && (words[word.toLowerCase()].state.indexOf("inDataStep") !== -1 || words[word.toLowerCase()].state.indexOf("ALL") !== -1)) { + //backup to the start of the word + if (stream.start < stream.pos) { + stream.backUp(stream.pos - stream.start); + } + //advance the length of the word and return + for (var i = 0; i < word.length; ++i) { + stream.next(); + } + return words[word.toLowerCase()].style; + } + + + } + // Are we in an Proc statement? + if (state.inProc) { + if (word.toLowerCase() === 'run;' || word.toLowerCase() === 'quit;') { + state.inProc = false; + return 'builtin'; + } + // do we have a proc keyword + if (word && words.hasOwnProperty(word.toLowerCase()) && (words[word.toLowerCase()].state.indexOf("inProc") !== -1 || words[word.toLowerCase()].state.indexOf("ALL") !== -1)) { + stream.match(/[\w]+/); + return words[word].style; + } + + + } + // Are we in a Macro statement? + if (state.inMacro) { + if (word.toLowerCase() === '%mend') { + if (stream.peek() === ';') { + stream.next(); + } + state.inMacro = false; + return 'builtin'; + } + if (word && words.hasOwnProperty(word.toLowerCase()) && (words[word.toLowerCase()].state.indexOf("inMacro") !== -1 || words[word.toLowerCase()].state.indexOf("ALL") !== -1)) { + stream.match(/[\w]+/); + return words[word.toLowerCase()].style; + } + + return 'atom'; + } + // Do we have Keywords specific words? + if (word && words.hasOwnProperty(word.toLowerCase())) { + // Negates the initial next() + stream.backUp(1); + // Actually move the stream + stream.match(/[\w]+/); + if (word.toLowerCase() === 'data' && /=/.test(stream.peek()) === false) { + state.inDataStep = true; + state.nextword = true; + return 'builtin'; + } + if (word.toLowerCase() === 'proc') { + state.inProc = true; + state.nextword = true; + return 'builtin'; + } + if (word.toLowerCase() === '%macro') { + state.inMacro = true; + state.nextword = true; + return 'builtin'; + } + if (/title[1-9]/i.test(word/*+stream.peek()*/)) { + //if (/title[1-9]/.test(word.toLowerCase())) { + //stream.next(); + return 'def'; + } + if (word.toLowerCase() === 'footnote' && /[1-9]/.test(stream.peek())) { + stream.eat(); + return 'def'; + } + else if (word.toLowerCase() === 'footnote') { + return 'def'; + } + + // Returns their value as state in the prior define methods + if (state.inDataStep === true && words[word.toLowerCase()].state.indexOf("inDataStep") !== -1) { + return words[word.toLowerCase()].style; + } + else if (state.inProc === true && words[word.toLowerCase()].state.indexOf("inProc") !== -1) { + return words[word.toLowerCase()].style; + } + else if (state.inMacro === true && words[word.toLowerCase()].state.indexOf("inMacro") !== -1) { + return words[word.toLowerCase()].style; + } + else if (words[word.toLowerCase()].state.indexOf("ALL") !== -1) { + return words[word.toLowerCase()].style; + } + else { + return null; + } + } + // Return a blank line for everything else + return null; + } + + // Start here + return { + startState: function () { + var state = {}; + state.inDataStep = false; + state.inProc = false; + state.inMacro = false; + state.pending = false; + state.lastToken = null; + state.nextword = false; + state.continueString = null; + state.continueComment = false; + state.tokenize = null; + return state; + }, + token: function (stream, state) { + if (state.tokenize != null) { + return state.tokenize(stream, state); + } + // Strip the spaces, but regex will account for them either way + if (stream.eatSpace()) return null; + var style = state.tokenize; + if (style === "comment") return style; + // Go through the main process + return tokenize(stream, state); + }, + + blockCommentStart: "/*", + blockCommentEnd: "*/" + }; + + }); + + CodeMirror.defineMIME("text/x-sas", "sas"); + +}); From 9389a050790e2be94530f34a3513e34602d39483 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Fri, 8 Apr 2016 16:44:18 +0200 Subject: [PATCH 0378/2444] [sas mode] Code style, integrate Issue #3932 --- mode/index.html | 1 + mode/sas/index.html | 34 +-- mode/sas/sas.js | 624 ++++++++++++++++++++------------------------ 3 files changed, 294 insertions(+), 365 deletions(-) diff --git a/mode/index.html b/mode/index.html index 822f04fc61..be583159e1 100644 --- a/mode/index.html +++ b/mode/index.html @@ -114,6 +114,7 @@

    Language modes

  • reStructuredText
  • Ruby
  • Rust
  • +
  • SAS
  • Sass
  • Spreadsheet
  • Scala
  • diff --git a/mode/sas/index.html b/mode/sas/index.html index 80957403d5..636e06594b 100644 --- a/mode/sas/index.html +++ b/mode/sas/index.html @@ -6,15 +6,14 @@ - + .CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;} + .cm-s-default .cm-trailing-space-a:before, + .cm-s-default .cm-trailing-space-b:before {position: absolute; content: "\00B7"; color: #777;} + .cm-s-default .cm-trailing-space-new-line:before {position: absolute; content: "\21B5"; color: #777;} +
    - Get the current version: 5.19.0.
    + Get the current version: 5.20.0.
    You can see the code,
    read the release notes,
    or study the user manual. diff --git a/package.json b/package.json index 057280c569..74040d5658 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "codemirror", - "version": "5.19.1", + "version": "5.20.0", "main": "lib/codemirror.js", "description": "Full-featured in-browser code editor", "license": "MIT", From 81d7f09b6de4044e2945bed39edb48e61d1f5495 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Thu, 20 Oct 2016 11:33:05 +0200 Subject: [PATCH 0642/2444] Bump version number post-5.20 --- doc/manual.html | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/manual.html b/doc/manual.html index 36354b71f3..0cff1be813 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -69,7 +69,7 @@

    User manual and reference guide - version 5.20.0 + version 5.20.1

    CodeMirror is a code-editor component that can be embedded in diff --git a/package.json b/package.json index 74040d5658..7dbf4751e1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "codemirror", - "version": "5.20.0", + "version": "5.20.1", "main": "lib/codemirror.js", "description": "Full-featured in-browser code editor", "license": "MIT", From cea0e041e3fcefdb0869891cb02880bdc07ab966 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Thu, 20 Oct 2016 15:39:49 +0200 Subject: [PATCH 0643/2444] Drop bower.json To further underline our lack of commitment to having the github repository serve as a package distribution mechanism. --- bower.json | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100644 bower.json diff --git a/bower.json b/bower.json deleted file mode 100644 index 903d9f55f8..0000000000 --- a/bower.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "name": "codemirror", - "main": ["lib/codemirror.js", "lib/codemirror.css"], - "ignore": [ - "**/.*", - "node_modules", - "components", - "bin", - "demo", - "doc", - "test", - "index.html", - "package.json", - "mode/*/*test.js", - "mode/*/*.html" - ] -} From 33f2044c8105b37b5f4b4e60893d457f696ba634 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Thu, 20 Oct 2016 21:56:21 +0200 Subject: [PATCH 0644/2444] Fix installation instruction Closes #4333 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 84466293b4..1b3309881c 100644 --- a/README.md +++ b/README.md @@ -30,5 +30,5 @@ conduct. ### Quickstart To build the project, make sure you have Node.js installed (at least version 6) -and then `npm install && npm build`. To run, just open `index.html` in your +and then `npm install && npm run build`. To run, just open `index.html` in your browser (you don't need to run a webserver). Run the tests with `npm test`. From f73ff23d5aa3247e0fc46d3ffde73cf9c900f48d Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Fri, 21 Oct 2016 08:13:42 +0200 Subject: [PATCH 0645/2444] Fix release script to bump version in correct file --- bin/release | 2 +- src/edit/main.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/release b/bin/release index df1fb269c3..b31d511857 100755 --- a/bin/release +++ b/bin/release @@ -16,7 +16,7 @@ function rewrite(file, f) { fs.writeFileSync(file, f(fs.readFileSync(file, "utf8")), "utf8"); } -rewrite("lib/codemirror.js", function(lib) { +rewrite("src/edit/main.js", function(lib) { return lib.replace(/CodeMirror\.version = "\d+\.\d+\.\d+"/, "CodeMirror.version = \"" + number + "\""); }); diff --git a/src/edit/main.js b/src/edit/main.js index 2831d2a03d..16dc032155 100644 --- a/src/edit/main.js +++ b/src/edit/main.js @@ -66,4 +66,4 @@ import { addLegacyProps } from "./legacy" addLegacyProps(CodeMirror) -CodeMirror.version = "5.19.1" +CodeMirror.version = "5.20.1" From d221bf5d15680e06528e1558c014d178c4bc740d Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Fri, 21 Oct 2016 08:17:46 +0200 Subject: [PATCH 0646/2444] Mark release 5.20.2 --- CHANGELOG.md | 6 ++++++ doc/manual.html | 2 +- index.html | 2 +- package.json | 2 +- src/edit/main.js | 2 +- 5 files changed, 10 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b243546569..a7e995ab4b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## 5.20.2 (2016-10-21) + +### Bug fixes + +Fix `CodeMirror.version` returning the wrong version number. + ## 5.20.0 (2016-10-20) ### Bug fixes diff --git a/doc/manual.html b/doc/manual.html index 0cff1be813..2944f0d5e5 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -69,7 +69,7 @@

    User manual and reference guide - version 5.20.1 + version 5.20.2

    CodeMirror is a code-editor component that can be embedded in diff --git a/index.html b/index.html index f4e56a70c8..1d1bb3c8a2 100644 --- a/index.html +++ b/index.html @@ -96,7 +96,7 @@

    This is CodeMirror

    - Get the current version: 5.20.0.
    + Get the current version: 5.20.2.
    You can see the code,
    read the release notes,
    or study the user manual. diff --git a/package.json b/package.json index 7dbf4751e1..8a58fbded2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "codemirror", - "version": "5.20.1", + "version": "5.20.2", "main": "lib/codemirror.js", "description": "Full-featured in-browser code editor", "license": "MIT", diff --git a/src/edit/main.js b/src/edit/main.js index 16dc032155..4335965626 100644 --- a/src/edit/main.js +++ b/src/edit/main.js @@ -66,4 +66,4 @@ import { addLegacyProps } from "./legacy" addLegacyProps(CodeMirror) -CodeMirror.version = "5.20.1" +CodeMirror.version = "5.20.2" From 06431f4d7eb24b0945bc7bb0b775a4f644766c64 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Fri, 21 Oct 2016 08:19:57 +0200 Subject: [PATCH 0647/2444] Bump version number post-5.20.2 --- doc/manual.html | 2 +- package.json | 2 +- src/edit/main.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/manual.html b/doc/manual.html index 2944f0d5e5..6ef27689ce 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -69,7 +69,7 @@

    User manual and reference guide - version 5.20.2 + version 5.20.3

    CodeMirror is a code-editor component that can be embedded in diff --git a/package.json b/package.json index 8a58fbded2..1d07d681b8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "codemirror", - "version": "5.20.2", + "version": "5.20.3", "main": "lib/codemirror.js", "description": "Full-featured in-browser code editor", "license": "MIT", diff --git a/src/edit/main.js b/src/edit/main.js index 4335965626..57fcffa04e 100644 --- a/src/edit/main.js +++ b/src/edit/main.js @@ -66,4 +66,4 @@ import { addLegacyProps } from "./legacy" addLegacyProps(CodeMirror) -CodeMirror.version = "5.20.2" +CodeMirror.version = "5.20.3" From 63bf6594d80b09359025ebc9282e49ed37574cd2 Mon Sep 17 00:00:00 2001 From: Todd Berman Date: Thu, 20 Oct 2016 20:37:42 -0700 Subject: [PATCH 0648/2444] Add classes to each pane for isolated style changes, handle document swapping --- addon/merge/merge.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/addon/merge/merge.js b/addon/merge/merge.js index 2f53406edc..b0f78c87fd 100644 --- a/addon/merge/merge.js +++ b/addon/merge/merge.js @@ -116,8 +116,14 @@ // Update faster when a line was added/removed setDealign(change.text.length - 1 != change.to.line - change.from.line); } + function swapDoc() { + dv.diffOutOfDate = true; + update("full"); + } dv.edit.on("change", change); dv.orig.on("change", change); + dv.edit.on("swapDoc", swapDoc); + dv.orig.on("swapDoc", swapDoc); dv.edit.on("markerAdded", setDealign); dv.edit.on("markerCleared", setDealign); dv.orig.on("markerAdded", setDealign); @@ -464,18 +470,18 @@ if (hasLeft) { left = this.left = new DiffView(this, "left"); - var leftPane = elt("div", null, "CodeMirror-merge-pane"); + var leftPane = elt("div", null, "CodeMirror-merge-pane CodeMirror-merge-left"); wrap.push(leftPane); wrap.push(buildGap(left)); } - var editPane = elt("div", null, "CodeMirror-merge-pane"); + var editPane = elt("div", null, "CodeMirror-merge-pane CodeMirror-merge-editor"); wrap.push(editPane); if (hasRight) { right = this.right = new DiffView(this, "right"); wrap.push(buildGap(right)); - var rightPane = elt("div", null, "CodeMirror-merge-pane"); + var rightPane = elt("div", null, "CodeMirror-merge-pane CodeMirror-merge-right"); wrap.push(rightPane); } From e83ee37e5c54d0b088087bfdb897c7e3d5aacbad Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Sat, 22 Oct 2016 09:03:43 +0200 Subject: [PATCH 0649/2444] [css mode] Drop marker-offset property Closes #4340 --- mode/css/css.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mode/css/css.js b/mode/css/css.js index e56e3dd8c6..b75732034e 100644 --- a/mode/css/css.js +++ b/mode/css/css.js @@ -494,7 +494,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) { "line-stacking-shift", "line-stacking-strategy", "list-style", "list-style-image", "list-style-position", "list-style-type", "margin", "margin-bottom", "margin-left", "margin-right", "margin-top", - "marker-offset", "marks", "marquee-direction", "marquee-loop", + "marks", "marquee-direction", "marquee-loop", "marquee-play-count", "marquee-speed", "marquee-style", "max-height", "max-width", "min-height", "min-width", "move-to", "nav-down", "nav-index", "nav-left", "nav-right", "nav-up", "object-fit", "object-position", From db12d64243ee9d2994e12ffb2935ebac0cbf3c1c Mon Sep 17 00:00:00 2001 From: Todd Berman Date: Sat, 22 Oct 2016 17:59:55 -0700 Subject: [PATCH 0650/2444] [merge addon] Remove the end class when removing chunk styling --- addon/merge/merge.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addon/merge/merge.js b/addon/merge/merge.js index b0f78c87fd..e9700821b1 100644 --- a/addon/merge/merge.js +++ b/addon/merge/merge.js @@ -205,7 +205,7 @@ for (var i = 0; i < locs.length; i++) { editor.removeLineClass(line, locs[i], classes.chunk); editor.removeLineClass(line, locs[i], classes.start); - editor.removeLineClass(line, locs[i], classes.chunk); + editor.removeLineClass(line, locs[i], classes.end); } } From 0164f02bf1ce823e300520ef198d620f30d47220 Mon Sep 17 00:00:00 2001 From: BigBlueHat Date: Wed, 26 Oct 2016 17:01:08 -0400 Subject: [PATCH 0651/2444] [yaml mode] Add text/yaml MIME type --- mode/meta.js | 2 +- mode/yaml/yaml.js | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/mode/meta.js b/mode/meta.js index 47e9a31ce8..cb0684b984 100644 --- a/mode/meta.js +++ b/mode/meta.js @@ -157,7 +157,7 @@ {name: "XML", mimes: ["application/xml", "text/xml"], mode: "xml", ext: ["xml", "xsl", "xsd"], alias: ["rss", "wsdl", "xsd"]}, {name: "XQuery", mime: "application/xquery", mode: "xquery", ext: ["xy", "xquery"]}, {name: "Yacas", mime: "text/x-yacas", mode: "yacas", ext: ["ys"]}, - {name: "YAML", mime: "text/x-yaml", mode: "yaml", ext: ["yaml", "yml"], alias: ["yml"]}, + {name: "YAML", mimes: ["text/x-yaml", "text/yaml"], mode: "yaml", ext: ["yaml", "yml"], alias: ["yml"]}, {name: "Z80", mime: "text/x-z80", mode: "z80", ext: ["z80"]}, {name: "mscgen", mime: "text/x-mscgen", mode: "mscgen", ext: ["mscgen", "mscin", "msc"]}, {name: "xu", mime: "text/x-xu", mode: "mscgen", ext: ["xu"]}, diff --git a/mode/yaml/yaml.js b/mode/yaml/yaml.js index b7015e599c..59c0ecdbec 100644 --- a/mode/yaml/yaml.js +++ b/mode/yaml/yaml.js @@ -113,5 +113,6 @@ CodeMirror.defineMode("yaml", function() { }); CodeMirror.defineMIME("text/x-yaml", "yaml"); +CodeMirror.defineMIME("text/yaml", "yaml"); }); From 2eb94e54b6e9e1df5004fe8089311be8e3b73146 Mon Sep 17 00:00:00 2001 From: BigBlueHat Date: Thu, 27 Oct 2016 10:41:00 -0400 Subject: [PATCH 0652/2444] [vue mode] Fix media type Demo had the correct `text/x-vue` defineMIME was using `script/x-vue` There is, however, no `script/*` top-level media type: http://www.iana.org/assignments/media-types/media-types.xhtml Left, old `script/x-vue` for backwards compatibility. --- mode/meta.js | 1 + mode/vue/vue.js | 1 + 2 files changed, 2 insertions(+) diff --git a/mode/meta.js b/mode/meta.js index cb0684b984..8faf7677df 100644 --- a/mode/meta.js +++ b/mode/meta.js @@ -154,6 +154,7 @@ {name: "Velocity", mime: "text/velocity", mode: "velocity", ext: ["vtl"]}, {name: "Verilog", mime: "text/x-verilog", mode: "verilog", ext: ["v"]}, {name: "VHDL", mime: "text/x-vhdl", mode: "vhdl", ext: ["vhd", "vhdl"]}, + {name: "Vue.js Component", mimes: ["script/x-vue", "text/x-vue"], mode: "vue", ext: ["vue"]}, {name: "XML", mimes: ["application/xml", "text/xml"], mode: "xml", ext: ["xml", "xsl", "xsd"], alias: ["rss", "wsdl", "xsd"]}, {name: "XQuery", mime: "application/xquery", mode: "xquery", ext: ["xy", "xquery"]}, {name: "Yacas", mime: "text/x-yacas", mode: "yacas", ext: ["ys"]}, diff --git a/mode/vue/vue.js b/mode/vue/vue.js index f8089af501..c0eab6b82f 100644 --- a/mode/vue/vue.js +++ b/mode/vue/vue.js @@ -66,4 +66,5 @@ }, "htmlmixed", "xml", "javascript", "coffeescript", "css", "sass", "stylus", "pug", "handlebars"); CodeMirror.defineMIME("script/x-vue", "vue"); + CodeMirror.defineMIME("text/x-vue", "vue"); }); From e2c146e6463f31839b49bfef303e962116970a88 Mon Sep 17 00:00:00 2001 From: Adrien Bertrand Date: Sat, 29 Oct 2016 19:14:54 +0200 Subject: [PATCH 0653/2444] Fix constructor typo for MergeView. --- addon/merge/merge.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addon/merge/merge.js b/addon/merge/merge.js index e9700821b1..72526d0179 100644 --- a/addon/merge/merge.js +++ b/addon/merge/merge.js @@ -545,7 +545,7 @@ } MergeView.prototype = { - constuctor: MergeView, + constructor: MergeView, editor: function() { return this.edit; }, rightOriginal: function() { return this.right && this.right.orig; }, leftOriginal: function() { return this.left && this.left.orig; }, From 7b00c30cdb959cf1980ca5f5cbac3cf331b83b08 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Mon, 31 Oct 2016 09:47:35 +0100 Subject: [PATCH 0654/2444] [ruby mode] Make else and elsif electric Closes #4345 --- mode/ruby/ruby.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mode/ruby/ruby.js b/mode/ruby/ruby.js index 10cad8d9f1..085f909f5f 100644 --- a/mode/ruby/ruby.js +++ b/mode/ruby/ruby.js @@ -275,7 +275,7 @@ CodeMirror.defineMode("ruby", function(config) { (state.continuedLine ? config.indentUnit : 0); }, - electricInput: /^\s*(?:end|rescue|\})$/, + electricInput: /^\s*(?:end|rescue|elsif|else|\})$/, lineComment: "#" }; }); From c4d9363e18925842b7741e11611d870baf4bb14e Mon Sep 17 00:00:00 2001 From: sverweij Date: Fri, 28 Oct 2016 23:03:34 +0200 Subject: [PATCH 0655/2444] [mscgen mode] adds support for language constants MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit and adds the xù specific keyword 'xu' --- mode/mscgen/index.html | 2 +- mode/mscgen/mscgen.js | 8 +++++++- mode/mscgen/mscgen_test.js | 10 +++++++++- mode/mscgen/msgenny_test.js | 7 ++++++- mode/mscgen/xu_test.js | 19 +++++++++++++++---- 5 files changed, 38 insertions(+), 8 deletions(-) diff --git a/mode/mscgen/index.html b/mode/mscgen/index.html index 8c28ee6200..b1d7e7c2e6 100644 --- a/mode/mscgen/index.html +++ b/mode/mscgen/index.html @@ -59,7 +59,7 @@

    Xù mode

    # Xù - expansions to MscGen to support inline expressions # https://github.com/sverweij/mscgen_js/blob/master/wikum/xu.md # More samples: https://sverweij.github.io/mscgen_js -msc { +xu { hscale="0.8", width="700"; diff --git a/mode/mscgen/mscgen.js b/mode/mscgen/mscgen.js index d61b470652..2cd6f42703 100644 --- a/mode/mscgen/mscgen.js +++ b/mode/mscgen/mscgen.js @@ -23,6 +23,7 @@ mscgen: { "keywords" : ["msc"], "options" : ["hscale", "width", "arcgradient", "wordwraparcs"], + "constants" : ["true", "false", "on", "off"], "attributes" : ["label", "idurl", "id", "url", "linecolor", "linecolour", "textcolor", "textcolour", "textbgcolor", "textbgcolour", "arclinecolor", "arclinecolour", "arctextcolor", "arctextcolour", "arctextbgcolor", "arctextbgcolour", "arcskip"], "brackets" : ["\\{", "\\}"], // [ and ] are brackets too, but these get handled in with lists "arcsWords" : ["note", "abox", "rbox", "box"], @@ -31,8 +32,9 @@ "operators" : ["="] }, xu: { - "keywords" : ["msc"], + "keywords" : ["msc", "xu"], "options" : ["hscale", "width", "arcgradient", "wordwraparcs", "watermark"], + "constants" : ["true", "false", "on", "off", "auto"], "attributes" : ["label", "idurl", "id", "url", "linecolor", "linecolour", "textcolor", "textcolour", "textbgcolor", "textbgcolour", "arclinecolor", "arclinecolour", "arctextcolor", "arctextcolour", "arctextbgcolor", "arctextbgcolour", "arcskip"], "brackets" : ["\\{", "\\}"], // [ and ] are brackets too, but these get handled in with lists "arcsWords" : ["note", "abox", "rbox", "box", "alt", "else", "opt", "break", "par", "seq", "strict", "neg", "critical", "ignore", "consider", "assert", "loop", "ref", "exc"], @@ -43,6 +45,7 @@ msgenny: { "keywords" : null, "options" : ["hscale", "width", "arcgradient", "wordwraparcs", "watermark"], + "constants" : ["true", "false", "on", "off", "auto"], "attributes" : null, "brackets" : ["\\{", "\\}"], "arcsWords" : ["note", "abox", "rbox", "box", "alt", "else", "opt", "break", "par", "seq", "strict", "neg", "critical", "ignore", "consider", "assert", "loop", "ref", "exc"], @@ -146,6 +149,9 @@ if (!!pConfig.operators && pStream.match(wordRegexp(pConfig.operators), true, true)) return "operator"; + if (!!pConfig.constants && pStream.match(wordRegexp(pConfig.constants), true, true)) + return "variable"; + /* attribute lists */ if (!pConfig.inAttributeList && !!pConfig.attributes && pStream.match(/\[/, true, true)) { pConfig.inAttributeList = true; diff --git a/mode/mscgen/mscgen_test.js b/mode/mscgen/mscgen_test.js index e319a3997e..956c5758e1 100644 --- a/mode/mscgen/mscgen_test.js +++ b/mode/mscgen/mscgen_test.js @@ -29,6 +29,14 @@ "[base alt loop opt ref else break par seq assert]" ); + MT("xù/ msgenny constants classify as 'base'", + "[base auto]" + ); + + MT("mscgen constants classify as 'variable'", + "[variable true]", "[variable false]", "[variable on]", "[variable off]" + ); + MT("mscgen options classify as keyword", "[keyword hscale]", "[keyword width]", "[keyword arcgradient]", "[keyword wordwraparcs]" ); @@ -63,7 +71,7 @@ MT("a typical program", "[comment # typical mscgen program]", "[keyword msc][base ][bracket {]", - "[keyword wordwraparcs][operator =][string \"true\"][base , ][keyword hscale][operator =][string \"0.8\"][keyword arcgradient][operator =][base 30;]", + "[keyword wordwraparcs][operator =][variable true][base , ][keyword hscale][operator =][string \"0.8\"][base , ][keyword arcgradient][operator =][base 30;]", "[base a][bracket [[][attribute label][operator =][string \"Entity A\"][bracket ]]][base ,]", "[base b][bracket [[][attribute label][operator =][string \"Entity B\"][bracket ]]][base ,]", "[base c][bracket [[][attribute label][operator =][string \"Entity C\"][bracket ]]][base ;]", diff --git a/mode/mscgen/msgenny_test.js b/mode/mscgen/msgenny_test.js index 80173de082..edf9da09af 100644 --- a/mode/mscgen/msgenny_test.js +++ b/mode/mscgen/msgenny_test.js @@ -23,6 +23,11 @@ "[keyword alt]","[keyword loop]","[keyword opt]","[keyword ref]","[keyword else]","[keyword break]","[keyword par]","[keyword seq]","[keyword assert]" ); + MT("xù/ msgenny constants classify as 'variable'", + "[variable auto]", + "[variable true]", "[variable false]", "[variable on]", "[variable off]" + ); + MT("mscgen options classify as keyword", "[keyword hscale]", "[keyword width]", "[keyword arcgradient]", "[keyword wordwraparcs]" ); @@ -56,7 +61,7 @@ MT("a typical program", "[comment # typical msgenny program]", - "[keyword wordwraparcs][operator =][string \"true\"][base , ][keyword hscale][operator =][string \"0.8\"][base , ][keyword arcgradient][operator =][base 30;]", + "[keyword wordwraparcs][operator =][variable true][base , ][keyword hscale][operator =][string \"0.8\"][base , ][keyword arcgradient][operator =][base 30;]", "[base a : ][string \"Entity A\"][base ,]", "[base b : Entity B,]", "[base c : Entity C;]", diff --git a/mode/mscgen/xu_test.js b/mode/mscgen/xu_test.js index f9a50f0af2..950aeca1f9 100644 --- a/mode/mscgen/xu_test.js +++ b/mode/mscgen/xu_test.js @@ -9,7 +9,13 @@ "[keyword msc][bracket {]", "[base ]", "[bracket }]" - ); + ); + + MT("empty chart", + "[keyword xu][bracket {]", + "[base ]", + "[bracket }]" + ); MT("comments", "[comment // a single line comment]", @@ -29,6 +35,11 @@ "[keyword alt]","[keyword loop]","[keyword opt]","[keyword ref]","[keyword else]","[keyword break]","[keyword par]","[keyword seq]","[keyword assert]" ); + MT("xù/ msgenny constants classify as 'variable'", + "[variable auto]", + "[variable true]", "[variable false]", "[variable on]", "[variable off]" + ); + MT("mscgen options classify as keyword", "[keyword hscale]", "[keyword width]", "[keyword arcgradient]", "[keyword wordwraparcs]" ); @@ -61,9 +72,9 @@ ); MT("a typical program", - "[comment # typical mscgen program]", - "[keyword msc][base ][bracket {]", - "[keyword wordwraparcs][operator =][string \"true\"][keyword hscale][operator =][string \"0.8\"][keyword arcgradient][operator =][base 30;]", + "[comment # typical xu program]", + "[keyword xu][base ][bracket {]", + "[keyword wordwraparcs][operator =][string \"true\"][base , ][keyword hscale][operator =][string \"0.8\"][base , ][keyword arcgradient][operator =][base 30, ][keyword width][operator =][variable auto][base ;]", "[base a][bracket [[][attribute label][operator =][string \"Entity A\"][bracket ]]][base ,]", "[base b][bracket [[][attribute label][operator =][string \"Entity B\"][bracket ]]][base ,]", "[base c][bracket [[][attribute label][operator =][string \"Entity C\"][bracket ]]][base ;]", From d34e94781fac24518a31a33b8d0980639ad8547e Mon Sep 17 00:00:00 2001 From: Steve Hoover Date: Mon, 24 Oct 2016 14:57:06 -0400 Subject: [PATCH 0656/2444] [verilog mode] Cleanup/rewrite. --- mode/verilog/verilog.js | 400 ++++++++++++++++++++++++++-------------- 1 file changed, 264 insertions(+), 136 deletions(-) diff --git a/mode/verilog/verilog.js b/mode/verilog/verilog.js index 7513dcede2..1f6ecb9f99 100644 --- a/mode/verilog/verilog.js +++ b/mode/verilog/verilog.js @@ -302,7 +302,13 @@ CodeMirror.defineMode("verilog", function(config, parserConfig) { state.indented = stream.indentation(); state.startOfLine = true; } - if (hooks.token) hooks.token(stream, state); + if (hooks.token) { + // Call hook, with an optional return value of a style to override verilog styling. + var style = hooks.token(stream, state); + if (style !== undefined) { + return style; + } + } if (stream.eatSpace()) return null; curPunc = null; curKeyword = null; @@ -375,163 +381,285 @@ CodeMirror.defineMode("verilog", function(config, parserConfig) { name: "verilog" }); - // TLVVerilog mode - var tlvchScopePrefixes = { - ">": "property", "->": "property", "-": "hr", "|": "link", "?$": "qualifier", "?*": "qualifier", - "@-": "variable-3", "@": "variable-3", "?": "qualifier" + + // TL-Verilog mode. + // See tl-x.org for language spec. + // See the mode in action at makerchip.com. + // Contact: steve.hoover@redwoodeda.com + + // TLV Identifier prefixes. + // Note that sign is not treated separately, so "+/-" versions of numeric identifiers + // are included. + var tlvIdentifierStyle = { + "|": "link", + ">": "property", // Should condition this off for > TLV 1c. + "$": "variable", + "$$": "variable", + "?$": "qualifier", + "?*": "qualifier", + "-": "hr", + "/": "property", + "/-": "property", + "@": "variable-3", + "@-": "variable-3", + "@++": "variable-3", + "@+=": "variable-3", + "@+=-": "variable-3", + "@--": "variable-3", + "@-=": "variable-3", + "%+": "tag", + "%-": "tag", + "%": "tag", + ">>": "tag", + "<<": "tag", + "<>": "tag", + "#": "tag", // Need to choose a style for this. + "^": "attribute", + "^^": "attribute", + "^!": "attribute", + "*": "variable-2", + "**": "variable-2", + "\\": "keyword", + "\"": "comment" }; - function tlvGenIndent(stream, state) { - var tlvindentUnit = 2; - var rtnIndent = -1, indentUnitRq = 0, curIndent = stream.indentation(); - switch (state.tlvCurCtlFlowChar) { - case "\\": - curIndent = 0; - break; - case "|": - if (state.tlvPrevPrevCtlFlowChar == "@") { - indentUnitRq = -2; //-2 new pipe rq after cur pipe - break; - } - if (tlvchScopePrefixes[state.tlvPrevCtlFlowChar]) - indentUnitRq = 1; // +1 new scope - break; - case "M": // m4 - if (state.tlvPrevPrevCtlFlowChar == "@") { - indentUnitRq = -2; //-2 new inst rq after pipe - break; - } - if (tlvchScopePrefixes[state.tlvPrevCtlFlowChar]) - indentUnitRq = 1; // +1 new scope - break; - case "@": - if (state.tlvPrevCtlFlowChar == "S") - indentUnitRq = -1; // new pipe stage after stmts - if (state.tlvPrevCtlFlowChar == "|") - indentUnitRq = 1; // 1st pipe stage - break; - case "S": - if (state.tlvPrevCtlFlowChar == "@") - indentUnitRq = 1; // flow in pipe stage - if (tlvchScopePrefixes[state.tlvPrevCtlFlowChar]) - indentUnitRq = 1; // +1 new scope - break; - } - var statementIndentUnit = tlvindentUnit; - rtnIndent = curIndent + (indentUnitRq*statementIndentUnit); - return rtnIndent >= 0 ? rtnIndent : curIndent; + // Lines starting with these characters define scope (result in indentation). + var tlvScopePrefixChars = { + "/": "beh-hier", + ">": "beh-hier", + "-": "phys-hier", + "|": "pipe", + "?": "when", + "@": "stage", + "\\": "keyword" + }; + var tlvIndentUnit = 3; + var tlvTrackStatements = false; + var tlvIdentMatch = /^([~!@#\$%\^&\*-\+=\?\/\\\|'"<>]+)([\d\w_]*)/; // Matches an identifiere. + // Note that ':' is excluded, because of it's use in [:]. + var tlvFirstLevelIndentMatch = /^[! ] /; + var tlvLineIndentationMatch = /^[! ] */; + var tlvCommentMatch = /^\/[\/\*]/; + + + // Returns a style specific to the scope at the given indentation column. + // Type is one of: "indent", "scope-ident", "before-scope-ident". + function tlvScopeStyle(state, indentation, type) { + // Begin scope. + var depth = indentation / tlvIndentUnit; // TODO: Pass this in instead. + return "tlv-" + state.tlvIndentationStyle[depth] + "-" + type; + } + + // Return true if the next thing in the stream is an identifier with a mnemonic. + function tlvIdentNext(stream) { + var match; + return (match = stream.match(tlvIdentMatch, false)) && match[2].length > 0; } CodeMirror.defineMIME("text/x-tlv", { name: "verilog", + hooks: { - "\\": function(stream, state) { - var vxIndent = 0, style = false; - var curPunc = stream.string; - if ((stream.sol()) && ((/\\SV/.test(stream.string)) || (/\\TLV/.test(stream.string)))) { - curPunc = (/\\TLV_version/.test(stream.string)) - ? "\\TLV_version" : stream.string; - stream.skipToEnd(); - if (curPunc == "\\SV" && state.vxCodeActive) {state.vxCodeActive = false;}; - if ((/\\TLV/.test(curPunc) && !state.vxCodeActive) - || (curPunc=="\\TLV_version" && state.vxCodeActive)) {state.vxCodeActive = true;}; - style = "keyword"; - state.tlvCurCtlFlowChar = state.tlvPrevPrevCtlFlowChar - = state.tlvPrevCtlFlowChar = ""; - if (state.vxCodeActive == true) { - state.tlvCurCtlFlowChar = "\\"; - vxIndent = tlvGenIndent(stream, state); + + electricInput: false, + + + // Return undefined for verilog tokenizing, or style for TLV token (null not used). + // Standard CM styles are used for most formatting, but some TL-Verilog-specific highlighting + // can be enabled with the definition of cm-tlv-* styles, including highlighting for: + // - M4 tokens + // - TLV scope indentation + // - Statement delimitation (enabled by tlvTrackStatements) + token: function(stream, state) { + var style = undefined; + var match; // Return value of pattern matches. + + // Set highlighting mode based on code region (TLV or SV). + if (stream.sol() && ! state.tlvInBlockComment) { + // Process region. + if (stream.peek() == '\\') { + style = "def"; + stream.skipToEnd(); + if (stream.string.match(/\\SV/)) { + state.tlvCodeActive = false; + } else if (stream.string.match(/\\TLV/)){ + state.tlvCodeActive = true; + } + } + // Correct indentation in the face of a line prefix char. + if (state.tlvCodeActive && stream.pos == 0 && + (state.indented == 0) && (match = stream.match(tlvLineIndentationMatch, false))) { + state.indented = match[0].length; + } + + // Compute indentation state: + // o Required indentation on next line + // o Indentation scope styles + var indented = state.indented; + var depth = indented / tlvIndentUnit; + if (depth <= state.tlvIndentationStyle.length) { + // not deeper than current scope + + var blankline = stream.string.length == indented; + var chPos = depth * tlvIndentUnit; + if (chPos < stream.string.length) { + var bodyString = stream.string.slice(chPos); + var ch = bodyString[0]; + if (tlvScopePrefixChars[ch] && ((match = bodyString.match(tlvIdentMatch)) && + tlvIdentifierStyle[match[1]])) { + // this line begins scope (except non-region keyword identifiers, which are statements themselves) + if (!(ch == "\\" && chPos > 0)) { + indented += tlvIndentUnit; + state.tlvIndentationStyle[depth] = tlvScopePrefixChars[ch]; + if (tlvTrackStatements) {state.statementComment = false;} + depth++; + } + } + } + // Clear out deeper indentation levels unless line is blank. + if (!blankline) { + while (state.tlvIndentationStyle.length > depth) { + state.tlvIndentationStyle.pop(); + } + } } - state.vxIndentRq = vxIndent; } - return style; - }, - tokenBase: function(stream, state) { - var vxIndent = 0, style = false; - var tlvisOperatorChar = /[\[\]=:]/; - var tlvkpScopePrefixs = { - "**":"variable-2", "*":"variable-2", "$$":"variable", "$":"variable", - "^^":"attribute", "^":"attribute"}; - var ch = stream.peek(); - var vxCurCtlFlowCharValueAtStart = state.tlvCurCtlFlowChar; - if (state.vxCodeActive == true) { - if (/[\[\]{}\(\);\:]/.test(ch)) { - // bypass nesting and 1 char punc - style = "meta"; - stream.next(); - } else if (ch == "/") { - stream.next(); - if (stream.eat("/")) { + + if (state.tlvCodeActive) { + // Highlight as TLV. + + var beginStatement = false; + if (tlvTrackStatements) { + // This starts a statement if the position is at the scope level + // and we're not within a statement leading comment. + beginStatement = + (stream.peek() != " ") && // not a space + (style === undefined) && // not a region identifier + !state.tlvInBlockComment && // not in block comment + //!stream.match(tlvCommentMatch, false) && // not comment start + (stream.column() == state.tlvIndentationStyle.length * tlvIndentUnit); // at scope level + if (beginStatement) { + if (state.statementComment) { + // statement already started by comment + beginStatement = false; + } + state.statementComment = + stream.match(tlvCommentMatch, false); // comment start + } + } + + var match; + if (style !== undefined) { + // Region line. + style += " " + tlvScopeStyle(state, 0, "scope-ident") + } else if (((stream.pos / tlvIndentUnit) < state.tlvIndentationStyle.length) && + (match = stream.match(stream.sol() ? tlvFirstLevelIndentMatch : /^ /))) { + // Indentation + style = // make this style distinct from the previous one to prevent + // codemirror from combining spans + "tlv-indent-" + (((stream.pos % 2) == 0) ? "even" : "odd") + + // and style it + " " + tlvScopeStyle(state, stream.pos - tlvIndentUnit, "indent"); + // Style the line prefix character. + if (match[0].charAt(0) == "!") { + style += " tlv-alert-line-prefix"; + } + // Place a class before a scope identifier. + if (tlvIdentNext(stream)) { + style += " " + tlvScopeStyle(state, stream.pos, "before-scope-ident"); + } + } else if (state.tlvInBlockComment) { + // In a block comment. + if (stream.match(/^.*?\*\//)) { + // Exit block comment. + state.tlvInBlockComment = false; + if (tlvTrackStatements && !stream.eol()) { + // Anything after comment is assumed to be real statement content. + state.statementComment = false; + } + } else { + stream.skipToEnd(); + } + style = "comment"; + } else if ((match = stream.match(tlvCommentMatch)) && !state.tlvInBlockComment) { + // Start comment. + if (match[0] == "//") { + // Line comment. stream.skipToEnd(); - style = "comment"; - state.tlvCurCtlFlowChar = "S"; } else { - stream.backUp(1); + // Block comment. + state.tlvInBlockComment = true; } - } else if (ch == "@") { - // pipeline stage - style = tlvchScopePrefixes[ch]; - state.tlvCurCtlFlowChar = "@"; - stream.next(); - stream.eatWhile(/[\w\$_]/); - } else if (stream.match(/\b[mM]4+/, true)) { // match: function(pattern, consume, caseInsensitive) - // m4 pre proc - stream.skipTo("("); - style = "def"; - state.tlvCurCtlFlowChar = "M"; - } else if (ch == "!" && stream.sol()) { - // v stmt in tlv region - // state.tlvCurCtlFlowChar = "S"; style = "comment"; + } else if (match = stream.match(tlvIdentMatch)) { + // looks like an identifier (or identifier prefix) + var prefix = match[1]; + var mnemonic = match[2]; + if (// is identifier prefix + (prefix in tlvIdentifierStyle) && + // has mnemonic or we're at the end of the line (maybe it hasn't been typed yet) + (mnemonic.length > 0 || stream.eol())) { + style = tlvIdentifierStyle[prefix]; + if (stream.column() == state.indented) { + // Begin scope. + style += " " + tlvScopeStyle(state, stream.column(), "scope-ident") + } + } else { + // Just swallow one character and try again. + // This enables subsequent identifier match with preceding symbol character, which + // is legal within a statement. (Eg, !$reset). It also enables detection of + // comment start with preceding symbols. + stream.backUp(stream.current().length - 1); + style = "tlv-default"; + } + } else if (stream.match(/^\t+/)) { + // Highlight tabs, which are illegal. + style = "tlv-tab"; + } else if (stream.match(/^[\[\]{}\(\);\:]+/)) { + // [:], (), {}, ;. + style = "meta"; + } else if (match = stream.match(/^[mM]4([\+_])?[\w\d_]*/)) { + // m4 pre proc + style = (match[1] == "+") ? "tlv-m4-plus" : "tlv-m4"; + } else if (stream.match(/^ +/)){ + // Skip over spaces. + if (stream.eol()) { + // Trailing spaces. + style = "error"; + } else { + // Non-trailing spaces. + style = "tlv-default"; + } + } else if (stream.match(/^[\w\d_]+/)) { + // alpha-numeric token. + style = "number"; + } else { + // Eat the next char w/ no formatting. stream.next(); - } else if (tlvisOperatorChar.test(ch)) { - // operators - stream.eatWhile(tlvisOperatorChar); - style = "operator"; - } else if (ch == "#") { - // phy hier - state.tlvCurCtlFlowChar = (state.tlvCurCtlFlowChar == "") - ? ch : state.tlvCurCtlFlowChar; - stream.next(); - stream.eatWhile(/[+-]\d/); - style = "tag"; - } else if (tlvkpScopePrefixs.propertyIsEnumerable(ch)) { - // special TLV operators - style = tlvkpScopePrefixs[ch]; - state.tlvCurCtlFlowChar = state.tlvCurCtlFlowChar == "" ? "S" : state.tlvCurCtlFlowChar; // stmt - stream.next(); - stream.match(/[a-zA-Z_0-9]+/); - } else if (style = tlvchScopePrefixes[ch] || false) { - // special TLV operators - state.tlvCurCtlFlowChar = state.tlvCurCtlFlowChar == "" ? ch : state.tlvCurCtlFlowChar; - stream.next(); - stream.match(/[a-zA-Z_0-9]+/); + style = "tlv-default"; + } + if (beginStatement) { + style += " tlv-statement"; } - if (state.tlvCurCtlFlowChar != vxCurCtlFlowCharValueAtStart) { // flow change - vxIndent = tlvGenIndent(stream, state); - state.vxIndentRq = vxIndent; + } else { + if (stream.match(/^[mM]4([\w\d_]*)/)) { + // m4 pre proc + style = "tlv-m4"; } } return style; }, - token: function(stream, state) { - if (state.vxCodeActive == true && stream.sol() && state.tlvCurCtlFlowChar != "") { - state.tlvPrevPrevCtlFlowChar = state.tlvPrevCtlFlowChar; - state.tlvPrevCtlFlowChar = state.tlvCurCtlFlowChar; - state.tlvCurCtlFlowChar = ""; - } - }, - indent: function(state) { - return (state.vxCodeActive == true) ? state.vxIndentRq : -1; - }, + startState: function(state) { - state.tlvCurCtlFlowChar = ""; - state.tlvPrevCtlFlowChar = ""; - state.tlvPrevPrevCtlFlowChar = ""; - state.vxCodeActive = true; - state.vxIndentRq = 0; + state.tlvIndentationStyle = []; // Styles to use for each level of indentation. + state.tlvCodeActive = true; // True when we're in a TLV region (and at beginning of file). + state.tlvInBlockComment = false; // True inside /**/ comment. + if (tlvTrackStatements) { + state.statementComment = false; // True inside a statement's header comment. + } } + } }); }); From 5105da7fcd5a98dbaf276b769ce8581daac84121 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Tue, 1 Nov 2016 11:04:58 +0100 Subject: [PATCH 0657/2444] [merge addon] Fix bug in chunk-aligning algorithm Closes #4353 --- addon/merge/merge.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addon/merge/merge.js b/addon/merge/merge.js index 72526d0179..e7772ace66 100644 --- a/addon/merge/merge.js +++ b/addon/merge/merge.js @@ -343,11 +343,12 @@ j = -1; break; } else if (align[1] > chunk.editTo) { + j-- break; } } if (j > -1) - linesToAlign.splice(j - 1, 0, [getMatchingOrigLine(chunk.editTo, dv.chunks), chunk.editTo, chunk.origTo]); + linesToAlign.splice(j, 0, [getMatchingOrigLine(chunk.editTo, dv.chunks), chunk.editTo, chunk.origTo]); } } return linesToAlign; From 6d3a7457d1d9b6c4165a5b066be6e1da99776e2b Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Tue, 1 Nov 2016 11:07:10 +0100 Subject: [PATCH 0658/2444] [merge addon] Fix corner case in alignable-chunk sorting Issue #4353 --- addon/merge/merge.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addon/merge/merge.js b/addon/merge/merge.js index e7772ace66..1d7a5cccb0 100644 --- a/addon/merge/merge.js +++ b/addon/merge/merge.js @@ -340,14 +340,14 @@ for (var j = 0; j < linesToAlign.length; j++) { var align = linesToAlign[j]; if (align[1] == chunk.editTo) { - j = -1; + j = -2; break; } else if (align[1] > chunk.editTo) { j-- break; } } - if (j > -1) + if (j > -2) linesToAlign.splice(j, 0, [getMatchingOrigLine(chunk.editTo, dv.chunks), chunk.editTo, chunk.origTo]); } } From ea796dad693cc1f7c7d7f4628a1ee4953ae6b3db Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Wed, 2 Nov 2016 10:07:05 +0100 Subject: [PATCH 0659/2444] [merge addon] Fix sorted insertion in aligned line set (again) Issue #4353 --- addon/merge/merge.js | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/addon/merge/merge.js b/addon/merge/merge.js index 1d7a5cccb0..9bd086580b 100644 --- a/addon/merge/merge.js +++ b/addon/merge/merge.js @@ -335,20 +335,14 @@ linesToAlign.push([chunk.origTo, chunk.editTo, other ? getMatchingOrigLine(chunk.editTo, other.chunks) : null]); } if (other) { - for (var i = 0; i < other.chunks.length; i++) { + chunkLoop: for (var i = 0; i < other.chunks.length; i++) { var chunk = other.chunks[i]; for (var j = 0; j < linesToAlign.length; j++) { - var align = linesToAlign[j]; - if (align[1] == chunk.editTo) { - j = -2; - break; - } else if (align[1] > chunk.editTo) { - j-- - break; - } + var diff = linesToAlign[j][1] - chunk.editTo; + if (diff == 0) continue chunkLoop + if (diff > 0) break; } - if (j > -2) - linesToAlign.splice(j, 0, [getMatchingOrigLine(chunk.editTo, dv.chunks), chunk.editTo, chunk.origTo]); + linesToAlign.splice(j, 0, [getMatchingOrigLine(chunk.editTo, dv.chunks), chunk.editTo, chunk.origTo]); } } return linesToAlign; From 2466392a929761bd61e85cbea86cd533ac84eef4 Mon Sep 17 00:00:00 2001 From: Erik Welander Date: Tue, 1 Nov 2016 22:30:50 -0700 Subject: [PATCH 0660/2444] [rulers addon] Draw rulers all the way when scrollPastEnd is on. --- addon/display/rulers.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addon/display/rulers.js b/addon/display/rulers.js index 730054473a..151cc8205f 100644 --- a/addon/display/rulers.js +++ b/addon/display/rulers.js @@ -13,12 +13,12 @@ CodeMirror.defineOption("rulers", false, function(cm, val) { if (cm.state.rulerDiv) { - cm.display.lineSpace.removeChild(cm.state.rulerDiv) + cm.state.rulerDiv.parentElement.removeChild(cm.state.rulerDiv) cm.state.rulerDiv = null cm.off("refresh", drawRulers) } if (val && val.length) { - cm.state.rulerDiv = cm.display.lineSpace.insertBefore(document.createElement("div"), cm.display.cursorDiv) + cm.state.rulerDiv = cm.display.lineSpace.parentElement.insertBefore(document.createElement("div"), cm.display.lineSpace) cm.state.rulerDiv.className = "CodeMirror-rulers" drawRulers(cm) cm.on("refresh", drawRulers) From f5e211fa49315e0c0da212dffc275d769609d1ab Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Wed, 2 Nov 2016 11:08:17 +0100 Subject: [PATCH 0661/2444] Add an includeWidgets argument to heightAtLine And use it in the merge addon to get the proper offsets for merge buttons Issue #4364 --- addon/merge/merge.js | 8 ++++---- doc/manual.html | 7 +++++-- src/edit/methods.js | 4 ++-- src/measurement/position_measurement.js | 4 ++-- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/addon/merge/merge.js b/addon/merge/merge.js index 9bd086580b..0c54a66464 100644 --- a/addon/merge/merge.js +++ b/addon/merge/merge.js @@ -408,13 +408,13 @@ function drawConnectorsForChunk(dv, chunk, sTopOrig, sTopEdit, w) { var flip = dv.type == "left"; - var top = dv.orig.heightAtLine(chunk.origFrom, "local") - sTopOrig; + var top = dv.orig.heightAtLine(chunk.origFrom, "local", true) - sTopOrig; if (dv.svg) { var topLpx = top; - var topRpx = dv.edit.heightAtLine(chunk.editFrom, "local") - sTopEdit; + var topRpx = dv.edit.heightAtLine(chunk.editFrom, "local", true) - sTopEdit; if (flip) { var tmp = topLpx; topLpx = topRpx; topRpx = tmp; } - var botLpx = dv.orig.heightAtLine(chunk.origTo, "local") - sTopOrig; - var botRpx = dv.edit.heightAtLine(chunk.editTo, "local") - sTopEdit; + var botLpx = dv.orig.heightAtLine(chunk.origTo, "local", true) - sTopOrig; + var botRpx = dv.edit.heightAtLine(chunk.editTo, "local", true) - sTopEdit; if (flip) { var tmp = botLpx; botLpx = botRpx; botRpx = tmp; } var curveTop = " C " + w/2 + " " + topRpx + " " + w/2 + " " + topLpx + " " + (w + 2) + " " + topLpx; var curveBot = " C " + w/2 + " " + botLpx + " " + w/2 + " " + botRpx + " -1 " + botRpx; diff --git a/doc/manual.html b/doc/manual.html index 6ef27689ce..e74ec36200 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -1863,13 +1863,16 @@

    Sizing, scrolling and positioning methods

    height. mode can be one of the same strings that coordsChar accepts. -
    cm.heightAtLine(line: integer|LineHandle, ?mode: string) → number
    +
    cm.heightAtLine(line: integer|LineHandle, ?mode: string, ?includeWidgets: bool) → number
    Computes the height of the top of a line, in the coordinate system specified by mode (see coordsChar), which defaults to "page". When a line below the bottom of the document is specified, the returned value is the bottom of - the last line in the document.
    + the last line in the document. By default, the position of the + actual text is returned. If `includeWidgets` is true and the + line has line widgets, the position above the first line widget + is returned.
    cm.defaultTextHeight() → number
    Returns the line height of the default font for the editor.
    cm.defaultCharWidth() → number
    diff --git a/src/edit/methods.js b/src/edit/methods.js index b63f9bd26b..8aa2a437b0 100644 --- a/src/edit/methods.js +++ b/src/edit/methods.js @@ -201,7 +201,7 @@ export default function(CodeMirror) { height = fromCoordSystem(this, {top: height, left: 0}, mode || "page").top return lineAtHeight(this.doc, height + this.display.viewOffset) }, - heightAtLine: function(line, mode) { + heightAtLine: function(line, mode, includeWidgets) { let end = false, lineObj if (typeof line == "number") { let last = this.doc.first + this.doc.size - 1 @@ -211,7 +211,7 @@ export default function(CodeMirror) { } else { lineObj = line } - return intoCoordSystem(this, lineObj, {top: 0, left: 0}, mode || "page").top + + return intoCoordSystem(this, lineObj, {top: 0, left: 0}, mode || "page", includeWidgets).top + (end ? this.doc.height - heightAtLine(lineObj) : 0) }, diff --git a/src/measurement/position_measurement.js b/src/measurement/position_measurement.js index 4ece080e49..f62672c494 100644 --- a/src/measurement/position_measurement.js +++ b/src/measurement/position_measurement.js @@ -287,8 +287,8 @@ function pageScrollY() { return window.pageYOffset || (document.documentElement // coordinates into another coordinate system. Context may be one of // "line", "div" (display.lineDiv), "local"./null (editor), "window", // or "page". -export function intoCoordSystem(cm, lineObj, rect, context) { - if (lineObj.widgets) for (let i = 0; i < lineObj.widgets.length; ++i) if (lineObj.widgets[i].above) { +export function intoCoordSystem(cm, lineObj, rect, context, includeWidgets) { + if (!includeWidgets && lineObj.widgets) for (let i = 0; i < lineObj.widgets.length; ++i) if (lineObj.widgets[i].above) { let size = widgetHeight(lineObj.widgets[i]) rect.top += size; rect.bottom += size } From e6ec325be0535893137b26545ec14b1c411fb16d Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Wed, 2 Nov 2016 11:15:32 +0100 Subject: [PATCH 0662/2444] Make sure initial connectors are drawn after aligning/collapsing So that their vertical offsets actually match the position of the corresponding lines. Issue #4364 --- addon/merge/merge.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/addon/merge/merge.js b/addon/merge/merge.js index 0c54a66464..f0d746449d 100644 --- a/addon/merge/merge.js +++ b/addon/merge/merge.js @@ -49,6 +49,8 @@ this.diffOutOfDate = this.dealigned = false; this.showDifferences = options.showDifferences !== false; + }, + registerEvents: function() { this.forceUpdate = registerUpdate(this); setScrollLock(this, true, false); registerScroll(this); @@ -91,10 +93,11 @@ updateMarks(dv.edit, dv.diff, edit, DIFF_INSERT, dv.classes); updateMarks(dv.orig, dv.diff, orig, DIFF_DELETE, dv.classes); } - makeConnections(dv); if (dv.mv.options.connect == "align") alignChunks(dv); + makeConnections(dv); + updating = false; } function setDealign(fast) { @@ -489,7 +492,6 @@ if (left) left.init(leftPane, origLeft, options); if (right) right.init(rightPane, origRight, options); - if (options.collapseIdentical) this.editor().operation(function() { collapseIdenticalStretches(self, options.collapseIdentical); @@ -498,6 +500,9 @@ this.aligners = []; alignChunks(this.left || this.right, true); } + if (left) left.registerEvents() + if (right) right.registerEvents() + var onResize = function() { if (left) makeConnections(left); From 73c5bf098ffff029a892a91d91bb8249d40c635f Mon Sep 17 00:00:00 2001 From: Steve Hoover Date: Thu, 3 Nov 2016 10:37:00 -0400 Subject: [PATCH 0663/2444] [verilog mode] Fixed inadvertent removal of TL-Verilog indent(..) function. --- mode/verilog/verilog.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/mode/verilog/verilog.js b/mode/verilog/verilog.js index 1f6ecb9f99..460cdb3b1c 100644 --- a/mode/verilog/verilog.js +++ b/mode/verilog/verilog.js @@ -494,7 +494,7 @@ CodeMirror.defineMode("verilog", function(config, parserConfig) { } // Compute indentation state: - // o Required indentation on next line + // o Auto indentation on next line // o Indentation scope styles var indented = state.indented; var depth = indented / tlvIndentUnit; @@ -508,9 +508,12 @@ CodeMirror.defineMode("verilog", function(config, parserConfig) { var ch = bodyString[0]; if (tlvScopePrefixChars[ch] && ((match = bodyString.match(tlvIdentMatch)) && tlvIdentifierStyle[match[1]])) { - // this line begins scope (except non-region keyword identifiers, which are statements themselves) + // This line begins scope. + // Next line gets indented one level. + indented += tlvIndentUnit; + // Style the next level of indentation (except non-region keyword identifiers, + // which are statements themselves) if (!(ch == "\\" && chPos > 0)) { - indented += tlvIndentUnit; state.tlvIndentationStyle[depth] = tlvScopePrefixChars[ch]; if (tlvTrackStatements) {state.statementComment = false;} depth++; @@ -524,6 +527,8 @@ CodeMirror.defineMode("verilog", function(config, parserConfig) { } } } + // Set next level of indentation. + state.tlvNextIndent = indented; } if (state.tlvCodeActive) { @@ -651,9 +656,14 @@ CodeMirror.defineMode("verilog", function(config, parserConfig) { return style; }, + indent: function(state) { + return (state.tlvCodeActive == true) ? state.tlvNextIndent : -1; + }, + startState: function(state) { state.tlvIndentationStyle = []; // Styles to use for each level of indentation. state.tlvCodeActive = true; // True when we're in a TLV region (and at beginning of file). + state.tlvNextIndent = -1; // The number of spaces to autoindent the next line if tlvCodeActive. state.tlvInBlockComment = false; // True inside /**/ comment. if (tlvTrackStatements) { state.statementComment = false; // True inside a statement's header comment. From dd10e2eef8a73349b3a8535508b3c878967a3215 Mon Sep 17 00:00:00 2001 From: pabloferz Date: Fri, 5 Feb 2016 12:09:26 +0100 Subject: [PATCH 0664/2444] [julia mode] Fixes for julia 0.5 --- mode/julia/julia.js | 217 ++++++++++++++++++++++++-------------------- 1 file changed, 119 insertions(+), 98 deletions(-) diff --git a/mode/julia/julia.js b/mode/julia/julia.js index 004de4431c..6c40bf20ee 100644 --- a/mode/julia/julia.js +++ b/mode/julia/julia.js @@ -11,51 +11,62 @@ })(function(CodeMirror) { "use strict"; -CodeMirror.defineMode("julia", function(_conf, parserConf) { - var ERRORCLASS = 'error'; - +CodeMirror.defineMode("julia", function(config, parserConf) { function wordRegexp(words, end) { - if (typeof end === 'undefined') { end = "\\b"; } + if (typeof end === "undefined") { end = "\\b"; } return new RegExp("^((" + words.join(")|(") + "))" + end); } var octChar = "\\\\[0-7]{1,3}"; var hexChar = "\\\\x[A-Fa-f0-9]{1,2}"; - var specialChar = "\\\\[abfnrtv0%?'\"\\\\]"; - var singleChar = "([^\\u0027\\u005C\\uD800-\\uDFFF]|[\\uD800-\\uDFFF][\\uDC00-\\uDFFF])"; - var operators = parserConf.operators || /^\.?[|&^\\%*+\-<>!=\/]=?|\?|~|:|\$|\.[<>]|<<=?|>>>?=?|\.[<>=]=|->?|\/\/|\bin\b(?!\()|[\u2208\u2209](?!\()/; + var sChar = "\\\\[abefnrtv0%?'\"\\\\]"; + var uChar = "([^\\u0027\\u005C\\uD800-\\uDFFF]|[\\uD800-\\uDFFF][\\uDC00-\\uDFFF])"; + + var operators = parserConf.operators || wordRegexp([ + "\\.?[\\\\%*+\\-<>!=\\/^]=?", "\\.?[|&\\u00F7\\u2260\\u2264\\u2265]", + "\\u00D7", "\\u2208", "\\u2209", "\\u220B", "\\u220C", "\\u2229", + "\\u222A", "\\u2286", "\\u2288", "\\u228A", "\\u22c5", "\\?", "~", ":", + "\\$", "\\.[<>]", "<<=?", ">>>?=?", "\\.[<>=]=", "->?", "\\/\\/", "=>", + "<:", "\\bin\\b(?!\\()"], ""); var delimiters = parserConf.delimiters || /^[;,()[\]{}]/; var identifiers = parserConf.identifiers || /^[_A-Za-z\u00A1-\uFFFF][\w\u00A1-\uFFFF]*!*/; - var charsList = [octChar, hexChar, specialChar, singleChar]; - var blockOpeners = ["begin", "function", "type", "immutable", "let", "macro", "for", "while", "quote", "if", "else", "elseif", "try", "finally", "catch", "do"]; - var blockClosers = ["end", "else", "elseif", "catch", "finally"]; - var keywordList = ['if', 'else', 'elseif', 'while', 'for', 'begin', 'let', 'end', 'do', 'try', 'catch', 'finally', 'return', 'break', 'continue', 'global', 'local', 'const', 'export', 'import', 'importall', 'using', 'function', 'macro', 'module', 'baremodule', 'type', 'immutable', 'quote', 'typealias', 'abstract', 'bitstype']; - var builtinList = ['true', 'false', 'nothing', 'NaN', 'Inf']; - - //var stringPrefixes = new RegExp("^[br]?('|\")") - var stringPrefixes = /^(`|"{3}|([brv]?"))/; - var chars = wordRegexp(charsList, "'"); - var keywords = wordRegexp(keywordList); - var builtins = wordRegexp(builtinList); - var openers = wordRegexp(blockOpeners); - var closers = wordRegexp(blockClosers); + + var chars = wordRegexp([octChar, hexChar, sChar, uChar], "'"); + var openers = wordRegexp(["begin", "function", "type", "immutable", "let", + "macro", "for", "while", "quote", "if", "else", "elseif", "try", + "finally", "catch", "do"]); + var closers = wordRegexp(["end", "else", "elseif", "catch", "finally"]); + var keywords = wordRegexp(["if", "else", "elseif", "while", "for", "begin", + "let", "end", "do", "try", "catch", "finally", "return", "break", + "continue", "global", "local", "const", "export", "import", "importall", + "using", "function", "macro", "module", "baremodule", "type", + "immutable", "quote", "typealias", "abstract", "bitstype"]); + var builtins = wordRegexp(["true", "false", "nothing", "NaN", "Inf"]); + var macro = /^@[_A-Za-z][\w]*/; var symbol = /^:[_A-Za-z\u00A1-\uFFFF][\w\u00A1-\uFFFF]*!*/; - var typeAnnotation = /^::[^,;"{()=$\s]+({[^}]*}+)*/; + var stringPrefixes = /^(`|"{3}|([_A-Za-z\u00A1-\uFFFF]*"))/; function inArray(state) { - var ch = currentScope(state); - if (ch == '[') { + return inGenerator(state, '[') + } + + function inGenerator(state, bracket) { + var curr = currentScope(state), + prev = currentScope(state, 1); + if (typeof(bracket) === "undefined") { bracket = '('; } + if (curr === bracket || (prev === bracket && curr === "for")) { return true; } return false; } - function currentScope(state) { - if (state.scopes.length == 0) { + function currentScope(state, n) { + if (typeof(n) === "undefined") { n = 0; } + if (state.scopes.length <= n) { return null; } - return state.scopes[state.scopes.length - 1]; + return state.scopes[state.scopes.length - (n + 1)]; } // tokenizers @@ -72,14 +83,15 @@ CodeMirror.defineMode("julia", function(_conf, parserConf) { leavingExpr = false; } state.leavingExpr = false; + if (leavingExpr) { if (stream.match(/^'+/)) { - return 'operator'; + return "operator"; } } if (stream.match(/^\.{2,3}/)) { - return 'operator'; + return "operator"; } if (stream.eatSpace()) { @@ -91,7 +103,7 @@ CodeMirror.defineMode("julia", function(_conf, parserConf) { // Handle single line comments if (ch === '#') { stream.skipToEnd(); - return 'comment'; + return "comment"; } if (ch === '[') { @@ -104,36 +116,55 @@ CodeMirror.defineMode("julia", function(_conf, parserConf) { var scope = currentScope(state); - if (scope == '[' && ch === ']') { + if (inArray(state) && ch === ']') { + if (scope === "for") { state.scopes.pop(); } state.scopes.pop(); state.leavingExpr = true; } - if (scope == '(' && ch === ')') { + if (inGenerator(state) && ch === ')') { + if (scope === "for") { state.scopes.pop(); } state.scopes.pop(); state.leavingExpr = true; } var match; - if (!inArray(state) && (match=stream.match(openers, false))) { - state.scopes.push(match); + if (match = stream.match(openers, false)) { + state.scopes.push(match[0]); } - if (!inArray(state) && stream.match(closers, false)) { + if (stream.match(closers, false)) { state.scopes.pop(); } if (inArray(state)) { - if (state.lastToken == 'end' && stream.match(/^:/)) { - return 'operator'; + if (state.lastToken == "end" && stream.match(/^:/)) { + return "operator"; } if (stream.match(/^end/)) { - return 'number'; + return "number"; } } - if (stream.match(/^=>/)) { - return 'operator'; + // Handle type annotations + if (stream.match(/^::(?![:\$])/)) { + state.tokenize = tokenAnnotation; + return state.tokenize(stream, state); + } + + // Handle symbols + if (!leavingExpr && stream.match(symbol) || stream.match(/:\./)) { + return "builtin"; + } + + // Handle parametric types + if (stream.match(/^{[^}]*}(?=\()/)) { + return "builtin"; + } + + // Handle operators and Delimiters + if (stream.match(operators)) { + return "operator"; } // Handle Number Literals @@ -156,33 +187,10 @@ CodeMirror.defineMode("julia", function(_conf, parserConf) { // Integer literals may be "long" stream.match(imMatcher); state.leavingExpr = true; - return 'number'; + return "number"; } } - if (stream.match(/^<:/)) { - return 'operator'; - } - - if (stream.match(typeAnnotation)) { - return 'builtin'; - } - - // Handle symbols - if (!leavingExpr && stream.match(symbol) || stream.match(/:\./)) { - return 'builtin'; - } - - // Handle parametric types - if (stream.match(/^{[^}]*}(?=\()/)) { - return 'builtin'; - } - - // Handle operators and Delimiters - if (stream.match(operators)) { - return 'operator'; - } - // Handle Chars if (stream.match(/^'/)) { state.tokenize = tokenChar; @@ -196,7 +204,7 @@ CodeMirror.defineMode("julia", function(_conf, parserConf) { } if (stream.match(macro)) { - return 'meta'; + return "meta"; } if (stream.match(delimiters)) { @@ -204,38 +212,36 @@ CodeMirror.defineMode("julia", function(_conf, parserConf) { } if (stream.match(keywords)) { - return 'keyword'; + return "keyword"; } if (stream.match(builtins)) { - return 'builtin'; + return "builtin"; } - var isDefinition = state.isDefinition || - state.lastToken == 'function' || - state.lastToken == 'macro' || - state.lastToken == 'type' || - state.lastToken == 'immutable'; + var isDefinition = state.isDefinition || state.lastToken == "function" || + state.lastToken == "macro" || state.lastToken == "type" || + state.lastToken == "immutable"; if (stream.match(identifiers)) { if (isDefinition) { if (stream.peek() === '.') { state.isDefinition = true; - return 'variable'; + return "variable"; } state.isDefinition = false; - return 'def'; + return "def"; } if (stream.match(/^({[^}]*})*\(/, false)) { return callOrDef(stream, state); } state.leavingExpr = true; - return 'variable'; + return "variable"; } // Handle non-detected items stream.next(); - return ERRORCLASS; + return "error"; } function callOrDef(stream, state) { @@ -255,8 +261,8 @@ CodeMirror.defineMode("julia", function(_conf, parserConf) { state.firstParenPos = -1; state.charsAdvanced = 0; if (isDefinition) - return 'def'; - return 'builtin'; + return "def"; + return "builtin"; } } // Unfortunately javascript does not support multiline strings, so we have @@ -268,25 +274,40 @@ CodeMirror.defineMode("julia", function(_conf, parserConf) { state.scopes.pop(); state.firstParenPos = -1; state.charsAdvanced = 0; - return 'builtin'; + return "builtin"; } state.charsAdvanced += stream.match(/^([^()]*)/)[1].length; return callOrDef(stream, state); } + function tokenAnnotation(stream, state) { + stream.match(/.*?(?=,|;|{|}|\(|\)|=|$|\s)/); + if (stream.match(/^{/)) { + state.nestedLevels++; + } else if (stream.match(/^}/)) { + state.nestedLevels--; + } + if (state.nestedLevels > 0) { + stream.match(/.*?(?={|})/); + } else if (state.nestedLevels == 0) { + state.tokenize = tokenBase; + } + return "builtin"; + } + function tokenComment(stream, state) { if (stream.match(/^#=/)) { - state.weakScopes++; + state.nestedLevels++; } if (!stream.match(/.*?(?=(#=|=#))/)) { stream.skipToEnd(); } if (stream.match(/^=#/)) { - state.weakScopes--; - if (state.weakScopes == 0) + state.nestedLevels--; + if (state.nestedLevels == 0) state.tokenize = tokenBase; } - return 'comment'; + return "comment"; } function tokenChar(stream, state) { @@ -309,33 +330,29 @@ CodeMirror.defineMode("julia", function(_conf, parserConf) { if (isChar) { state.leavingExpr = true; state.tokenize = tokenBase; - return 'string'; + return "string"; } if (!stream.match(/^[^']+(?=')/)) { stream.skipToEnd(); } if (stream.match(/^'/)) { state.tokenize = tokenBase; } - return ERRORCLASS; + return "error"; } function tokenStringFactory(delimiter) { - while ('bruv'.indexOf(delimiter.charAt(0).toLowerCase()) >= 0) { - delimiter = delimiter.substr(1); - } - var OUTCLASS = 'string'; - + delimiter = (delimiter === '`' || delimiter === '"""') ? delimiter : '"' function tokenString(stream, state) { while (!stream.eol()) { - stream.eatWhile(/[^"\\]/); + stream.eatWhile(/[^\\"]/); if (stream.eat('\\')) { stream.next(); } else if (stream.match(delimiter)) { state.tokenize = tokenBase; state.leavingExpr = true; - return OUTCLASS; + return "string"; } else { - stream.eat(/["]/); + stream.eat('"'); } } - return OUTCLASS; + return "string"; } tokenString.isString = true; return tokenString; @@ -346,10 +363,10 @@ CodeMirror.defineMode("julia", function(_conf, parserConf) { return { tokenize: tokenBase, scopes: [], - weakScopes: 0, lastToken: null, leavingExpr: false, isDefinition: false, + nestedLevels: 0, charsAdvanced: 0, firstParenPos: -1 }; @@ -366,20 +383,24 @@ CodeMirror.defineMode("julia", function(_conf, parserConf) { // Handle '.' connected identifiers if (current === '.') { style = stream.match(identifiers, false) || stream.match(macro, false) || - stream.match(/\(/, false) ? 'operator' : ERRORCLASS; + stream.match(/\(/, false) ? "operator" : "error"; } return style; }, indent: function(state, textAfter) { var delta = 0; - if (textAfter == "]" || textAfter == ")" || textAfter == "end" || textAfter == "else" || textAfter == "elseif" || textAfter == "catch" || textAfter == "finally") { + if ( textAfter === ']' || textAfter === ')' || textAfter === "end" || + textAfter === "else" || textAfter === "catch" || + textAfter === "finally" ) { delta = -1; } - return (state.scopes.length + delta) * _conf.indentUnit; + return (state.scopes.length + delta) * config.indentUnit; }, - electricInput: /(end|else(if)?|catch|finally)$/, + electricInput: /\b(end|else|catch|finally)\b/, + blockCommentStart: "#=", + blockCommentEnd: "=#", lineComment: "#", fold: "indent" }; From 4a1ed91341378942e49a4ca1d978d99eff4dd33e Mon Sep 17 00:00:00 2001 From: Jim Avery Date: Thu, 3 Nov 2016 16:38:14 -0500 Subject: [PATCH 0665/2444] [swift mode] Various improvements - Added for as a defining keyword - Added new types and operators - Fixed numbers so basic integers are represented - Identifiers can now be surrounded with backticks - Properties and #/@ instructions are now distinct, with the latter represented as a builtin type - Properties are now matched before punctuation. Code can now fold. - Remove the regexp checking as that syntax does not currently exist in Swift - Added tests --- mode/swift/swift.js | 39 +++++++----- mode/swift/test.js | 149 ++++++++++++++++++++++++++++++++++++++++++++ test/index.html | 2 + 3 files changed, 176 insertions(+), 14 deletions(-) create mode 100644 mode/swift/test.js diff --git a/mode/swift/swift.js b/mode/swift/swift.js index 9dcd822e91..329470664c 100644 --- a/mode/swift/swift.js +++ b/mode/swift/swift.js @@ -26,14 +26,20 @@ "defer","return","inout","mutating","nonmutating","catch","do","rethrows","throw","throws","try","didSet","get","set","willSet", "assignment","associativity","infix","left","none","operator","postfix","precedence","precedencegroup","prefix","right", "Any","AnyObject","Type","dynamicType","Self","Protocol","__COLUMN__","__FILE__","__FUNCTION__","__LINE__"]) - var definingKeywords = wordSet(["var","let","class","enum","extension","import","protocol","struct","func","typealias","associatedtype"]) + var definingKeywords = wordSet(["var","let","class","enum","extension","import","protocol","struct","func","typealias","associatedtype","for"]) var atoms = wordSet(["true","false","nil","self","super","_"]) - var types = wordSet(["Array","Bool","Dictionary","Double","Float","Int","Never","Optional","String","Void"]) - var operators = "+-/*%=|&<>" - var punc = ";,.(){}[]" - var number = /^-?(?:(?:[\d_]+\.[_\d]*|\.[_\d]+|0o[0-7_\.]+|0b[01_\.]+)(?:e-?[\d_]+)?|0x[\d_a-f\.]+(?:p-?[\d_]+)?)/i - var identifier = /^[_A-Za-z$][_A-Za-z$0-9]*/ - var property = /^[@\#\.][_A-Za-z$][_A-Za-z$0-9]*/ + var types = wordSet(["Array","Bool","Character","Dictionary","Double","Float","Int","Int8","Int16","Int32","Int64","Never","Optional","Set","String", + "UInt8","UInt16","UInt32","UInt64","Void"]) + var operators = "+-/*%=|&<>~^?!" + var punc = ":;,.(){}[]" + var binary = /^\-?0b[01][01_]*/ + var octal = /^\-?0o[0-7][0-7_]*/ + var hexadecimal = /^\-?0x[\dA-Fa-f][\dA-Fa-f_]*(?:(?:\.[\dA-Fa-f][\dA-Fa-f_]*)?[Pp]\-?\d[\d_]*)?/ + var decimal = /^\-?\d[\d_]*(?:\.\d[\d_]*)?(?:[Ee]\-?\d[\d_]*)?/ + var identifier = /^\$\d+|(`?)[_A-Za-z][_A-Za-z$0-9]*\1/ + var property = /^\.(?:\$\d+|(`?)[_A-Za-z][_A-Za-z$0-9]*\1)/ + var instruction = /^\#[A-Za-z]+/ + var attribute = /^@(?:\$\d+|(`?)[_A-Za-z][_A-Za-z$0-9]*\1)/ var regexp = /^\/(?!\s)(?:\/\/)?(?:\\.|[^\/])+\// function tokenBase(stream, state, prev) { @@ -50,8 +56,14 @@ state.tokenize.push(tokenComment) return tokenComment(stream, state) } - if (stream.match(regexp)) return "string-2" } + if (stream.match(instruction)) return "builtin" + if (stream.match(attribute)) return "attribute" + if (stream.match(binary)) return "number" + if (stream.match(octal)) return "number" + if (stream.match(hexadecimal)) return "number" + if (stream.match(decimal)) return "number" + if (stream.match(property)) return "property" if (operators.indexOf(ch) > -1) { stream.next() return "operator" @@ -68,18 +80,15 @@ return tokenize(stream, state) } - if (stream.match(number)) return "number" - if (stream.match(property)) return "property" - if (stream.match(identifier)) { var ident = stream.current() + if (types.hasOwnProperty(ident)) return "variable-2" + if (atoms.hasOwnProperty(ident)) return "atom" if (keywords.hasOwnProperty(ident)) { if (definingKeywords.hasOwnProperty(ident)) state.prev = "define" return "keyword" } - if (types.hasOwnProperty(ident)) return "variable-2" - if (atoms.hasOwnProperty(ident)) return "atom" if (prev == "define") return "def" return "variable" } @@ -191,7 +200,9 @@ lineComment: "//", blockCommentStart: "/*", - blockCommentEnd: "*/" + blockCommentEnd: "*/", + fold: "brace", + closeBrackets: "()[]{}''\"\"``" } }) diff --git a/mode/swift/test.js b/mode/swift/test.js new file mode 100644 index 0000000000..8c8ee2f65a --- /dev/null +++ b/mode/swift/test.js @@ -0,0 +1,149 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: http://codemirror.net/LICENSE + +(function() { + var mode = CodeMirror.getMode({indentUnit: 2}, "swift"); + function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); } + + // Ensure all number types are properly represented. + MT("numbers", + "[keyword var] [def a] [operator =] [number 17]", + "[keyword var] [def b] [operator =] [number -0.5]", + "[keyword var] [def c] [operator =] [number 0.3456e-4]", + "[keyword var] [def d] [operator =] [number 345e2]", + "[keyword var] [def e] [operator =] [number 0o7324]", + "[keyword var] [def f] [operator =] [number 0b10010]", + "[keyword var] [def g] [operator =] [number -0x35ade]", + "[keyword var] [def h] [operator =] [number 0xaea.ep-13]". + "[keyword var] [def i] [operator =] [number 0x13ep6"); + + // Variable/class/etc definition. + MT("definition", + "[keyword var] [def a] [operator =] [number 5]", + "[keyword let] [def b][punctuation :] [variable-2 Int] [operator =] [number 10]", + "[keyword class] [def C] [punctuation {] [punctuation }]", + "[keyword struct] [def D] [punctuation {] [punctuation }]", + "[keyword enum] [def E] [punctuation {] [punctuation }]", + "[keyword extension] [def F] [punctuation {] [punctuation }]", + "[keyword protocol] [def G] [punctuation {] [punctuation }]", + "[keyword func] [def h][punctuation ()] [punctuation {] [punctuation }]", + "[keyword import] [def Foundation]", + "[keyword typealias] [def NewString] [operator =] [variable-2 String]", + "[keyword associatedtype] [def I]", + "[keyword for] [def j] [keyword in] [number 0][punctuation ..][operator <][number 3] [punctuation {] [punctuation }]"); + + // Strings and string interpolation. + MT("strings", + "[keyword var] [def a][punctuation :] [variable-2 String] [operator =] [string \"test\"]", + "[keyword var] [def b][punctuation :] [variable-2 String] [operator =] [string \"\\(][variable a][string )\"]"); + + // Comments. + MT("comments", + "[comment // This is a comment]", + "[comment /* This is another comment */]", + "[keyword var] [def a] [operator =] [number 5] [comment // Third comment]"); + + // Atoms. + MT("atoms", + "[keyword class] [def FooClass] [punctuation {]", + " [keyword let] [def fooBool][punctuation :] [variable-2 Bool][operator ?]", + " [keyword let] [def fooInt][punctuation :] [variable-2 Int][operator ?]", + " [keyword func] [keyword init][punctuation (][variable fooBool][punctuation :] [variable-2 Bool][punctuation ,] [variable barBool][punctuation :] [variable-2 Bool][punctuation )] [punctuation {]", + " [atom super][property .init][punctuation ()]", + " [atom self][property .fooBool] [operator =] [variable fooBool]", + " [variable fooInt] [operator =] [atom nil]", + " [keyword if] [variable barBool] [operator ==] [atom true] [punctuation {]", + " [variable print][punctuation (][string \"True!\"][punctuation )]", + " [punctuation }] [keyword else] [keyword if] [variable barBool] [operator ==] [atom false] [punctuation {]", + " [keyword for] [atom _] [keyword in] [number 0][punctuation ...][number 5] [punctuation {]", + " [variable print][punctuation (][string \"False!\"][punctuation )]", + " [punctuation }]", + " [punctuation }]", + " [punctuation }]", + "[punctuation }]"); + + // Types. + MT("types", + "[keyword var] [def a] [operator =] [variable-2 Array][operator <][variable-2 Int][operator >]", + "[keyword var] [def b] [operator =] [variable-2 Set][operator <][variable-2 Bool][operator >]", + "[keyword var] [def c] [operator =] [variable-2 Dictionary][operator <][variable-2 String][punctuation ,][variable-2 Character][operator >]", + "[keyword var] [def d][punctuation :] [variable-2 Int64][operator ?] [operator =] [variable-2 Optional][punctuation (][number 8][punctuation )]", + "[keyword func] [def e][punctuation ()] [operator ->] [variable-2 Void] [punctuation {]", + " [keyword var] [def e1][punctuation :] [variable-2 Float] [operator =] [number 1.2]", + "[punctuation }]", + "[keyword func] [def f][punctuation ()] [operator ->] [variable-2 Never] [punctuation {]", + " [keyword var] [def f1][punctuation :] [variable-2 Double] [operator =] [number 2.4]", + "[punctuation }]"); + + // Operators. + MT("operators", + "[keyword var] [def a] [operator =] [number 1] [operator +] [number 2]", + "[keyword var] [def b] [operator =] [number 1] [operator -] [number 2]", + "[keyword var] [def c] [operator =] [number 1] [operator *] [number 2]", + "[keyword var] [def d] [operator =] [number 1] [operator /] [number 2]", + "[keyword var] [def e] [operator =] [number 1] [operator %] [number 2]", + "[keyword var] [def f] [operator =] [number 1] [operator |] [number 2]", + "[keyword var] [def g] [operator =] [number 1] [operator &] [number 2]", + "[keyword var] [def h] [operator =] [number 1] [operator <<] [number 2]", + "[keyword var] [def i] [operator =] [number 1] [operator >>] [number 2]", + "[keyword var] [def j] [operator =] [number 1] [operator ^] [number 2]", + "[keyword var] [def k] [operator =] [operator ~][number 1]", + "[keyword var] [def l] [operator =] [variable foo] [operator ?] [number 1] [punctuation :] [number 2]", + "[keyword var] [def m][punctuation :] [variable-2 Int] [operator =] [variable-2 Optional][punctuation (][number 8][punctuation )][operator !]"); + + // Punctuation. + MT("punctuation", + "[keyword let] [def a] [operator =] [number 1][punctuation ;] [keyword let] [def b] [operator =] [number 2]", + "[keyword let] [def testArr][punctuation :] [punctuation [[][variable-2 Int][punctuation ]]] [operator =] [punctuation [[][variable a][punctuation ,] [variable b][punctuation ]]]", + "[keyword for] [def i] [keyword in] [number 0][punctuation ..][operator <][variable testArr][property .count] [punctuation {]", + " [variable print][punctuation (][variable testArr][punctuation [[][variable i][punctuation ]])]", + "[punctuation }]"); + + // Identifiers. + MT("identifiers", + "[keyword let] [def abc] [operator =] [number 1]", + "[keyword let] [def ABC] [operator =] [number 2]", + "[keyword let] [def _123] [operator =] [number 3]", + "[keyword let] [def _$1$2$3] [operator =] [number 4]", + "[keyword let] [def A1$_c32_$_] [operator =] [number 5]", + "[keyword let] [def `var`] [operator =] [punctuation [[][number 1][punctuation ,] [number 2][punctuation ,] [number 3][punctuation ]]]", + "[keyword let] [def square$] [operator =] [variable `var`][property .map] [punctuation {][variable $0] [operator *] [variable $0][punctuation }]", + "$$ [number 1][variable a] $[atom _] [variable _$] [variable __] `[variable a] [variable b]`"); + + // Properties. + MT("properties", + "[variable print][punctuation (][variable foo][property .abc][punctuation )]", + "[variable print][punctuation (][variable foo][property .ABC][punctuation )]", + "[variable print][punctuation (][variable foo][property ._123][punctuation )]", + "[variable print][punctuation (][variable foo][property ._$1$2$3][punctuation )]", + "[variable print][punctuation (][variable foo][property .A1$_c32_$_][punctuation )]", + "[variable print][punctuation (][variable foo][property .`var`][punctuation )]", + "[variable print][punctuation (][variable foo][property .__][punctuation )]"); + + // Instructions or other things that start with #. + MT("instructions", + "[keyword if] [instruction #available][punctuation (][variable iOS] [number 9][punctuation ,] [operator *][punctuation )] [punctuation {}", + "[variable print][punctuation (][instruction #file][punctuation ,] [instruction #function][punctuation )]", + "[variable print][punctuation (][instruction #line][punctuation ,] [instruction #column][punctuation )]", + "[instruction #if] [atom true]", + " [keyword import] [variable A]", + "[instruction #elseif] [atom false]", + " [keyword import] [variable B]", + "[instruction #endif]", + "[instruction #sourceLocation][punctuation (][variable file][punctuation :] [string \"file.swift\"][punctuation ,] [variable line][punctuation :] [number 2][punctuation )]"); + + // Attributes; things that start with @. + MT("attributes", + "[instruction @objc][punctuation (][variable objcFoo][punctuation :)]", + "[instruction @available][punctuation (][variable iOS][punctuation )]"); + + // Property/number edge case. + MT("property_number", + "[variable print][punctuation (][variable foo][property ._123][punctuation )]", + "[variable print][punctuation (]") + + // TODO: correctly identify when multiple variables are being declared + // by use of a comma-separated list. + // TODO: correctly identify when variables are being declared in a tuple. + // TODO: identify protocols as types when used before an extension? +})(); diff --git a/test/index.html b/test/index.html index 8ac33c0913..cfa3bb71fb 100644 --- a/test/index.html +++ b/test/index.html @@ -35,6 +35,7 @@ + @@ -122,6 +123,7 @@

    Test Suite

    + From 18c1bcb556bd1e5bab56d2564fd79cefee4ddc79 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Wed, 9 Nov 2016 11:03:13 +0100 Subject: [PATCH 0666/2444] [swift mode] Make tests syntactically valid and in agreement with the mode Issue #4374 --- mode/swift/swift.js | 2 +- mode/swift/test.js | 26 +++++++++++++------------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/mode/swift/swift.js b/mode/swift/swift.js index 329470664c..43ab7c8fb4 100644 --- a/mode/swift/swift.js +++ b/mode/swift/swift.js @@ -40,7 +40,7 @@ var property = /^\.(?:\$\d+|(`?)[_A-Za-z][_A-Za-z$0-9]*\1)/ var instruction = /^\#[A-Za-z]+/ var attribute = /^@(?:\$\d+|(`?)[_A-Za-z][_A-Za-z$0-9]*\1)/ - var regexp = /^\/(?!\s)(?:\/\/)?(?:\\.|[^\/])+\// + //var regexp = /^\/(?!\s)(?:\/\/)?(?:\\.|[^\/])+\// function tokenBase(stream, state, prev) { if (stream.sol()) state.indented = stream.indentation() diff --git a/mode/swift/test.js b/mode/swift/test.js index 8c8ee2f65a..786b89e299 100644 --- a/mode/swift/test.js +++ b/mode/swift/test.js @@ -14,8 +14,8 @@ "[keyword var] [def e] [operator =] [number 0o7324]", "[keyword var] [def f] [operator =] [number 0b10010]", "[keyword var] [def g] [operator =] [number -0x35ade]", - "[keyword var] [def h] [operator =] [number 0xaea.ep-13]". - "[keyword var] [def i] [operator =] [number 0x13ep6"); + "[keyword var] [def h] [operator =] [number 0xaea.ep-13]", + "[keyword var] [def i] [operator =] [number 0x13ep6]"); // Variable/class/etc definition. MT("definition", @@ -122,20 +122,20 @@ // Instructions or other things that start with #. MT("instructions", - "[keyword if] [instruction #available][punctuation (][variable iOS] [number 9][punctuation ,] [operator *][punctuation )] [punctuation {}", - "[variable print][punctuation (][instruction #file][punctuation ,] [instruction #function][punctuation )]", - "[variable print][punctuation (][instruction #line][punctuation ,] [instruction #column][punctuation )]", - "[instruction #if] [atom true]", - " [keyword import] [variable A]", - "[instruction #elseif] [atom false]", - " [keyword import] [variable B]", - "[instruction #endif]", - "[instruction #sourceLocation][punctuation (][variable file][punctuation :] [string \"file.swift\"][punctuation ,] [variable line][punctuation :] [number 2][punctuation )]"); + "[keyword if] [builtin #available][punctuation (][variable iOS] [number 9][punctuation ,] [operator *][punctuation )] [punctuation {}]", + "[variable print][punctuation (][builtin #file][punctuation ,] [builtin #function][punctuation )]", + "[variable print][punctuation (][builtin #line][punctuation ,] [builtin #column][punctuation )]", + "[builtin #if] [atom true]", + "[keyword import] [def A]", + "[builtin #elseif] [atom false]", + "[keyword import] [def B]", + "[builtin #endif]", + "[builtin #sourceLocation][punctuation (][variable file][punctuation :] [string \"file.swift\"][punctuation ,] [variable line][punctuation :] [number 2][punctuation )]"); // Attributes; things that start with @. MT("attributes", - "[instruction @objc][punctuation (][variable objcFoo][punctuation :)]", - "[instruction @available][punctuation (][variable iOS][punctuation )]"); + "[attribute @objc][punctuation (][variable objcFoo][punctuation :)]", + "[attribute @available][punctuation (][variable iOS][punctuation )]"); // Property/number edge case. MT("property_number", From a34c02883bcf5ad0d9328de6fff0fafde9a7aa3f Mon Sep 17 00:00:00 2001 From: Paris Kasidiaris Date: Thu, 10 Nov 2016 10:16:01 +0200 Subject: [PATCH 0667/2444] [real-world uses] Add SourceLair --- doc/realworld.html | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/realworld.html b/doc/realworld.html index 8db34cd9fa..e52c9f00f8 100644 --- a/doc/realworld.html +++ b/doc/realworld.html @@ -146,6 +146,7 @@

    CodeMirror real-world uses

  • Shadertoy (shader sharing)
  • sketchPatch Livecodelab
  • Skulpt (in-browser Python environment)
  • +
  • SourceLair (in-browser IDE for Django, Node.js, PHP and HTML5)
  • Snap Tomato (HTML editing/testing page)
  • Snippets.pro (code snippet sharing)
  • SolidShops (hosted e-commerce platform)
  • From 5d235c1b6ecb299892179ab8fe0f3f28693aabf1 Mon Sep 17 00:00:00 2001 From: Sander Verweij Date: Sun, 13 Nov 2016 15:26:24 +0100 Subject: [PATCH 0668/2444] [real world uses] adds mscgen.js.org --- doc/realworld.html | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/realworld.html b/doc/realworld.html index e52c9f00f8..dc2a7f6a97 100644 --- a/doc/realworld.html +++ b/doc/realworld.html @@ -118,6 +118,7 @@

    CodeMirror real-world uses

  • MIHTool (iOS web-app debugging tool)
  • Mongo MapReduce WebBrowser
  • Montage Studio (web app creator suite)
  • +
  • mscgen_js (online sequence chart editor)
  • MVC Playground
  • My2ndGeneration (social coding)
  • Navigate CMS
  • From e6eebeb19291889aa05f2bd34ce113702ec44090 Mon Sep 17 00:00:00 2001 From: pabloferz Date: Sat, 12 Nov 2016 23:13:25 -0600 Subject: [PATCH 0669/2444] [julia mode] Fix string tokenizer --- mode/julia/julia.js | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/mode/julia/julia.js b/mode/julia/julia.js index 6c40bf20ee..0174210b55 100644 --- a/mode/julia/julia.js +++ b/mode/julia/julia.js @@ -338,23 +338,20 @@ CodeMirror.defineMode("julia", function(config, parserConf) { } function tokenStringFactory(delimiter) { - delimiter = (delimiter === '`' || delimiter === '"""') ? delimiter : '"' + delimiter = (delimiter === '`' || delimiter === '"""') ? delimiter : '"'; function tokenString(stream, state) { - while (!stream.eol()) { - stream.eatWhile(/[^\\"]/); - if (stream.eat('\\')) { - stream.next(); - } else if (stream.match(delimiter)) { - state.tokenize = tokenBase; - state.leavingExpr = true; - return "string"; - } else { - stream.eat('"'); - } + if (stream.eat('\\')) { + stream.next(); + } else if (stream.match(delimiter)) { + state.tokenize = tokenBase; + state.leavingExpr = true; + return "string"; + } else { + stream.eat(/[`"]/); } + stream.eatWhile(/[^\\`"]/); return "string"; } - tokenString.isString = true; return tokenString; } From 0a90aa456c6c850956b2bdc45334dfe5ce7f0d5e Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Mon, 14 Nov 2016 10:36:23 +0100 Subject: [PATCH 0670/2444] Simplify build instructions in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1b3309881c..3328e3bdfb 100644 --- a/README.md +++ b/README.md @@ -30,5 +30,5 @@ conduct. ### Quickstart To build the project, make sure you have Node.js installed (at least version 6) -and then `npm install && npm run build`. To run, just open `index.html` in your +and then `npm install`. To run, just open `index.html` in your browser (you don't need to run a webserver). Run the tests with `npm test`. From 90819c54aae09c0002286cd43e57522432580d7c Mon Sep 17 00:00:00 2001 From: Mark Peace Date: Fri, 11 Nov 2016 16:48:36 +0000 Subject: [PATCH 0671/2444] [cypher mode] Highlight empty string literals correctly --- mode/cypher/cypher.js | 6 +++--- mode/cypher/test.js | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/mode/cypher/cypher.js b/mode/cypher/cypher.js index 1d9ca4334a..9b2490014c 100644 --- a/mode/cypher/cypher.js +++ b/mode/cypher/cypher.js @@ -20,12 +20,12 @@ CodeMirror.defineMode("cypher", function(config) { var tokenBase = function(stream/*, state*/) { var ch = stream.next(); - if (ch === "\"") { - stream.match(/.+?["]/); + if (ch ==='"') { + stream.match(/.*?"/); return "string"; } if (ch === "'") { - stream.match(/.+?[']/); + stream.match(/.*?'/); return "string"; } if (/[{}\(\),\.;\[\]]/.test(ch)) { diff --git a/mode/cypher/test.js b/mode/cypher/test.js index 34cf96caff..76d0d08296 100644 --- a/mode/cypher/test.js +++ b/mode/cypher/test.js @@ -16,4 +16,22 @@ MT("singleQuotedString", "[string 'a'][variable b]"); + + MT("single attribute (with content)", + "[node {][atom a:][string 'a'][node }]"); + + MT("multiple attribute, singleQuotedString (with content)", + "[node {][atom a:][string 'a'][node ,][atom b:][string 'b'][node }]"); + + MT("multiple attribute, doubleQuotedString (with content)", + "[node {][atom a:][string \"a\"][node ,][atom b:][string \"b\"][node }]"); + + MT("single attribute (without content)", + "[node {][atom a:][string 'a'][node }]"); + + MT("multiple attribute, singleQuotedString (without content)", + "[node {][atom a:][string ''][node ,][atom b:][string ''][node }]"); + + MT("multiple attribute, doubleQuotedString (without content)", + "[node {][atom a:][string \"\"][node ,][atom b:][string \"\"][node }]"); })(); From 532ae310c9248e696caa21ca34519b79367cd4eb Mon Sep 17 00:00:00 2001 From: Marcelo Camargo Date: Mon, 14 Nov 2016 17:37:54 -0200 Subject: [PATCH 0672/2444] [sql mode] Remove non-strict useless comparison for booleans --- mode/sql/sql.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/mode/sql/sql.js b/mode/sql/sql.js index e3cbae54cf..32ced3e9de 100644 --- a/mode/sql/sql.js +++ b/mode/sql/sql.js @@ -32,13 +32,13 @@ CodeMirror.defineMode("sql", function(config, parserConfig) { if (result !== false) return result; } - if (support.hexNumber == true && + if (support.hexNumber && ((ch == "0" && stream.match(/^[xX][0-9a-fA-F]+/)) || (ch == "x" || ch == "X") && stream.match(/^'[0-9a-fA-F]+'/))) { // hex // ref: http://dev.mysql.com/doc/refman/5.5/en/hexadecimal-literals.html return "number"; - } else if (support.binaryNumber == true && + } else if (support.binaryNumber && (((ch == "b" || ch == "B") && stream.match(/^'[01]+'/)) || (ch == "0" && stream.match(/^b[01]+/)))) { // bitstring @@ -48,7 +48,7 @@ CodeMirror.defineMode("sql", function(config, parserConfig) { // numbers // ref: http://dev.mysql.com/doc/refman/5.5/en/number-literals.html stream.match(/^[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?/); - support.decimallessFloat == true && stream.eat('.'); + support.decimallessFloat && stream.eat('.'); return "number"; } else if (ch == "?" && (stream.eatSpace() || stream.eol() || stream.eat(";"))) { // placeholders @@ -58,8 +58,8 @@ CodeMirror.defineMode("sql", function(config, parserConfig) { // ref: http://dev.mysql.com/doc/refman/5.5/en/string-literals.html state.tokenize = tokenLiteral(ch); return state.tokenize(stream, state); - } else if ((((support.nCharCast == true && (ch == "n" || ch == "N")) - || (support.charsetCast == true && ch == "_" && stream.match(/[a-z][a-z0-9]*/i))) + } else if ((((support.nCharCast && (ch == "n" || ch == "N")) + || (support.charsetCast && ch == "_" && stream.match(/[a-z][a-z0-9]*/i))) && (stream.peek() == "'" || stream.peek() == '"'))) { // charset casting: _utf8'str', N'str', n'str' // ref: http://dev.mysql.com/doc/refman/5.5/en/string-literals.html @@ -84,12 +84,12 @@ CodeMirror.defineMode("sql", function(config, parserConfig) { return state.tokenize(stream, state); } else if (ch == ".") { // .1 for 0.1 - if (support.zerolessFloat == true && stream.match(/^(?:\d+(?:e[+-]?\d+)?)/i)) { + if (support.zerolessFloat && stream.match(/^(?:\d+(?:e[+-]?\d+)?)/i)) { return "number"; } // .table_name (ODBC) // // ref: http://dev.mysql.com/doc/refman/5.6/en/identifier-qualifiers.html - if (support.ODBCdotTable == true && stream.match(/^[a-zA-Z_]+/)) { + if (support.ODBCdotTable && stream.match(/^[a-zA-Z_]+/)) { return "variable-2"; } } else if (operatorChars.test(ch)) { From beb838248ad29721f11c5b33ce08c701d93875da Mon Sep 17 00:00:00 2001 From: takamori Date: Mon, 14 Nov 2016 12:44:30 -0800 Subject: [PATCH 0673/2444] [css mode] Support user-select. As described in http://caniuse.com/#feat=user-select-none and https://developer.mozilla.org/en-US/docs/Web/CSS/user-select --- mode/css/css.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mode/css/css.js b/mode/css/css.js index b75732034e..985287f475 100644 --- a/mode/css/css.js +++ b/mode/css/css.js @@ -522,7 +522,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) { "text-wrap", "top", "transform", "transform-origin", "transform-style", "transition", "transition-delay", "transition-duration", "transition-property", "transition-timing-function", "unicode-bidi", - "vertical-align", "visibility", "voice-balance", "voice-duration", + "user-select", "vertical-align", "visibility", "voice-balance", "voice-duration", "voice-family", "voice-pitch", "voice-range", "voice-rate", "voice-stress", "voice-volume", "volume", "white-space", "widows", "width", "word-break", "word-spacing", "word-wrap", "z-index", From 5012e8772371632bc4e4162e1a0f674d42cd1d79 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Tue, 15 Nov 2016 13:18:46 +0100 Subject: [PATCH 0674/2444] [contenteditable input] Force editor selection in focus method So that the selection isn't reset to the start of the element by div.focus(). --- src/input/ContentEditableInput.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/input/ContentEditableInput.js b/src/input/ContentEditableInput.js index cdaa825488..594f17f663 100644 --- a/src/input/ContentEditableInput.js +++ b/src/input/ContentEditableInput.js @@ -199,7 +199,11 @@ ContentEditableInput.prototype = copyObj({ }, focus: function() { - if (this.cm.options.readOnly != "nocursor") this.div.focus() + if (this.cm.options.readOnly != "nocursor") { + if (!this.selectionInEditor()) + this.showSelection(this.prepareSelection(), true) + this.div.focus() + } }, blur: function() { this.div.blur() }, getField: function() { return this.div }, From da8a35d05e720db980c4ae2307c7615aceaa53ac Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Tue, 15 Nov 2016 13:46:59 +0100 Subject: [PATCH 0675/2444] Handle compositionupdate events without corresponding compositionstart Because Android, especially Google Keyboard, just doesn't care --- src/input/ContentEditableInput.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/input/ContentEditableInput.js b/src/input/ContentEditableInput.js index 594f17f663..524d571e5e 100644 --- a/src/input/ContentEditableInput.js +++ b/src/input/ContentEditableInput.js @@ -37,8 +37,7 @@ ContentEditableInput.prototype = copyObj({ }), 20) }) - on(div, "compositionstart", e => { - let data = e.data + function startComposing(data) { input.composing = {sel: cm.doc.sel, data: data, startData: data} if (!data) return let prim = cm.doc.sel.primary() @@ -47,8 +46,13 @@ ContentEditableInput.prototype = copyObj({ if (found > -1 && found <= prim.head.ch) input.composing.sel = simpleSelection(Pos(prim.head.line, found), Pos(prim.head.line, found + data.length)) + } + + on(div, "compositionstart", e => startComposing(e.data)) + on(div, "compositionupdate", e => { + if (input.composing) input.composing.data = e.data + else startComposing(e.data) }) - on(div, "compositionupdate", e => input.composing.data = e.data) on(div, "compositionend", e => { let ours = input.composing if (!ours) return From 0e545326ddb3a82df1b76eb18b2221990536e588 Mon Sep 17 00:00:00 2001 From: Todd Berman Date: Tue, 8 Nov 2016 09:17:56 -0800 Subject: [PATCH 0676/2444] Move setGutterMarker, clearGutter and lineInfo to Doc --- doc/manual.html | 6 +++--- src/edit/methods.js | 42 ++---------------------------------------- src/model/Doc.js | 41 ++++++++++++++++++++++++++++++++++++++++- 3 files changed, 45 insertions(+), 44 deletions(-) diff --git a/doc/manual.html b/doc/manual.html index e74ec36200..ecfe3071f7 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -1699,7 +1699,7 @@

    Text-marking methods

    Widget, gutter, and decoration methods

    -
    cm.setGutterMarker(line: integer|LineHandle, gutterID: string, value: Element) → LineHandle
    +
    doc.setGutterMarker(line: integer|LineHandle, gutterID: string, value: Element) → LineHandle
    Sets the gutter marker for the given gutter (identified by its CSS class, see the gutters option) @@ -1708,7 +1708,7 @@

    Widget, gutter, and decoration methods

    will be shown in the specified gutter next to the specified line.
    -
    cm.clearGutter(gutterID: string)
    +
    doc.clearGutter(gutterID: string)
    Remove all gutter markers in the gutter with the given ID.
    @@ -1733,7 +1733,7 @@

    Widget, gutter, and decoration methods

    can be left off to remove all classes for the specified node, or be a string to remove only a specific class. -
    cm.lineInfo(line: integer|LineHandle) → object
    +
    doc.lineInfo(line: integer|LineHandle) → object
    Returns the line number, text content, and marker status of the given line, which can be either a number or a line handle. The returned object has the structure {line, handle, text, diff --git a/src/edit/methods.js b/src/edit/methods.js index 8aa2a437b0..7efaf20e2c 100644 --- a/src/edit/methods.js +++ b/src/edit/methods.js @@ -1,5 +1,4 @@ import { deleteNearSelection } from "./deleteNearSelection" -import { changeLine } from "../model/changes" import { commands } from "./commands" import { attachDoc } from "../model/document_data" import { activeElt, addClass, rmClass } from "../util/dom" @@ -18,9 +17,9 @@ import { addToScrollPos, calculateScrollPos, ensureCursorVisible, resolveScrollT import { heightAtLine } from "../line/spans" import { updateGutterSpace } from "../display/update_display" import { lineLeft, lineRight, moveLogically, moveVisually } from "../util/bidi" -import { indexOf, insertSorted, isEmpty, isWordChar, sel_dontScroll, sel_move } from "../util/misc" +import { indexOf, insertSorted, isWordChar, sel_dontScroll, sel_move } from "../util/misc" import { signalLater } from "../util/operation_group" -import { getLine, isLine, lineAtHeight, lineNo } from "../line/utils_line" +import { getLine, isLine, lineAtHeight } from "../line/utils_line" import { regChange, regLineChange } from "../display/view_tracking" // The publicly visible API. Note that methodOp(f) means @@ -218,43 +217,6 @@ export default function(CodeMirror) { defaultTextHeight: function() { return textHeight(this.display) }, defaultCharWidth: function() { return charWidth(this.display) }, - setGutterMarker: methodOp(function(line, gutterID, value) { - return changeLine(this.doc, line, "gutter", line => { - let markers = line.gutterMarkers || (line.gutterMarkers = {}) - markers[gutterID] = value - if (!value && isEmpty(markers)) line.gutterMarkers = null - return true - }) - }), - - clearGutter: methodOp(function(gutterID) { - let doc = this.doc, i = doc.first - doc.iter(line => { - if (line.gutterMarkers && line.gutterMarkers[gutterID]) { - line.gutterMarkers[gutterID] = null - regLineChange(this, i, "gutter") - if (isEmpty(line.gutterMarkers)) line.gutterMarkers = null - } - ++i - }) - }), - - lineInfo: function(line) { - let n - if (typeof line == "number") { - if (!isLine(this.doc, line)) return null - n = line - line = getLine(this.doc, line) - if (!line) return null - } else { - n = lineNo(line) - if (n == null) return null - } - return {line: n, handle: line, text: line.text, gutterMarkers: line.gutterMarkers, - textClass: line.textClass, bgClass: line.bgClass, wrapClass: line.wrapClass, - widgets: line.widgets} - }, - getViewport: function() { return {from: this.display.viewFrom, to: this.display.viewTo}}, addWidget: function(pos, node, scroll, vert, horiz) { diff --git a/src/model/Doc.js b/src/model/Doc.js index fcb2c1e109..27b62d1945 100644 --- a/src/model/Doc.js +++ b/src/model/Doc.js @@ -6,7 +6,7 @@ import { visualLine } from "../line/spans" import { getBetween, getLine, getLines, isLine, lineNo } from "../line/utils_line" import { classTest } from "../util/dom" import { splitLinesAuto } from "../util/feature_detection" -import { createObj, map, sel_dontScroll } from "../util/misc" +import { createObj, map, isEmpty, sel_dontScroll } from "../util/misc" import { ensureCursorVisible } from "../display/scrolling" import { changeLine, makeChange, makeChangeFromHistory, replaceRange } from "./changes" @@ -219,6 +219,45 @@ Doc.prototype = createObj(BranchChunk.prototype, { hist.undone = copyHistoryArray(histData.undone.slice(0), null, true) }, + setGutterMarker: docMethodOp(function(line, gutterID, value) { + return changeLine(this, line, "gutter", line => { + let markers = line.gutterMarkers || (line.gutterMarkers = {}) + markers[gutterID] = value + if (!value && isEmpty(markers)) line.gutterMarkers = null + return true + }) + }), + + clearGutter: docMethodOp(function(gutterID) { + let i = this.first + this.iter(line => { + if (line.gutterMarkers && line.gutterMarkers[gutterID]) { + changeLine(this, line, "gutter", () => { + line.gutterMarkers[gutterID] = null + if (isEmpty(line.gutterMarkers)) line.gutterMarkers = null + return true + }) + } + ++i + }) + }), + + lineInfo: function(line) { + let n + if (typeof line == "number") { + if (!isLine(this, line)) return null + n = line + line = getLine(this, line) + if (!line) return null + } else { + n = lineNo(line) + if (n == null) return null + } + return {line: n, handle: line, text: line.text, gutterMarkers: line.gutterMarkers, + textClass: line.textClass, bgClass: line.bgClass, wrapClass: line.wrapClass, + widgets: line.widgets} + }, + addLineClass: docMethodOp(function(handle, where, cls) { return changeLine(this, handle, where == "gutter" ? "gutter" : "class", line => { let prop = where == "text" ? "textClass" From 441641e6cb75ebbd2f5551befe2b2cde9ddf9ab2 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Tue, 15 Nov 2016 14:54:05 +0100 Subject: [PATCH 0677/2444] [contenteditable input] Read from the DOM to get composition input And do so only after a delay, so that subsequent input events get a chance to fire. --- src/edit/CodeMirror.js | 1 + src/edit/mouse_events.js | 1 + src/input/ContentEditableInput.js | 67 +++++++++++++------------------ 3 files changed, 30 insertions(+), 39 deletions(-) diff --git a/src/edit/CodeMirror.js b/src/edit/CodeMirror.js index 7e17002d15..a3dc622cf1 100644 --- a/src/edit/CodeMirror.js +++ b/src/edit/CodeMirror.js @@ -142,6 +142,7 @@ function registerEventHandlers(cm) { } on(d.scroller, "touchstart", e => { if (!signalDOMEvent(cm, e) && !isMouseLikeTouchEvent(e)) { + d.input.ensurePolled() clearTimeout(touchFinished) let now = +new Date d.activeTouch = {start: now, moved: false, diff --git a/src/edit/mouse_events.js b/src/edit/mouse_events.js index 784f195b3e..0b96f4cfda 100644 --- a/src/edit/mouse_events.js +++ b/src/edit/mouse_events.js @@ -21,6 +21,7 @@ import { bind, countColumn, findColumn, sel_mouse } from "../util/misc" export function onMouseDown(e) { let cm = this, display = cm.display if (signalDOMEvent(cm, e) || display.activeTouch && display.input.supportsTouch()) return + display.input.ensurePolled() display.shift = e.shiftKey if (eventInWidget(display, e)) { diff --git a/src/input/ContentEditableInput.js b/src/input/ContentEditableInput.js index 524d571e5e..a7254b12c2 100644 --- a/src/input/ContentEditableInput.js +++ b/src/input/ContentEditableInput.js @@ -20,7 +20,9 @@ export default function ContentEditableInput(cm) { this.cm = cm this.lastAnchorNode = this.lastAnchorOffset = this.lastFocusNode = this.lastFocusOffset = null this.polling = new Delayed() + this.composing = null this.gracePeriod = false + this.readDOMTimeout = null } ContentEditableInput.prototype = copyObj({ @@ -37,44 +39,23 @@ ContentEditableInput.prototype = copyObj({ }), 20) }) - function startComposing(data) { - input.composing = {sel: cm.doc.sel, data: data, startData: data} - if (!data) return - let prim = cm.doc.sel.primary() - let line = cm.getLine(prim.head.line) - let found = line.indexOf(data, Math.max(0, prim.head.ch - data.length)) - if (found > -1 && found <= prim.head.ch) - input.composing.sel = simpleSelection(Pos(prim.head.line, found), - Pos(prim.head.line, found + data.length)) - } - - on(div, "compositionstart", e => startComposing(e.data)) + on(div, "compositionstart", e => { + this.composing = {data: e.data} + }) on(div, "compositionupdate", e => { - if (input.composing) input.composing.data = e.data - else startComposing(e.data) + if (!this.composing) this.composing = {data: e.data} }) on(div, "compositionend", e => { - let ours = input.composing - if (!ours) return - if (e.data != ours.startData && !/\u200b/.test(e.data)) - ours.data = e.data - // Need a small delay to prevent other code (input event, - // selection polling) from doing damage when fired right after - // compositionend. - setTimeout(() => { - if (!ours.handled) - input.applyComposition(ours) - if (input.composing == ours) - input.composing = null - }, 50) + if (this.composing) { + if (e.data != this.composing.data) this.readFromDOMSoon() + this.composing = null + } }) on(div, "touchstart", () => input.forceCompositionEnd()) on(div, "input", () => { - if (input.composing) return - if (cm.isReadOnly() || !input.pollContent()) - runInOp(input.cm, () => regChange(cm)) + if (!this.composing) this.readFromDOMSoon() }) function onCopyCut(e) { @@ -237,7 +218,7 @@ ContentEditableInput.prototype = copyObj({ }, pollSelection: function() { - if (!this.composing && !this.gracePeriod && this.selectionChanged()) { + if (!this.composing && this.readDOMTimeout == null && !this.gracePeriod && this.selectionChanged()) { let sel = window.getSelection(), cm = this.cm this.rememberSelection() let anchor = domToPos(cm, sel.anchorNode, sel.anchorOffset) @@ -250,6 +231,11 @@ ContentEditableInput.prototype = copyObj({ }, pollContent: function() { + if (this.readDOMTimeout != null) { + clearTimeout(this.readDOMTimeout) + this.readDOMTimeout = null + } + let cm = this.cm, display = cm.display, sel = cm.doc.sel.primary() let from = sel.from(), to = sel.to() if (from.line < display.viewFrom || to.line > display.viewTo - 1) return false @@ -309,17 +295,20 @@ ContentEditableInput.prototype = copyObj({ this.forceCompositionEnd() }, forceCompositionEnd: function() { - if (!this.composing || this.composing.handled) return - this.applyComposition(this.composing) - this.composing.handled = true + if (!this.composing) return + this.composing = null + if (!this.pollContent()) regChange(this.cm) this.div.blur() this.div.focus() }, - applyComposition: function(composing) { - if (this.cm.isReadOnly()) - operation(this.cm, regChange)(this.cm) - else if (composing.data && composing.data != composing.startData) - operation(this.cm, applyTextInput)(this.cm, composing.data, 0, composing.sel) + readFromDOMSoon: function() { + if (this.readDOMTimeout != null) return + this.readDOMTimeout = setTimeout(() => { + this.readDOMTimeout = null + if (this.composing) return + if (this.cm.isReadOnly() || !this.pollContent()) + runInOp(this.cm, () => regChange(this.cm)) + }, 80) }, setUneditable: function(node) { From d7b1370ca45d742c0961ce98d25ea2c2d3f0f484 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Tue, 15 Nov 2016 17:04:49 +0100 Subject: [PATCH 0678/2444] Copy event handler arrays on write Rather than on read --- src/util/event.js | 35 ++++++++++++++++++----------------- src/util/operation_group.js | 2 +- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/src/util/event.js b/src/util/event.js index e667a9f3c0..29fd4c5981 100644 --- a/src/util/event.js +++ b/src/util/event.js @@ -6,39 +6,40 @@ import { indexOf } from "./misc" // Lightweight event framework. on/off also work on DOM nodes, // registering native DOM handlers. +const noHandlers = [] + export let on = function(emitter, type, f) { - if (emitter.addEventListener) + if (emitter.addEventListener) { emitter.addEventListener(type, f, false) - else if (emitter.attachEvent) + } else if (emitter.attachEvent) { emitter.attachEvent("on" + type, f) - else { + } else { let map = emitter._handlers || (emitter._handlers = {}) - let arr = map[type] || (map[type] = []) - arr.push(f) + map[type] = (map[type] || noHandlers).concat(f) } } -let noHandlers = [] -export function getHandlers(emitter, type, copy) { - let arr = emitter._handlers && emitter._handlers[type] - if (copy) return arr && arr.length > 0 ? arr.slice() : noHandlers - else return arr || noHandlers +export function getHandlers(emitter, type) { + return emitter._handlers && emitter._handlers[type] || noHandlers } export function off(emitter, type, f) { - if (emitter.removeEventListener) + if (emitter.removeEventListener) { emitter.removeEventListener(type, f, false) - else if (emitter.detachEvent) + } else if (emitter.detachEvent) { emitter.detachEvent("on" + type, f) - else { - let handlers = getHandlers(emitter, type, false) - for (let i = 0; i < handlers.length; ++i) - if (handlers[i] == f) { handlers.splice(i, 1); break } + } else { + let map = emitter._handlers, arr = map && map[type] + if (arr) { + let index = indexOf(arr, f) + if (index > -1) + map[type] = arr.slice(0, index).concat(arr.slice(index + 1)) + } } } export function signal(emitter, type /*, values...*/) { - let handlers = getHandlers(emitter, type, true) + let handlers = getHandlers(emitter, type) if (!handlers.length) return let args = Array.prototype.slice.call(arguments, 2) for (let i = 0; i < handlers.length; ++i) handlers[i].apply(null, args) diff --git a/src/util/operation_group.js b/src/util/operation_group.js index f50da343a9..b8fa78ac48 100644 --- a/src/util/operation_group.js +++ b/src/util/operation_group.js @@ -50,7 +50,7 @@ let orphanDelayedCallbacks = null // them to be executed when the last operation ends, or, if no // operation is active, when a timeout fires. export function signalLater(emitter, type /*, values...*/) { - let arr = getHandlers(emitter, type, false) + let arr = getHandlers(emitter, type) if (!arr.length) return let args = Array.prototype.slice.call(arguments, 2), list if (operationGroup) { From 6019b1308d4c513cb327f1e7c3f7ff86f258a217 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Tue, 15 Nov 2016 17:33:10 +0100 Subject: [PATCH 0679/2444] [contenteditable input] Expand scanned range when selection at start/end of line So that the code doesn't get confused when backspacing or deleting across a line. This is still flaky. Ideally we'd capture backspace as a key event, but Android Chrome makes that impossible. Issue #4307 --- src/input/ContentEditableInput.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/input/ContentEditableInput.js b/src/input/ContentEditableInput.js index a7254b12c2..c385bea12e 100644 --- a/src/input/ContentEditableInput.js +++ b/src/input/ContentEditableInput.js @@ -238,6 +238,10 @@ ContentEditableInput.prototype = copyObj({ let cm = this.cm, display = cm.display, sel = cm.doc.sel.primary() let from = sel.from(), to = sel.to() + if (from.ch == 0 && from.line > cm.firstLine()) + from = Pos(from.line - 1, getLine(cm.doc, from.line - 1).length) + if (to.ch == getLine(cm.doc, to.line).text.length && to.line < cm.lastLine()) + to = Pos(to.line + 1, 0) if (from.line < display.viewFrom || to.line > display.viewTo - 1) return false let fromIndex, fromLine, fromNode @@ -258,6 +262,7 @@ ContentEditableInput.prototype = copyObj({ toNode = display.view[toIndex + 1].node.previousSibling } + if (!fromNode) return false let newText = cm.doc.splitLines(domTextBetween(cm, fromNode, toNode, fromLine, toLine)) let oldText = getBetween(cm.doc, Pos(fromLine, 0), Pos(toLine, getLine(cm.doc, toLine).text.length)) while (newText.length > 1 && oldText.length > 1) { From 69669e4b74c30a6fa2c25751970b17daf53cf88c Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Tue, 15 Nov 2016 17:22:20 -0800 Subject: [PATCH 0680/2444] =?UTF-8?q?Avoid=20=E2=80=9CUnspecified=20Error?= =?UTF-8?q?=E2=80=9D=20in=20IE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit when accessing `document.activeElement` from inside an iframe. --- src/util/dom.js | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/util/dom.js b/src/util/dom.js index 465dbb5a5e..349fae07d3 100644 --- a/src/util/dom.js +++ b/src/util/dom.js @@ -1,4 +1,4 @@ -import { ie, ie_version, ios } from "./browser" +import { ie, ios } from "./browser" export function classTest(cls) { return new RegExp("(^|\\s)" + cls + "(?:$|\\s)\\s*") } @@ -58,18 +58,20 @@ export function contains(parent, child) { } while (child = child.parentNode) } -export let activeElt = function() { - let activeElement = document.activeElement +export function activeElt() { + // IE and Edge may throw an "Unspecified Error" when accessing document.activeElement. + // IE < 10 will throw when accessed while the page is loading or in an iframe. + // IE > 9 and Edge will throw when accessed in an iframe if document.body is unavailable. + let activeElement + try { + activeElement = document.activeElement + } catch(e) { + activeElement = document.body || null + } while (activeElement && activeElement.root && activeElement.root.activeElement) activeElement = activeElement.root.activeElement return activeElement } -// Older versions of IE throws unspecified error when touching -// document.activeElement in some cases (during loading, in iframe) -if (ie && ie_version < 11) activeElt = function() { - try { return document.activeElement } - catch(e) { return document.body } -} export function addClass(node, cls) { let current = node.className From 8ecbdc5c6aedbac6b4038d94c30b97bddc950b1b Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Mon, 21 Nov 2016 10:12:06 +0100 Subject: [PATCH 0681/2444] [markdown mode] Allow lists without a blank line above As per CommonMark (conflicting with markdown.pl, but never mind markdown.pl) Closes #4395 --- mode/markdown/markdown.js | 15 ++++----------- mode/markdown/test.js | 7 +++---- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/mode/markdown/markdown.js b/mode/markdown/markdown.js index 3dcce8d3b1..6aedc360b0 100644 --- a/mode/markdown/markdown.js +++ b/mode/markdown/markdown.js @@ -83,9 +83,8 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) { } var hrRE = /^([*\-_])(?:\s*\1){2,}\s*$/ - , ulRE = /^[*\-+]\s+/ - , olRE = /^[0-9]+([.)])\s+/ - , taskListRE = /^\[(x| )\](?=\s)/ // Must follow ulRE or olRE + , listRE = /^(?:[*\-+]|^[0-9]+([.)]))\s+/ + , taskListRE = /^\[(x| )\](?=\s)/ // Must follow listRE , atxHeaderRE = modeCfg.allowAtxHeaderWithoutSpace ? /^(#+)/ : /^(#+)(?: |$)/ , setextHeaderRE = /^ *(?:\={1,}|-{1,})\s*$/ , textRE = /^[^#!\[\]*_\\<>` "'(~]+/ @@ -189,14 +188,8 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) { } else if (stream.match(hrRE, true)) { state.hr = true; return tokenTypes.hr; - } else if ((lineIsEmpty(state.prevLine) || prevLineIsList) && (stream.match(ulRE, false) || stream.match(olRE, false))) { - var listType = null; - if (stream.match(ulRE, true)) { - listType = 'ul'; - } else { - stream.match(olRE, true); - listType = 'ol'; - } + } else if (match = stream.match(listRE)) { + var listType = match[1] ? "ol" : "ul"; state.indentation = stream.column() + stream.current().length; state.list = true; diff --git a/mode/markdown/test.js b/mode/markdown/test.js index 2f43a170ca..37ecb4bbfe 100644 --- a/mode/markdown/test.js +++ b/mode/markdown/test.js @@ -357,11 +357,10 @@ "[variable-2 1. foo]", "[variable-2 2. bar]"); - // Lists require a preceding blank line (per Dingus) - MT("listBogus", + MT("listFromParagraph", "foo", - "1. bar", - "2. hello"); + "[variable-2 1. bar]", + "[variable-2 2. hello]"); // List after hr MT("listAfterHr", From 333a1f2bfb09151f8119b4c4de5ed26c47dba2f1 Mon Sep 17 00:00:00 2001 From: Kazuhito Hokamura Date: Wed, 9 Nov 2016 23:21:13 +0900 Subject: [PATCH 0682/2444] [vim mode] Add keymap to indent --- keymap/vim.js | 5 +++++ test/vim_test.js | 15 +++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/keymap/vim.js b/keymap/vim.js index a166f72b10..34570bb889 100644 --- a/keymap/vim.js +++ b/keymap/vim.js @@ -190,6 +190,8 @@ { keys: '.', type: 'action', action: 'repeatLastEdit' }, { keys: '', type: 'action', action: 'incrementNumberToken', isEdit: true, actionArgs: {increase: true, backtrack: false}}, { keys: '', type: 'action', action: 'incrementNumberToken', isEdit: true, actionArgs: {increase: false, backtrack: false}}, + { keys: '', type: 'action', action: 'indent', actionArgs: { indentRight: true }, context: 'insert' }, + { keys: '', type: 'action', action: 'indent', actionArgs: { indentRight: false }, context: 'insert' }, // Text object motions { keys: 'a', type: 'motion', motion: 'textObjectManipulation' }, { keys: 'i', type: 'motion', motion: 'textObjectManipulation', motionArgs: { textObjectInner: true }}, @@ -2616,6 +2618,9 @@ } repeatLastEdit(cm, vim, repeat, false /** repeatForInsert */); }, + indent: function(cm, actionArgs) { + cm.indentLine(cm.getCursor().line, actionArgs.indentRight); + }, exitInsertMode: exitInsertMode }; diff --git a/test/vim_test.js b/test/vim_test.js index 6eea5553db..703a07a779 100644 --- a/test/vim_test.js +++ b/test/vim_test.js @@ -3393,6 +3393,21 @@ testVim('[m, ]m, [M, ]M', function(cm, vim, helpers) { helpers.assertCursorAt(7,3); }, { value: squareBracketMotionSandbox}); +testVim('i_indent_right', function(cm, vim, helpers) { + cm.setCursor(0, 3); + var expectedValue = ' word1\nword2\nword3 '; + helpers.doKeys('i', ''); + eq(expectedValue, cm.getValue()); + helpers.assertCursorAt(0, 5); +}, { value: ' word1\nword2\nword3 ', indentUnit: 2 }); +testVim('i_indent_left', function(cm, vim, helpers) { + cm.setCursor(0, 3); + var expectedValue = ' word1\nword2\nword3 '; + helpers.doKeys('i', ''); + eq(expectedValue, cm.getValue()); + helpers.assertCursorAt(0, 1); +}, { value: ' word1\nword2\nword3 ', indentUnit: 2 }); + // Ex mode tests testVim('ex_go_to_line', function(cm, vim, helpers) { cm.setCursor(0, 0); From 692393d609e4cc96a1726830ff161c3f4e56670e Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Mon, 21 Nov 2016 10:49:06 +0100 Subject: [PATCH 0683/2444] Drop zero-width spaces in text read from DOM Issue #4307 --- src/input/ContentEditableInput.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/input/ContentEditableInput.js b/src/input/ContentEditableInput.js index c385bea12e..d76058ffd5 100644 --- a/src/input/ContentEditableInput.js +++ b/src/input/ContentEditableInput.js @@ -282,8 +282,8 @@ ContentEditableInput.prototype = copyObj({ newBot.charCodeAt(newBot.length - cutEnd - 1) == oldBot.charCodeAt(oldBot.length - cutEnd - 1)) ++cutEnd - newText[newText.length - 1] = newBot.slice(0, newBot.length - cutEnd) - newText[0] = newText[0].slice(cutFront) + newText[newText.length - 1] = newBot.slice(0, newBot.length - cutEnd).replace(/^\u200b+/, "") + newText[0] = newText[0].slice(cutFront).replace(/\u200b+$/, "") let chFrom = Pos(fromLine, cutFront) let chTo = Pos(toLine, oldText.length ? lst(oldText).length - cutEnd : 0) @@ -361,8 +361,8 @@ function domTextBetween(cm, from, to, fromLine, toLine) { if (node.nodeType == 1) { let cmText = node.getAttribute("cm-text") if (cmText != null) { - if (cmText == "") cmText = node.textContent.replace(/\u200b/g, "") - text += cmText + if (cmText == "") text += node.textContent.replace(/\u200b/g, "") + else text += cmText return } let markerID = node.getAttribute("cm-marker"), range From b63d14df7846691db1b45e47ca11409ee3540482 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Mon, 21 Nov 2016 11:12:00 +0100 Subject: [PATCH 0684/2444] Mark release 5.21.0 --- AUTHORS | 10 ++++++++++ CHANGELOG.md | 30 ++++++++++++++++++++++++++++++ doc/manual.html | 2 +- doc/releases.html | 17 +++++++++++++++++ index.html | 2 +- package.json | 2 +- src/edit/main.js | 2 +- 7 files changed, 61 insertions(+), 4 deletions(-) diff --git a/AUTHORS b/AUTHORS index e2cb74a557..09fb4cc852 100644 --- a/AUTHORS +++ b/AUTHORS @@ -10,6 +10,7 @@ adanlobato Adán Lobato Adrian Aichner Adrian Heine +Adrien Bertrand aeroson Ahmad Amireh Ahmad M. Zawawi @@ -85,6 +86,7 @@ Ben Mosher Bernhard Sirlinger Bert Chang Bharad +BigBlueHat Billy Moon binny B Krishna Chaitanya @@ -274,6 +276,7 @@ Jeff Pickhardt jem (graphite) Jeremy Parmenter Jim +Jim Avery JobJob jochenberger Jochen Berger @@ -281,6 +284,7 @@ Joel Einbinder joelpinheiro Johan Ask John Connor +John-David Dalton John Engler John Lees-Miller John Snelson @@ -311,6 +315,7 @@ jwallers@gmail.com kaniga karevn Kayur Patel +Kazuhito Hokamura Ken Newman ken restivo Ken Rockot @@ -355,6 +360,7 @@ Manideep Manuel Rego Casasnovas Marat Dreizin Marcel Gerber +Marcelo Camargo Marco Aurélio Marco Munizaga Marcus Bointon @@ -455,6 +461,7 @@ Page Panupong Pasupat paris Paris +Paris Kasidiaris Patil Arpith Patrick Stoica Patrick Strawderman @@ -506,6 +513,7 @@ Samuel Ainsworth Sam Wilson sandeepshetty Sander AKA Redsandro +Sander Verweij santec Sascha Peilicke satamas @@ -542,12 +550,14 @@ Steffen Beyer Steffen Bruchmann Stephen Lavelle Steve Champagne +Steve Hoover Steve O'Hara stoskov Stu Kennedy Sungho Kim sverweij Taha Jahangir +takamori Tako Schotanus Takuji Shimokawa Tarmil diff --git a/CHANGELOG.md b/CHANGELOG.md index a7e995ab4b..2404815f88 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,33 @@ +## 5.21.0 (2016-11-21) + +### Bug fixes + +Tapping/clicking the editor in [contentEditable mode](http://codemirror.net/doc/manual.html#option_inputStyle) on Chrome now puts the cursor at the tapped position. + +Fix various crashes and misbehaviors when reading composition events in [contentEditable mode](http://codemirror.net/doc/manual.html#option_inputStyle). + +Catches and ignores an IE 'Unspecified Error' when creating an editor in an iframe before there is a ``. + +[merge addon](http://codemirror.net/doc/manual.html#addon_merge): Fix several issues in the chunk-aligning feature. + +[verilog mode](http://codemirror.net/mode/verilog): Rewritten to address various issues. + +[julia mode](http://codemirror.net/mode/julia): Recognize Julia 0.5 syntax. + +[swift mode](http://codemirror.net/mode/swift): Various fixes and adjustments to current syntax. + +[markdown mode](http://codemirror.net/mode/markdown): Allow lists without a blank line above them. + +### New features + +The [`setGutterMarker`](http://codemirror.net/doc/manual.html#setGutterMarker), [`clearGutter`](http://codemirror.net/doc/manual.html#clearGutter), and [`lineInfo`](http://codemirror.net/doc/manual.html#lineInfo) methods are now available on `Doc` objects. + +The [`heightAtLine`](http://codemirror.net/doc/manual.html#heightAtLine) method now takes an extra argument to allow finding the height at the top of the line's line widgets. + +[ruby mode](http://codemirror.net/mode/ruby): `else` and `elsif` are now immediately indented. + +[vim bindings](http://codemirror.net/demo/vim.html): Bind Ctrl-T and Ctrl-D to in- and dedent in insert mode. + ## 5.20.2 (2016-10-21) ### Bug fixes diff --git a/doc/manual.html b/doc/manual.html index ecfe3071f7..be834f0f10 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -69,7 +69,7 @@

    User manual and reference guide - version 5.20.3 + version 5.21.0

    CodeMirror is a code-editor component that can be embedded in diff --git a/doc/releases.html b/doc/releases.html index cfc366f3e2..5880469189 100644 --- a/doc/releases.html +++ b/doc/releases.html @@ -30,6 +30,23 @@

    Release notes and version history

    Version 5.x

    +

    21-11-2016: Version 5.21.0:

    + +
      +
    • Tapping/clicking the editor in contentEditable mode on Chrome now puts the cursor at the tapped position.
    • +
    • Fix various crashes and misbehaviors when reading composition events in contentEditable mode.
    • +
    • Catches and ignores an IE 'Unspecified Error' when creating an editor in an iframe before there is a <body>.
    • +
    • merge addon: Fix several issues in the chunk-aligning feature.
    • +
    • verilog mode: Rewritten to address various issues.
    • +
    • julia mode: Recognize Julia 0.5 syntax.
    • +
    • swift mode: Various fixes and adjustments to current syntax.
    • +
    • markdown mode: Allow lists without a blank line above them.
    • +
    • The setGutterMarker, clearGutter, and lineInfo methods are now available on Doc objects.
    • +
    • The heightAtLine method now takes an extra argument to allow finding the height at the top of the line's line widgets.
    • +
    • ruby mode: else and elsif are now immediately indented.
    • +
    • vim bindings: Bind Ctrl-T and Ctrl-D to in- and dedent in insert mode.
    • +
    +

    20-10-2016: Version 5.20.0:

      diff --git a/index.html b/index.html index 1d1bb3c8a2..7164296018 100644 --- a/index.html +++ b/index.html @@ -96,7 +96,7 @@

      This is CodeMirror

    - Get the current version: 5.20.2.
    + Get the current version: 5.21.0.
    You can see the code,
    read the release notes,
    or study the user manual. diff --git a/package.json b/package.json index 1d07d681b8..3235a47d8d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "codemirror", - "version": "5.20.3", + "version": "5.21.0", "main": "lib/codemirror.js", "description": "Full-featured in-browser code editor", "license": "MIT", diff --git a/src/edit/main.js b/src/edit/main.js index 57fcffa04e..78c6da49d3 100644 --- a/src/edit/main.js +++ b/src/edit/main.js @@ -66,4 +66,4 @@ import { addLegacyProps } from "./legacy" addLegacyProps(CodeMirror) -CodeMirror.version = "5.20.3" +CodeMirror.version = "5.21.0" From 5fc55e8227b3c0d1d8e3178a45fbb37f6f581e48 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Mon, 21 Nov 2016 11:24:43 +0100 Subject: [PATCH 0685/2444] Bump version number post-5.21.0 --- doc/manual.html | 2 +- package.json | 2 +- src/edit/main.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/manual.html b/doc/manual.html index be834f0f10..05c49718c9 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -69,7 +69,7 @@

    User manual and reference guide - version 5.21.0 + version 5.21.1

    CodeMirror is a code-editor component that can be embedded in diff --git a/package.json b/package.json index 3235a47d8d..d2e45f2f87 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "codemirror", - "version": "5.21.0", + "version": "5.21.1", "main": "lib/codemirror.js", "description": "Full-featured in-browser code editor", "license": "MIT", diff --git a/src/edit/main.js b/src/edit/main.js index 78c6da49d3..64b647b5d2 100644 --- a/src/edit/main.js +++ b/src/edit/main.js @@ -66,4 +66,4 @@ import { addLegacyProps } from "./legacy" addLegacyProps(CodeMirror) -CodeMirror.version = "5.21.0" +CodeMirror.version = "5.21.1" From d0cde7f8470d6638aee972ec29108abd564598e0 Mon Sep 17 00:00:00 2001 From: Todd Berman Date: Tue, 22 Nov 2016 11:23:04 -0800 Subject: [PATCH 0686/2444] [overlay addon] Fix the `combine` option for overlay modes inside blankLines --- addon/mode/overlay.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/addon/mode/overlay.js b/addon/mode/overlay.js index e1b9ed3753..4e96010a65 100644 --- a/addon/mode/overlay.js +++ b/addon/mode/overlay.js @@ -76,8 +76,13 @@ CodeMirror.overlayMode = function(base, overlay, combine) { innerMode: function(state) { return {state: state.base, mode: base}; }, blankLine: function(state) { - if (base.blankLine) base.blankLine(state.base); - if (overlay.blankLine) overlay.blankLine(state.overlay); + var baseToken, overlayToken; + if (base.blankLine) baseToken = base.blankLine(state.base); + if (overlay.blankLine) overlayToken = overlay.blankLine(state.overlay); + + return overlayToken == null ? + baseToken : + (combine ? baseToken + " " + overlayToken : overlayToken); } }; }; From 214b6bf63ccf3d542930a303fe96f5c8f4134365 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Wed, 23 Nov 2016 09:39:07 +0100 Subject: [PATCH 0687/2444] [overlay addon] Fix another append-null-as-string issue --- addon/mode/overlay.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addon/mode/overlay.js b/addon/mode/overlay.js index 4e96010a65..4a9f99a072 100644 --- a/addon/mode/overlay.js +++ b/addon/mode/overlay.js @@ -82,7 +82,7 @@ CodeMirror.overlayMode = function(base, overlay, combine) { return overlayToken == null ? baseToken : - (combine ? baseToken + " " + overlayToken : overlayToken); + (combine && baseToken != null ? baseToken + " " + overlayToken : overlayToken); } }; }; From 8bfabc472acf00eaee0d4a099f3b90d8b5dd47a8 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Wed, 23 Nov 2016 09:42:52 +0100 Subject: [PATCH 0688/2444] [commonlisp mode] Recognize character literal syntax Closes #4401 --- mode/commonlisp/commonlisp.js | 1 + 1 file changed, 1 insertion(+) diff --git a/mode/commonlisp/commonlisp.js b/mode/commonlisp/commonlisp.js index fb1f99c631..5b407a9285 100644 --- a/mode/commonlisp/commonlisp.js +++ b/mode/commonlisp/commonlisp.js @@ -48,6 +48,7 @@ CodeMirror.defineMode("commonlisp", function (config) { else if (/\d/.test(ch) && stream.match(/^\d*#/)) return null; else if (ch == "|") return (state.tokenize = inComment)(stream, state); else if (ch == ":") { readSym(stream); return "meta"; } + else if (ch == "\\") { stream.next(); readSym(stream); return "string-2" } else return "error"; } else { var name = readSym(stream); From 959f8690d2f643ba7730cc847da0154767c29777 Mon Sep 17 00:00:00 2001 From: Adrian Heine Date: Wed, 23 Nov 2016 13:48:29 +0100 Subject: [PATCH 0689/2444] Correct bidi types for some chars --- src/util/bidi.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/util/bidi.js b/src/util/bidi.js index 4c365f4c9b..6812d4fdeb 100644 --- a/src/util/bidi.js +++ b/src/util/bidi.js @@ -121,12 +121,12 @@ export function moveLogically(line, start, dir, byUnit) { export let bidiOrdering = (function() { // Character types for codepoints 0 to 0xff let lowTypes = "bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN" - // Character types for codepoints 0x600 to 0x6ff - let arabicTypes = "rrrrrrrrrrrr,rNNmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmrrrrrrrnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmNmmmm" + // Character types for codepoints 0x600 to 0x6f9 + let arabicTypes = "rrrrrrrrrrrr,rNNmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmrrrrrrrnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmrrmmNmmmmrr1111111111" function charType(code) { if (code <= 0xf7) return lowTypes.charAt(code) else if (0x590 <= code && code <= 0x5f4) return "R" - else if (0x600 <= code && code <= 0x6ed) return arabicTypes.charAt(code - 0x600) + else if (0x600 <= code && code <= 0x6f9) return arabicTypes.charAt(code - 0x600) else if (0x6ee <= code && code <= 0x8ac) return "r" else if (0x2000 <= code && code <= 0x200b) return "w" else if (code == 0x200c) return "b" From dac0b89f8cd14b4dd64d657db6e35e4c320659ac Mon Sep 17 00:00:00 2001 From: Adrian Heine Date: Thu, 24 Nov 2016 11:38:45 +0100 Subject: [PATCH 0690/2444] Correct bidi types for remaining Arabic chars --- src/util/bidi.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/bidi.js b/src/util/bidi.js index 6812d4fdeb..6a84914035 100644 --- a/src/util/bidi.js +++ b/src/util/bidi.js @@ -122,7 +122,7 @@ export let bidiOrdering = (function() { // Character types for codepoints 0 to 0xff let lowTypes = "bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN" // Character types for codepoints 0x600 to 0x6f9 - let arabicTypes = "rrrrrrrrrrrr,rNNmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmrrrrrrrnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmrrmmNmmmmrr1111111111" + let arabicTypes = "nnnnnnNNr%%r,rNNmmmmmmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmmmnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmnNmmmmmmrrmmNmmmmrr1111111111" function charType(code) { if (code <= 0xf7) return lowTypes.charAt(code) else if (0x590 <= code && code <= 0x5f4) return "R" From 2bed274eb4287624cdc5c07762a32c4042e3b3dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oskar=20Segersv=C3=A4rd?= Date: Fri, 25 Nov 2016 14:42:07 +0100 Subject: [PATCH 0691/2444] [soy mode] Extend and add tests Add template/variable definitions, checking, types, additional keywords and indentation fixes. --- mode/soy/soy.js | 123 ++++++++++++++++++++++++++++++++++++++++++----- mode/soy/test.js | 75 +++++++++++++++++++++++++++++ test/index.html | 2 + 3 files changed, 189 insertions(+), 11 deletions(-) create mode 100644 mode/soy/test.js diff --git a/mode/soy/soy.js b/mode/soy/soy.js index 580c306f15..9fd75c6d27 100644 --- a/mode/soy/soy.js +++ b/mode/soy/soy.js @@ -45,12 +45,40 @@ return result; } + function contains(list, element) { + while (list) { + if (list.element === element) return true; + list = list.next; + } + return false; + } + + function prepend(list, element) { + return { + element: element, + next: list + }; + } + + function pop(list) { + return list && list.next; + } + + // Reference a variable `name` in `list`. + // Let `loose` be truthy to ignore missing identifiers. + function ref(list, name, loose) { + return contains(list, name) ? "variable-2" : (loose ? "variable" : "variable-2 error"); + } + return { startState: function() { return { kind: [], kindTag: [], soyState: [], + templates: null, + variables: null, + scopes: null, indent: 0, localMode: modes.html, localState: CodeMirror.startState(modes.html) @@ -63,6 +91,9 @@ kind: state.kind.concat([]), // Values of kind="" attributes. kindTag: state.kindTag.concat([]), // Opened tags with kind="" attributes. soyState: state.soyState.concat([]), + templates: state.templates, + variables: state.variables, + scopes: state.scopes, indent: state.indent, // Indentation of the following line. localMode: state.localMode, localState: CodeMirror.copyState(state.localMode, state.localState) @@ -81,19 +112,71 @@ } return "comment"; - case "variable": - if (stream.match(/^}/)) { - state.indent -= 2 * config.indentUnit; + case "templ-def": + if (match = stream.match(/^\.?([\w]+(?!\.[\w]+)*)/)) { + state.templates = prepend(state.templates, match[1]); + state.scopes = prepend(state.scopes, state.variables); + state.soyState.pop(); + return "def"; + } + stream.next(); + return null; + + case "templ-ref": + if (match = stream.match(/^\.?([\w]+)/)) { + state.soyState.pop(); + // If the first character is '.', try to match against a local template name. + if (match[0][0] == '.') { + return ref(state.templates, match[1], true); + } + // Otherwise + return "variable"; + } + stream.next(); + return null; + + case "param-def": + if (match = stream.match(/^([\w]+)(?=:)/)) { + state.variables = prepend(state.variables, match[1]); state.soyState.pop(); - return "variable-2"; + state.soyState.push("param-type"); + return "def"; + } + stream.next(); + return null; + + case "param-type": + if (stream.peek() == "}") { + state.soyState.pop(); + return null; + } + if (stream.eatWhile(/^[\w]+/)) { + return "variable-3"; + } + stream.next(); + return null; + + case "var-def": + if (match = stream.match(/^\$([\w]+)/)) { + state.variables = prepend(state.variables, match[1]); + state.soyState.pop(); + return "def"; } stream.next(); return null; case "tag": if (stream.match(/^\/?}/)) { - if (state.tag == "/template" || state.tag == "/deltemplate") state.indent = 0; - else state.indent -= (stream.current() == "/}" || indentingTags.indexOf(state.tag) == -1 ? 2 : 1) * config.indentUnit; + if (state.tag == "/template" || state.tag == "/deltemplate") { + state.variables = state.scopes = pop(state.scopes); + state.indent = 0; + } else { + if (state.tag == "/for" || state.tag == "/foreach") { + state.variables = state.scopes = pop(state.scopes); + } + state.indent -= config.indentUnit * + (stream.current() == "/}" || indentingTags.indexOf(state.tag) == -1 ? 2 : 1); + } state.soyState.pop(); return "keyword"; } else if (stream.match(/^([\w?]+)(?==)/)) { @@ -109,6 +192,12 @@ state.soyState.push("string"); return "string"; } + if (match = stream.match(/^\$([\w]+)/)) { + return ref(state.variables, match[1]); + } + if (stream.match(/(?:as|and|or|not|in)/)) { + return "keyword"; + } stream.next(); return null; @@ -135,17 +224,13 @@ return "comment"; } else if (stream.match(stream.sol() ? /^\s*\/\/.*/ : /^\s+\/\/.*/)) { return "comment"; - } else if (stream.match(/^\{\$[\w?]*/)) { - state.indent += 2 * config.indentUnit; - state.soyState.push("variable"); - return "variable-2"; } else if (stream.match(/^\{literal}/)) { state.indent += config.indentUnit; state.soyState.push("literal"); return "keyword"; } else if (match = stream.match(/^\{([\/@\\]?[\w?]*)/)) { if (match[1] != "/switch") - state.indent += (/^(\/|(else|elseif|case|default)$)/.test(match[1]) && state.tag != "switch" ? 1 : 2) * config.indentUnit; + state.indent += (/^(\/|(else|elseif|ifempty|case|default)$)/.test(match[1]) && state.tag != "switch" ? 1 : 2) * config.indentUnit; state.tag = match[1]; if (state.tag == "/" + last(state.kindTag)) { // We found the tag that opened the current kind="". @@ -155,6 +240,22 @@ state.localState = CodeMirror.startState(state.localMode); } state.soyState.push("tag"); + if (state.tag == "template" || state.tag == "deltemplate") { + state.soyState.push("templ-def"); + } + if (state.tag == "call" || state.tag == "delcall") { + state.soyState.push("templ-ref"); + } + if (state.tag == "let") { + state.soyState.push("var-def"); + } + if (state.tag == "for" || state.tag == "foreach") { + state.scopes = prepend(state.scopes, state.variables); + state.soyState.push("var-def"); + } + if (state.tag.match(/^@param\??/)) { + state.soyState.push("param-def"); + } return "keyword"; } diff --git a/mode/soy/test.js b/mode/soy/test.js new file mode 100644 index 0000000000..1a962de3e7 --- /dev/null +++ b/mode/soy/test.js @@ -0,0 +1,75 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: http://codemirror.net/LICENSE + +(function() { + var mode = CodeMirror.getMode({indentUnit: 2}, "soy"); + function MT(name) {test.mode(name, mode, Array.prototype.slice.call(arguments, 1));} + + MT('let-test', + '[keyword {template] [def .name][keyword }]', + ' [keyword {let] [def $name]: [string "world"][keyword /}]', + ' [tag&bracket <][tag h1][tag&bracket >]', + ' Hello, [keyword {][variable-2 $name][keyword }]', + ' [tag&bracket ]', + '[keyword {/template}]', + ''); + + MT('param-type-test', + '[keyword {@param] [def a]: ' + + '[variable-3 list]<[[[variable-3 a]: [variable-3 int], ' + + '[variable-3 b]: [variable-3 map]<[variable-3 string], ' + + '[variable-3 bool]>]]>][keyword }]'); + + MT('undefined-var', + '[keyword {][variable-2&error $var]'); + + MT('param-scope-test', + '[keyword {template] [def .a][keyword }]', + ' [keyword {@param] [def x]: [variable-3 string][keyword }]', + ' [keyword {][variable-2 $x][keyword }]', + '[keyword {/template}]', + '', + '[keyword {template] [def .b][keyword }]', + ' [keyword {][variable-2&error $x][keyword }]', + '[keyword {/template}]', + ''); + + MT('if-variable-test', + '[keyword {if] [variable-2&error $showThing][keyword }]', + ' Yo!', + '[keyword {/if}]', + ''); + + MT('defined-if-variable-test', + '[keyword {template] [def .foo][keyword }]', + ' [keyword {@param?] [def showThing]: [variable-3 bool][keyword }]', + ' [keyword {if] [variable-2 $showThing][keyword }]', + ' Yo!', + ' [keyword {/if}]', + '[keyword {/template}]', + ''); + + MT('template-calls-test', + '[keyword {template] [def .foo][keyword }]', + ' Yo!', + '[keyword {/template}]', + '[keyword {call] [variable-2 .foo][keyword /}]', + '[keyword {call] [variable foo][keyword /}]', + '[keyword {call] [variable .bar][keyword /}]', + '[keyword {call] [variable bar][keyword /}]', + ''); + + MT('foreach-scope-test', + '[keyword {foreach] [def $foo] [keyword in] [variable-2&error $foos][keyword }]', + ' [keyword {][variable-2 $foo][keyword }]', + '[keyword {/foreach}]', + '[keyword {][variable-2&error $foo][keyword }]'); + + MT('foreach-ifempty-indent-test', + '[keyword {foreach] [def $foo] [keyword in] [variable-2&error $foos][keyword }]', + ' something', + '[keyword {ifempty}]', + ' nothing', + '[keyword {/foreach}]', + ''); +})(); diff --git a/test/index.html b/test/index.html index cfa3bb71fb..6ddf5b1021 100644 --- a/test/index.html +++ b/test/index.html @@ -33,6 +33,7 @@ + @@ -122,6 +123,7 @@

    Test Suite

    + From 0d296633aa4f297741a09ad8efa031589f6b2d9c Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 24 Nov 2016 17:38:01 +0200 Subject: [PATCH 0692/2444] [npmignore] add files that do nothing when installed with npm --- .npmignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.npmignore b/.npmignore index 5ed053f893..de3a24080b 100644 --- a/.npmignore +++ b/.npmignore @@ -8,3 +8,5 @@ /mode/*/*.html /mode/index.html .* +bin +rollup.config.js From 69159ccd6780c51526f112a9e028b46fbf6ecb42 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Sat, 3 Dec 2016 10:18:14 +0100 Subject: [PATCH 0693/2444] [sublime bindings] Make selectBetweenBrackets multi-cursor-aware Closes #4419 --- keymap/sublime.js | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/keymap/sublime.js b/keymap/sublime.js index 98fce4d302..171e692e67 100644 --- a/keymap/sublime.js +++ b/keymap/sublime.js @@ -166,17 +166,23 @@ var mirror = "(){}[]"; function selectBetweenBrackets(cm) { - var pos = cm.getCursor(), opening = cm.scanForBracket(pos, -1); - if (!opening) return; - for (;;) { - var closing = cm.scanForBracket(pos, 1); - if (!closing) return; - if (closing.ch == mirror.charAt(mirror.indexOf(opening.ch) + 1)) { - cm.setSelection(Pos(opening.pos.line, opening.pos.ch + 1), closing.pos, false); - return true; + var ranges = cm.listSelections(), newRanges = [] + for (var i = 0; i < ranges.length; i++) { + let range = ranges[i], pos = range.head, opening = cm.scanForBracket(pos, -1); + if (!opening) return false; + for (;;) { + var closing = cm.scanForBracket(pos, 1); + if (!closing) return false; + if (closing.ch == mirror.charAt(mirror.indexOf(opening.ch) + 1)) { + newRanges.push({anchor: Pos(opening.pos.line, opening.pos.ch + 1), + head: closing.pos}); + break; + } + pos = Pos(closing.pos.line, closing.pos.ch + 1); } - pos = Pos(closing.pos.line, closing.pos.ch + 1); } + cm.setSelections(newRanges); + return true; } cmds[map["Shift-" + ctrl + "Space"] = "selectScope"] = function(cm) { From af766c48523eb70cbf672fae6165c7612ad04e1a Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Sat, 3 Dec 2016 10:22:14 +0100 Subject: [PATCH 0694/2444] Fix accidental use of 'let' --- keymap/sublime.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/keymap/sublime.js b/keymap/sublime.js index 171e692e67..c5d2906bc0 100644 --- a/keymap/sublime.js +++ b/keymap/sublime.js @@ -168,7 +168,7 @@ function selectBetweenBrackets(cm) { var ranges = cm.listSelections(), newRanges = [] for (var i = 0; i < ranges.length; i++) { - let range = ranges[i], pos = range.head, opening = cm.scanForBracket(pos, -1); + var range = ranges[i], pos = range.head, opening = cm.scanForBracket(pos, -1); if (!opening) return false; for (;;) { var closing = cm.scanForBracket(pos, 1); From 5e342f21ed72f87f77f70e5ac69f111e32470704 Mon Sep 17 00:00:00 2001 From: Andrew Cheng Date: Wed, 7 Dec 2016 02:33:06 -0500 Subject: [PATCH 0695/2444] [emacs keymap] export kill, killRegion, repeated so other potential emacs-type modules can use --- keymap/emacs.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/keymap/emacs.js b/keymap/emacs.js index 3eec1e5762..57cf6e8525 100644 --- a/keymap/emacs.js +++ b/keymap/emacs.js @@ -271,6 +271,8 @@ clearMark(cm); } + CodeMirror.emacs = {kill: kill, killRegion: killRegion, repeated: repeated}; + // Actual keymap var keyMap = CodeMirror.keyMap.emacs = CodeMirror.normalizeKeyMap({ From 7760d1bb83f1f881834e9ee8ea780baeb01936e5 Mon Sep 17 00:00:00 2001 From: Adrian Heine Date: Fri, 9 Dec 2016 10:54:48 +0100 Subject: [PATCH 0696/2444] Add U+061C Arabic Letter Mark to special chars --- src/edit/options.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/edit/options.js b/src/edit/options.js index ea19d5ba2a..97587f73e4 100644 --- a/src/edit/options.js +++ b/src/edit/options.js @@ -68,7 +68,7 @@ export function defineOptions(CodeMirror) { for (let i = newBreaks.length - 1; i >= 0; i--) replaceRange(cm.doc, val, newBreaks[i], Pos(newBreaks[i].line, newBreaks[i].ch + val.length)) }) - option("specialChars", /[\u0000-\u001f\u007f\u00ad\u200b-\u200f\u2028\u2029\ufeff]/g, (cm, val, old) => { + option("specialChars", /[\u0000-\u001f\u007f\u00ad\u061c\u200b-\u200f\u2028\u2029\ufeff]/g, (cm, val, old) => { cm.state.specialChars = new RegExp(val.source + (val.test("\t") ? "" : "|\t"), "g") if (old != Init) cm.refresh() }) From 41804498097a446ee55390f2f90d27804d371c9f Mon Sep 17 00:00:00 2001 From: Tom Klancer Date: Wed, 30 Nov 2016 17:47:38 -0500 Subject: [PATCH 0697/2444] [active-line addon] Highlight active line even when text is selected Adds an option to keep the active line highlighted even when text inside the line is selected. --- addon/selection/active-line.js | 16 ++++++++++++---- demo/activeline.html | 14 +++++++++++++- doc/manual.html | 26 ++++++++++++++++++++------ 3 files changed, 45 insertions(+), 11 deletions(-) diff --git a/addon/selection/active-line.js b/addon/selection/active-line.js index b0b3f61af2..68db3f4d3b 100644 --- a/addon/selection/active-line.js +++ b/addon/selection/active-line.js @@ -3,9 +3,13 @@ // Because sometimes you need to style the cursor's line. // -// Adds an option 'styleActiveLine' which, when enabled, gives the -// active line's wrapping
    the CSS class "CodeMirror-activeline", -// and gives its background
    the class "CodeMirror-activeline-background". +// 'styleActiveLine': when enabled, gives the active line's wrapping +//
    the CSS class "CodeMirror-activeline", and gives its background +//
    the class "CodeMirror-activeline-background". +// +// 'styleActiveSelected': An optional parameter of 'styleActiveLine'. +// When enabled, keeps the active line's styling active even when text is +// selected within the line. Has no effect if 'styleActiveLine' is not enabled. (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS @@ -52,7 +56,11 @@ var active = []; for (var i = 0; i < ranges.length; i++) { var range = ranges[i]; - if (!range.empty()) continue; + if (cm.getOption('styleActiveLine').styleActiveSelected == true) { + if (range.anchor.line != range.head.line) continue; + } else { + if (!range.empty()) continue; + } var line = cm.getLineHandleVisualStart(range.head.line); if (active[active.length - 1] != line) active.push(line); } diff --git a/demo/activeline.html b/demo/activeline.html index 741f6c45a4..7a273a77ee 100644 --- a/demo/activeline.html +++ b/demo/activeline.html @@ -65,14 +65,26 @@

    Active Line Demo

    Styling the current cursor line.

    + + diff --git a/doc/manual.html b/doc/manual.html index 05c49718c9..b5b451ae5c 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -2760,12 +2760,26 @@

    Addons

    like in this demo.
    selection/active-line.js
    -
    Defines a styleActiveLine option that, when enabled, - gives the wrapper of the active line the class CodeMirror-activeline, - adds a background with the class CodeMirror-activeline-background, - and adds the class CodeMirror-activeline-gutter to the - line's gutter space is enabled. See the - demo.
    +
    Controls highlighting of the active line. +
    Defines an option + styleActiveLine which, when enabled, gives the wrapper of + the active line the class CodeMirror-activeline, adds a + background with the class CodeMirror-activeline-background, + and adds the class CodeMirror-activeline-gutter to the + line's gutter space. +
    +
    + In addition, defines an option styleActiveSelected, + that controls highlighting behavior when selected. + styleActiveSelected is an optional parameter of + styleActiveLine. If true, + the active line will remain highlighted when text within the line is + selected. If false or unspecified, the active line will + become unhighlighted as soon as text is selected. Has no effect if + styleActiveLine is not enabled. +
    +
    See the demo.
    +
    selection/selection-pointer.js
    Defines a selectionPointer option which you can From 33d0057f1edbd8e48726bb357ba960645161a8b1 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Tue, 13 Dec 2016 10:53:22 +0100 Subject: [PATCH 0698/2444] [active-line addon] Rename and clean up nonEmpty options Issue #4413 --- addon/selection/active-line.js | 32 +++++++++++--------------------- demo/activeline.html | 14 ++++++-------- doc/manual.html | 34 ++++++++++++++-------------------- 3 files changed, 31 insertions(+), 49 deletions(-) diff --git a/addon/selection/active-line.js b/addon/selection/active-line.js index 68db3f4d3b..aa295d0d86 100644 --- a/addon/selection/active-line.js +++ b/addon/selection/active-line.js @@ -1,16 +1,6 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: http://codemirror.net/LICENSE -// Because sometimes you need to style the cursor's line. -// -// 'styleActiveLine': when enabled, gives the active line's wrapping -//
    the CSS class "CodeMirror-activeline", and gives its background -//
    the class "CodeMirror-activeline-background". -// -// 'styleActiveSelected': An optional parameter of 'styleActiveLine'. -// When enabled, keeps the active line's styling active even when text is -// selected within the line. Has no effect if 'styleActiveLine' is not enabled. - (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror")); @@ -25,16 +15,18 @@ var GUTT_CLASS = "CodeMirror-activeline-gutter"; CodeMirror.defineOption("styleActiveLine", false, function(cm, val, old) { - var prev = old && old != CodeMirror.Init; - if (val && !prev) { - cm.state.activeLines = []; - updateActiveLines(cm, cm.listSelections()); - cm.on("beforeSelectionChange", selectionChange); - } else if (!val && prev) { + var prev = old == CodeMirror.Init ? false : old; + if (val == prev) return + if (prev) { cm.off("beforeSelectionChange", selectionChange); clearActiveLines(cm); delete cm.state.activeLines; } + if (val) { + cm.state.activeLines = []; + updateActiveLines(cm, cm.listSelections()); + cm.on("beforeSelectionChange", selectionChange); + } }); function clearActiveLines(cm) { @@ -56,11 +48,9 @@ var active = []; for (var i = 0; i < ranges.length; i++) { var range = ranges[i]; - if (cm.getOption('styleActiveLine').styleActiveSelected == true) { - if (range.anchor.line != range.head.line) continue; - } else { - if (!range.empty()) continue; - } + var option = cm.getOption("styleActiveLine"); + if (typeof option == "object" && option.nonEmpty ? range.anchor.line != range.head.line : !range.empty()) + continue var line = cm.getLineHandleVisualStart(range.head.line); if (active[active.length - 1] != line) active.push(line); } diff --git a/demo/activeline.html b/demo/activeline.html index 7a273a77ee..86c8c18e1d 100644 --- a/demo/activeline.html +++ b/demo/activeline.html @@ -65,26 +65,24 @@

    Active Line Demo

    Styling the current cursor line.

    - + diff --git a/doc/manual.html b/doc/manual.html index b5b451ae5c..0065790810 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -2760,26 +2760,20 @@

    Addons

    like in this demo.
    selection/active-line.js
    -
    Controls highlighting of the active line. -
    Defines an option - styleActiveLine which, when enabled, gives the wrapper of - the active line the class CodeMirror-activeline, adds a - background with the class CodeMirror-activeline-background, - and adds the class CodeMirror-activeline-gutter to the - line's gutter space. -
    -
    - In addition, defines an option styleActiveSelected, - that controls highlighting behavior when selected. - styleActiveSelected is an optional parameter of - styleActiveLine. If true, - the active line will remain highlighted when text within the line is - selected. If false or unspecified, the active line will - become unhighlighted as soon as text is selected. Has no effect if - styleActiveLine is not enabled. -
    -
    See the demo.
    - +
    Defines a styleActiveLine option that, when + enabled, gives the wrapper of the line that contains the cursor + the class CodeMirror-activeline, adds a background + with the class CodeMirror-activeline-background, + and adds the class CodeMirror-activeline-gutter to + the line's gutter space is enabled. The option's value may be a + boolean or an object specifying the following options: +
    +
    nonEmpty: bool
    +
    Controls whether single-line selections, or just cursor + selections, are styled. Defaults to false (only cursor + selections).
    +
    + See the demo.
    selection/selection-pointer.js
    Defines a selectionPointer option which you can From 460452d73c3a6100662f33bf675e8eca07becaa0 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Tue, 13 Dec 2016 23:05:37 +0100 Subject: [PATCH 0699/2444] =?UTF-8?q?Upgrade=20Bubl=C3=A9,=20use=20namedFu?= =?UTF-8?q?nctionExpressions=20option?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- rollup.config.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index d2e45f2f87..e2b97a9cd1 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "node-static": "0.6.0", "phantomjs-prebuilt": "^2.1.12", "rollup": "^0.34.10", - "rollup-plugin-buble": "^0.14.0", + "rollup-plugin-buble": "^0.15.0", "rollup-watch": "^2.5.0" }, "bugs": "http://github.com/codemirror/CodeMirror/issues", diff --git a/rollup.config.js b/rollup.config.js index 584dfe1ec4..9a17b24ff7 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -14,5 +14,5 @@ export default { format: "umd", dest: "lib/codemirror.js", moduleName: "CodeMirror", - plugins: [ buble() ] + plugins: [ buble({namedFunctionExpressions: false}) ] }; From 957c28f4d8c41afe8b0e0d6ec3a7a454590761ce Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Wed, 14 Dec 2016 08:26:07 +0100 Subject: [PATCH 0700/2444] [javascript mode] Accept strings and numbers as type expressions Closes #4432 --- mode/javascript/javascript.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mode/javascript/javascript.js b/mode/javascript/javascript.js index a717745897..b9f3925951 100644 --- a/mode/javascript/javascript.js +++ b/mode/javascript/javascript.js @@ -539,6 +539,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { } function typeexpr(type) { if (type == "variable") {cx.marked = "variable-3"; return cont(afterType);} + if (type == "string" || type == "number") return cont(afterType); if (type == "{") return cont(commasep(typeprop, "}")) if (type == "(") return cont(commasep(typearg, ")"), maybeReturnType) } @@ -559,6 +560,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { } function afterType(type, value) { if (value == "<") return cont(commasep(typeexpr, ">"), afterType) + if (value == "|") return cont(typeexpr) if (type == "[") return cont(expect("]"), afterType) } function vardef() { From 70ea4303bc4efcdb7ef1956bb6123667440f0a19 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Wed, 14 Dec 2016 18:49:33 +0100 Subject: [PATCH 0701/2444] [source-highlight util] Fix looking up of modes --- bin/source-highlight | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/bin/source-highlight b/bin/source-highlight index 6d15f1ae3f..0d6239c2bc 100755 --- a/bin/source-highlight +++ b/bin/source-highlight @@ -17,14 +17,11 @@ if (sPos == -1 || sPos == process.argv.length - 1) { process.exit(1); } var lang = process.argv[sPos + 1].toLowerCase(), modeName = lang; -CodeMirror.modeInfo.forEach(function(info) { - if (info.mime == lang) { - modeName = info.mode; - } else if (info.name.toLowerCase() == lang) { - modeName = info.mode; - lang = info.mime; - } -}); +var found = CodeMirror.findModeByMIME(lang) || CodeMirror.findModeByName(lang) +if (found) { + modeName = found.mode + lang = found.mime +} if (!CodeMirror.modes[modeName]) require("../mode/" + modeName + "/" + modeName + ".js"); From c2a11a315ebe95478134e9eb94c040f14021df4f Mon Sep 17 00:00:00 2001 From: ficristo Date: Wed, 14 Dec 2016 20:35:27 +0100 Subject: [PATCH 0702/2444] [css mode] Add will-change property and its values --- mode/css/css.js | 12 ++++++------ mode/stylus/stylus.js | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/mode/css/css.js b/mode/css/css.js index 985287f475..a1d5a388e5 100644 --- a/mode/css/css.js +++ b/mode/css/css.js @@ -524,7 +524,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) { "transition-property", "transition-timing-function", "unicode-bidi", "user-select", "vertical-align", "visibility", "voice-balance", "voice-duration", "voice-family", "voice-pitch", "voice-range", "voice-rate", "voice-stress", - "voice-volume", "volume", "white-space", "widows", "width", "word-break", + "voice-volume", "volume", "white-space", "widows", "width", "will-change", "word-break", "word-spacing", "word-wrap", "z-index", // SVG-specific "clip-path", "clip-rule", "mask", "enable-background", "filter", "flood-color", @@ -598,7 +598,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) { "cell", "center", "checkbox", "circle", "cjk-decimal", "cjk-earthly-branch", "cjk-heavenly-stem", "cjk-ideographic", "clear", "clip", "close-quote", "col-resize", "collapse", "color", "color-burn", "color-dodge", "column", "column-reverse", - "compact", "condensed", "contain", "content", + "compact", "condensed", "contain", "content", "contents", "content-box", "context-menu", "continuous", "copy", "counter", "counters", "cover", "crop", "cross", "crosshair", "currentcolor", "cursive", "cyclic", "darken", "dashed", "decimal", "decimal-leading-zero", "default", "default-button", "dense", "destination-atop", @@ -641,7 +641,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) { "mix", "mongolian", "monospace", "move", "multiple", "multiply", "myanmar", "n-resize", "narrower", "ne-resize", "nesw-resize", "no-close-quote", "no-drop", "no-open-quote", "no-repeat", "none", "normal", "not-allowed", "nowrap", - "ns-resize", "numbers", "numeric", "nw-resize", "nwse-resize", "oblique", "octal", "open-quote", + "ns-resize", "numbers", "numeric", "nw-resize", "nwse-resize", "oblique", "octal", "opacity", "open-quote", "optimizeLegibility", "optimizeSpeed", "oriya", "oromo", "outset", "outside", "outside-shape", "overlay", "overline", "padding", "padding-box", "painted", "page", "paused", "persian", "perspective", "plus-darker", "plus-lighter", @@ -653,7 +653,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) { "rgb", "rgba", "ridge", "right", "rotate", "rotate3d", "rotateX", "rotateY", "rotateZ", "round", "row", "row-resize", "row-reverse", "rtl", "run-in", "running", "s-resize", "sans-serif", "saturation", "scale", "scale3d", "scaleX", "scaleY", "scaleZ", "screen", - "scroll", "scrollbar", "se-resize", "searchfield", + "scroll", "scrollbar", "scroll-position", "se-resize", "searchfield", "searchfield-cancel-button", "searchfield-decoration", "searchfield-results-button", "searchfield-results-decoration", "semi-condensed", "semi-expanded", "separate", "serif", "show", "sidama", @@ -671,9 +671,9 @@ CodeMirror.defineMode("css", function(config, parserConfig) { "thick", "thin", "threeddarkshadow", "threedface", "threedhighlight", "threedlightshadow", "threedshadow", "tibetan", "tigre", "tigrinya-er", "tigrinya-er-abegede", "tigrinya-et", "tigrinya-et-abegede", "to", "top", - "trad-chinese-formal", "trad-chinese-informal", + "trad-chinese-formal", "trad-chinese-informal", "transform", "translate", "translate3d", "translateX", "translateY", "translateZ", - "transparent", "ultra-condensed", "ultra-expanded", "underline", "up", + "transparent", "ultra-condensed", "ultra-expanded", "underline", "unset", "up", "upper-alpha", "upper-armenian", "upper-greek", "upper-hexadecimal", "upper-latin", "upper-norwegian", "upper-roman", "uppercase", "urdu", "url", "var", "vertical", "vertical-text", "visible", "visibleFill", "visiblePainted", diff --git a/mode/stylus/stylus.js b/mode/stylus/stylus.js index 662cd03c04..8d83a01807 100644 --- a/mode/stylus/stylus.js +++ b/mode/stylus/stylus.js @@ -732,11 +732,11 @@ var documentTypes_ = ["domain", "regexp", "url", "url-prefix"]; var mediaTypes_ = ["all","aural","braille","handheld","print","projection","screen","tty","tv","embossed"]; var mediaFeatures_ = ["width","min-width","max-width","height","min-height","max-height","device-width","min-device-width","max-device-width","device-height","min-device-height","max-device-height","aspect-ratio","min-aspect-ratio","max-aspect-ratio","device-aspect-ratio","min-device-aspect-ratio","max-device-aspect-ratio","color","min-color","max-color","color-index","min-color-index","max-color-index","monochrome","min-monochrome","max-monochrome","resolution","min-resolution","max-resolution","scan","grid"]; - var propertyKeywords_ = ["align-content","align-items","align-self","alignment-adjust","alignment-baseline","anchor-point","animation","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-timing-function","appearance","azimuth","backface-visibility","background","background-attachment","background-clip","background-color","background-image","background-origin","background-position","background-repeat","background-size","baseline-shift","binding","bleed","bookmark-label","bookmark-level","bookmark-state","bookmark-target","border","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-decoration-break","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","clear","clip","color","color-profile","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","content","counter-increment","counter-reset","crop","cue","cue-after","cue-before","cursor","direction","display","dominant-baseline","drop-initial-after-adjust","drop-initial-after-align","drop-initial-before-adjust","drop-initial-before-align","drop-initial-size","drop-initial-value","elevation","empty-cells","fit","fit-position","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","float-offset","flow-from","flow-into","font","font-feature-settings","font-family","font-kerning","font-language-override","font-size","font-size-adjust","font-stretch","font-style","font-synthesis","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-ligatures","font-variant-numeric","font-variant-position","font-weight","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-position","grid-auto-rows","grid-column","grid-column-end","grid-column-start","grid-row","grid-row-end","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphens","icon","image-orientation","image-rendering","image-resolution","inline-box-align","justify-content","left","letter-spacing","line-break","line-height","line-stacking","line-stacking-ruby","line-stacking-shift","line-stacking-strategy","list-style","list-style-image","list-style-position","list-style-type","margin","margin-bottom","margin-left","margin-right","margin-top","marker-offset","marks","marquee-direction","marquee-loop","marquee-play-count","marquee-speed","marquee-style","max-height","max-width","min-height","min-width","move-to","nav-down","nav-index","nav-left","nav-right","nav-up","object-fit","object-position","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-style","overflow-wrap","overflow-x","overflow-y","padding","padding-bottom","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","page-policy","pause","pause-after","pause-before","perspective","perspective-origin","pitch","pitch-range","play-during","position","presentation-level","punctuation-trim","quotes","region-break-after","region-break-before","region-break-inside","region-fragment","rendering-intent","resize","rest","rest-after","rest-before","richness","right","rotation","rotation-point","ruby-align","ruby-overhang","ruby-position","ruby-span","shape-image-threshold","shape-inside","shape-margin","shape-outside","size","speak","speak-as","speak-header","speak-numeral","speak-punctuation","speech-rate","stress","string-set","tab-size","table-layout","target","target-name","target-new","target-position","text-align","text-align-last","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-style","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-height","text-indent","text-justify","text-outline","text-overflow","text-shadow","text-size-adjust","text-space-collapse","text-transform","text-underline-position","text-wrap","top","transform","transform-origin","transform-style","transition","transition-delay","transition-duration","transition-property","transition-timing-function","unicode-bidi","vertical-align","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","volume","white-space","widows","width","word-break","word-spacing","word-wrap","z-index","clip-path","clip-rule","mask","enable-background","filter","flood-color","flood-opacity","lighting-color","stop-color","stop-opacity","pointer-events","color-interpolation","color-interpolation-filters","color-rendering","fill","fill-opacity","fill-rule","image-rendering","marker","marker-end","marker-mid","marker-start","shape-rendering","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","text-rendering","baseline-shift","dominant-baseline","glyph-orientation-horizontal","glyph-orientation-vertical","text-anchor","writing-mode","font-smoothing","osx-font-smoothing"]; + var propertyKeywords_ = ["align-content","align-items","align-self","alignment-adjust","alignment-baseline","anchor-point","animation","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-timing-function","appearance","azimuth","backface-visibility","background","background-attachment","background-clip","background-color","background-image","background-origin","background-position","background-repeat","background-size","baseline-shift","binding","bleed","bookmark-label","bookmark-level","bookmark-state","bookmark-target","border","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-decoration-break","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","clear","clip","color","color-profile","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","content","counter-increment","counter-reset","crop","cue","cue-after","cue-before","cursor","direction","display","dominant-baseline","drop-initial-after-adjust","drop-initial-after-align","drop-initial-before-adjust","drop-initial-before-align","drop-initial-size","drop-initial-value","elevation","empty-cells","fit","fit-position","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","float-offset","flow-from","flow-into","font","font-feature-settings","font-family","font-kerning","font-language-override","font-size","font-size-adjust","font-stretch","font-style","font-synthesis","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-ligatures","font-variant-numeric","font-variant-position","font-weight","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-position","grid-auto-rows","grid-column","grid-column-end","grid-column-start","grid-row","grid-row-end","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphens","icon","image-orientation","image-rendering","image-resolution","inline-box-align","justify-content","left","letter-spacing","line-break","line-height","line-stacking","line-stacking-ruby","line-stacking-shift","line-stacking-strategy","list-style","list-style-image","list-style-position","list-style-type","margin","margin-bottom","margin-left","margin-right","margin-top","marker-offset","marks","marquee-direction","marquee-loop","marquee-play-count","marquee-speed","marquee-style","max-height","max-width","min-height","min-width","move-to","nav-down","nav-index","nav-left","nav-right","nav-up","object-fit","object-position","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-style","overflow-wrap","overflow-x","overflow-y","padding","padding-bottom","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","page-policy","pause","pause-after","pause-before","perspective","perspective-origin","pitch","pitch-range","play-during","position","presentation-level","punctuation-trim","quotes","region-break-after","region-break-before","region-break-inside","region-fragment","rendering-intent","resize","rest","rest-after","rest-before","richness","right","rotation","rotation-point","ruby-align","ruby-overhang","ruby-position","ruby-span","shape-image-threshold","shape-inside","shape-margin","shape-outside","size","speak","speak-as","speak-header","speak-numeral","speak-punctuation","speech-rate","stress","string-set","tab-size","table-layout","target","target-name","target-new","target-position","text-align","text-align-last","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-style","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-height","text-indent","text-justify","text-outline","text-overflow","text-shadow","text-size-adjust","text-space-collapse","text-transform","text-underline-position","text-wrap","top","transform","transform-origin","transform-style","transition","transition-delay","transition-duration","transition-property","transition-timing-function","unicode-bidi","vertical-align","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","volume","white-space","widows","width","will-change","word-break","word-spacing","word-wrap","z-index","clip-path","clip-rule","mask","enable-background","filter","flood-color","flood-opacity","lighting-color","stop-color","stop-opacity","pointer-events","color-interpolation","color-interpolation-filters","color-rendering","fill","fill-opacity","fill-rule","image-rendering","marker","marker-end","marker-mid","marker-start","shape-rendering","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","text-rendering","baseline-shift","dominant-baseline","glyph-orientation-horizontal","glyph-orientation-vertical","text-anchor","writing-mode","font-smoothing","osx-font-smoothing"]; var nonStandardPropertyKeywords_ = ["scrollbar-arrow-color","scrollbar-base-color","scrollbar-dark-shadow-color","scrollbar-face-color","scrollbar-highlight-color","scrollbar-shadow-color","scrollbar-3d-light-color","scrollbar-track-color","shape-inside","searchfield-cancel-button","searchfield-decoration","searchfield-results-button","searchfield-results-decoration","zoom"]; var fontProperties_ = ["font-family","src","unicode-range","font-variant","font-feature-settings","font-stretch","font-weight","font-style"]; var colorKeywords_ = ["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","grey","green","greenyellow","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"]; - var valueKeywords_ = ["above","absolute","activeborder","additive","activecaption","afar","after-white-space","ahead","alias","all","all-scroll","alphabetic","alternate","always","amharic","amharic-abegede","antialiased","appworkspace","arabic-indic","armenian","asterisks","attr","auto","avoid","avoid-column","avoid-page","avoid-region","background","backwards","baseline","below","bidi-override","binary","bengali","blink","block","block-axis","bold","bolder","border","border-box","both","bottom","break","break-all","break-word","bullets","button","button-bevel","buttonface","buttonhighlight","buttonshadow","buttontext","calc","cambodian","capitalize","caps-lock-indicator","caption","captiontext","caret","cell","center","checkbox","circle","cjk-decimal","cjk-earthly-branch","cjk-heavenly-stem","cjk-ideographic","clear","clip","close-quote","col-resize","collapse","column","compact","condensed","contain","content","content-box","context-menu","continuous","copy","counter","counters","cover","crop","cross","crosshair","currentcolor","cursive","cyclic","dashed","decimal","decimal-leading-zero","default","default-button","destination-atop","destination-in","destination-out","destination-over","devanagari","disc","discard","disclosure-closed","disclosure-open","document","dot-dash","dot-dot-dash","dotted","double","down","e-resize","ease","ease-in","ease-in-out","ease-out","element","ellipse","ellipsis","embed","end","ethiopic","ethiopic-abegede","ethiopic-abegede-am-et","ethiopic-abegede-gez","ethiopic-abegede-ti-er","ethiopic-abegede-ti-et","ethiopic-halehame-aa-er","ethiopic-halehame-aa-et","ethiopic-halehame-am-et","ethiopic-halehame-gez","ethiopic-halehame-om-et","ethiopic-halehame-sid-et","ethiopic-halehame-so-et","ethiopic-halehame-ti-er","ethiopic-halehame-ti-et","ethiopic-halehame-tig","ethiopic-numeric","ew-resize","expanded","extends","extra-condensed","extra-expanded","fantasy","fast","fill","fixed","flat","flex","footnotes","forwards","from","geometricPrecision","georgian","graytext","groove","gujarati","gurmukhi","hand","hangul","hangul-consonant","hebrew","help","hidden","hide","higher","highlight","highlighttext","hiragana","hiragana-iroha","horizontal","hsl","hsla","icon","ignore","inactiveborder","inactivecaption","inactivecaptiontext","infinite","infobackground","infotext","inherit","initial","inline","inline-axis","inline-block","inline-flex","inline-table","inset","inside","intrinsic","invert","italic","japanese-formal","japanese-informal","justify","kannada","katakana","katakana-iroha","keep-all","khmer","korean-hangul-formal","korean-hanja-formal","korean-hanja-informal","landscape","lao","large","larger","left","level","lighter","line-through","linear","linear-gradient","lines","list-item","listbox","listitem","local","logical","loud","lower","lower-alpha","lower-armenian","lower-greek","lower-hexadecimal","lower-latin","lower-norwegian","lower-roman","lowercase","ltr","malayalam","match","matrix","matrix3d","media-controls-background","media-current-time-display","media-fullscreen-button","media-mute-button","media-play-button","media-return-to-realtime-button","media-rewind-button","media-seek-back-button","media-seek-forward-button","media-slider","media-sliderthumb","media-time-remaining-display","media-volume-slider","media-volume-slider-container","media-volume-sliderthumb","medium","menu","menulist","menulist-button","menulist-text","menulist-textfield","menutext","message-box","middle","min-intrinsic","mix","mongolian","monospace","move","multiple","myanmar","n-resize","narrower","ne-resize","nesw-resize","no-close-quote","no-drop","no-open-quote","no-repeat","none","normal","not-allowed","nowrap","ns-resize","numbers","numeric","nw-resize","nwse-resize","oblique","octal","open-quote","optimizeLegibility","optimizeSpeed","oriya","oromo","outset","outside","outside-shape","overlay","overline","padding","padding-box","painted","page","paused","persian","perspective","plus-darker","plus-lighter","pointer","polygon","portrait","pre","pre-line","pre-wrap","preserve-3d","progress","push-button","radial-gradient","radio","read-only","read-write","read-write-plaintext-only","rectangle","region","relative","repeat","repeating-linear-gradient","repeating-radial-gradient","repeat-x","repeat-y","reset","reverse","rgb","rgba","ridge","right","rotate","rotate3d","rotateX","rotateY","rotateZ","round","row-resize","rtl","run-in","running","s-resize","sans-serif","scale","scale3d","scaleX","scaleY","scaleZ","scroll","scrollbar","se-resize","searchfield","searchfield-cancel-button","searchfield-decoration","searchfield-results-button","searchfield-results-decoration","semi-condensed","semi-expanded","separate","serif","show","sidama","simp-chinese-formal","simp-chinese-informal","single","skew","skewX","skewY","skip-white-space","slide","slider-horizontal","slider-vertical","sliderthumb-horizontal","sliderthumb-vertical","slow","small","small-caps","small-caption","smaller","solid","somali","source-atop","source-in","source-out","source-over","space","spell-out","square","square-button","start","static","status-bar","stretch","stroke","sub","subpixel-antialiased","super","sw-resize","symbolic","symbols","table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row","table-row-group","tamil","telugu","text","text-bottom","text-top","textarea","textfield","thai","thick","thin","threeddarkshadow","threedface","threedhighlight","threedlightshadow","threedshadow","tibetan","tigre","tigrinya-er","tigrinya-er-abegede","tigrinya-et","tigrinya-et-abegede","to","top","trad-chinese-formal","trad-chinese-informal","translate","translate3d","translateX","translateY","translateZ","transparent","ultra-condensed","ultra-expanded","underline","up","upper-alpha","upper-armenian","upper-greek","upper-hexadecimal","upper-latin","upper-norwegian","upper-roman","uppercase","urdu","url","var","vertical","vertical-text","visible","visibleFill","visiblePainted","visibleStroke","visual","w-resize","wait","wave","wider","window","windowframe","windowtext","words","x-large","x-small","xor","xx-large","xx-small","bicubic","optimizespeed","grayscale","row","row-reverse","wrap","wrap-reverse","column-reverse","flex-start","flex-end","space-between","space-around"]; + var valueKeywords_ = ["above","absolute","activeborder","additive","activecaption","afar","after-white-space","ahead","alias","all","all-scroll","alphabetic","alternate","always","amharic","amharic-abegede","antialiased","appworkspace","arabic-indic","armenian","asterisks","attr","auto","avoid","avoid-column","avoid-page","avoid-region","background","backwards","baseline","below","bidi-override","binary","bengali","blink","block","block-axis","bold","bolder","border","border-box","both","bottom","break","break-all","break-word","bullets","button","button-bevel","buttonface","buttonhighlight","buttonshadow","buttontext","calc","cambodian","capitalize","caps-lock-indicator","caption","captiontext","caret","cell","center","checkbox","circle","cjk-decimal","cjk-earthly-branch","cjk-heavenly-stem","cjk-ideographic","clear","clip","close-quote","col-resize","collapse","column","compact","condensed","contain","content","contents","content-box","context-menu","continuous","copy","counter","counters","cover","crop","cross","crosshair","currentcolor","cursive","cyclic","dashed","decimal","decimal-leading-zero","default","default-button","destination-atop","destination-in","destination-out","destination-over","devanagari","disc","discard","disclosure-closed","disclosure-open","document","dot-dash","dot-dot-dash","dotted","double","down","e-resize","ease","ease-in","ease-in-out","ease-out","element","ellipse","ellipsis","embed","end","ethiopic","ethiopic-abegede","ethiopic-abegede-am-et","ethiopic-abegede-gez","ethiopic-abegede-ti-er","ethiopic-abegede-ti-et","ethiopic-halehame-aa-er","ethiopic-halehame-aa-et","ethiopic-halehame-am-et","ethiopic-halehame-gez","ethiopic-halehame-om-et","ethiopic-halehame-sid-et","ethiopic-halehame-so-et","ethiopic-halehame-ti-er","ethiopic-halehame-ti-et","ethiopic-halehame-tig","ethiopic-numeric","ew-resize","expanded","extends","extra-condensed","extra-expanded","fantasy","fast","fill","fixed","flat","flex","footnotes","forwards","from","geometricPrecision","georgian","graytext","groove","gujarati","gurmukhi","hand","hangul","hangul-consonant","hebrew","help","hidden","hide","higher","highlight","highlighttext","hiragana","hiragana-iroha","horizontal","hsl","hsla","icon","ignore","inactiveborder","inactivecaption","inactivecaptiontext","infinite","infobackground","infotext","inherit","initial","inline","inline-axis","inline-block","inline-flex","inline-table","inset","inside","intrinsic","invert","italic","japanese-formal","japanese-informal","justify","kannada","katakana","katakana-iroha","keep-all","khmer","korean-hangul-formal","korean-hanja-formal","korean-hanja-informal","landscape","lao","large","larger","left","level","lighter","line-through","linear","linear-gradient","lines","list-item","listbox","listitem","local","logical","loud","lower","lower-alpha","lower-armenian","lower-greek","lower-hexadecimal","lower-latin","lower-norwegian","lower-roman","lowercase","ltr","malayalam","match","matrix","matrix3d","media-controls-background","media-current-time-display","media-fullscreen-button","media-mute-button","media-play-button","media-return-to-realtime-button","media-rewind-button","media-seek-back-button","media-seek-forward-button","media-slider","media-sliderthumb","media-time-remaining-display","media-volume-slider","media-volume-slider-container","media-volume-sliderthumb","medium","menu","menulist","menulist-button","menulist-text","menulist-textfield","menutext","message-box","middle","min-intrinsic","mix","mongolian","monospace","move","multiple","myanmar","n-resize","narrower","ne-resize","nesw-resize","no-close-quote","no-drop","no-open-quote","no-repeat","none","normal","not-allowed","nowrap","ns-resize","numbers","numeric","nw-resize","nwse-resize","oblique","octal","open-quote","optimizeLegibility","optimizeSpeed","oriya","oromo","outset","outside","outside-shape","overlay","overline","padding","padding-box","painted","page","paused","persian","perspective","plus-darker","plus-lighter","pointer","polygon","portrait","pre","pre-line","pre-wrap","preserve-3d","progress","push-button","radial-gradient","radio","read-only","read-write","read-write-plaintext-only","rectangle","region","relative","repeat","repeating-linear-gradient","repeating-radial-gradient","repeat-x","repeat-y","reset","reverse","rgb","rgba","ridge","right","rotate","rotate3d","rotateX","rotateY","rotateZ","round","row-resize","rtl","run-in","running","s-resize","sans-serif","scale","scale3d","scaleX","scaleY","scaleZ","scroll","scrollbar","scroll-position","se-resize","searchfield","searchfield-cancel-button","searchfield-decoration","searchfield-results-button","searchfield-results-decoration","semi-condensed","semi-expanded","separate","serif","show","sidama","simp-chinese-formal","simp-chinese-informal","single","skew","skewX","skewY","skip-white-space","slide","slider-horizontal","slider-vertical","sliderthumb-horizontal","sliderthumb-vertical","slow","small","small-caps","small-caption","smaller","solid","somali","source-atop","source-in","source-out","source-over","space","spell-out","square","square-button","start","static","status-bar","stretch","stroke","sub","subpixel-antialiased","super","sw-resize","symbolic","symbols","table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row","table-row-group","tamil","telugu","text","text-bottom","text-top","textarea","textfield","thai","thick","thin","threeddarkshadow","threedface","threedhighlight","threedlightshadow","threedshadow","tibetan","tigre","tigrinya-er","tigrinya-er-abegede","tigrinya-et","tigrinya-et-abegede","to","top","trad-chinese-formal","trad-chinese-informal","translate","translate3d","translateX","translateY","translateZ","transparent","ultra-condensed","ultra-expanded","underline","up","upper-alpha","upper-armenian","upper-greek","upper-hexadecimal","upper-latin","upper-norwegian","upper-roman","uppercase","urdu","url","var","vertical","vertical-text","visible","visibleFill","visiblePainted","visibleStroke","visual","w-resize","wait","wave","wider","window","windowframe","windowtext","words","x-large","x-small","xor","xx-large","xx-small","bicubic","optimizespeed","grayscale","row","row-reverse","wrap","wrap-reverse","column-reverse","flex-start","flex-end","space-between","space-around", "unset"]; var wordOperatorKeywords_ = ["in","and","or","not","is not","is a","is","isnt","defined","if unless"], blockKeywords_ = ["for","if","else","unless", "from", "to"], From 897bb77e55846cfefca7d84ede99f83cf4b2747e Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Thu, 15 Dec 2016 10:44:28 +0100 Subject: [PATCH 0703/2444] [javascript mode] Recognize TS bool literal types and type names with dots Closes #4437 --- mode/javascript/javascript.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mode/javascript/javascript.js b/mode/javascript/javascript.js index b9f3925951..2ad7a1e970 100644 --- a/mode/javascript/javascript.js +++ b/mode/javascript/javascript.js @@ -539,7 +539,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { } function typeexpr(type) { if (type == "variable") {cx.marked = "variable-3"; return cont(afterType);} - if (type == "string" || type == "number") return cont(afterType); + if (type == "string" || type == "number" || type == "atom") return cont(afterType); if (type == "{") return cont(commasep(typeprop, "}")) if (type == "(") return cont(commasep(typearg, ")"), maybeReturnType) } @@ -560,7 +560,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { } function afterType(type, value) { if (value == "<") return cont(commasep(typeexpr, ">"), afterType) - if (value == "|") return cont(typeexpr) + if (value == "|" || type == ".") return cont(typeexpr) if (type == "[") return cont(expect("]"), afterType) } function vardef() { From b0d8dd4f53fa88d1e6447cf2d759159a53f84229 Mon Sep 17 00:00:00 2001 From: Rishi Goomar Date: Thu, 1 Dec 2016 09:40:09 -0600 Subject: [PATCH 0704/2444] [mode/meta] Allow for syntax highlighting on ".R" files --- mode/meta.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mode/meta.js b/mode/meta.js index 8faf7677df..47364448f1 100644 --- a/mode/meta.js +++ b/mode/meta.js @@ -109,7 +109,7 @@ {name: "Python", mime: "text/x-python", mode: "python", ext: ["BUILD", "bzl", "py", "pyw"], file: /^(BUCK|BUILD)$/}, {name: "Puppet", mime: "text/x-puppet", mode: "puppet", ext: ["pp"]}, {name: "Q", mime: "text/x-q", mode: "q", ext: ["q"]}, - {name: "R", mime: "text/x-rsrc", mode: "r", ext: ["r"], alias: ["rscript"]}, + {name: "R", mime: "text/x-rsrc", mode: "r", ext: ["r", "R"], alias: ["rscript"]}, {name: "reStructuredText", mime: "text/x-rst", mode: "rst", ext: ["rst"], alias: ["rst"]}, {name: "RPM Changes", mime: "text/x-rpm-changes", mode: "rpm"}, {name: "RPM Spec", mime: "text/x-rpm-spec", mode: "rpm", ext: ["spec"]}, From e157e82a86cf1464feb21d81c66218c6d14f6435 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Thu, 15 Dec 2016 11:51:20 +0100 Subject: [PATCH 0705/2444] Add optionChange event Issue #4417 --- doc/manual.html | 3 +++ src/edit/methods.js | 1 + 2 files changed, 4 insertions(+) diff --git a/doc/manual.html b/doc/manual.html index 0065790810..c6745e3ce6 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -639,6 +639,9 @@

    Events

    or resized. Mostly useful to invalidate cached values that depend on the editor or character size.
    +
    "optionChange" (instance: CodeMirror, option: string)
    +
    Dispatched every time an option is changed with setOption.
    +
    "scrollCursorIntoView" (instance: CodeMirror, event: Event)
    Fires when the editor tries to scroll its cursor into view. Can be hooked into to take care of additional scrollable diff --git a/src/edit/methods.js b/src/edit/methods.js index 7efaf20e2c..144e4773f6 100644 --- a/src/edit/methods.js +++ b/src/edit/methods.js @@ -45,6 +45,7 @@ export default function(CodeMirror) { options[option] = value if (optionHandlers.hasOwnProperty(option)) operation(this, optionHandlers[option])(this, value, old) + signal(this, "optionChange", this, option) }, getOption: function(option) {return this.options[option]}, From 35ec5ee2169aae3b0efe8ca437e063833c80f5d9 Mon Sep 17 00:00:00 2001 From: callodacity Date: Sat, 10 Dec 2016 11:11:19 +1100 Subject: [PATCH 0706/2444] [markdown mode] Improve markdown image lookahead --- mode/markdown/markdown.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mode/markdown/markdown.js b/mode/markdown/markdown.js index 6aedc360b0..86c017c3f0 100644 --- a/mode/markdown/markdown.js +++ b/mode/markdown/markdown.js @@ -436,7 +436,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) { return getType(state); } - if (ch === '[' && state.imageMarker) { + if (ch === '[' && stream.match(/[^\]]*\](\(.*\)| ?\[.*?\])/, false) && state.imageMarker) { state.imageMarker = false; state.imageAltText = true if (modeCfg.highlightFormatting) state.formatting = "image"; From 1b9056f861f28d5baed07718eacae9988d0fd266 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Thu, 15 Dec 2016 12:07:22 +0100 Subject: [PATCH 0707/2444] [markdown mode] Make image lookahead a little cheaper Issue #4426 --- mode/markdown/markdown.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mode/markdown/markdown.js b/mode/markdown/markdown.js index 86c017c3f0..4cc1dc6890 100644 --- a/mode/markdown/markdown.js +++ b/mode/markdown/markdown.js @@ -436,7 +436,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) { return getType(state); } - if (ch === '[' && stream.match(/[^\]]*\](\(.*\)| ?\[.*?\])/, false) && state.imageMarker) { + if (ch === '[' && state.imageMarker && stream.match(/[^\]]*\](\(.*?\)| ?\[.*?\])/, false)) { state.imageMarker = false; state.imageAltText = true if (modeCfg.highlightFormatting) state.formatting = "image"; From 12bece3ae4cb814344d1cf3c786f2dc0e7026ad5 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Thu, 15 Dec 2016 12:18:44 +0100 Subject: [PATCH 0708/2444] Remove timeout kludge in guttersChanged Closes #4412 --- src/edit/options.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/edit/options.js b/src/edit/options.js index 97587f73e4..dffc577be6 100644 --- a/src/edit/options.js +++ b/src/edit/options.js @@ -158,7 +158,7 @@ export function defineOptions(CodeMirror) { function guttersChanged(cm) { updateGutters(cm) regChange(cm) - setTimeout(() => alignHorizontally(cm), 20) + alignHorizontally(cm) } function dragDropChanged(cm, value, old) { From 45c54ada1942566a25bc16bb32eb4ebd868ce22a Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Thu, 15 Dec 2016 13:50:31 +0100 Subject: [PATCH 0709/2444] [merge addon] Don't use DMP's cleanupSemantic function It sometimes produces invalid output. Closes #4410 --- addon/merge/merge.js | 1 - 1 file changed, 1 deletion(-) diff --git a/addon/merge/merge.js b/addon/merge/merge.js index f0d746449d..352e27dc6f 100644 --- a/addon/merge/merge.js +++ b/addon/merge/merge.js @@ -571,7 +571,6 @@ var dmp = new diff_match_patch(); function getDiff(a, b) { var diff = dmp.diff_main(a, b); - dmp.diff_cleanupSemantic(diff); // The library sometimes leaves in empty parts, which confuse the algorithm for (var i = 0; i < diff.length; ++i) { var part = diff[i]; From 900659feeb6d4ce95abb68c7d68767c1bb586111 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Thu, 15 Dec 2016 13:54:30 +0100 Subject: [PATCH 0710/2444] Don't autofocus until the editor has a .state property Since the input object might try to read from that on focusing Issue #4439 --- src/edit/CodeMirror.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/edit/CodeMirror.js b/src/edit/CodeMirror.js index a3dc622cf1..3c482c599f 100644 --- a/src/edit/CodeMirror.js +++ b/src/edit/CodeMirror.js @@ -45,7 +45,6 @@ export function CodeMirror(place, options) { themeChanged(this) if (options.lineWrapping) this.display.wrapper.className += " CodeMirror-wrap" - if (options.autofocus && !mobile) display.input.focus() initScrollbars(this) this.state = { @@ -64,6 +63,8 @@ export function CodeMirror(place, options) { specialChars: null } + if (options.autofocus && !mobile) display.input.focus() + // Override magic textarea content restore that IE sometimes does // on our hidden textarea on reload if (ie && ie_version < 11) setTimeout(() => this.display.input.reset(true), 20) From d5d12e0d0a631034c6363e113c808b0d6c466783 Mon Sep 17 00:00:00 2001 From: Adrian Heine Date: Thu, 29 Sep 2016 11:11:38 +0200 Subject: [PATCH 0711/2444] Convert some classes to ES6 --- src/display/scrollbars.js | 81 +++++++++++---------- src/display/update_display.js | 44 ++++++------ src/input/ContentEditableInput.js | 114 +++++++++++++++--------------- src/input/TextareaInput.js | 108 ++++++++++++++-------------- src/util/misc.js | 2 +- 5 files changed, 177 insertions(+), 172 deletions(-) diff --git a/src/display/scrollbars.js b/src/display/scrollbars.js index a85fffe9a5..2026a3b0a1 100644 --- a/src/display/scrollbars.js +++ b/src/display/scrollbars.js @@ -3,7 +3,7 @@ import { on } from "../util/event" import { scrollGap, paddingVert } from "../measurement/position_measurement" import { ie, ie_version, mac, mac_geMountainLion } from "../util/browser" import { updateHeightsInViewport } from "./update_lines" -import { copyObj, Delayed } from "../util/misc" +import { Delayed } from "../util/misc" import { setScrollLeft, setScrollTop } from "./scroll_events" @@ -27,26 +27,26 @@ export function measureForScrollbars(cm) { } } -function NativeScrollbars(place, scroll, cm) { - this.cm = cm - let vert = this.vert = elt("div", [elt("div", null, null, "min-width: 1px")], "CodeMirror-vscrollbar") - let horiz = this.horiz = elt("div", [elt("div", null, null, "height: 100%; min-height: 1px")], "CodeMirror-hscrollbar") - place(vert); place(horiz) - - on(vert, "scroll", () => { - if (vert.clientHeight) scroll(vert.scrollTop, "vertical") - }) - on(horiz, "scroll", () => { - if (horiz.clientWidth) scroll(horiz.scrollLeft, "horizontal") - }) - - this.checkedZeroWidth = false - // Need to set a minimum width to see the scrollbar on IE7 (but must not set it on IE8). - if (ie && ie_version < 8) this.horiz.style.minHeight = this.vert.style.minWidth = "18px" -} +class NativeScrollbars { + constructor(place, scroll, cm) { + this.cm = cm + let vert = this.vert = elt("div", [elt("div", null, null, "min-width: 1px")], "CodeMirror-vscrollbar") + let horiz = this.horiz = elt("div", [elt("div", null, null, "height: 100%; min-height: 1px")], "CodeMirror-hscrollbar") + place(vert); place(horiz) + + on(vert, "scroll", () => { + if (vert.clientHeight) scroll(vert.scrollTop, "vertical") + }) + on(horiz, "scroll", () => { + if (horiz.clientWidth) scroll(horiz.scrollLeft, "horizontal") + }) + + this.checkedZeroWidth = false + // Need to set a minimum width to see the scrollbar on IE7 (but must not set it on IE8). + if (ie && ie_version < 8) this.horiz.style.minHeight = this.vert.style.minWidth = "18px" + } -NativeScrollbars.prototype = copyObj({ - update: function(measure) { + update(measure) { let needsH = measure.scrollWidth > measure.clientWidth + 1 let needsV = measure.scrollHeight > measure.clientHeight + 1 let sWidth = measure.nativeBarWidth @@ -81,23 +81,27 @@ NativeScrollbars.prototype = copyObj({ } return {right: needsV ? sWidth : 0, bottom: needsH ? sWidth : 0} - }, - setScrollLeft: function(pos) { + } + + setScrollLeft(pos) { if (this.horiz.scrollLeft != pos) this.horiz.scrollLeft = pos if (this.disableHoriz) this.enableZeroWidthBar(this.horiz, this.disableHoriz) - }, - setScrollTop: function(pos) { + } + + setScrollTop(pos) { if (this.vert.scrollTop != pos) this.vert.scrollTop = pos if (this.disableVert) this.enableZeroWidthBar(this.vert, this.disableVert) - }, - zeroWidthHack: function() { + } + + zeroWidthHack() { let w = mac && !mac_geMountainLion ? "12px" : "18px" this.horiz.style.height = this.vert.style.width = w this.horiz.style.pointerEvents = this.vert.style.pointerEvents = "none" this.disableHoriz = new Delayed this.disableVert = new Delayed - }, - enableZeroWidthBar: function(bar, delay) { + } + + enableZeroWidthBar(bar, delay) { bar.style.pointerEvents = "auto" function maybeDisable() { // To find out whether the scrollbar is still visible, we @@ -112,22 +116,21 @@ NativeScrollbars.prototype = copyObj({ else delay.set(1000, maybeDisable) } delay.set(1000, maybeDisable) - }, - clear: function() { + } + + clear() { let parent = this.horiz.parentNode parent.removeChild(this.horiz) parent.removeChild(this.vert) } -}, NativeScrollbars.prototype) - -function NullScrollbars() {} +} -NullScrollbars.prototype = copyObj({ - update: function() { return {bottom: 0, right: 0} }, - setScrollLeft: function() {}, - setScrollTop: function() {}, - clear: function() {} -}, NullScrollbars.prototype) +class NullScrollbars { + update() { return {bottom: 0, right: 0} } + setScrollLeft() {} + setScrollTop() {} + clear() {} +} export function updateScrollbars(cm, measure) { if (!measure) measure = measureForScrollbars(cm) diff --git a/src/display/update_display.js b/src/display/update_display.js index 4e016a2515..17d5a069e5 100644 --- a/src/display/update_display.js +++ b/src/display/update_display.js @@ -17,28 +17,30 @@ import { adjustView, countDirtyView, resetView } from "./view_tracking" // DISPLAY DRAWING -export function DisplayUpdate(cm, viewport, force) { - let display = cm.display - - this.viewport = viewport - // Store some values that we'll need later (but don't want to force a relayout for) - this.visible = visibleLines(display, cm.doc, viewport) - this.editorIsHidden = !display.wrapper.offsetWidth - this.wrapperHeight = display.wrapper.clientHeight - this.wrapperWidth = display.wrapper.clientWidth - this.oldDisplayWidth = displayWidth(cm) - this.force = force - this.dims = getDimensions(cm) - this.events = [] -} +export class DisplayUpdate { + constructor(cm, viewport, force) { + let display = cm.display + + this.viewport = viewport + // Store some values that we'll need later (but don't want to force a relayout for) + this.visible = visibleLines(display, cm.doc, viewport) + this.editorIsHidden = !display.wrapper.offsetWidth + this.wrapperHeight = display.wrapper.clientHeight + this.wrapperWidth = display.wrapper.clientWidth + this.oldDisplayWidth = displayWidth(cm) + this.force = force + this.dims = getDimensions(cm) + this.events = [] + } -DisplayUpdate.prototype.signal = function(emitter, type) { - if (hasHandler(emitter, type)) - this.events.push(arguments) -} -DisplayUpdate.prototype.finish = function() { - for (let i = 0; i < this.events.length; i++) - signal.apply(null, this.events[i]) + signal(emitter, type) { + if (hasHandler(emitter, type)) + this.events.push(arguments) + } + finish() { + for (let i = 0; i < this.events.length; i++) + signal.apply(null, this.events[i]) + } } export function maybeClipScrollbars(cm) { diff --git a/src/input/ContentEditableInput.js b/src/input/ContentEditableInput.js index d76058ffd5..57114af681 100644 --- a/src/input/ContentEditableInput.js +++ b/src/input/ContentEditableInput.js @@ -12,21 +12,21 @@ import { getBidiPartAt, getOrder } from "../util/bidi" import { gecko, ie_version } from "../util/browser" import { contains, range, removeChildrenAndAdd, selectInput } from "../util/dom" import { on, signalDOMEvent } from "../util/event" -import { copyObj, Delayed, lst, nothing, sel_dontScroll } from "../util/misc" +import { Delayed, lst, sel_dontScroll } from "../util/misc" // CONTENTEDITABLE INPUT STYLE -export default function ContentEditableInput(cm) { - this.cm = cm - this.lastAnchorNode = this.lastAnchorOffset = this.lastFocusNode = this.lastFocusOffset = null - this.polling = new Delayed() - this.composing = null - this.gracePeriod = false - this.readDOMTimeout = null -} +export default class ContentEditableInput { + constructor(cm) { + this.cm = cm + this.lastAnchorNode = this.lastAnchorOffset = this.lastFocusNode = this.lastFocusOffset = null + this.polling = new Delayed() + this.composing = null + this.gracePeriod = false + this.readDOMTimeout = null + } -ContentEditableInput.prototype = copyObj({ - init: function(display) { + init(display) { let input = this, cm = input.cm let div = input.div = display.lineDiv disableBrowserMagic(div, cm.options.spellcheck) @@ -99,21 +99,21 @@ ContentEditableInput.prototype = copyObj({ } on(div, "copy", onCopyCut) on(div, "cut", onCopyCut) - }, + } - prepareSelection: function() { + prepareSelection() { let result = prepareSelection(this.cm, false) result.focus = this.cm.state.focused return result - }, + } - showSelection: function(info, takeFocus) { + showSelection(info, takeFocus) { if (!info || !this.cm.display.view.length) return if (info.focus || takeFocus) this.showPrimarySelection() this.showMultipleSelections(info) - }, + } - showPrimarySelection: function() { + showPrimarySelection() { let sel = window.getSelection(), prim = this.cm.doc.sel.primary() let curAnchor = domToPos(this.cm, sel.anchorNode, sel.anchorOffset) let curFocus = domToPos(this.cm, sel.focusNode, sel.focusOffset) @@ -154,48 +154,48 @@ ContentEditableInput.prototype = copyObj({ else if (gecko) this.startGracePeriod() } this.rememberSelection() - }, + } - startGracePeriod: function() { + startGracePeriod() { clearTimeout(this.gracePeriod) this.gracePeriod = setTimeout(() => { this.gracePeriod = false if (this.selectionChanged()) this.cm.operation(() => this.cm.curOp.selectionChanged = true) }, 20) - }, + } - showMultipleSelections: function(info) { + showMultipleSelections(info) { removeChildrenAndAdd(this.cm.display.cursorDiv, info.cursors) removeChildrenAndAdd(this.cm.display.selectionDiv, info.selection) - }, + } - rememberSelection: function() { + rememberSelection() { let sel = window.getSelection() this.lastAnchorNode = sel.anchorNode; this.lastAnchorOffset = sel.anchorOffset this.lastFocusNode = sel.focusNode; this.lastFocusOffset = sel.focusOffset - }, + } - selectionInEditor: function() { + selectionInEditor() { let sel = window.getSelection() if (!sel.rangeCount) return false let node = sel.getRangeAt(0).commonAncestorContainer return contains(this.div, node) - }, + } - focus: function() { + focus() { if (this.cm.options.readOnly != "nocursor") { if (!this.selectionInEditor()) this.showSelection(this.prepareSelection(), true) this.div.focus() } - }, - blur: function() { this.div.blur() }, - getField: function() { return this.div }, + } + blur() { this.div.blur() } + getField() { return this.div } - supportsTouch: function() { return true }, + supportsTouch() { return true } - receivedFocus: function() { + receivedFocus() { let input = this if (this.selectionInEditor()) this.pollSelection() @@ -209,15 +209,15 @@ ContentEditableInput.prototype = copyObj({ } } this.polling.set(this.cm.options.pollInterval, poll) - }, + } - selectionChanged: function() { + selectionChanged() { let sel = window.getSelection() return sel.anchorNode != this.lastAnchorNode || sel.anchorOffset != this.lastAnchorOffset || sel.focusNode != this.lastFocusNode || sel.focusOffset != this.lastFocusOffset - }, + } - pollSelection: function() { + pollSelection() { if (!this.composing && this.readDOMTimeout == null && !this.gracePeriod && this.selectionChanged()) { let sel = window.getSelection(), cm = this.cm this.rememberSelection() @@ -228,9 +228,9 @@ ContentEditableInput.prototype = copyObj({ if (anchor.bad || head.bad) cm.curOp.selectionChanged = true }) } - }, + } - pollContent: function() { + pollContent() { if (this.readDOMTimeout != null) { clearTimeout(this.readDOMTimeout) this.readDOMTimeout = null @@ -291,22 +291,22 @@ ContentEditableInput.prototype = copyObj({ replaceRange(cm.doc, newText, chFrom, chTo, "+input") return true } - }, + } - ensurePolled: function() { + ensurePolled() { this.forceCompositionEnd() - }, - reset: function() { + } + reset() { this.forceCompositionEnd() - }, - forceCompositionEnd: function() { + } + forceCompositionEnd() { if (!this.composing) return this.composing = null if (!this.pollContent()) regChange(this.cm) this.div.blur() this.div.focus() - }, - readFromDOMSoon: function() { + } + readFromDOMSoon() { if (this.readDOMTimeout != null) return this.readDOMTimeout = setTimeout(() => { this.readDOMTimeout = null @@ -314,27 +314,27 @@ ContentEditableInput.prototype = copyObj({ if (this.cm.isReadOnly() || !this.pollContent()) runInOp(this.cm, () => regChange(this.cm)) }, 80) - }, + } - setUneditable: function(node) { + setUneditable(node) { node.contentEditable = "false" - }, + } - onKeyPress: function(e) { + onKeyPress(e) { e.preventDefault() if (!this.cm.isReadOnly()) operation(this.cm, applyTextInput)(this.cm, String.fromCharCode(e.charCode == null ? e.keyCode : e.charCode), 0) - }, + } - readOnlyChanged: function(val) { + readOnlyChanged(val) { this.div.contentEditable = String(val != "nocursor") - }, + } - onContextMenu: nothing, - resetPosition: nothing, + onContextMenu() {} + resetPosition() {} +} - needsContentAttribute: true - }, ContentEditableInput.prototype) +ContentEditableInput.prototype.needsContentAttribute = true function posToDOM(cm, pos) { let view = findViewForLine(cm, pos.line) diff --git a/src/input/TextareaInput.js b/src/input/TextareaInput.js index a150f05d16..28b3327376 100644 --- a/src/input/TextareaInput.js +++ b/src/input/TextareaInput.js @@ -9,31 +9,31 @@ import { captureRightClick, ie, ie_version, ios, mac, mobile, presto, webkit } f import { activeElt, removeChildrenAndAdd, selectInput } from "../util/dom" import { e_preventDefault, e_stop, off, on, signalDOMEvent } from "../util/event" import { hasCopyEvent, hasSelection } from "../util/feature_detection" -import { copyObj, Delayed, nothing, sel_dontScroll } from "../util/misc" +import { Delayed, sel_dontScroll } from "../util/misc" // TEXTAREA INPUT STYLE -export default function TextareaInput(cm) { - this.cm = cm - // See input.poll and input.reset - this.prevInput = "" - - // Flag that indicates whether we expect input to appear real soon - // now (after some event like 'keypress' or 'input') and are - // polling intensively. - this.pollingFast = false - // Self-resetting timeout for the poller - this.polling = new Delayed() - // Tracks when input.reset has punted to just putting a short - // string into the textarea instead of the full selection. - this.inaccurateSelection = false - // Used to work around IE issue with selection being forgotten when focus moves away from textarea - this.hasSelection = false - this.composing = null -} - -TextareaInput.prototype = copyObj({ - init: function(display) { +export default class TextareaInput { + constructor(cm) { + this.cm = cm + // See input.poll and input.reset + this.prevInput = "" + + // Flag that indicates whether we expect input to appear real soon + // now (after some event like 'keypress' or 'input') and are + // polling intensively. + this.pollingFast = false + // Self-resetting timeout for the poller + this.polling = new Delayed() + // Tracks when input.reset has punted to just putting a short + // string into the textarea instead of the full selection. + this.inaccurateSelection = false + // Used to work around IE issue with selection being forgotten when focus moves away from textarea + this.hasSelection = false + this.composing = null + } + + init(display) { let input = this, cm = this.cm // Wraps and hides input textarea @@ -112,9 +112,9 @@ TextareaInput.prototype = copyObj({ input.composing = null } }) - }, + } - prepareSelection: function() { + prepareSelection() { // Redraw the selection and/or cursor let cm = this.cm, display = cm.display, doc = cm.doc let result = prepareSelection(cm) @@ -130,9 +130,9 @@ TextareaInput.prototype = copyObj({ } return result - }, + } - showSelection: function(drawn) { + showSelection(drawn) { let cm = this.cm, display = cm.display removeChildrenAndAdd(display.cursorDiv, drawn.cursors) removeChildrenAndAdd(display.selectionDiv, drawn.selection) @@ -140,11 +140,11 @@ TextareaInput.prototype = copyObj({ this.wrapper.style.top = drawn.teTop + "px" this.wrapper.style.left = drawn.teLeft + "px" } - }, + } // Reset the input to correspond to the selection (or to be empty, // when not typing and nothing is selected) - reset: function(typing) { + reset(typing) { if (this.contextMenuPending) return let minimal, selected, cm = this.cm, doc = cm.doc if (cm.somethingSelected()) { @@ -161,41 +161,41 @@ TextareaInput.prototype = copyObj({ if (ie && ie_version >= 9) this.hasSelection = null } this.inaccurateSelection = minimal - }, + } - getField: function() { return this.textarea }, + getField() { return this.textarea } - supportsTouch: function() { return false }, + supportsTouch() { return false } - focus: function() { + focus() { if (this.cm.options.readOnly != "nocursor" && (!mobile || activeElt() != this.textarea)) { try { this.textarea.focus() } catch (e) {} // IE8 will throw if the textarea is display: none or not in DOM } - }, + } - blur: function() { this.textarea.blur() }, + blur() { this.textarea.blur() } - resetPosition: function() { + resetPosition() { this.wrapper.style.top = this.wrapper.style.left = 0 - }, + } - receivedFocus: function() { this.slowPoll() }, + receivedFocus() { this.slowPoll() } // Poll for input changes, using the normal rate of polling. This // runs as long as the editor is focused. - slowPoll: function() { + slowPoll() { if (this.pollingFast) return this.polling.set(this.cm.options.pollInterval, () => { this.poll() if (this.cm.state.focused) this.slowPoll() }) - }, + } // When an event has just come in that is likely to add or change // something in the input textarea, we poll faster, to ensure that // the change appears on the screen quickly. - fastPoll: function() { + fastPoll() { let missed = false, input = this input.pollingFast = true function p() { @@ -204,7 +204,7 @@ TextareaInput.prototype = copyObj({ else {input.pollingFast = false; input.slowPoll()} } input.polling.set(20, p) - }, + } // Read input from the textarea, and update the document to match. // When something is selected, it is present in the textarea, and @@ -212,7 +212,7 @@ TextareaInput.prototype = copyObj({ // used). When nothing is selected, the cursor sits after previously // seen text (can be empty), which is stored in prevInput (we must // not reset the textarea when typing, because that breaks IME). - poll: function() { + poll() { let cm = this.cm, input = this.textarea, prevInput = this.prevInput // Since this is called a *lot*, try to bail out as cheaply as // possible when it is clear that nothing happened. hasSelection @@ -259,18 +259,18 @@ TextareaInput.prototype = copyObj({ } }) return true - }, + } - ensurePolled: function() { + ensurePolled() { if (this.pollingFast && this.poll()) this.pollingFast = false - }, + } - onKeyPress: function() { + onKeyPress() { if (ie && ie_version >= 9) this.hasSelection = null this.fastPoll() - }, + } - onContextMenu: function(e) { + onContextMenu(e) { let input = this, cm = input.cm, display = cm.display, te = input.textarea let pos = posFromMouse(cm, e), scrollPos = display.scroller.scrollTop if (!pos || presto) return // Opera is difficult. @@ -346,13 +346,13 @@ TextareaInput.prototype = copyObj({ } else { setTimeout(rehide, 50) } - }, + } - readOnlyChanged: function(val) { + readOnlyChanged(val) { if (!val) this.reset() - }, + } - setUneditable: nothing, + setUneditable() {} +} - needsContentAttribute: false -}, TextareaInput.prototype) +TextareaInput.prototype.needsContentAttribute = false diff --git a/src/util/misc.js b/src/util/misc.js index c94de8bd2c..2fb90914a8 100644 --- a/src/util/misc.js +++ b/src/util/misc.js @@ -87,7 +87,7 @@ export function insertSorted(array, value, score) { array.splice(pos, 0, value) } -export function nothing() {} +function nothing() {} export function createObj(base, props) { let inst From b557c1592942d29086889e65d4811d59977843ca Mon Sep 17 00:00:00 2001 From: Philipp A Date: Fri, 16 Dec 2016 12:46:39 +0100 Subject: [PATCH 0712/2444] CSS: Allow contextual glyph alternatives MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ligatures were disabled since some editors didn’t allow placing the cursor inside of them. “Contextual alternatives” on the other hand still allow this, therefore this commit enables them to support e.g. Fira Code’s main gimmick. --- lib/codemirror.css | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/codemirror.css b/lib/codemirror.css index d7821d17df..2a6a262282 100644 --- a/lib/codemirror.css +++ b/lib/codemirror.css @@ -249,8 +249,8 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;} position: relative; overflow: visible; -webkit-tap-highlight-color: transparent; - -webkit-font-variant-ligatures: none; - font-variant-ligatures: none; + -webkit-font-variant-ligatures: contextual; + font-variant-ligatures: contextual; } .CodeMirror-wrap pre { word-wrap: break-word; From e7080dcc8ecede7658d2381a17d8a6342c564f94 Mon Sep 17 00:00:00 2001 From: Martin Zagora Date: Mon, 19 Dec 2016 09:16:42 +1100 Subject: [PATCH 0713/2444] add passing test for #4437 --- mode/javascript/test.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/mode/javascript/test.js b/mode/javascript/test.js index 41765e75dd..971829d938 100644 --- a/mode/javascript/test.js +++ b/mode/javascript/test.js @@ -207,6 +207,18 @@ " [keyword private] [property _foo]: [variable-3 string];", "}") + TS("typescript_literal_types", + "[keyword import] [keyword *] [keyword as] [def Sequelize] [keyword from] [string 'sequelize'];", + "[keyword interface] [def MyAttributes] {", + " [property truthy]: [string 'true'] [operator |] [number 1] [operator |] [atom true];", + " [property falsy]: [string 'false'] [operator |] [number 0] [operator |] [atom false];", + "}", + "[keyword interface] [def MyInstance] [keyword extends] [variable-3 Sequelize].[variable-3 Instance] [operator <] [variable-3 MyAttributes] [operator >] {", + " [property rawAttributes]: [variable-3 MyAttributes];", + " [property truthy]: [string 'true'] [operator |] [number 1] [operator |] [atom true];", + " [property falsy]: [string 'false'] [operator |] [number 0] [operator |] [atom false];", + "}") + var jsonld_mode = CodeMirror.getMode( {indentUnit: 2}, {name: "javascript", jsonld: true} From b50e4310a4d6339db6ac55c7c7b3e3ae0117063e Mon Sep 17 00:00:00 2001 From: Martin Zagora Date: Mon, 19 Dec 2016 09:42:22 +1100 Subject: [PATCH 0714/2444] test: double >> breaks typescript parsing --- mode/javascript/test.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/mode/javascript/test.js b/mode/javascript/test.js index 971829d938..a38865d4ae 100644 --- a/mode/javascript/test.js +++ b/mode/javascript/test.js @@ -219,6 +219,18 @@ " [property falsy]: [string 'false'] [operator |] [number 0] [operator |] [atom false];", "}") + TS("typescript_extend_operators", + "[keyword export] [keyword interface] [def UserModel] [keyword extends]", + " [variable-3 Sequelize].[variable-3 Model] [operator <] [variable-3 UserInstance], [variable-3 UserAttributes] [operator >] {", + " [property findById]: (", + " [variable userId]: [variable-3 number]", + " ) [operator =>] [variable-3 Promise] [operator <] [variable-3 Array] [operator <] { [property id], [property name] } [operator >][operator >];", + " [property updateById]: (", + " [variable userId]: [variable-3 number],", + " [variable isActive]: [variable-3 boolean]", + " ) [operator =>] [variable-3 Promise] [operator <] [variable-3 AccountHolderNotificationPreferenceInstance] [operator >];", + " }") + var jsonld_mode = CodeMirror.getMode( {indentUnit: 2}, {name: "javascript", jsonld: true} From c71b86b9890c69f40d7dfdd44a9bb7d197201add Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Mon, 19 Dec 2016 09:59:25 +0100 Subject: [PATCH 0715/2444] [javascript mode] Parse '>>' as two separate ops in TS type param list Closes #4448 --- mode/javascript/javascript.js | 5 +++-- mode/javascript/test.js | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/mode/javascript/javascript.js b/mode/javascript/javascript.js index 2ad7a1e970..10419bf9de 100644 --- a/mode/javascript/javascript.js +++ b/mode/javascript/javascript.js @@ -146,7 +146,8 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { stream.skipToEnd(); return ret("error", "error"); } else if (isOperatorChar.test(ch)) { - stream.eatWhile(isOperatorChar); + if (ch != ">" || !state.lexical || state.lexical.type != ">") + stream.eatWhile(isOperatorChar); return ret("operator", "operator", stream.current()); } else if (wordRE.test(ch)) { stream.eatWhile(wordRE); @@ -559,7 +560,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { else if (type == ":") return cont(typeexpr) } function afterType(type, value) { - if (value == "<") return cont(commasep(typeexpr, ">"), afterType) + if (value == "<") return cont(pushlex(">"), commasep(typeexpr, ">"), poplex, afterType) if (value == "|" || type == ".") return cont(typeexpr) if (type == "[") return cont(expect("]"), afterType) } diff --git a/mode/javascript/test.js b/mode/javascript/test.js index a38865d4ae..2caefea439 100644 --- a/mode/javascript/test.js +++ b/mode/javascript/test.js @@ -224,7 +224,7 @@ " [variable-3 Sequelize].[variable-3 Model] [operator <] [variable-3 UserInstance], [variable-3 UserAttributes] [operator >] {", " [property findById]: (", " [variable userId]: [variable-3 number]", - " ) [operator =>] [variable-3 Promise] [operator <] [variable-3 Array] [operator <] { [property id], [property name] } [operator >][operator >];", + " ) [operator =>] [variable-3 Promise] [operator <] [variable-3 Array] [operator <] { [property id], [property name] } [operator >>];", " [property updateById]: (", " [variable userId]: [variable-3 number],", " [variable isActive]: [variable-3 boolean]", From b411c18740642ebe47ac135e3daeac0a1e58a704 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Mon, 19 Dec 2016 10:24:04 +0100 Subject: [PATCH 0716/2444] Link to elixir mode --- mode/index.html | 1 + 1 file changed, 1 insertion(+) diff --git a/mode/index.html b/mode/index.html index 3a2fe5513e..c0001a53ee 100644 --- a/mode/index.html +++ b/mode/index.html @@ -56,6 +56,7 @@

    Language modes

  • EBNF
  • ECL
  • Eiffel
  • +
  • Elixir
  • Elm
  • Erlang
  • Factor
  • From d756ea1eb931d6ce7aa6f5eb3c8ea2e34a1bce20 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Mon, 19 Dec 2016 15:39:46 +0100 Subject: [PATCH 0717/2444] Make sure composition changes aren't dropped when forced after compositionend event. Issue #4441 --- src/input/ContentEditableInput.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/input/ContentEditableInput.js b/src/input/ContentEditableInput.js index 57114af681..4c7b58ebde 100644 --- a/src/input/ContentEditableInput.js +++ b/src/input/ContentEditableInput.js @@ -40,15 +40,15 @@ export default class ContentEditableInput { }) on(div, "compositionstart", e => { - this.composing = {data: e.data} + this.composing = {data: e.data, done: false} }) on(div, "compositionupdate", e => { - if (!this.composing) this.composing = {data: e.data} + if (!this.composing) this.composing = {data: e.data, done: false} }) on(div, "compositionend", e => { if (this.composing) { if (e.data != this.composing.data) this.readFromDOMSoon() - this.composing = null + this.composing.done = true } }) @@ -301,6 +301,7 @@ export default class ContentEditableInput { } forceCompositionEnd() { if (!this.composing) return + clearTimeout(this.readDOMTimeout) this.composing = null if (!this.pollContent()) regChange(this.cm) this.div.blur() @@ -310,7 +311,10 @@ export default class ContentEditableInput { if (this.readDOMTimeout != null) return this.readDOMTimeout = setTimeout(() => { this.readDOMTimeout = null - if (this.composing) return + if (this.composing) { + if (this.composing.done) this.composing = null + else return + } if (this.cm.isReadOnly() || !this.pollContent()) runInOp(this.cm, () => regChange(this.cm)) }, 80) From 33d920b06a7b52ceffbf9b083e1aab00993caef7 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Tue, 20 Dec 2016 10:12:28 +0100 Subject: [PATCH 0718/2444] [javascript mode] Properly tokenize a regexp after the export keyword Closes #4452 --- mode/javascript/javascript.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mode/javascript/javascript.js b/mode/javascript/javascript.js index 10419bf9de..fe9b805f1f 100644 --- a/mode/javascript/javascript.js +++ b/mode/javascript/javascript.js @@ -12,7 +12,7 @@ "use strict"; function expressionAllowed(stream, state, backUp) { - return /^(?:operator|sof|keyword c|case|new|[\[{}\(,;:]|=>)$/.test(state.lastType) || + return /^(?:operator|sof|keyword c|case|new|export|[\[{}\(,;:]|=>)$/.test(state.lastType) || (state.lastType == "quasi" && /\{\s*$/.test(stream.string.slice(0, stream.pos - (backUp || 0)))) } From 708084a28130a8c22553fd6193b7870ae66fee40 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Tue, 20 Dec 2016 10:21:46 +0100 Subject: [PATCH 0719/2444] [javascript mode] Improve import/export parsing Closes #4451 --- mode/javascript/javascript.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/mode/javascript/javascript.js b/mode/javascript/javascript.js index fe9b805f1f..10fc95bd8a 100644 --- a/mode/javascript/javascript.js +++ b/mode/javascript/javascript.js @@ -658,14 +658,19 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { if (type == ":") return cont(typeexpr, maybeAssign) return pass(functiondef) } - function afterExport(_type, value) { + function afterExport(type, value) { if (value == "*") { cx.marked = "keyword"; return cont(maybeFrom, expect(";")); } if (value == "default") { cx.marked = "keyword"; return cont(expression, expect(";")); } + if (type == "{") return cont(commasep(exportField, "}"), maybeFrom, expect(";")); return pass(statement); } + function exportField(type, value) { + if (value == "as") { cx.marked = "keyword"; return cont(expect("variable")); } + if (type == "variable") return pass(expressionNoComma, exportField); + } function afterImport(type) { if (type == "string") return cont(); - return pass(importSpec, maybeFrom); + return pass(importSpec, maybeMoreImports, maybeFrom); } function importSpec(type, value) { if (type == "{") return contCommasep(importSpec, "}"); @@ -673,6 +678,9 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { if (value == "*") cx.marked = "keyword"; return cont(maybeAs); } + function maybeMoreImports(type) { + if (type == ",") return cont(importSpec, maybeMoreImports) + } function maybeAs(_type, value) { if (value == "as") { cx.marked = "keyword"; return cont(importSpec); } } From ae45e2bdad8bb4a00c7f1cd7f6127a6963d9df8f Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Tue, 20 Dec 2016 14:04:43 +0100 Subject: [PATCH 0720/2444] [javascript mode] Also allow a regexp after 'default' (For 'export default' syntax) Issue #4452 --- mode/javascript/javascript.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mode/javascript/javascript.js b/mode/javascript/javascript.js index 10fc95bd8a..c185106ce4 100644 --- a/mode/javascript/javascript.js +++ b/mode/javascript/javascript.js @@ -12,7 +12,7 @@ "use strict"; function expressionAllowed(stream, state, backUp) { - return /^(?:operator|sof|keyword c|case|new|export|[\[{}\(,;:]|=>)$/.test(state.lastType) || + return /^(?:operator|sof|keyword c|case|new|export|default|[\[{}\(,;:]|=>)$/.test(state.lastType) || (state.lastType == "quasi" && /\{\s*$/.test(stream.string.slice(0, stream.pos - (backUp || 0)))) } From bfdfb212f76f479b3e651daa688f5da6909e7f48 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Tue, 20 Dec 2016 15:40:12 +0100 Subject: [PATCH 0721/2444] Mark version 5.22.0 --- AUTHORS | 4 ++++ CHANGELOG.md | 18 ++++++++++++++++++ doc/manual.html | 2 +- doc/releases.html | 13 ++++++++++++- index.html | 2 +- package.json | 2 +- src/edit/main.js | 2 +- 7 files changed, 38 insertions(+), 5 deletions(-) diff --git a/AUTHORS b/AUTHORS index 09fb4cc852..9b9b3355ba 100644 --- a/AUTHORS +++ b/AUTHORS @@ -45,6 +45,7 @@ Andrea G Andreas Reischuck Andres Taylor Andre von Houck +Andrew Cheng Andrey Fedorov Andrey Klyuchnikov Andrey Lushnikov @@ -186,6 +187,7 @@ fbuchinger feizhang365 Felipe Lalanne Felix Raab +ficristo Filip Noetzel Filip Stollár flack @@ -500,6 +502,7 @@ Remi Nyborg Richard Denton Richard van der Meer Richard Z.H. Wang +Rishi Goomar Robert Crossfield Roberto Abdelkader Martínez Pérez robertop23 @@ -582,6 +585,7 @@ Todd Berman Tomas-A Tomas Varaneckas Tom Erik Støwer +Tom Klancer Tom MacWright Tony Jian Travis Heppe diff --git a/CHANGELOG.md b/CHANGELOG.md index 2404815f88..f3eb79ff5c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,21 @@ +## 5.22.0 (2016-12-20) + +### Bug fixes + +[sublime bindings](http://codemirror.net/demo/sublime.html): Make `selectBetweenBrackets` work with multiple cursors. + +[javascript mode](http://codemirror.net/mode/javascript/): Fix issues with parsing complex TypeScript types, imports, and exports. + +A contentEditable editor instance with autofocus enabled no longer crashes during initializing. + +### New features + +[emacs bindings](http://codemirror.net/demo/emacs.html): Export `CodeMirror.emacs` to allow other addons to hook into Emacs-style functionality. + +[active-line addon](http://codemirror.net/doc/manual.html#addon_active-line): Add `nonEmpty` option. + +New event: [`optionChange`](http://codemirror.net/doc/manual.html#event_optionChange). + ## 5.21.0 (2016-11-21) ### Bug fixes diff --git a/doc/manual.html b/doc/manual.html index c6745e3ce6..704984fc71 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -69,7 +69,7 @@

    User manual and reference guide - version 5.21.1 + version 5.22.0

    CodeMirror is a code-editor component that can be embedded in diff --git a/doc/releases.html b/doc/releases.html index 5880469189..2dfd1fe482 100644 --- a/doc/releases.html +++ b/doc/releases.html @@ -30,7 +30,18 @@

    Release notes and version history

    Version 5.x

    -

    21-11-2016: Version 5.21.0:

    +

    20-12-2016: Version 5.22.0:

    + +
      +
    • sublime bindings: Make selectBetweenBrackets work with multiple cursors.
    • +
    • javascript mode: Fix issues with parsing complex TypeScript types, imports, and exports.
    • +
    • A contentEditable editor instance with autofocus enabled no longer crashes during initializing.
    • +
    • emacs bindings: Export CodeMirror.emacs to allow other addons to hook into Emacs-style functionality.
    • +
    • active-line addon: Add nonEmpty option.
    • +
    • New event: optionChange.
    • +
    + +

    21-11-2016: Version 5.21.0:

    • Tapping/clicking the editor in contentEditable mode on Chrome now puts the cursor at the tapped position.
    • diff --git a/index.html b/index.html index 7164296018..06fdc1567f 100644 --- a/index.html +++ b/index.html @@ -96,7 +96,7 @@

      This is CodeMirror

    - Get the current version: 5.21.0.
    + Get the current version: 5.22.0.
    You can see the code,
    read the release notes,
    or study the user manual. diff --git a/package.json b/package.json index e2b97a9cd1..c007b2a87c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "codemirror", - "version": "5.21.1", + "version": "5.22.0", "main": "lib/codemirror.js", "description": "Full-featured in-browser code editor", "license": "MIT", diff --git a/src/edit/main.js b/src/edit/main.js index 64b647b5d2..8da8f48e3a 100644 --- a/src/edit/main.js +++ b/src/edit/main.js @@ -66,4 +66,4 @@ import { addLegacyProps } from "./legacy" addLegacyProps(CodeMirror) -CodeMirror.version = "5.21.1" +CodeMirror.version = "5.22.0" From adfa066411473c6fe2f3a6fa15e076d52eceeb94 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Tue, 20 Dec 2016 15:52:23 +0100 Subject: [PATCH 0722/2444] Bump version number post-5.22.0 --- doc/manual.html | 2 +- index.html | 2 +- package.json | 2 +- src/edit/main.js | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/manual.html b/doc/manual.html index 704984fc71..98c160946f 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -69,7 +69,7 @@

    User manual and reference guide - version 5.22.0 + version 5.22.1

    CodeMirror is a code-editor component that can be embedded in diff --git a/index.html b/index.html index 06fdc1567f..dd4b1ded05 100644 --- a/index.html +++ b/index.html @@ -96,7 +96,7 @@

    This is CodeMirror

    - Get the current version: 5.22.0.
    + Get the current version: 5.22.1.
    You can see the code,
    read the release notes,
    or study the user manual. diff --git a/package.json b/package.json index c007b2a87c..0c565e9b2b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "codemirror", - "version": "5.22.0", + "version": "5.22.1", "main": "lib/codemirror.js", "description": "Full-featured in-browser code editor", "license": "MIT", diff --git a/src/edit/main.js b/src/edit/main.js index 8da8f48e3a..429cfe94e7 100644 --- a/src/edit/main.js +++ b/src/edit/main.js @@ -66,4 +66,4 @@ import { addLegacyProps } from "./legacy" addLegacyProps(CodeMirror) -CodeMirror.version = "5.22.0" +CodeMirror.version = "5.22.1" From 38932a8e332ca02f73d395f899cfdfa76922e132 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Tue, 20 Dec 2016 15:53:55 +0100 Subject: [PATCH 0723/2444] Remove link to google group --- index.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/index.html b/index.html index dd4b1ded05..9812829e52 100644 --- a/index.html +++ b/index.html @@ -163,10 +163,10 @@

    Community

    Discussion around the project is done on a discussion forum. - There is also - the codemirror-announce - list, which is only used for major announcements (such as new - versions). If needed, you can + Announcements related to the project, such as new versions, are + posted in the + forum's "announce" + category. If needed, you can contact the maintainer directly. We aim to be an inclusive, welcoming community. To make that explicit, we have From 12abb7c7f0fcfff441810eb5ce5a8905385c84c2 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Thu, 22 Dec 2016 16:55:10 +0100 Subject: [PATCH 0724/2444] Remove check for license blob in linter Closes #3909 --- test/lint.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/lint.js b/test/lint.js index cc03ce64c0..12146ffd28 100644 --- a/test/lint.js +++ b/test/lint.js @@ -3,8 +3,7 @@ var blint = require("blint"); ["mode", "lib", "addon", "keymap"].forEach(function(dir) { blint.checkDir(dir, { browser: true, - allowedGlobals: ["CodeMirror", "define", "test", "requirejs"], - blob: "// CodeMirror, copyright (c) by Marijn Haverbeke and others\n// Distributed under an MIT license: http:\/\/codemirror.net\/LICENSE\n\n" + allowedGlobals: ["CodeMirror", "define", "test", "requirejs"] }); }); From 3dc1a5db143bd99fd3a1a9bca1ee1005ef5c828d Mon Sep 17 00:00:00 2001 From: Emmanuel Schanzer Date: Thu, 22 Dec 2016 11:51:59 -0500 Subject: [PATCH 0725/2444] screenreader fixes --- src/line/line_data.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/line/line_data.js b/src/line/line_data.js index 93b57577da..7583c3424e 100644 --- a/src/line/line_data.js +++ b/src/line/line_data.js @@ -66,6 +66,9 @@ export function buildLineContent(cm, lineView) { col: 0, pos: 0, cm: cm, trailingSpace: false, splitSpaces: (ie || webkit) && cm.getOption("lineWrapping")} + // hide from accessibility tree + content.setAttribute("role", "presentation") + builder.pre.setAttribute("role", "presentation") lineView.measure = {} // Iterate over the logical lines that make up this visual line. From 85956bed14dc8cdfd6610487c08243edf7ac0076 Mon Sep 17 00:00:00 2001 From: Emmanuel Schanzer Date: Thu, 22 Dec 2016 13:39:29 -0500 Subject: [PATCH 0726/2444] Also give widgets a role attribute of 'presentation' --- src/model/mark_text.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/model/mark_text.js b/src/model/mark_text.js index 4250288ef3..15ec28498f 100644 --- a/src/model/mark_text.js +++ b/src/model/mark_text.js @@ -163,6 +163,7 @@ export function markText(doc, from, to, options, type) { // Showing up as a widget implies collapsed (widget replaces text) marker.collapsed = true marker.widgetNode = elt("span", [marker.replacedWith], "CodeMirror-widget") + marker.widgetNode.setAttribute("role", "presentation") // hide from accessibility tree if (!options.handleMouseEvents) marker.widgetNode.setAttribute("cm-ignore-events", "true") if (options.insertLeft) marker.widgetNode.insertLeft = true } From aeb547774525ea6e3544a27ad3b2b387fb384e05 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Fri, 23 Dec 2016 14:03:58 +0100 Subject: [PATCH 0727/2444] Update htmlmixed documentation --- mode/htmlmixed/index.html | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/mode/htmlmixed/index.html b/mode/htmlmixed/index.html index f94df9e21a..caa7546c1e 100644 --- a/mode/htmlmixed/index.html +++ b/mode/htmlmixed/index.html @@ -72,15 +72,26 @@

    Mixed HTML Example

    The HTML mixed mode depends on the XML, JavaScript, and CSS modes.

    It takes an optional mode configuration - option, scriptTypes, which can be used to add custom - behavior for specific <script type="..."> tags. If - given, it should hold an array of {matches, mode} - objects, where matches is a string or regexp that - matches the script type, and mode is - either null, for script types that should stay in - HTML mode, or a mode - spec corresponding to the mode that should be used for the - script.

    + option, tags, which can be used to add custom + behavior for specific tags. When given, it should be an object + mapping tag names (for example script) to arrays or + three-element arrays. Those inner arrays indicate [attributeName, + valueRegexp, modeSpec] + specifications. For example, you could use ["type", /^foo$/, + "foo"] to map the attribute type="foo" to + the foo mode. When the first two fields are null + ([null, null, "mode"]), the given mode is used for + any such tag that doesn't match any of the previously given + attributes. For example:

    + +
    var myModeSpec = {
    +  name: "htmlmixed",
    +  tags: {
    +    style: [["type", /^text/(x-)?scss$/, "text/x-scss"],
    +            [null, null, "css"]],
    +    custom: [[null, null, "customMode"]]
    +  }
    +}

    MIME types defined: text/html (redefined, only takes effect if you load this parser after the From 9a015790f9833dd2ef395e7fb7c505376dd46568 Mon Sep 17 00:00:00 2001 From: Adrian Heine Date: Mon, 26 Dec 2016 11:47:18 +0100 Subject: [PATCH 0728/2444] Remove unused variable This variable was unused after 0e545326ddb3a82df1b76eb18b2221990536e588. --- src/model/Doc.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/model/Doc.js b/src/model/Doc.js index 27b62d1945..006598f1fe 100644 --- a/src/model/Doc.js +++ b/src/model/Doc.js @@ -229,7 +229,6 @@ Doc.prototype = createObj(BranchChunk.prototype, { }), clearGutter: docMethodOp(function(gutterID) { - let i = this.first this.iter(line => { if (line.gutterMarkers && line.gutterMarkers[gutterID]) { changeLine(this, line, "gutter", () => { @@ -238,7 +237,6 @@ Doc.prototype = createObj(BranchChunk.prototype, { return true }) } - ++i }) }), From 97eb5221f05c09cfeafefa45b52da022fbcc46af Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Mon, 26 Dec 2016 21:48:09 +0100 Subject: [PATCH 0729/2444] [python mode] Recognize f-strings Closes #4462 --- mode/python/python.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mode/python/python.js b/mode/python/python.js index 30f1428e3a..4310f9fb6b 100644 --- a/mode/python/python.js +++ b/mode/python/python.js @@ -70,7 +70,7 @@ myBuiltins = myBuiltins.concat(["apply", "basestring", "buffer", "cmp", "coerce", "execfile", "file", "intern", "long", "raw_input", "reduce", "reload", "unichr", "unicode", "xrange", "False", "True", "None"]); - var stringPrefixes = new RegExp("^(([rub]|(ur)|(br))?('{3}|\"{3}|['\"]))", "i"); + var stringPrefixes = new RegExp("^(([rubf]|(ur)|(br))?('{3}|\"{3}|['\"]))", "i"); } var keywords = wordRegexp(myKeywords); var builtins = wordRegexp(myBuiltins); From 409c83aaf8f29a38328c4f751d4b3c460dee72a7 Mon Sep 17 00:00:00 2001 From: Manuel Rego Casasnovas Date: Tue, 27 Dec 2016 12:32:27 +0100 Subject: [PATCH 0730/2444] [css mode] Add "auto-flow" value for grid property See: https://drafts.csswg.org/css-grid/#grid-shorthand --- mode/css/css.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mode/css/css.js b/mode/css/css.js index a1d5a388e5..90de4ee795 100644 --- a/mode/css/css.js +++ b/mode/css/css.js @@ -589,7 +589,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) { "above", "absolute", "activeborder", "additive", "activecaption", "afar", "after-white-space", "ahead", "alias", "all", "all-scroll", "alphabetic", "alternate", "always", "amharic", "amharic-abegede", "antialiased", "appworkspace", - "arabic-indic", "armenian", "asterisks", "attr", "auto", "avoid", "avoid-column", "avoid-page", + "arabic-indic", "armenian", "asterisks", "attr", "auto", "auto-flow", "avoid", "avoid-column", "avoid-page", "avoid-region", "background", "backwards", "baseline", "below", "bidi-override", "binary", "bengali", "blink", "block", "block-axis", "bold", "bolder", "border", "border-box", "both", "bottom", "break", "break-all", "break-word", "bullets", "button", "button-bevel", From ea5ee6466a916b9f6a85e480c543f877d138e626 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Wed, 28 Dec 2016 23:49:53 +0100 Subject: [PATCH 0731/2444] [groovy mode] Don't reindent block comment conent Closes #4466 --- mode/groovy/groovy.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mode/groovy/groovy.js b/mode/groovy/groovy.js index 721933b01c..daa798722e 100644 --- a/mode/groovy/groovy.js +++ b/mode/groovy/groovy.js @@ -210,7 +210,7 @@ CodeMirror.defineMode("groovy", function(config) { }, indent: function(state, textAfter) { - if (!state.tokenize[state.tokenize.length-1].isBase) return 0; + if (!state.tokenize[state.tokenize.length-1].isBase) return CodeMirror.Pass; var firstChar = textAfter && textAfter.charAt(0), ctx = state.context; if (ctx.type == "statement" && !expectExpression(state.lastToken, true)) ctx = ctx.prev; var closing = firstChar == ctx.type; From 117ecfca5b28f9931c1407e257667972020d667c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oskar=20Segersv=C3=A4rd?= Date: Wed, 28 Dec 2016 13:43:55 +0100 Subject: [PATCH 0732/2444] [soy mode] Fix bug when popping scopes. --- mode/soy/soy.js | 15 +++++++++------ mode/soy/test.js | 4 +++- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/mode/soy/soy.js b/mode/soy/soy.js index 9fd75c6d27..3876333f94 100644 --- a/mode/soy/soy.js +++ b/mode/soy/soy.js @@ -60,16 +60,19 @@ }; } - function pop(list) { - return list && list.next; - } - // Reference a variable `name` in `list`. // Let `loose` be truthy to ignore missing identifiers. function ref(list, name, loose) { return contains(list, name) ? "variable-2" : (loose ? "variable" : "variable-2 error"); } + function popscope(state) { + if (state.scopes) { + state.variables = state.scopes.element; + state.scopes = state.scopes.next; + } + } + return { startState: function() { return { @@ -168,11 +171,11 @@ case "tag": if (stream.match(/^\/?}/)) { if (state.tag == "/template" || state.tag == "/deltemplate") { - state.variables = state.scopes = pop(state.scopes); + popscope(state); state.indent = 0; } else { if (state.tag == "/for" || state.tag == "/foreach") { - state.variables = state.scopes = pop(state.scopes); + popscope(state); } state.indent -= config.indentUnit * (stream.current() == "/}" || indentingTags.indexOf(state.tag) == -1 ? 2 : 1); diff --git a/mode/soy/test.js b/mode/soy/test.js index 1a962de3e7..1a4c6c934f 100644 --- a/mode/soy/test.js +++ b/mode/soy/test.js @@ -60,10 +60,12 @@ ''); MT('foreach-scope-test', + '[keyword {@param] [def bar]: [variable-3 string][keyword }]', '[keyword {foreach] [def $foo] [keyword in] [variable-2&error $foos][keyword }]', ' [keyword {][variable-2 $foo][keyword }]', '[keyword {/foreach}]', - '[keyword {][variable-2&error $foo][keyword }]'); + '[keyword {][variable-2&error $foo][keyword }]', + '[keyword {][variable-2 $bar][keyword }]'); MT('foreach-ifempty-indent-test', '[keyword {foreach] [def $foo] [keyword in] [variable-2&error $foos][keyword }]', From 7a094220148815d025fcc62f7e8a0b56316a2744 Mon Sep 17 00:00:00 2001 From: Jake Peyser Date: Wed, 28 Dec 2016 13:19:55 -0500 Subject: [PATCH 0733/2444] [materialy theme] Make general background selector more specific --- theme/material.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/theme/material.css b/theme/material.css index 91ed6cef29..01d867932a 100644 --- a/theme/material.css +++ b/theme/material.css @@ -7,7 +7,7 @@ */ -.cm-s-material { +.cm-s-material.CodeMirror { background-color: #263238; color: rgba(233, 237, 237, 1); } From 6d3783d02911d51a16bf648b602febf2ad811bc7 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Thu, 29 Dec 2016 08:54:03 +0100 Subject: [PATCH 0734/2444] [mllike mode] Don't treat every unrecognized char as a variable Closes #4473 --- mode/mllike/mllike.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/mode/mllike/mllike.js b/mode/mllike/mllike.js index bf0b8a674f..4d0be609c4 100644 --- a/mode/mllike/mllike.js +++ b/mode/mllike/mllike.js @@ -83,9 +83,12 @@ CodeMirror.defineMode('mllike', function(_config, parserConfig) { if ( /[+\-*&%=<>!?|]/.test(ch)) { return 'operator'; } - stream.eatWhile(/\w/); - var cur = stream.current(); - return words.hasOwnProperty(cur) ? words[cur] : 'variable'; + if (/[\w\xa1-\uffff]/.test(ch)) { + stream.eatWhile(/[\w\xa1-\uffff]/); + var cur = stream.current(); + return words.hasOwnProperty(cur) ? words[cur] : 'variable'; + } + return null } function tokenString(stream, state) { From 9fe20534371a496375e409f987d2176b90c6f1e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oskar=20Segersv=C3=A4rd?= Date: Thu, 29 Dec 2016 11:01:27 +0100 Subject: [PATCH 0735/2444] [soy mode] Add missing `\b`s to keyword regex Closes #4468 --- mode/soy/soy.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mode/soy/soy.js b/mode/soy/soy.js index 3876333f94..3e9c04a49e 100644 --- a/mode/soy/soy.js +++ b/mode/soy/soy.js @@ -198,7 +198,7 @@ if (match = stream.match(/^\$([\w]+)/)) { return ref(state.variables, match[1]); } - if (stream.match(/(?:as|and|or|not|in)/)) { + if (stream.match(/\b(?:as|and|or|not|in)\b/)) { return "keyword"; } stream.next(); From 77eb24c188131a89a06990523c32bd37ccc96e80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oskar=20Segersv=C3=A4rd?= Date: Thu, 29 Dec 2016 11:47:11 +0100 Subject: [PATCH 0736/2444] [soy mode] Add tests for 9fe2053, find bug and fix it --- mode/soy/soy.js | 4 ++-- mode/soy/test.js | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/mode/soy/soy.js b/mode/soy/soy.js index 3e9c04a49e..b9eec59a4c 100644 --- a/mode/soy/soy.js +++ b/mode/soy/soy.js @@ -198,8 +198,8 @@ if (match = stream.match(/^\$([\w]+)/)) { return ref(state.variables, match[1]); } - if (stream.match(/\b(?:as|and|or|not|in)\b/)) { - return "keyword"; + if (match = stream.match(/^\w+/)) { + return /^(?:as|and|or|not|in)$/.test(match[0]) ? "keyword" : null; } stream.next(); return null; diff --git a/mode/soy/test.js b/mode/soy/test.js index 1a4c6c934f..9e265c1b0c 100644 --- a/mode/soy/test.js +++ b/mode/soy/test.js @@ -5,6 +5,12 @@ var mode = CodeMirror.getMode({indentUnit: 2}, "soy"); function MT(name) {test.mode(name, mode, Array.prototype.slice.call(arguments, 1));} + // Test of small keywords and words containing them. + MT('keywords-test', + '[keyword {] [keyword as] worrying [keyword and] notorious [keyword as]', + ' the Fandor-alias assassin, [keyword or]', + ' Corcand cannot fit [keyword in] [keyword }]'); + MT('let-test', '[keyword {template] [def .name][keyword }]', ' [keyword {let] [def $name]: [string "world"][keyword /}]', From 4c39f5e8be2bcaa716c5c81f3db18d0db1810d76 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Mon, 2 Jan 2017 00:39:12 +0100 Subject: [PATCH 0737/2444] Make findModeByMIME +xml/+json aware Issue #4476 --- mode/meta.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mode/meta.js b/mode/meta.js index 47364448f1..bb60502416 100644 --- a/mode/meta.js +++ b/mode/meta.js @@ -155,7 +155,7 @@ {name: "Verilog", mime: "text/x-verilog", mode: "verilog", ext: ["v"]}, {name: "VHDL", mime: "text/x-vhdl", mode: "vhdl", ext: ["vhd", "vhdl"]}, {name: "Vue.js Component", mimes: ["script/x-vue", "text/x-vue"], mode: "vue", ext: ["vue"]}, - {name: "XML", mimes: ["application/xml", "text/xml"], mode: "xml", ext: ["xml", "xsl", "xsd"], alias: ["rss", "wsdl", "xsd"]}, + {name: "XML", mimes: ["application/xml", "text/xml"], mode: "xml", ext: ["xml", "xsl", "xsd", "svg"], alias: ["rss", "wsdl", "xsd"]}, {name: "XQuery", mime: "application/xquery", mode: "xquery", ext: ["xy", "xquery"]}, {name: "Yacas", mime: "text/x-yacas", mode: "yacas", ext: ["ys"]}, {name: "YAML", mimes: ["text/x-yaml", "text/yaml"], mode: "yaml", ext: ["yaml", "yml"], alias: ["yml"]}, @@ -178,6 +178,8 @@ if (info.mimes) for (var j = 0; j < info.mimes.length; j++) if (info.mimes[j] == mime) return info; } + if (/\+xml$/.test(mime)) return CodeMirror.findModeByMIME("application/xml") + if (/\+json$/.test(mime)) return CodeMirror.findModeByMIME("application/json") }; CodeMirror.findModeByExtension = function(ext) { From ec8e89ba441495c79710c5fda7fd05d61a6787b6 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Mon, 2 Jan 2017 00:45:36 +0100 Subject: [PATCH 0738/2444] [closebrackets addon] Add override option Closes #4478 --- addon/edit/closebrackets.js | 2 +- doc/manual.html | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/addon/edit/closebrackets.js b/addon/edit/closebrackets.js index 7c47bcd096..62b99c1ba8 100644 --- a/addon/edit/closebrackets.js +++ b/addon/edit/closebrackets.js @@ -45,7 +45,7 @@ function getConfig(cm) { var deflt = cm.state.closeBrackets; - if (!deflt) return null; + if (!deflt || deflt.override) return deflt; var mode = cm.getModeAt(cm.getCursor()); return mode.closeBrackets || deflt; } diff --git a/doc/manual.html b/doc/manual.html index 98c160946f..3c252381ba 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -2314,7 +2314,13 @@

    Addons

    it. explode should be a similar string that gives the pairs of characters that, when enter is pressed between them, should have the second character also moved to its own - line. Demo here. + line. By default, if the active mode has + a closeBrackets property, that overrides the + configuration given in the option. But you can add + an override property with a truthy value to + override mode-specific + configuration. Demo + here.
    edit/matchtags.js
    Defines an option matchTags that, when enabled, From 7ff3b02e724300d61d6a7b81eb8139778060a529 Mon Sep 17 00:00:00 2001 From: ficristo Date: Mon, 2 Jan 2017 09:00:08 +0100 Subject: [PATCH 0739/2444] [javascript mode] add tests for async keyword --- mode/javascript/test.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/mode/javascript/test.js b/mode/javascript/test.js index 2caefea439..56b90e3cfe 100644 --- a/mode/javascript/test.js +++ b/mode/javascript/test.js @@ -190,6 +190,36 @@ " }", "}"); + MT("async", + "[keyword async] [keyword function] [def foo]([def args]) { [keyword return] [atom true]; }"); + + MT("async_assignment", + "[keyword const] [def foo] [operator =] [keyword async] [keyword function] ([def args]) { [keyword return] [atom true]; };"); + + MT("async_object", + "[keyword let] [def obj] [operator =] { [property async]: [atom false] };"); + + // async be highlighet as keyword and foo as def, but it requires potentially expensive look-ahead. See #4173 + MT("async_object_function", + "[keyword let] [def obj] [operator =] { [property async] [property foo]([def args]) { [keyword return] [atom true]; } };"); + + MT("async_object_properties", + "[keyword let] [def obj] [operator =] {", + " [property prop1]: [keyword async] [keyword function] ([def args]) { [keyword return] [atom true]; },", + " [property prop2]: [keyword async] [keyword function] ([def args]) { [keyword return] [atom true]; },", + " [property prop3]: [keyword async] [keyword function] [def prop3]([def args]) { [keyword return] [atom true]; },", + "};"); + + MT("async_arrow", + "[keyword const] [def foo] [operator =] [keyword async] ([def args]) [operator =>] { [keyword return] [atom true]; };"); + + MT("async_jquery", + "[variable $].[property ajax]({", + " [property url]: [variable url],", + " [property async]: [atom true],", + " [property method]: [string 'GET']", + "});"); + var ts_mode = CodeMirror.getMode({indentUnit: 2}, "application/typescript") function TS(name) { test.mode(name, ts_mode, Array.prototype.slice.call(arguments, 1)) From 90d7915450f33f03d0d251b6bdda7228289acd41 Mon Sep 17 00:00:00 2001 From: Paul Masson Date: Tue, 3 Jan 2017 14:03:42 -0800 Subject: [PATCH 0740/2444] Update LICENSE --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index 766132177a..1bca6bfed4 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (C) 2016 by Marijn Haverbeke and others +Copyright (C) 2017 by Marijn Haverbeke and others Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From d4e2e7ac0b745b04a82cd2f2847c44951b98822a Mon Sep 17 00:00:00 2001 From: Paul Masson Date: Tue, 3 Jan 2017 14:11:38 -0800 Subject: [PATCH 0741/2444] [real-world uses] Add SageMathCell --- doc/realworld.html | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/realworld.html b/doc/realworld.html index dc2a7f6a97..2429ba1655 100644 --- a/doc/realworld.html +++ b/doc/realworld.html @@ -142,6 +142,7 @@

    CodeMirror real-world uses

  • Rascal (tiny computer)
  • RealTime.io (Internet-of-Things infrastructure)
  • Refork (animation demo gallery and sharing)
  • +
  • SageMathCell (interactive mathematical software)
  • SageMathCloud (interactive mathematical software environment)
  • ServePHP (PHP code testing in Chrome dev tools)
  • Shadertoy (shader sharing)
  • From 3a83dccdfa96e2dc90c3129d281525ff41241255 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Wed, 4 Jan 2017 09:58:53 +0100 Subject: [PATCH 0742/2444] [markdown mode] Be somewhat more restrictive about HTML open tags Closes #4484 --- mode/markdown/markdown.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mode/markdown/markdown.js b/mode/markdown/markdown.js index 4cc1dc6890..1aeb34414c 100644 --- a/mode/markdown/markdown.js +++ b/mode/markdown/markdown.js @@ -490,7 +490,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) { return type + tokenTypes.linkEmail; } - if (ch === '<' && stream.match(/^(!--|\w)/, false)) { + if (ch === '<' && stream.match(/^(!--|[a-z]+(?:\s+[a-z_:.\-]+(?:\s*=\s*[^ >]+)?)*\s*>)/i, false)) { var end = stream.string.indexOf(">", stream.pos); if (end != -1) { var atts = stream.string.substring(stream.start, end); From 6928fec6695f468f17b5031e48192ad2f7d505f1 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Wed, 4 Jan 2017 10:59:11 +0100 Subject: [PATCH 0743/2444] [panel addon] Implement a 'stable' option Issue #4485 --- addon/display/panel.js | 9 +++++++++ demo/panel.html | 4 ++-- doc/manual.html | 11 +++++++---- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/addon/display/panel.js b/addon/display/panel.js index ba29484d6c..a6ac74f0ca 100644 --- a/addon/display/panel.js +++ b/addon/display/panel.js @@ -38,6 +38,9 @@ var height = (options && options.height) || node.offsetHeight; this._setSize(null, info.heightLeft -= height); info.panels++; + if (options.stable && isAtTop(this, node)) + this.scrollTo(null, this.getScrollInfo().top + height) + return new Panel(this, node, options, height); }); @@ -109,4 +112,10 @@ cm.setSize = cm._setSize; cm.setSize(); } + + function isAtTop(cm, dom) { + for (let sibling = dom.nextSibling; sibling; sibling = sibling.nextSibling) + if (sibling == cm.getWrapperElement()) return true + return false + } }); diff --git a/demo/panel.html b/demo/panel.html index b3b0b7ca6b..1ce3d87c79 100644 --- a/demo/panel.html +++ b/demo/panel.html @@ -115,7 +115,7 @@

    Panel Demo

    } function addPanel(where) { var node = makePanel(where); - panels[node.id] = editor.addPanel(node, {position: where}); + panels[node.id] = editor.addPanel(node, {position: where, stable: true}); } addPanel("top"); @@ -126,7 +126,7 @@

    Panel Demo

    var panel = panels["panel-" + id]; var node = makePanel(""); - panels[node.id] = editor.addPanel(node, {replace: panel, position: "after-top"}); + panels[node.id] = editor.addPanel(node, {replace: panel, position: "after-top", stable: true}); return false; } diff --git a/doc/manual.html b/doc/manual.html index 3c252381ba..7acc872b8b 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -2910,7 +2910,7 @@

    Addons

    changed.
    The method accepts the following options:
    -
    position : string
    +
    position: string
    Controls the position of the newly added panel. The following values are recognized:
    @@ -2924,12 +2924,15 @@

    Addons

    Adds the panel at the top of the bottom panels.
    -
    before : Panel
    +
    before: Panel
    The new panel will be added before the given panel.
    -
    after : Panel
    +
    after: Panel
    The new panel will be added after the given panel.
    -
    replace : Panel
    +
    replace: Panel
    The new panel will replace the given panel.
    +
    stable: bool
    +
    Whether to scroll the editor to keep the text's vertical + position stable, when adding a panel above it. Defaults to false.
    When using the after, before or replace options, if the panel doesn't exists or has been removed, From 35f09250d7d3dbb3da28aa3a7efdf757bdfdc42f Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Wed, 4 Jan 2017 11:02:56 +0100 Subject: [PATCH 0744/2444] Fix ES6-ism in addon --- addon/display/panel.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addon/display/panel.js b/addon/display/panel.js index a6ac74f0ca..7da34a42da 100644 --- a/addon/display/panel.js +++ b/addon/display/panel.js @@ -114,7 +114,7 @@ } function isAtTop(cm, dom) { - for (let sibling = dom.nextSibling; sibling; sibling = sibling.nextSibling) + for (var sibling = dom.nextSibling; sibling; sibling = sibling.nextSibling) if (sibling == cm.getWrapperElement()) return true return false } From f78c0915e5c403c925e48c714fd1fd671a4c35f0 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Wed, 4 Jan 2017 11:03:50 +0100 Subject: [PATCH 0745/2444] Lint addons and modes with ecmaVersion 5 --- test/lint.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/lint.js b/test/lint.js index 12146ffd28..502706de8e 100644 --- a/test/lint.js +++ b/test/lint.js @@ -3,7 +3,8 @@ var blint = require("blint"); ["mode", "lib", "addon", "keymap"].forEach(function(dir) { blint.checkDir(dir, { browser: true, - allowedGlobals: ["CodeMirror", "define", "test", "requirejs"] + allowedGlobals: ["CodeMirror", "define", "test", "requirejs"], + ecmaVersion: 5 }); }); From 0fb17df6694b0ba63ec0568d84709e9a07e19a9b Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Thu, 5 Jan 2017 09:44:27 +0100 Subject: [PATCH 0746/2444] [panel plugin] Make stable option also take effect when a panel is removed Issue #4485 --- addon/display/panel.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/addon/display/panel.js b/addon/display/panel.js index 7da34a42da..74199ff059 100644 --- a/addon/display/panel.js +++ b/addon/display/panel.js @@ -57,6 +57,8 @@ this.cleared = true; var info = this.cm.state.panels; this.cm._setSize(null, info.heightLeft += this.height); + if (this.options.stable && isAtTop(this.cm, this.node)) + this.cm.scrollTo(null, this.cm.getScrollInfo().top - this.height) info.wrapper.removeChild(this.node); if (--info.panels == 0) removePanels(this.cm); }; From dc94b0f0c6ea97c09344d1a34da70f8e2d1d708f Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Thu, 12 Jan 2017 14:35:32 +0100 Subject: [PATCH 0747/2444] [merge addon] Anchor copy button to editable side for insertions Since showing it next to an empty chunk looks bad Issue #4492 --- addon/merge/merge.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addon/merge/merge.js b/addon/merge/merge.js index 352e27dc6f..b3a9af405c 100644 --- a/addon/merge/merge.js +++ b/addon/merge/merge.js @@ -431,10 +431,10 @@ var editOriginals = dv.mv.options.allowEditingOriginals; copy.title = editOriginals ? "Push to left" : "Revert chunk"; copy.chunk = chunk; - copy.style.top = top + "px"; + copy.style.top = (chunk.origTo < chunk.origFrom ? top : dv.edit.heightAtLine(chunk.editFrom, "local") - sTopEdit) + "px"; if (editOriginals) { - var topReverse = dv.orig.heightAtLine(chunk.editFrom, "local") - sTopEdit; + var topReverse = dv.edit.heightAtLine(chunk.editFrom, "local") - sTopEdit; var copyReverse = dv.copyButtons.appendChild(elt("div", dv.type == "right" ? "\u21dd" : "\u21dc", "CodeMirror-merge-copy-reverse")); copyReverse.title = "Push to right"; From fc93599160949802e8752ecf32b63e24c0c1b461 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Thu, 12 Jan 2017 14:37:39 +0100 Subject: [PATCH 0748/2444] Don't exclude rollup.config.js from NPM See https://discuss.codemirror.net/t/npm-install-failing-for-cm-git-dependency/1088 --- .npmignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.npmignore b/.npmignore index de3a24080b..f23ca7195d 100644 --- a/.npmignore +++ b/.npmignore @@ -9,4 +9,3 @@ /mode/index.html .* bin -rollup.config.js From 8a0c813b208b5a2c0dae7b5a9b635168017165ba Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Thu, 12 Jan 2017 14:40:43 +0100 Subject: [PATCH 0749/2444] Include 5.22.2 in release notes --- CHANGELOG.md | 6 ++++++ doc/manual.html | 2 +- package.json | 2 +- src/edit/main.js | 2 +- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f3eb79ff5c..9074c1b0c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## 5.22.2 (2017-01-12) + +### Bug fixes + +Include rollup.config.js in NPM package, so that it can be used to build from source. + ## 5.22.0 (2016-12-20) ### Bug fixes diff --git a/doc/manual.html b/doc/manual.html index 7acc872b8b..f765185eb3 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -69,7 +69,7 @@

    User manual and reference guide - version 5.22.1 + version 5.22.3

    CodeMirror is a code-editor component that can be embedded in diff --git a/package.json b/package.json index 0c565e9b2b..fa82dd11dc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "codemirror", - "version": "5.22.1", + "version": "5.22.3", "main": "lib/codemirror.js", "description": "Full-featured in-browser code editor", "license": "MIT", diff --git a/src/edit/main.js b/src/edit/main.js index 429cfe94e7..c16f377119 100644 --- a/src/edit/main.js +++ b/src/edit/main.js @@ -66,4 +66,4 @@ import { addLegacyProps } from "./legacy" addLegacyProps(CodeMirror) -CodeMirror.version = "5.22.1" +CodeMirror.version = "5.22.3" From 66d9403c8e5511b5469e1009534e8266296d64ed Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Fri, 13 Jan 2017 08:19:44 +0100 Subject: [PATCH 0750/2444] [merge addon] Fix incorrect compare Issue #4492 --- addon/merge/merge.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addon/merge/merge.js b/addon/merge/merge.js index b3a9af405c..a8132b605d 100644 --- a/addon/merge/merge.js +++ b/addon/merge/merge.js @@ -431,7 +431,7 @@ var editOriginals = dv.mv.options.allowEditingOriginals; copy.title = editOriginals ? "Push to left" : "Revert chunk"; copy.chunk = chunk; - copy.style.top = (chunk.origTo < chunk.origFrom ? top : dv.edit.heightAtLine(chunk.editFrom, "local") - sTopEdit) + "px"; + copy.style.top = (chunk.origTo > chunk.origFrom ? top : dv.edit.heightAtLine(chunk.editFrom, "local") - sTopEdit) + "px"; if (editOriginals) { var topReverse = dv.edit.heightAtLine(chunk.editFrom, "local") - sTopEdit; From 379c1aeb941b8403c51be15a8e64c614ed61143f Mon Sep 17 00:00:00 2001 From: Martin Zagora Date: Mon, 16 Jan 2017 14:59:51 +1100 Subject: [PATCH 0751/2444] TypeScript: add a test for usage of interface syntax with const --- mode/javascript/test.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mode/javascript/test.js b/mode/javascript/test.js index 56b90e3cfe..c02eb06c31 100644 --- a/mode/javascript/test.js +++ b/mode/javascript/test.js @@ -261,6 +261,12 @@ " ) [operator =>] [variable-3 Promise] [operator <] [variable-3 AccountHolderNotificationPreferenceInstance] [operator >];", " }") + TS("typescript_interface_with_const", + "[keyword const] [def hello]: {", + " [property prop1][operator ?]: [variable-3 string];", + " [property prop2][operator ?]: [variable-3 string];", + "} [operator =] {};") + var jsonld_mode = CodeMirror.getMode( {indentUnit: 2}, {name: "javascript", jsonld: true} From 7166a44efbfcc9b84dc9efb4ec36da478370663d Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Mon, 16 Jan 2017 21:47:45 +0100 Subject: [PATCH 0752/2444] [javascript mode] Improve TypeScript interface type parsing Issue #4494 --- mode/javascript/javascript.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/mode/javascript/javascript.js b/mode/javascript/javascript.js index c185106ce4..17890dcc12 100644 --- a/mode/javascript/javascript.js +++ b/mode/javascript/javascript.js @@ -505,9 +505,9 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { if (type == ":") return cont(expressionNoComma); if (type == "(") return pass(functiondef); } - function commasep(what, end) { + function commasep(what, end, sep) { function proceed(type, value) { - if (type == ",") { + if (sep ? sep.indexOf(type) > -1 : type == ",") { var lex = cx.state.lexical; if (lex.info == "call") lex.pos = (lex.pos || 0) + 1; return cont(function(type, value) { @@ -541,16 +541,18 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { function typeexpr(type) { if (type == "variable") {cx.marked = "variable-3"; return cont(afterType);} if (type == "string" || type == "number" || type == "atom") return cont(afterType); - if (type == "{") return cont(commasep(typeprop, "}")) + if (type == "{") return cont(pushlex("}"), commasep(typeprop, "}", ",;"), poplex) if (type == "(") return cont(commasep(typearg, ")"), maybeReturnType) } function maybeReturnType(type) { if (type == "=>") return cont(typeexpr) } - function typeprop(type) { + function typeprop(type, value) { if (type == "variable" || cx.style == "keyword") { cx.marked = "property" return cont(typeprop) + } else if (value == "?") { + return cont(typeprop) } else if (type == ":") { return cont(typeexpr) } From 6709974d3b01dc6aa153de37edf4170b0431b1f6 Mon Sep 17 00:00:00 2001 From: Zeno Rocha Date: Wed, 18 Jan 2017 06:28:31 -0800 Subject: [PATCH 0753/2444] [dracula theme] Adjust colors, remove duplicate definition --- theme/dracula.css | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/theme/dracula.css b/theme/dracula.css index b2ef62913c..53a660b521 100644 --- a/theme/dracula.css +++ b/theme/dracula.css @@ -24,8 +24,7 @@ .cm-s-dracula span.cm-number { color: #bd93f9; } .cm-s-dracula span.cm-variable { color: #50fa7b; } .cm-s-dracula span.cm-variable-2 { color: white; } -.cm-s-dracula span.cm-def { color: #ffb86c; } -.cm-s-dracula span.cm-keyword { color: #ff79c6; } +.cm-s-dracula span.cm-def { color: #50fa7b; } .cm-s-dracula span.cm-operator { color: #ff79c6; } .cm-s-dracula span.cm-keyword { color: #ff79c6; } .cm-s-dracula span.cm-atom { color: #bd93f9; } @@ -35,7 +34,7 @@ .cm-s-dracula span.cm-qualifier { color: #50fa7b; } .cm-s-dracula span.cm-property { color: #66d9ef; } .cm-s-dracula span.cm-builtin { color: #50fa7b; } -.cm-s-dracula span.cm-variable-3 { color: #50fa7b; } +.cm-s-dracula span.cm-variable-3 { color: #ffb86c; } .cm-s-dracula .CodeMirror-activeline-background { background: rgba(255,255,255,0.1); } .cm-s-dracula .CodeMirror-matchingbracket { text-decoration: underline; color: white !important; } From 73c4e24a8e6c0bb078f5fb497edb484bd5523f12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Vr=C3=A1na?= Date: Tue, 20 Dec 2016 16:45:20 +0100 Subject: [PATCH 0754/2444] [sublime bindings] Don't sort last line with no selected chars Selecting two full lines including line ends makes a selection from line 1 to line 3 (ch: 0). This command used to sort three lines (1 to 3) which is not what I expect. This change makes it sort only two lines if there are no selected characters on the last line. It also fixes a fatal error if there are more than one selection on the same line (the code used 'range' instead of 'ranges'). It also selects the trailing newline after sorting the lines so that the whole lines are selected. --- keymap/sublime.js | 5 +++-- test/sublime_test.js | 8 ++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/keymap/sublime.js b/keymap/sublime.js index c5d2906bc0..3d112ab961 100644 --- a/keymap/sublime.js +++ b/keymap/sublime.js @@ -310,7 +310,8 @@ if (range.empty()) continue; var from = range.from().line, to = range.to().line; while (i < ranges.length - 1 && ranges[i + 1].from().line == to) - to = range[++i].to().line; + to = ranges[++i].to().line; + if (!ranges[i].to().ch) to--; toSort.push(from, to); } if (toSort.length) selected = true; @@ -331,7 +332,7 @@ return a < b ? -1 : a == b ? 0 : 1; }); cm.replaceRange(lines, start, end); - if (selected) ranges.push({anchor: start, head: end}); + if (selected) ranges.push({anchor: start, head: Pos(to + 1, 0)}); } if (selected) cm.setSelections(ranges, 0); }); diff --git a/test/sublime_test.js b/test/sublime_test.js index c5c19c0a23..57f16485e1 100644 --- a/test/sublime_test.js +++ b/test/sublime_test.js @@ -249,11 +249,11 @@ "undo", setSel(0, 0, 2, 0, 3, 0, 5, 0), - "sortLines", val("a\nb\nc\nA\nB\nC"), - hasSel(0, 0, 2, 1, - 3, 0, 5, 1), + "sortLines", val("b\nc\na\nB\nC\nA"), + hasSel(0, 0, 2, 0, + 3, 0, 5, 0), "undo", - setSel(1, 0, 4, 0), "sortLinesInsensitive", val("c\na\nB\nb\nC\nA")); + setSel(1, 0, 5, 0), "sortLinesInsensitive", val("c\na\nB\nb\nC\nA")); stTest("bookmarks", "abc\ndef\nghi\njkl", Pos(0, 1), "toggleBookmark", From 73638df40c9631155b1985f0ee63b6ffe2398b6a Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Thu, 19 Jan 2017 23:35:01 +0100 Subject: [PATCH 0755/2444] Mark version 5.23.0 --- AUTHORS | 3 +++ CHANGELOG.md | 16 ++++++++++++++++ doc/manual.html | 2 +- doc/releases.html | 34 ++++++++++++++++++++++------------ index.html | 2 +- package.json | 2 +- src/edit/main.js | 2 +- 7 files changed, 45 insertions(+), 16 deletions(-) diff --git a/AUTHORS b/AUTHORS index 9b9b3355ba..866c78f842 100644 --- a/AUTHORS +++ b/AUTHORS @@ -175,6 +175,7 @@ eborden edsharp ekhaled Elisée +Emmanuel Schanzer Enam Mijbah Noor Eric Allam Erik Welander @@ -247,6 +248,7 @@ Irakli Gozalishvili Ivan Kurnosov Ivoah Jacob Lee +Jake Peyser Jakob Miland Jakub Vrana Jakub Vrána @@ -617,6 +619,7 @@ Yunchi Luo Yuvi Panda Zac Anger Zachary Dremann +Zeno Rocha Zhang Hao zziuni 魏鹏刚 diff --git a/CHANGELOG.md b/CHANGELOG.md index 9074c1b0c5..07ed0295e5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,19 @@ +## 5.23.0 (2017-01-19) + +### Bug fixes + +Presentation-related elements DOM elements are now marked as such to help screen readers. + +[markdown mode](http://codemirror.net/mode/markdown/): Be more picky about what HTML tags look like to avoid false positives. + +### New features + +`findModeByMIME` now understands `+json` and `+xml` MIME suffixes. + +[closebrackets addon](http://codemirror.net/doc/manual.html#addon_closebrackets): Add support for an `override` option to ignore language-specific defaults. + +[panel addon](http://codemirror.net/doc/manual.html#addon_panel): Add a `stable` option that auto-scrolls the content to keep it in the same place when inserting/removing a panel. + ## 5.22.2 (2017-01-12) ### Bug fixes diff --git a/doc/manual.html b/doc/manual.html index f765185eb3..a5eb223355 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -69,7 +69,7 @@

    User manual and reference guide - version 5.22.3 + version 5.23.0

    CodeMirror is a code-editor component that can be embedded in diff --git a/doc/releases.html b/doc/releases.html index 2dfd1fe482..69c0e66b10 100644 --- a/doc/releases.html +++ b/doc/releases.html @@ -30,18 +30,28 @@

    Release notes and version history

    Version 5.x

    -

    20-12-2016: Version 5.22.0:

    - -
      -
    • sublime bindings: Make selectBetweenBrackets work with multiple cursors.
    • -
    • javascript mode: Fix issues with parsing complex TypeScript types, imports, and exports.
    • -
    • A contentEditable editor instance with autofocus enabled no longer crashes during initializing.
    • -
    • emacs bindings: Export CodeMirror.emacs to allow other addons to hook into Emacs-style functionality.
    • -
    • active-line addon: Add nonEmpty option.
    • -
    • New event: optionChange.
    • -
    - -

    21-11-2016: Version 5.21.0:

    +

    19-01-2017: Version 5.23.0:

    + +
      +
    • Presentation-related elements DOM elements are now marked as such to help screen readers.
    • +
    • markdown mode: Be more picky about what HTML tags look like to avoid false positives.
    • +
    • findModeByMIME now understands +json and +xml MIME suffixes.
    • +
    • closebrackets addon: Add support for an override option to ignore language-specific defaults.
    • +
    • panel addon: Add a stable option that auto-scrolls the content to keep it in the same place when inserting/removing a panel.
    • +
    + +

    20-12-2016: Version 5.22.0:

    + +
      +
    • sublime bindings: Make selectBetweenBrackets work with multiple cursors.
    • +
    • javascript mode: Fix issues with parsing complex TypeScript types, imports, and exports.
    • +
    • A contentEditable editor instance with autofocus enabled no longer crashes during initializing.
    • +
    • emacs bindings: Export CodeMirror.emacs to allow other addons to hook into Emacs-style functionality.
    • +
    • active-line addon: Add nonEmpty option.
    • +
    • New event: optionChange.
    • +
    + +

    21-11-2016: Version 5.21.0:

    • Tapping/clicking the editor in contentEditable mode on Chrome now puts the cursor at the tapped position.
    • diff --git a/index.html b/index.html index 9812829e52..df98ffd096 100644 --- a/index.html +++ b/index.html @@ -96,7 +96,7 @@

      This is CodeMirror

    - Get the current version: 5.22.1.
    + Get the current version: 5.23.0.
    You can see the code,
    read the release notes,
    or study the user manual. diff --git a/package.json b/package.json index fa82dd11dc..f7b617cd22 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "codemirror", - "version": "5.22.3", + "version": "5.23.0", "main": "lib/codemirror.js", "description": "Full-featured in-browser code editor", "license": "MIT", diff --git a/src/edit/main.js b/src/edit/main.js index c16f377119..b6d3d488ad 100644 --- a/src/edit/main.js +++ b/src/edit/main.js @@ -66,4 +66,4 @@ import { addLegacyProps } from "./legacy" addLegacyProps(CodeMirror) -CodeMirror.version = "5.22.3" +CodeMirror.version = "5.23.0" From 82162728938e8536d39a3f9937d7eb905e00eb9b Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Fri, 20 Jan 2017 08:25:33 +0100 Subject: [PATCH 0756/2444] [shell mode] Improve tokenizing of $'' strings Closes #4505 --- mode/shell/shell.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mode/shell/shell.js b/mode/shell/shell.js index 570b4e2419..a636387395 100644 --- a/mode/shell/shell.js +++ b/mode/shell/shell.js @@ -108,8 +108,8 @@ CodeMirror.defineMode('shell', function() { if (state.tokens.length > 1) stream.eat('$'); var ch = stream.next(), hungry = /\w/; if (ch === '{') hungry = /[^}]/; - if (ch === '(') { - state.tokens[0] = tokenString(')'); + if (/['"(]/.test(ch)) { + state.tokens[0] = tokenString(ch == "(" ? ")" : ch); return tokenize(stream, state); } if (!/\d/.test(ch)) { From 39ad3b619ba9ea481f2847fb85aed647b67d17d1 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Fri, 20 Jan 2017 22:12:11 +0100 Subject: [PATCH 0757/2444] [python mode] Accept underscores in number literals Closes #4506 --- mode/python/python.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/mode/python/python.js b/mode/python/python.js index 4310f9fb6b..b539d84aa6 100644 --- a/mode/python/python.js +++ b/mode/python/python.js @@ -113,8 +113,8 @@ if (stream.match(/^[0-9\.]/, false)) { var floatLiteral = false; // Floats - if (stream.match(/^\d*\.\d+(e[\+\-]?\d+)?/i)) { floatLiteral = true; } - if (stream.match(/^\d+\.\d*/)) { floatLiteral = true; } + if (stream.match(/^[\d_]*\.\d+(e[\+\-]?\d+)?/i)) { floatLiteral = true; } + if (stream.match(/^[\d_]+\.\d*/)) { floatLiteral = true; } if (stream.match(/^\.\d+/)) { floatLiteral = true; } if (floatLiteral) { // Float literals may be "imaginary" @@ -124,13 +124,13 @@ // Integers var intLiteral = false; // Hex - if (stream.match(/^0x[0-9a-f]+/i)) intLiteral = true; + if (stream.match(/^0x[0-9a-f_]+/i)) intLiteral = true; // Binary - if (stream.match(/^0b[01]+/i)) intLiteral = true; + if (stream.match(/^0b[01_]+/i)) intLiteral = true; // Octal - if (stream.match(/^0o[0-7]+/i)) intLiteral = true; + if (stream.match(/^0o[0-7_]+/i)) intLiteral = true; // Decimal - if (stream.match(/^[1-9]\d*(e[\+\-]?\d+)?/)) { + if (stream.match(/^[1-9][\d_]*(e[\+\-]?[\d_]+)?/)) { // Decimal literals may be "imaginary" stream.eat(/J/i); // TODO - Can you have imaginary longs? From 71af74da531f7ac7b08e6fcad37892dbf5375664 Mon Sep 17 00:00:00 2001 From: ficristo Date: Thu, 22 Dec 2016 16:33:50 +0100 Subject: [PATCH 0758/2444] [sass mode] Use same token types as CSS/SCSS mode. Add tests --- mode/sass/index.html | 4 +- mode/sass/sass.js | 71 +++++++++++++++++++++-------- mode/sass/test.js | 103 +++++++++++++++++++++++++++++++++++++++++++ test/index.html | 2 + 4 files changed, 161 insertions(+), 19 deletions(-) create mode 100644 mode/sass/test.js diff --git a/mode/sass/index.html b/mode/sass/index.html index 9f4a790221..6305649e5c 100644 --- a/mode/sass/index.html +++ b/mode/sass/index.html @@ -7,6 +7,7 @@ +
    - Get the current version: 5.27.4.
    + Get the current version: 5.28.0.
    You can see the code,
    read the release notes,
    or study the user manual. diff --git a/package.json b/package.json index ef824b0b0a..e413d2c57b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "codemirror", - "version": "5.27.5", + "version": "5.28.0", "main": "lib/codemirror.js", "style": "lib/codemirror.css", "description": "Full-featured in-browser code editor", diff --git a/src/edit/main.js b/src/edit/main.js index 54a7a6e3cc..5a20c6473e 100644 --- a/src/edit/main.js +++ b/src/edit/main.js @@ -66,4 +66,4 @@ import { addLegacyProps } from "./legacy" addLegacyProps(CodeMirror) -CodeMirror.version = "5.27.5" +CodeMirror.version = "5.28.0" From e246c6b165697c28ae584584d1cb56a31c87c707 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Fri, 21 Jul 2017 12:21:43 +0200 Subject: [PATCH 1113/2444] Bump version number post-5.28.0 --- doc/manual.html | 2 +- package.json | 2 +- src/edit/main.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/manual.html b/doc/manual.html index b4500c375b..da4423f960 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -69,7 +69,7 @@

    User manual and reference guide - version 5.28.0 + version 5.28.1

    CodeMirror is a code-editor component that can be embedded in diff --git a/package.json b/package.json index e413d2c57b..ff6971cd8e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "codemirror", - "version": "5.28.0", + "version": "5.28.1", "main": "lib/codemirror.js", "style": "lib/codemirror.css", "description": "Full-featured in-browser code editor", diff --git a/src/edit/main.js b/src/edit/main.js index 5a20c6473e..e7a2122d6e 100644 --- a/src/edit/main.js +++ b/src/edit/main.js @@ -66,4 +66,4 @@ import { addLegacyProps } from "./legacy" addLegacyProps(CodeMirror) -CodeMirror.version = "5.28.0" +CodeMirror.version = "5.28.1" From 0a1fb070028e2bc9ac6fb1e0c5940102bf7d0fa7 Mon Sep 17 00:00:00 2001 From: dwelle Date: Fri, 21 Jul 2017 17:56:58 +0200 Subject: [PATCH 1114/2444] [gfm mode] update doc --- mode/gfm/index.html | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/mode/gfm/index.html b/mode/gfm/index.html index 642c8ce71d..bec130ca51 100644 --- a/mode/gfm/index.html +++ b/mode/gfm/index.html @@ -70,21 +70,32 @@

    GFM mode

    ## A bit of GitHub spice +See http://github.github.com/github-flavored-markdown/. + +(Set `gitHubSpice: false` in mode options to disable): + * SHA: be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2 * User@SHA ref: mojombo@be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2 * User/Project@SHA: mojombo/god@be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2 * \#Num: #1 * User/#Num: mojombo#1 * User/Project#Num: mojombo/god#1 -* emoji: :smile: (note: you must add the CSS rule yourself. Set `emoji: false` in mode options to disable) -See http://github.github.com/github-flavored-markdown/. +(Set `emoji: false` in mode options to disable): + +* emoji: :smile: + + @@ -115,6 +116,7 @@

    Test Suite

    + From 3ec7088b8aef7910db0f554ccd4c94d1a77bd71c Mon Sep 17 00:00:00 2001 From: Michael Walker Date: Mon, 24 Jul 2017 09:45:42 +0100 Subject: [PATCH 1119/2444] Use background-color for cm-searching --- lib/codemirror.css | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/codemirror.css b/lib/codemirror.css index b008351a62..f4d3c5f40b 100644 --- a/lib/codemirror.css +++ b/lib/codemirror.css @@ -319,8 +319,8 @@ div.CodeMirror-dragcursors { .CodeMirror-line::-moz-selection, .CodeMirror-line > span::-moz-selection, .CodeMirror-line > span > span::-moz-selection { background: #d7d4f0; } .cm-searching { - background: #ffa; - background: rgba(255, 255, 0, .4); + background-color: #ffa; + background-color: rgba(255, 255, 0, .4); } /* Used to force a border model for a node */ From c53dc1678a0a1fce9e75f57e902ff73fad2ce64b Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Tue, 25 Jul 2017 19:09:51 +0200 Subject: [PATCH 1120/2444] [python mode] Simplify tokenizing of operators, fix recognition of several ops Issue #4876 --- mode/python/python.js | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/mode/python/python.js b/mode/python/python.js index 2d2b08c810..c318793207 100644 --- a/mode/python/python.js +++ b/mode/python/python.js @@ -41,10 +41,11 @@ CodeMirror.defineMode("python", function(conf, parserConf) { var ERRORCLASS = "error"; - var singleDelimiters = parserConf.singleDelimiters || /^[\(\)\[\]\{\}@,:`=;\.]/; - var doubleOperators = parserConf.doubleOperators || /^([!<>]==|<>|<<|>>|\/\/|\*\*)/; - var doubleDelimiters = parserConf.doubleDelimiters || /^(\+=|\-=|\*=|%=|\/=|&=|\|=|\^=)/; - var tripleDelimiters = parserConf.tripleDelimiters || /^(\/\/=|>>=|<<=|\*\*=)/; + var delimiters = parserConf.delimiters || parserConf.singleDelimiters || /^[\(\)\[\]\{\}@,:`=;\.]/; + // (Backwards-compatiblity with old, cumbersome config system) + var operators = [parserConf.singleOperators, parserConf.doubleOperators, parserConf.doubleDelimiters, parserConf.tripleDelimiters, + parserConf.operators || /^([-+*/%\/&|^]=?|[<>=]+|\/\/=?|\*\*=?|!=|[~!@])/] + for (var i = 0; i < operators.length; i++) if (!operators[i]) operators.splice(i--, 1) var hangingIndent = parserConf.hangingIndent || conf.indentUnit; @@ -58,13 +59,11 @@ var py3 = !(parserConf.version && Number(parserConf.version) < 3) if (py3) { // since http://legacy.python.org/dev/peps/pep-0465/ @ is also an operator - var singleOperators = parserConf.singleOperators || /^[\+\-\*\/%&|\^~<>!@]/; var identifiers = parserConf.identifiers|| /^[_A-Za-z\u00A1-\uFFFF][_A-Za-z0-9\u00A1-\uFFFF]*/; myKeywords = myKeywords.concat(["nonlocal", "False", "True", "None", "async", "await"]); myBuiltins = myBuiltins.concat(["ascii", "bytes", "exec", "print"]); var stringPrefixes = new RegExp("^(([rbuf]|(br))?('{3}|\"{3}|['\"]))", "i"); } else { - var singleOperators = parserConf.singleOperators || /^[\+\-\*\/%&|\^~<>!]/; var identifiers = parserConf.identifiers|| /^[_A-Za-z][_A-Za-z0-9]*/; myKeywords = myKeywords.concat(["exec", "print"]); myBuiltins = myBuiltins.concat(["apply", "basestring", "buffer", "cmp", "coerce", "execfile", @@ -151,15 +150,10 @@ return state.tokenize(stream, state); } - // Handle operators and Delimiters - if (stream.match(tripleDelimiters) || stream.match(doubleDelimiters)) - return "punctuation"; + for (var i = 0; i < operators.length; i++) + if (stream.match(operators[i])) return "operator" - if (stream.match(doubleOperators) || stream.match(singleOperators)) - return "operator"; - - if (stream.match(singleDelimiters)) - return "punctuation"; + if (stream.match(delimiters)) return "punctuation"; if (state.lastToken == "." && stream.match(identifiers)) return "property"; From e4c6f2b34f32681682c59f09d68f90a80d22d18a Mon Sep 17 00:00:00 2001 From: dwelle Date: Thu, 27 Jul 2017 12:51:39 +0200 Subject: [PATCH 1121/2444] [markdown mode] disallow lists and fencedCode inside blockquote --- mode/markdown/markdown.js | 6 +++--- mode/markdown/test.js | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/mode/markdown/markdown.js b/mode/markdown/markdown.js index db8359e9b9..d646d884b4 100644 --- a/mode/markdown/markdown.js +++ b/mode/markdown/markdown.js @@ -196,7 +196,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) { } else if (stream.match(hrRE, true)) { state.hr = true; return tokenTypes.hr; - } else if (match = stream.match(listRE)) { + } else if (!state.quote && (match = stream.match(listRE))) { var listType = match[1] ? "ol" : "ul"; state.indentation = lineIndentation + stream.current().length; @@ -211,7 +211,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) { state.f = state.inline; if (modeCfg.highlightFormatting) state.formatting = ["list", "list-" + listType]; return getType(state); - } else if (modeCfg.fencedCodeBlocks && (match = stream.match(fencedCodeRE, true))) { + } else if (modeCfg.fencedCodeBlocks && !state.quote && (match = stream.match(fencedCodeRE, true))) { state.fencedChars = match[1] // try switching mode state.localMode = getMode(match[2]); @@ -400,7 +400,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) { if (modeCfg.highlightFormatting) state.formatting = "code"; stream.eatWhile('`'); var count = stream.current().length - if (state.code == 0) { + if (state.code == 0 && (!state.quote || count == 1)) { state.code = count return getType(state) } else if (count == state.code) { // Must be exact diff --git a/mode/markdown/test.js b/mode/markdown/test.js index 8dac53aade..c2ac548305 100644 --- a/mode/markdown/test.js +++ b/mode/markdown/test.js @@ -323,6 +323,20 @@ "", "hello"); + // disallow lists inside blockquote for now because it causes problems outside blockquote + // TODO: fix to be CommonMark-compliant + MT("listNestedInBlockquote", + "[quote"e-1 > - foo]"); + + // disallow fenced blocks inside blockquote because it causes problems outside blockquote + // TODO: fix to be CommonMark-compliant + MT("fencedBlockNestedInBlockquote", + "[quote"e-1 > ```]", + "[quote"e-1 > code]", + "[quote"e-1 > ```]", + // ensure we still allow inline code + "[quote"e-1 > ][quote"e-1&comment `code`]"); + // Header with leading space after continued blockquote (#3287, negative indentation) MT("headerAfterContinuedBlockquote", "[quote"e-1 > foo]", From 0927b971c866c92602d7200f061d59ff78026e09 Mon Sep 17 00:00:00 2001 From: "Jan T. Sott" Date: Tue, 25 Jul 2017 22:32:28 +0200 Subject: [PATCH 1122/2444] [nsis mode] Add support for NSIS 3.02 --- mode/nsis/nsis.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mode/nsis/nsis.js b/mode/nsis/nsis.js index dc8c74cdf4..d6c61facf3 100644 --- a/mode/nsis/nsis.js +++ b/mode/nsis/nsis.js @@ -24,20 +24,20 @@ CodeMirror.defineSimpleMode("nsis",{ { regex: /`(?:[^\\`]|\\.)*`?/, token: "string" }, // Compile Time Commands - {regex: /^\s*(?:\!(include|addincludedir|addplugindir|appendfile|cd|delfile|echo|error|execute|packhdr|finalize|getdllversion|system|tempfile|warning|verbose|define|undef|insertmacro|makensis|searchparse|searchreplace))\b/, token: "keyword"}, + {regex: /^\s*(?:\!(include|addincludedir|addplugindir|appendfile|cd|delfile|echo|error|execute|packhdr|pragma|finalize|getdllversion|system|tempfile|warning|verbose|define|undef|insertmacro|makensis|searchparse|searchreplace))\b/, token: "keyword"}, // Conditional Compilation {regex: /^\s*(?:\!(if(?:n?def)?|ifmacron?def|macro))\b/, token: "keyword", indent: true}, {regex: /^\s*(?:\!(else|endif|macroend))\b/, token: "keyword", dedent: true}, // Runtime Commands - {regex: /^\s*(?:Abort|AddBrandingImage|AddSize|AllowRootDirInstall|AllowSkipFiles|AutoCloseWindow|BGFont|BGGradient|BrandingText|BringToFront|Call|CallInstDLL|Caption|ChangeUI|CheckBitmap|ClearErrors|CompletedText|ComponentText|CopyFiles|CRCCheck|CreateDirectory|CreateFont|CreateShortCut|Delete|DeleteINISec|DeleteINIStr|DeleteRegKey|DeleteRegValue|DetailPrint|DetailsButtonText|DirText|DirVar|DirVerify|EnableWindow|EnumRegKey|EnumRegValue|Exch|Exec|ExecShell|ExecWait|ExpandEnvStrings|File|FileBufSize|FileClose|FileErrorText|FileOpen|FileRead|FileReadByte|FileReadUTF16LE|FileReadWord|FileWriteUTF16LE|FileSeek|FileWrite|FileWriteByte|FileWriteWord|FindClose|FindFirst|FindNext|FindWindow|FlushINI|GetCurInstType|GetCurrentAddress|GetDlgItem|GetDLLVersion|GetDLLVersionLocal|GetErrorLevel|GetFileTime|GetFileTimeLocal|GetFullPathName|GetFunctionAddress|GetInstDirError|GetLabelAddress|GetTempFileName|Goto|HideWindow|Icon|IfAbort|IfErrors|IfFileExists|IfRebootFlag|IfSilent|InitPluginsDir|InstallButtonText|InstallColors|InstallDir|InstallDirRegKey|InstProgressFlags|InstType|InstTypeGetText|InstTypeSetText|IntCmp|IntCmpU|IntFmt|IntOp|IsWindow|LangString|LicenseBkColor|LicenseData|LicenseForceSelection|LicenseLangString|LicenseText|LoadLanguageFile|LockWindow|LogSet|LogText|ManifestDPIAware|ManifestSupportedOS|MessageBox|MiscButtonText|Name|Nop|OutFile|Page|PageCallbacks|Pop|Push|Quit|ReadEnvStr|ReadINIStr|ReadRegDWORD|ReadRegStr|Reboot|RegDLL|Rename|RequestExecutionLevel|ReserveFile|Return|RMDir|SearchPath|SectionGetFlags|SectionGetInstTypes|SectionGetSize|SectionGetText|SectionIn|SectionSetFlags|SectionSetInstTypes|SectionSetSize|SectionSetText|SendMessage|SetAutoClose|SetBrandingImage|SetCompress|SetCompressor|SetCompressorDictSize|SetCtlColors|SetCurInstType|SetDatablockOptimize|SetDateSave|SetDetailsPrint|SetDetailsView|SetErrorLevel|SetErrors|SetFileAttributes|SetFont|SetOutPath|SetOverwrite|SetRebootFlag|SetRegView|SetShellVarContext|SetSilent|ShowInstDetails|ShowUninstDetails|ShowWindow|SilentInstall|SilentUnInstall|Sleep|SpaceTexts|StrCmp|StrCmpS|StrCpy|StrLen|SubCaption|Unicode|UninstallButtonText|UninstallCaption|UninstallIcon|UninstallSubCaption|UninstallText|UninstPage|UnRegDLL|Var|VIAddVersionKey|VIFileVersion|VIProductVersion|WindowIcon|WriteINIStr|WriteRegBin|WriteRegDWORD|WriteRegExpandStr|WriteRegStr|WriteUninstaller|XPStyle)\b/, token: "keyword"}, + {regex: /^\s*(?:Abort|AddBrandingImage|AddSize|AllowRootDirInstall|AllowSkipFiles|AutoCloseWindow|BGFont|BGGradient|BrandingText|BringToFront|Call|CallInstDLL|Caption|ChangeUI|CheckBitmap|ClearErrors|CompletedText|ComponentText|CopyFiles|CRCCheck|CreateDirectory|CreateFont|CreateShortCut|Delete|DeleteINISec|DeleteINIStr|DeleteRegKey|DeleteRegValue|DetailPrint|DetailsButtonText|DirText|DirVar|DirVerify|EnableWindow|EnumRegKey|EnumRegValue|Exch|Exec|ExecShell|ExecShellWait|ExecWait|ExpandEnvStrings|File|FileBufSize|FileClose|FileErrorText|FileOpen|FileRead|FileReadByte|FileReadUTF16LE|FileReadWord|FileWriteUTF16LE|FileSeek|FileWrite|FileWriteByte|FileWriteWord|FindClose|FindFirst|FindNext|FindWindow|FlushINI|GetCurInstType|GetCurrentAddress|GetDlgItem|GetDLLVersion|GetDLLVersionLocal|GetErrorLevel|GetFileTime|GetFileTimeLocal|GetFullPathName|GetFunctionAddress|GetInstDirError|GetLabelAddress|GetTempFileName|Goto|HideWindow|Icon|IfAbort|IfErrors|IfFileExists|IfRebootFlag|IfSilent|InitPluginsDir|InstallButtonText|InstallColors|InstallDir|InstallDirRegKey|InstProgressFlags|InstType|InstTypeGetText|InstTypeSetText|IntCmp|IntCmpU|IntFmt|IntOp|IsWindow|LangString|LicenseBkColor|LicenseData|LicenseForceSelection|LicenseLangString|LicenseText|LoadLanguageFile|LockWindow|LogSet|LogText|ManifestDPIAware|ManifestSupportedOS|MessageBox|MiscButtonText|Name|Nop|OutFile|Page|PageCallbacks|Pop|Push|Quit|ReadEnvStr|ReadINIStr|ReadRegDWORD|ReadRegStr|Reboot|RegDLL|Rename|RequestExecutionLevel|ReserveFile|Return|RMDir|SearchPath|SectionGetFlags|SectionGetInstTypes|SectionGetSize|SectionGetText|SectionIn|SectionSetFlags|SectionSetInstTypes|SectionSetSize|SectionSetText|SendMessage|SetAutoClose|SetBrandingImage|SetCompress|SetCompressor|SetCompressorDictSize|SetCtlColors|SetCurInstType|SetDatablockOptimize|SetDateSave|SetDetailsPrint|SetDetailsView|SetErrorLevel|SetErrors|SetFileAttributes|SetFont|SetOutPath|SetOverwrite|SetRebootFlag|SetRegView|SetShellVarContext|SetSilent|ShowInstDetails|ShowUninstDetails|ShowWindow|SilentInstall|SilentUnInstall|Sleep|SpaceTexts|StrCmp|StrCmpS|StrCpy|StrLen|SubCaption|Unicode|UninstallButtonText|UninstallCaption|UninstallIcon|UninstallSubCaption|UninstallText|UninstPage|UnRegDLL|Var|VIAddVersionKey|VIFileVersion|VIProductVersion|WindowIcon|WriteINIStr|WriteRegBin|WriteRegDWORD|WriteRegExpandStr|WriteRegMultiStr|WriteRegNone|WriteRegStr|WriteUninstaller|XPStyle)\b/, token: "keyword"}, {regex: /^\s*(?:Function|PageEx|Section(?:Group)?)\b/, token: "keyword", indent: true}, {regex: /^\s*(?:(Function|PageEx|Section(?:Group)?)End)\b/, token: "keyword", dedent: true}, // Command Options - {regex: /\b(?:ARCHIVE|FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_NORMAL|FILE_ATTRIBUTE_OFFLINE|FILE_ATTRIBUTE_READONLY|FILE_ATTRIBUTE_SYSTEM|FILE_ATTRIBUTE_TEMPORARY|HIDDEN|HKCC|HKCR|HKCU|HKDD|HKEY_CLASSES_ROOT|HKEY_CURRENT_CONFIG|HKEY_CURRENT_USER|HKEY_DYN_DATA|HKEY_LOCAL_MACHINE|HKEY_PERFORMANCE_DATA|HKEY_USERS|HKLM|HKPD|HKU|IDABORT|IDCANCEL|IDD_DIR|IDD_INST|IDD_INSTFILES|IDD_LICENSE|IDD_SELCOM|IDD_UNINST|IDD_VERIFY|IDIGNORE|IDNO|IDOK|IDRETRY|IDYES|MB_ABORTRETRYIGNORE|MB_DEFBUTTON1|MB_DEFBUTTON2|MB_DEFBUTTON3|MB_DEFBUTTON4|MB_ICONEXCLAMATION|MB_ICONINFORMATION|MB_ICONQUESTION|MB_ICONSTOP|MB_OK|MB_OKCANCEL|MB_RETRYCANCEL|MB_RIGHT|MB_RTLREADING|MB_SETFOREGROUND|MB_TOPMOST|MB_USERICON|MB_YESNO|MB_YESNOCANCEL|NORMAL|OFFLINE|READONLY|SHCTX|SHELL_CONTEXT|SW_HIDE|SW_SHOWDEFAULT|SW_SHOWMAXIMIZED|SW_SHOWMINIMIZED|SW_SHOWNORMAL|SYSTEM|TEMPORARY)\b/, token: "atom"}, - {regex: /\b(?:admin|all|auto|both|bottom|bzip2|components|current|custom|directory|force|hide|highest|ifdiff|ifnewer|instfiles|lastused|leave|left|license|listonly|lzma|nevershow|none|normal|notset|right|show|silent|silentlog|textonly|top|try|un\.components|un\.custom|un\.directory|un\.instfiles|un\.license|uninstConfirm|user|Win10|Win7|Win8|WinVista|zlib)\b/, token: "builtin"}, + {regex: /\b(?:ARCHIVE|FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_NORMAL|FILE_ATTRIBUTE_OFFLINE|FILE_ATTRIBUTE_READONLY|FILE_ATTRIBUTE_SYSTEM|FILE_ATTRIBUTE_TEMPORARY|HIDDEN|HKCC|HKCR(32|64)?|HKCU(32|64)?|HKDD|HKEY_CLASSES_ROOT|HKEY_CURRENT_CONFIG|HKEY_CURRENT_USER|HKEY_DYN_DATA|HKEY_LOCAL_MACHINE|HKEY_PERFORMANCE_DATA|HKEY_USERS|HKLM(32|64)?|HKPD|HKU|IDABORT|IDCANCEL|IDD_DIR|IDD_INST|IDD_INSTFILES|IDD_LICENSE|IDD_SELCOM|IDD_UNINST|IDD_VERIFY|IDIGNORE|IDNO|IDOK|IDRETRY|IDYES|MB_ABORTRETRYIGNORE|MB_DEFBUTTON1|MB_DEFBUTTON2|MB_DEFBUTTON3|MB_DEFBUTTON4|MB_ICONEXCLAMATION|MB_ICONINFORMATION|MB_ICONQUESTION|MB_ICONSTOP|MB_OK|MB_OKCANCEL|MB_RETRYCANCEL|MB_RIGHT|MB_RTLREADING|MB_SETFOREGROUND|MB_TOPMOST|MB_USERICON|MB_YESNO|MB_YESNOCANCEL|NORMAL|OFFLINE|READONLY|SHCTX|SHELL_CONTEXT|SW_HIDE|SW_SHOWDEFAULT|SW_SHOWMAXIMIZED|SW_SHOWMINIMIZED|SW_SHOWNORMAL|SYSTEM|TEMPORARY)\b/, token: "atom"}, + {regex: /\b(?:admin|all|auto|both|bottom|bzip2|components|current|custom|directory|false|force|hide|highest|ifdiff|ifnewer|instfiles|lastused|leave|left|license|listonly|lzma|nevershow|none|normal|notset|off|on|right|show|silent|silentlog|textonly|top|true|try|un\.components|un\.custom|un\.directory|un\.instfiles|un\.license|uninstConfirm|user|Win10|Win7|Win8|WinVista|zlib)\b/, token: "builtin"}, // LogicLib.nsh {regex: /\$\{(?:And(?:If(?:Not)?|Unless)|Break|Case(?:Else)?|Continue|Default|Do(?:Until|While)?|Else(?:If(?:Not)?|Unless)?|End(?:If|Select|Switch)|Exit(?:Do|For|While)|For(?:Each)?|If(?:Cmd|Not(?:Then)?|Then)?|Loop(?:Until|While)?|Or(?:If(?:Not)?|Unless)|Select|Switch|Unless|While)\}/, token: "variable-2", indent: true}, From 6bbdb75be5a839d6a9f92adaf7357a04af639705 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Fri, 28 Jul 2017 14:29:51 +0200 Subject: [PATCH 1123/2444] [continuecomment addon] Don't assume comment lines are a single token Issue codemirror/google-modes#8 --- addon/comment/continuecomment.js | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/addon/comment/continuecomment.js b/addon/comment/continuecomment.js index b11d51e6ca..d7385ef223 100644 --- a/addon/comment/continuecomment.js +++ b/addon/comment/continuecomment.js @@ -18,30 +18,28 @@ if (cm.getOption("disableInput")) return CodeMirror.Pass; var ranges = cm.listSelections(), mode, inserts = []; for (var i = 0; i < ranges.length; i++) { - var pos = ranges[i].head, token = cm.getTokenAt(pos); - if (token.type != "comment") return CodeMirror.Pass; - var modeHere = CodeMirror.innerMode(cm.getMode(), token.state).mode; + var pos = ranges[i].head + if (!/\bcomment\b/.test(cm.getTokenTypeAt(pos))) return CodeMirror.Pass; + var modeHere = cm.getModeAt(pos) if (!mode) mode = modeHere; else if (mode != modeHere) return CodeMirror.Pass; var insert = null; if (mode.blockCommentStart && mode.blockCommentContinue) { - var end = token.string.indexOf(mode.blockCommentEnd); - var full = cm.getRange(CodeMirror.Pos(pos.line, 0), CodeMirror.Pos(pos.line, token.end)), found; - if (end != -1 && end == token.string.length - mode.blockCommentEnd.length && pos.ch >= end) { + var line = cm.getLine(pos.line).slice(0, pos.ch) + var end = line.indexOf(mode.blockCommentEnd), found + if (end != -1 && end == pos.ch - mode.blockCommentEnd.length) { // Comment ended, don't continue it - } else if (token.string.indexOf(mode.blockCommentStart) == 0) { - insert = full.slice(0, token.start); - if (!/^\s*$/.test(insert)) { - insert = ""; - for (var j = 0; j < token.start; ++j) insert += " "; + } else if ((found = line.indexOf(mode.blockCommentStart)) > -1) { + insert = line.slice(0, found) + if (/\S/.test(insert)) { + insert = "" + for (var j = 0; j < found; ++j) insert += " " } - } else if ((found = full.indexOf(mode.blockCommentContinue)) != -1 && - found + mode.blockCommentContinue.length > token.start && - /^\s*$/.test(full.slice(0, found))) { - insert = full.slice(0, found); + } else if ((found = line.indexOf(mode.blockCommentContinue)) > -1 && !/\S/.test(line.slice(0, found))) { + insert = line.slice(0, found) } - if (insert != null) insert += mode.blockCommentContinue; + if (insert != null) insert += mode.blockCommentContinue } if (insert == null && mode.lineComment && continueLineCommentEnabled(cm)) { var line = cm.getLine(pos.line), found = line.indexOf(mode.lineComment); From 2b8b8e72e70b6e8e4205be3f35a8b9a50983595b Mon Sep 17 00:00:00 2001 From: Benjamin Young Date: Fri, 28 Jul 2017 11:27:27 -0400 Subject: [PATCH 1124/2444] Add alternate media type for Shell Seems Apache has its own list for non-registered media types. --- mode/meta.js | 2 +- mode/shell/index.html | 2 +- mode/shell/shell.js | 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/mode/meta.js b/mode/meta.js index edaae033eb..20973ace3d 100644 --- a/mode/meta.js +++ b/mode/meta.js @@ -121,7 +121,7 @@ {name: "Scala", mime: "text/x-scala", mode: "clike", ext: ["scala"]}, {name: "Scheme", mime: "text/x-scheme", mode: "scheme", ext: ["scm", "ss"]}, {name: "SCSS", mime: "text/x-scss", mode: "css", ext: ["scss"]}, - {name: "Shell", mime: "text/x-sh", mode: "shell", ext: ["sh", "ksh", "bash"], alias: ["bash", "sh", "zsh"], file: /^PKGBUILD$/}, + {name: "Shell", mimes: ["text/x-sh", "application/x-sh"], mode: "shell", ext: ["sh", "ksh", "bash"], alias: ["bash", "sh", "zsh"], file: /^PKGBUILD$/}, {name: "Sieve", mime: "application/sieve", mode: "sieve", ext: ["siv", "sieve"]}, {name: "Slim", mimes: ["text/x-slim", "application/x-slim"], mode: "slim", ext: ["slim"]}, {name: "Smalltalk", mime: "text/x-stsrc", mode: "smalltalk", ext: ["st"]}, diff --git a/mode/shell/index.html b/mode/shell/index.html index 0b56300b12..e42f4b5f3b 100644 --- a/mode/shell/index.html +++ b/mode/shell/index.html @@ -62,5 +62,5 @@

    Shell mode

    }); -

    MIME types defined: text/x-sh.

    +

    MIME types defined: text/x-sh, application/x-sh.

    diff --git a/mode/shell/shell.js b/mode/shell/shell.js index 6af814c43e..c5619afe7c 100644 --- a/mode/shell/shell.js +++ b/mode/shell/shell.js @@ -135,5 +135,8 @@ CodeMirror.defineMode('shell', function() { }); CodeMirror.defineMIME('text/x-sh', 'shell'); +// Apache uses a slightly different Media Type for Shell scripts +// http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types +CodeMirror.defineMIME('application/x-sh', 'shell'); }); From 81103a3f32220dfe4cf9027f863aa3da893ca6c2 Mon Sep 17 00:00:00 2001 From: Benjamin Young Date: Fri, 28 Jul 2017 11:32:12 -0400 Subject: [PATCH 1125/2444] Add application/pgp-encrypted MIME type Also .asc and .sig extensions Re: http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types --- mode/asciiarmor/asciiarmor.js | 1 + mode/asciiarmor/index.html | 2 +- mode/meta.js | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/mode/asciiarmor/asciiarmor.js b/mode/asciiarmor/asciiarmor.js index d830903767..fa1b0f8c61 100644 --- a/mode/asciiarmor/asciiarmor.js +++ b/mode/asciiarmor/asciiarmor.js @@ -68,6 +68,7 @@ }); CodeMirror.defineMIME("application/pgp", "asciiarmor"); + CodeMirror.defineMIME("application/pgp-encrypted", "asciiarmor"); CodeMirror.defineMIME("application/pgp-keys", "asciiarmor"); CodeMirror.defineMIME("application/pgp-signature", "asciiarmor"); }); diff --git a/mode/asciiarmor/index.html b/mode/asciiarmor/index.html index 8ba1b5c76c..4d584efbcd 100644 --- a/mode/asciiarmor/index.html +++ b/mode/asciiarmor/index.html @@ -41,6 +41,6 @@

    ASCII Armor (PGP) mode

    MIME types -defined: application/pgp, application/pgp-keys, application/pgp-signature

    +defined: application/pgp, application/pgp-encrypted, application/pgp-keys, application/pgp-signature

    diff --git a/mode/meta.js b/mode/meta.js index 20973ace3d..b08ff933f4 100644 --- a/mode/meta.js +++ b/mode/meta.js @@ -13,7 +13,7 @@ CodeMirror.modeInfo = [ {name: "APL", mime: "text/apl", mode: "apl", ext: ["dyalog", "apl"]}, - {name: "PGP", mimes: ["application/pgp", "application/pgp-keys", "application/pgp-signature"], mode: "asciiarmor", ext: ["pgp"]}, + {name: "PGP", mimes: ["application/pgp", "application/pgp-encrypted", "application/pgp-keys", "application/pgp-signature"], mode: "asciiarmor", ext: ["asc", "pgp", "sig"]}, {name: "ASN.1", mime: "text/x-ttcn-asn", mode: "asn.1", ext: ["asn", "asn1"]}, {name: "Asterisk", mime: "text/x-asterisk", mode: "asterisk", file: /^extensions\.conf$/i}, {name: "Brainfuck", mime: "text/x-brainfuck", mode: "brainfuck", ext: ["b", "bf"]}, From 902571b643c5df6b1cc8965377e5e35800ed706e Mon Sep 17 00:00:00 2001 From: Benjamin Young Date: Fri, 28 Jul 2017 11:51:35 -0400 Subject: [PATCH 1126/2444] Add additional CoffeeScript MIMES IANA registered application/vnd.coffeescript Also noted the text/coffeescript option in the demo --- mode/coffeescript/coffeescript.js | 4 ++++ mode/coffeescript/index.html | 2 +- mode/meta.js | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/mode/coffeescript/coffeescript.js b/mode/coffeescript/coffeescript.js index adf2184fd7..ae955db344 100644 --- a/mode/coffeescript/coffeescript.js +++ b/mode/coffeescript/coffeescript.js @@ -349,6 +349,10 @@ CodeMirror.defineMode("coffeescript", function(conf, parserConf) { return external; }); +// IANA registered media type +// https://www.iana.org/assignments/media-types/ +CodeMirror.defineMIME("application/vnd.coffeescript", "coffeescript"); + CodeMirror.defineMIME("text/x-coffeescript", "coffeescript"); CodeMirror.defineMIME("text/coffeescript", "coffeescript"); diff --git a/mode/coffeescript/index.html b/mode/coffeescript/index.html index 93a5f4f309..92d161e9dd 100644 --- a/mode/coffeescript/index.html +++ b/mode/coffeescript/index.html @@ -733,7 +733,7 @@

    CoffeeScript mode

    var editor = CodeMirror.fromTextArea(document.getElementById("code"), {}); -

    MIME types defined: text/x-coffeescript.

    +

    MIME types defined: application/vnd.coffeescript, text/coffeescript, text/x-coffeescript.

    The CoffeeScript mode was written by Jeff Pickhardt.

    diff --git a/mode/meta.js b/mode/meta.js index b08ff933f4..d1c42a03a7 100644 --- a/mode/meta.js +++ b/mode/meta.js @@ -25,7 +25,7 @@ {name: "ClojureScript", mime: "text/x-clojurescript", mode: "clojure", ext: ["cljs"]}, {name: "Closure Stylesheets (GSS)", mime: "text/x-gss", mode: "css", ext: ["gss"]}, {name: "CMake", mime: "text/x-cmake", mode: "cmake", ext: ["cmake", "cmake.in"], file: /^CMakeLists.txt$/}, - {name: "CoffeeScript", mime: "text/x-coffeescript", mode: "coffeescript", ext: ["coffee"], alias: ["coffee", "coffee-script"]}, + {name: "CoffeeScript", mimes: ["application/vnd.coffeescript", "text/coffeescript", "text/x-coffeescript"], mode: "coffeescript", ext: ["coffee"], alias: ["coffee", "coffee-script"]}, {name: "Common Lisp", mime: "text/x-common-lisp", mode: "commonlisp", ext: ["cl", "lisp", "el"], alias: ["lisp"]}, {name: "Cypher", mime: "application/x-cypher-query", mode: "cypher", ext: ["cyp", "cypher"]}, {name: "Cython", mime: "text/x-cython", mode: "python", ext: ["pyx", "pxd", "pxi"]}, From 910e3becbd8de199165e65e7bd1ade10937f9e0e Mon Sep 17 00:00:00 2001 From: Adrian Heine Date: Sat, 29 Jul 2017 00:41:32 +0200 Subject: [PATCH 1127/2444] [python mode] Add regression test for #4876 --- mode/python/test.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mode/python/test.js b/mode/python/test.js index c1a9c6a990..950eed51e6 100644 --- a/mode/python/test.js +++ b/mode/python/test.js @@ -24,6 +24,11 @@ MT("matmulWithSpace:", "[variable a] [operator @] [variable b]"); MT("matmulWithoutSpace:", "[variable a][operator @][variable b]"); MT("matmulSpaceBefore:", "[variable a] [operator @][variable b]"); + var before_equal_sign = ["+", "-", "*", "/", "=", "!", ">", "<"]; + for (var i = 0; i < before_equal_sign.length; ++i) { + var c = before_equal_sign[i] + MT("before_equal_sign_" + c, "[variable a] [operator " + c + "=] [variable b]"); + } MT("fValidStringPrefix", "[string f'this is a {formatted} string']"); MT("uValidStringPrefix", "[string u'this is an unicode string']"); From 166959fcd0f1fe8c9c58479ec3abe4e3f34ebfd8 Mon Sep 17 00:00:00 2001 From: Kazuhito Hokamura Date: Mon, 31 Jul 2017 20:29:06 +0900 Subject: [PATCH 1128/2444] Fix broken links --- CHANGELOG.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c0887ed5c..49290390fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -50,7 +50,7 @@ Calling the `Doc` constructor without `new` works again. [markdown mode](http://codemirror.net/mode/markdown/): Fix bug where markup was ignored on indented paragraph lines. -[vim bindings](http://codemirror.net/mode/demo/vim.html): Referencing invalid registers no longer causes an uncaught exception. +[vim bindings](http://codemirror.net/demo/vim.html): Referencing invalid registers no longer causes an uncaught exception. [rust mode](http://codemirror.net/mode/rust/): Add the correct MIME type. @@ -90,7 +90,7 @@ More careful restoration of selections in widgets, during editor redraw. ### New features -[vim bindings](http://codemirror.net/mode/demo/vim.html): Parse line offsets in line or range specs. +[vim bindings](http://codemirror.net/demo/vim.html): Parse line offsets in line or range specs. ## 5.25.2 (2017-04-20) @@ -148,7 +148,7 @@ Add `role=presentation` to more DOM elements to improve screen reader support. [continuelist addon](http://codemirror.net/doc/manual.html#addon_continuelist): Support continuing task lists. -[vim bindings](http://codemirror.net/mode/demo/vim.html): Make Y behave like yy. +[vim bindings](http://codemirror.net/demo/vim.html): Make Y behave like yy. [sql mode](http://codemirror.net/mode/sql/): Support sqlite dialect. @@ -194,7 +194,7 @@ Fix bug in handling of read-only marked text. Positions now support a `sticky` property which determines whether they should be associated with the character before (value `"before"`) or after (value `"after"`) them. -[vim bindings](http://codemirror.net/mode/demo/vim.html): Make it possible to remove built-in bindings through the API. +[vim bindings](http://codemirror.net/demo/vim.html): Make it possible to remove built-in bindings through the API. [comment addon](http://codemirror.net/doc/manual.html#addon_comment): Support a per-mode useInnerComments option to optionally suppress descending to the inner modes to get comment strings. From 4d448b29763032739a9fc356e3bdd326a23b3cd0 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Tue, 1 Aug 2017 10:15:44 +0200 Subject: [PATCH 1129/2444] Also fix vim links in releases.html --- doc/releases.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/releases.html b/doc/releases.html index 86cadb1512..1c882dc310 100644 --- a/doc/releases.html +++ b/doc/releases.html @@ -63,7 +63,7 @@

    Version 5.x

  • sql mode: Handle nested comments.
  • javascript mode: Improve support for TypeScript syntax.
  • markdown mode: Fix bug where markup was ignored on indented paragraph lines.
  • -
  • vim bindings: Referencing invalid registers no longer causes an uncaught exception.
  • +
  • vim bindings: Referencing invalid registers no longer causes an uncaught exception.
  • rust mode: Add the correct MIME type.
  • matchbrackets addon: Document options.
  • Mouse button clicks can now be bound in keymaps by using names like "LeftClick" or "Ctrl-Alt-MiddleTripleClick". When bound to a function, that function will be passed the position of the click as second argument.
  • @@ -79,7 +79,7 @@

    Version 5.x

    • In textarea-mode, don't reset the input field during composition.
    • More careful restoration of selections in widgets, during editor redraw.
    • -
    • vim bindings: Parse line offsets in line or range specs.
    • +
    • vim bindings: Parse line offsets in line or range specs.
    • javascript mode: More TypeScript parsing fixes.
    • julia mode: Fix issue where the mode gets stuck.
    • markdown mode: Understand cross-line links, parse all bracketed things as links.
    • @@ -118,7 +118,7 @@

      Version 5.x

    • soy mode: Improve indentation.
    • lint addon: Support asynchronous linters that return promises.
    • continuelist addon: Support continuing task lists.
    • -
    • vim bindings: Make Y behave like yy.
    • +
    • vim bindings: Make Y behave like yy.
    • sql mode: Support sqlite dialect.
    @@ -133,7 +133,7 @@

    Version 5.x

    • Positions now support a sticky property which determines whether they should be associated with the character before (value "before") or after (value "after") them.
    • -
    • vim bindings: Make it possible to remove built-in bindings through the API.
    • +
    • vim bindings: Make it possible to remove built-in bindings through the API.
    • comment addon: Support a per-mode useInnerComments option to optionally suppress descending to the inner modes to get comment strings.
    • A cursor directly before a line-wrapping break is now drawn before or after the line break depending on which direction you arrived from.
    • Visual cursor motion in line-wrapped right-to-left text should be much more correct.
    • From d600b9479fbd830f0b6b8710241f2f346c7f05e5 Mon Sep 17 00:00:00 2001 From: dwelle Date: Sun, 23 Jul 2017 14:35:41 +0200 Subject: [PATCH 1130/2444] [markdown mode] improve setext & hr tokenization --- mode/markdown/markdown.js | 66 +++++++++++++++++++++++++------------ mode/markdown/test.js | 68 +++++++++++++++++++++++++++++++++++---- 2 files changed, 108 insertions(+), 26 deletions(-) diff --git a/mode/markdown/markdown.js b/mode/markdown/markdown.js index d646d884b4..59a17012da 100644 --- a/mode/markdown/markdown.js +++ b/mode/markdown/markdown.js @@ -90,6 +90,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) { , textRE = /^[^#!\[\]*_\\<>` "'(~:]+/ , fencedCodeRE = new RegExp("^(" + (modeCfg.fencedCodeBlocks === true ? "~~~+|```+" : modeCfg.fencedCodeBlocks) + ")[ \\t]*([\\w+#\-]*)") + , linkDefRE = /^\s*\[[^\]]+?\]:\s*\S+(\s*\S*\s*)?$/ // naive link-definition , punctuation = /[!\"#$%&\'()*+,\-\.\/:;<=>?@\[\\\]^_`{|}~—]/ , expandedTab = " " // CommonMark specifies tab as 4 spaces @@ -110,6 +111,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) { // Blocks function blankLine(state) { + state.hr = false; // Reset linkTitle state state.linkTitle = false; // Reset EM state @@ -137,16 +139,18 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) { function blockNormal(stream, state) { var sol = stream.sol(); + var prevLineLineIsEmpty = lineIsEmpty(state.prevLine); + var prevLineIsIndentedCode = state.indentedCode; + var prevLineIsHr = state.hr; + var prevLineIsList = state.list !== false; + var maxNonCodeIndentation = (state.listStack[state.listStack.length - 1] || 0) + 3; - var prevLineIsList = state.list !== false, - prevLineIsIndentedCode = state.indentedCode; - + state.hr = false; state.indentedCode = false; - var lineIndentation; + var lineIndentation = state.indentation; // compute once per line (on first token) if (state.indentationDiff === null) { - lineIndentation = state.indentation; state.indentationDiff = state.indentation; if (prevLineIsList) { state.list = null; @@ -168,8 +172,11 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) { } } + var isHr = (state.list === false || prevLineIsHr || prevLineLineIsEmpty) && + state.indentation <= maxNonCodeIndentation && stream.match(hrRE); + var match = null; - if (state.indentationDiff >= 4 && (prevLineIsIndentedCode || lineIsEmpty(state.prevLine))) { + if (state.indentationDiff >= 4 && (prevLineIsIndentedCode || prevLineLineIsEmpty)) { stream.skipToEnd(); state.indentedCode = true; return tokenTypes.code; @@ -180,23 +187,12 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) { if (modeCfg.highlightFormatting) state.formatting = "header"; state.f = state.inline; return getType(state); - } else if (!lineIsEmpty(state.prevLine) && !state.quote && !prevLineIsList && - !prevLineIsIndentedCode && (match = stream.match(setextHeaderRE))) { - state.header = match[0].charAt(0) == '=' ? 1 : 2; - if (modeCfg.highlightFormatting) state.formatting = "header"; - state.f = state.inline; - return getType(state); } else if (stream.eat('>')) { state.quote = sol ? 1 : state.quote + 1; if (modeCfg.highlightFormatting) state.formatting = "quote"; stream.eatSpace(); return getType(state); - } else if (stream.peek() === '[') { - return switchInline(stream, state, footnoteLink); - } else if (stream.match(hrRE, true)) { - state.hr = true; - return tokenTypes.hr; - } else if (!state.quote && (match = stream.match(listRE))) { + } else if (!isHr && !state.quote && (match = stream.match(listRE))) { var listType = match[1] ? "ol" : "ul"; state.indentation = lineIndentation + stream.current().length; @@ -220,6 +216,35 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) { if (modeCfg.highlightFormatting) state.formatting = "code-block"; state.code = -1 return getType(state); + // SETEXT has lowest block-scope precedence after HR, so check it after + // the others (code, blockquote, list...) + } else if ( + // if setext set, indicates line after ---/=== + state.setext || ( + // line before ---/=== + !state.quote && state.list === false && !state.code && !isHr && + !prevLineIsList && !linkDefRE.test(stream.string) && + (match = stream.lookAhead(1)) && (match = match.match(setextHeaderRE)) + ) + ) { + if ( !state.setext ) { + state.header = match[0].charAt(0) == '=' ? 1 : 2; + state.setext = state.header; + } else { + state.header = state.setext; + // has no effect on type so we can reset it now + state.setext = 0; + stream.skipToEnd(); + if (modeCfg.highlightFormatting) state.formatting = "header"; + } + state.f = state.inline; + return getType(state); + } else if (isHr) { + stream.skipToEnd(); + state.hr = true; + return tokenTypes.hr; + } else if (stream.peek() === '[') { + return switchInline(stream, state, footnoteLink); } return switchInline(stream, state, state.inline); @@ -703,6 +728,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) { em: false, strong: false, header: 0, + setext: 0, hr: false, taskList: false, list: false, @@ -741,6 +767,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) { strikethrough: s.strikethrough, emoji: s.emoji, header: s.header, + setext: s.setext, hr: s.hr, taskList: s.taskList, list: s.list, @@ -760,9 +787,8 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) { state.formatting = false; if (stream != state.thisLine) { - // Reset state.header and state.hr + // Reset state.header state.header = 0; - state.hr = false; if (stream.match(/^\s*$/, true)) { blankLine(state); diff --git a/mode/markdown/test.js b/mode/markdown/test.js index c2ac548305..c2c9fb1120 100644 --- a/mode/markdown/test.js +++ b/mode/markdown/test.js @@ -67,7 +67,7 @@ "[header&header-1&formatting&formatting-header&formatting-header-1 # ][header&header-1 foo # bar ][header&header-1&formatting&formatting-header&formatting-header-1 #]"); FT("formatting_setextHeader", - "foo", + "[header&header-1 foo]", "[header&header-1&formatting&formatting-header&formatting-header-1 =]"); FT("formatting_blockquote", @@ -237,27 +237,27 @@ // // Check if single underlining = works MT("setextH1", - "foo", + "[header&header-1 foo]", "[header&header-1 =]"); // Check if 3+ ='s work MT("setextH1", - "foo", + "[header&header-1 foo]", "[header&header-1 ===]"); // Check if single underlining - works MT("setextH2", - "foo", + "[header&header-2 foo]", "[header&header-2 -]"); // Check if 3+ -'s work MT("setextH2", - "foo", + "[header&header-2 foo]", "[header&header-2 ---]"); // http://spec.commonmark.org/0.19/#example-45 MT("setextH2AllowSpaces", - "foo", + "[header&header-2 foo]", " [header&header-2 ---- ]"); // http://spec.commonmark.org/0.19/#example-44 @@ -265,15 +265,50 @@ " [comment foo]", "[hr ---]"); + MT("setextAfterFencedCode", + "[comment ```]", + "[comment foo]", + "[comment ```]", + "[header&header-2 bar]", + "[header&header-2 ---]"); + + MT("setextAferATX", + "[header&header-1 # foo]", + "[header&header-2 bar]", + "[header&header-2 ---]"); + // http://spec.commonmark.org/0.19/#example-51 MT("noSetextAfterQuote", "[quote"e-1 > foo]", + "[hr ---]", + "", + "[quote"e-1 > foo]", + "[quote"e-1 bar]", "[hr ---]"); MT("noSetextAfterList", "[variable-2 - foo]", + "[hr ---]", + "", + "[variable-2 - foo]", + "bar", + "[hr ---]"); + + MT("setext_nestedInlineMarkup", + "[header&header-1 foo ][em&header&header-1 *bar*]", + "[header&header-1 =]"); + + MT("setext_linkDef", + "[link [[aaa]]:] [string&url http://google.com 'title']", "[hr ---]"); + // currently, looks max one line ahead, thus won't catch valid CommonMark + // markup + MT("setext_oneLineLookahead", + "foo", + "[header&header-1 bar]", + "[header&header-1 =]"); + // Single-line blockquote with trailing space MT("blockquoteSpace", "[quote"e-1 > foo]"); @@ -394,6 +429,27 @@ "[variable-2 - foo]", "[hr -----]"); + MT("hrAfterFencedCode", + "[comment ```]", + "[comment code]", + "[comment ```]", + "[hr ---]"); + + // allow hr inside lists + // (require prev line to be empty or hr, TODO: non-CommonMark-compliant) + MT("hrInsideList", + "[variable-2 - foo]", + "", + " [hr ---]", + " [hr ---]", + "", + " [comment ---]"); + + MT("consecutiveHr", + "[hr ---]", + "[hr ---]", + "[hr ---]"); + // Formatting in lists (*) MT("listAsteriskFormatting", "[variable-2 * ][variable-2&em *foo*][variable-2 bar]", From 29fb2806bede834341dd8ea2b601084c31a35880 Mon Sep 17 00:00:00 2001 From: dwelle Date: Mon, 31 Jul 2017 19:22:35 +0200 Subject: [PATCH 1131/2444] [markdown mode] improve header, list & fencedCode behavior around blockquote & indentation --- mode/markdown/markdown.js | 10 +++++++--- mode/markdown/test.js | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 3 deletions(-) diff --git a/mode/markdown/markdown.js b/mode/markdown/markdown.js index 59a17012da..d7f225f82f 100644 --- a/mode/markdown/markdown.js +++ b/mode/markdown/markdown.js @@ -139,6 +139,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) { function blockNormal(stream, state) { var sol = stream.sol(); + var firstTokenOnLine = stream.column() === state.indentation; var prevLineLineIsEmpty = lineIsEmpty(state.prevLine); var prevLineIsIndentedCode = state.indentedCode; var prevLineIsHr = state.hr; @@ -182,7 +183,8 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) { return tokenTypes.code; } else if (stream.eatSpace()) { return null; - } else if ((match = stream.match(atxHeaderRE)) && match[1].length <= 6) { + } else if (firstTokenOnLine && state.indentation <= maxNonCodeIndentation && (match = stream.match(atxHeaderRE)) && match[1].length <= 6) { + state.quote = 0; state.header = match[1].length; if (modeCfg.highlightFormatting) state.formatting = "header"; state.f = state.inline; @@ -192,11 +194,12 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) { if (modeCfg.highlightFormatting) state.formatting = "quote"; stream.eatSpace(); return getType(state); - } else if (!isHr && !state.quote && (match = stream.match(listRE))) { + } else if (!isHr && firstTokenOnLine && state.indentation <= maxNonCodeIndentation && (match = stream.match(listRE))) { var listType = match[1] ? "ol" : "ul"; state.indentation = lineIndentation + stream.current().length; state.list = true; + state.quote = 0; // Add this list item's content's indentation to the stack state.listStack.push(state.indentation); @@ -207,7 +210,8 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) { state.f = state.inline; if (modeCfg.highlightFormatting) state.formatting = ["list", "list-" + listType]; return getType(state); - } else if (modeCfg.fencedCodeBlocks && !state.quote && (match = stream.match(fencedCodeRE, true))) { + } else if (modeCfg.fencedCodeBlocks && firstTokenOnLine && state.indentation <= maxNonCodeIndentation && (match = stream.match(fencedCodeRE, true))) { + state.quote = 0; state.fencedChars = match[1] // try switching mode state.localMode = getMode(match[2]); diff --git a/mode/markdown/test.js b/mode/markdown/test.js index c2c9fb1120..d01b07300a 100644 --- a/mode/markdown/test.js +++ b/mode/markdown/test.js @@ -228,6 +228,19 @@ MT("atxH1inline", "[header&header-1 # foo ][header&header-1&em *bar*]"); + MT("atxIndentedTooMuch", + "[header&header-1 # foo]", + " # bar"); + + // disable atx inside blockquote until we implement proper blockquote inner mode + // TODO: fix to be CommonMark-compliant + MT("atxNestedInsideBlockquote", + "[quote"e-1 > # foo]"); + + MT("atxAfterBlockquote", + "[quote"e-1 > foo]", + "[header&header-1 # bar]"); + // Setext headers - H1, H2 // Per documentation, "Any number of underlining =’s or -’s will work." // http://daringfireball.net/projects/markdown/syntax#header @@ -588,6 +601,19 @@ "", "\t\t[variable-3 part of list2]"); + MT("listAfterBlockquote", + "[quote"e-1 > foo]", + "[variable-2 - bar]"); + + // shouldn't create sublist if it's indented more than allowed + MT("nestedListIndentedTooMuch", + "[variable-2 - foo]", + " [variable-2 - bar]"); + + MT("listIndentedTooMuchAfterParagraph", + "foo", + " - bar"); + // Blockquote MT("blockquote", "[variable-2 * foo]", @@ -1096,6 +1122,19 @@ "[comment ~~~]", "bar"); + FencedTest("fencedCodeBlocksAfterBlockquote", + "[quote"e-1 > foo]", + "[comment ```]", + "[comment bar]", + "[comment ```]"); + + // fencedCode indented too much should act as simple indentedCode + // (hence has no highlight formatting) + FT("tooMuchIndentedFencedCode", + " [comment ```]", + " [comment code]", + " [comment ```]"); + // Tests that require XML mode MT("xmlMode", From 170885a12d2a41aa46229b3f6101449355576cc0 Mon Sep 17 00:00:00 2001 From: dwelle Date: Mon, 31 Jul 2017 19:45:32 +0200 Subject: [PATCH 1132/2444] [markdown mode] auto-terminate fencedCode after exiting list --- mode/markdown/markdown.js | 7 +++++-- mode/markdown/test.js | 10 ++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/mode/markdown/markdown.js b/mode/markdown/markdown.js index d7f225f82f..6082eab8b2 100644 --- a/mode/markdown/markdown.js +++ b/mode/markdown/markdown.js @@ -270,14 +270,17 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) { } function local(stream, state) { - if (state.fencedChars && stream.match(state.fencedChars)) { + var hasExitedList = state.indentation < state.listStack[state.listStack.length - 1]; + if (state.fencedChars && (hasExitedList || stream.match(state.fencedChars))) { if (modeCfg.highlightFormatting) state.formatting = "code-block"; - var returnType = getType(state) + var returnType; + if (!hasExitedList) returnType = getType(state) state.localMode = state.localState = null; state.block = blockNormal; state.f = inlineNormal; state.fencedChars = null; state.code = 0 + if (hasExitedList) return switchBlock(stream, state, state.block); return returnType; } else if (state.fencedChars && stream.skipTo(state.fencedChars)) { return "comment" diff --git a/mode/markdown/test.js b/mode/markdown/test.js index d01b07300a..e9025882f9 100644 --- a/mode/markdown/test.js +++ b/mode/markdown/test.js @@ -1135,6 +1135,16 @@ " [comment code]", " [comment ```]"); + FencedTest("autoTerminateFencedCodeWhenLeavingList", + "[variable-2 - list1]", + " [variable-3 - list2]", + " [variable-3&comment ```]", + " [comment code]", + " [variable-3 - list2]", + " [variable-2&comment ```]", + " [comment code]", + "[quote"e-1 > foo]"); + // Tests that require XML mode MT("xmlMode", From c81346e2c235961292ca5a7e797ee3e9e5fcf7a3 Mon Sep 17 00:00:00 2001 From: dwelle Date: Mon, 31 Jul 2017 19:55:02 +0200 Subject: [PATCH 1133/2444] [markdown mode] improve blockquote indentation behavior --- mode/markdown/markdown.js | 5 ++--- mode/markdown/test.js | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/mode/markdown/markdown.js b/mode/markdown/markdown.js index 6082eab8b2..0692f7eac3 100644 --- a/mode/markdown/markdown.js +++ b/mode/markdown/markdown.js @@ -138,7 +138,6 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) { } function blockNormal(stream, state) { - var sol = stream.sol(); var firstTokenOnLine = stream.column() === state.indentation; var prevLineLineIsEmpty = lineIsEmpty(state.prevLine); var prevLineIsIndentedCode = state.indentedCode; @@ -189,8 +188,8 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) { if (modeCfg.highlightFormatting) state.formatting = "header"; state.f = state.inline; return getType(state); - } else if (stream.eat('>')) { - state.quote = sol ? 1 : state.quote + 1; + } else if (state.indentation <= maxNonCodeIndentation && stream.eat('>')) { + state.quote = firstTokenOnLine ? 1 : state.quote + 1; if (modeCfg.highlightFormatting) state.formatting = "quote"; stream.eatSpace(); return getType(state); diff --git a/mode/markdown/test.js b/mode/markdown/test.js index e9025882f9..21829afbd0 100644 --- a/mode/markdown/test.js +++ b/mode/markdown/test.js @@ -335,12 +335,22 @@ "foo", "[quote"e-1 > bar]"); - // Nested blockquote - MT("blockquoteSpace", + MT("blockquoteNested", "[quote"e-1 > foo]", "[quote"e-1 >][quote"e-2 > foo]", "[quote"e-1 >][quote"e-2 >][quote"e-3 > foo]"); + // ensure quote-level is inferred correctly even if indented + MT("blockquoteNestedIndented", + " [quote"e-1 > foo]", + " [quote"e-1 >][quote"e-2 > foo]", + " [quote"e-1 >][quote"e-2 >][quote"e-3 > foo]"); + + // ensure quote-level is inferred correctly even if indented + MT("blockquoteIndentedTooMuch", + "foo", + " > bar"); + // Single-line blockquote followed by normal paragraph MT("blockquoteThenParagraph", "[quote"e-1 >foo]", From f8b9eeca8f0e90e8a8e8627796f60b4c8bec7954 Mon Sep 17 00:00:00 2001 From: dwelle Date: Tue, 1 Aug 2017 20:10:00 +0200 Subject: [PATCH 1134/2444] [markdown mode] support fencedCodeBlocks in base markdown as per CommonMark --- mode/gfm/gfm.js | 1 - mode/gfm/test.js | 46 ----------------------------------- mode/markdown/index.html | 50 +++++++++++++++++++++++---------------- mode/markdown/markdown.js | 10 ++------ mode/markdown/test.js | 45 ++++++++++++++++++++++------------- 5 files changed, 61 insertions(+), 91 deletions(-) diff --git a/mode/gfm/gfm.js b/mode/gfm/gfm.js index aac04812d8..689cd6e2ec 100644 --- a/mode/gfm/gfm.js +++ b/mode/gfm/gfm.js @@ -114,7 +114,6 @@ CodeMirror.defineMode("gfm", function(config, modeConfig) { var markdownConfig = { taskLists: true, - fencedCodeBlocks: '```', strikethrough: true, emoji: true }; diff --git a/mode/gfm/test.js b/mode/gfm/test.js index 5c8b0332ac..9cda5c45a3 100644 --- a/mode/gfm/test.js +++ b/mode/gfm/test.js @@ -14,11 +14,6 @@ FT("doubleBackticks", "[comment&formatting&formatting-code ``][comment foo ` bar][comment&formatting&formatting-code ``]"); - FT("codeBlock", - "[comment&formatting&formatting-code-block ```css]", - "[tag foo]", - "[comment&formatting&formatting-code-block ```]"); - FT("taskList", "[variable-2&formatting&formatting-list&formatting-list-ul - ][meta&formatting&formatting-task [ ]]][variable-2 foo]", "[variable-2&formatting&formatting-list&formatting-list-ul - ][property&formatting&formatting-task [x]]][variable-2 foo]"); @@ -41,31 +36,6 @@ MT("emStrongUnderscore", "[em&strong ___foo___] bar"); - MT("fencedCodeBlocks", - "[comment ```]", - "[comment foo]", - "", - "[comment ```]", - "bar"); - - MT("fencedCodeBlockModeSwitching", - "[comment ```javascript]", - "[variable foo]", - "", - "[comment ```]", - "bar"); - - MT("fencedCodeBlockModeSwitchingObjc", - "[comment ```objective-c]", - "[keyword @property] [variable NSString] [operator *] [variable foo];", - "[comment ```]", - "bar"); - - MT("fencedCodeBlocksNoTildes", - "~~~", - "foo", - "~~~"); - MT("taskListAsterisk", "[variable-2 * ][link&variable-2 [[]]][variable-2 foo]", // Invalid; must have space or x between [] "[variable-2 * ][link&variable-2 [[ ]]][variable-2 bar]", // Invalid; must have space after ] @@ -166,11 +136,6 @@ MT("notALink", "foo asfd:asdf bar"); - MT("notALink", - "[comment ```css]", - "[tag foo] {[property color]:[keyword black];}", - "[comment ```][link http://www.example.com/]"); - MT("notALink", "[comment ``foo `bar` http://www.example.com/``] hello"); @@ -181,17 +146,6 @@ "", "[link http://www.example.com/]"); - MT("headerCodeBlockGithub", - "[header&header-1 # heading]", - "", - "[comment ```]", - "[comment code]", - "[comment ```]", - "", - "Commit: [link be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2]", - "Issue: [link #1]", - "Link: [link http://www.example.com/]"); - MT("strikethrough", "[strikethrough ~~foo~~]"); diff --git a/mode/markdown/index.html b/mode/markdown/index.html index 15660c2618..77f56ab200 100644 --- a/mode/markdown/index.html +++ b/mode/markdown/index.html @@ -87,7 +87,7 @@

      Markdown mode

      A First Level Header ==================== - + A Second Level Header --------------------- @@ -97,11 +97,11 @@

      Markdown mode

      The quick brown fox jumped over the lazy dog's back. - + ### Header 3 > This is a blockquote. - > + > > This is the second paragraph in the blockquote. > > ## This is an H2 in a blockquote @@ -110,23 +110,23 @@

      Markdown mode

      Output: <h1>A First Level Header</h1> - + <h2>A Second Level Header</h2> - + <p>Now is the time for all good men to come to the aid of their country. This is just a regular paragraph.</p> - + <p>The quick brown fox jumped over the lazy dog's back.</p> - + <h3>Header 3</h3> - + <blockquote> <p>This is a blockquote.</p> - + <p>This is the second paragraph in the blockquote.</p> - + <h2>This is an H2 in a blockquote</h2> </blockquote> @@ -140,7 +140,7 @@

      Markdown mode

      Some of these words *are emphasized*. Some of these words _are emphasized also_. - + Use two asterisks for **strong emphasis**. Or, if you prefer, __use two underscores instead__. @@ -148,10 +148,10 @@

      Markdown mode

      <p>Some of these words <em>are emphasized</em>. Some of these words <em>are emphasized also</em>.</p> - + <p>Use two asterisks for <strong>strong emphasis</strong>. Or, if you prefer, <strong>use two underscores instead</strong>.</p> - + ## Lists ## @@ -204,7 +204,7 @@

      Markdown mode

      the paragraphs by 4 spaces or 1 tab: * A list item. - + With multiple paragraphs. * Another item in the list. @@ -216,7 +216,7 @@

      Markdown mode

      <p>With multiple paragraphs.</p></li> <li><p>Another item in the list.</p></li> </ul> - + ### Links ### @@ -311,7 +311,7 @@

      Markdown mode

      <p>I strongly recommend against using any <code>&lt;blink&gt;</code> tags.</p> - + <p>I wish SmartyPants used named entities like <code>&amp;mdash;</code> instead of decimal-encoded entites like <code>&amp;#8212;</code>.</p> @@ -334,11 +334,20 @@

      Markdown mode

      <p>If you want your page to validate under XHTML 1.0 Strict, you've got to put paragraph tags in your blockquotes:</p> - + <pre><code>&lt;blockquote&gt; &lt;p&gt;For example.&lt;/p&gt; &lt;/blockquote&gt; </code></pre> + +## Fenced code blocks (and syntax highlighting) + +```javascript +for (var i = 0; i < items.length; i++) { + console.log(items[i], i); // log them +} +``` + -

      You might want to use the Github-Flavored Markdown mode instead, which adds support for fenced code blocks and a few other things.

      +

      If you also want support strikethrough, emoji and few other goodies, check out Github-Flavored Markdown mode.

      + +

      Optionally depends on other modes for properly highlighted code blocks, + and XML mode for properly highlighted inline XML blocks.

      -

      Optionally depends on the XML mode for properly highlighted inline XML blocks.

      -

      MIME types defined: text/x-markdown.

      Parsing/Highlighting Tests: normal, verbose.

      diff --git a/mode/markdown/markdown.js b/mode/markdown/markdown.js index 0692f7eac3..beb29dd1e6 100644 --- a/mode/markdown/markdown.js +++ b/mode/markdown/markdown.js @@ -35,11 +35,6 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) { if (modeCfg.maxBlockquoteDepth === undefined) modeCfg.maxBlockquoteDepth = 0; - // Use `fencedCodeBlocks` to configure fenced code blocks. false to - // disable, string to specify a precise regexp that the fence should - // match, and true to allow three or more backticks or tildes (as - // per CommonMark). - // Turn on task lists? ("- [ ] " and "- [x] ") if (modeCfg.taskLists === undefined) modeCfg.taskLists = false; @@ -88,8 +83,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) { , atxHeaderRE = modeCfg.allowAtxHeaderWithoutSpace ? /^(#+)/ : /^(#+)(?: |$)/ , setextHeaderRE = /^ *(?:\={1,}|-{1,})\s*$/ , textRE = /^[^#!\[\]*_\\<>` "'(~:]+/ - , fencedCodeRE = new RegExp("^(" + (modeCfg.fencedCodeBlocks === true ? "~~~+|```+" : modeCfg.fencedCodeBlocks) + - ")[ \\t]*([\\w+#\-]*)") + , fencedCodeRE = /^(~~~+|```+)[ \t]*([\w+#-]*)/ , linkDefRE = /^\s*\[[^\]]+?\]:\s*\S+(\s*\S*\s*)?$/ // naive link-definition , punctuation = /[!\"#$%&\'()*+,\-\.\/:;<=>?@\[\\\]^_`{|}~—]/ , expandedTab = " " // CommonMark specifies tab as 4 spaces @@ -209,7 +203,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) { state.f = state.inline; if (modeCfg.highlightFormatting) state.formatting = ["list", "list-" + listType]; return getType(state); - } else if (modeCfg.fencedCodeBlocks && firstTokenOnLine && state.indentation <= maxNonCodeIndentation && (match = stream.match(fencedCodeRE, true))) { + } else if (firstTokenOnLine && state.indentation <= maxNonCodeIndentation && (match = stream.match(fencedCodeRE, true))) { state.quote = 0; state.fencedChars = match[1] // try switching mode diff --git a/mode/markdown/test.js b/mode/markdown/test.js index 21829afbd0..eb9d856abe 100644 --- a/mode/markdown/test.js +++ b/mode/markdown/test.js @@ -9,8 +9,6 @@ function FT(name) { test.mode(name, modeHighlightFormatting, Array.prototype.slice.call(arguments, 1)); } var modeAtxNoSpace = CodeMirror.getMode(config, {name: "markdown", allowAtxHeaderWithoutSpace: true}); function AtxNoSpaceTest(name) { test.mode(name, modeAtxNoSpace, Array.prototype.slice.call(arguments, 1)); } - var modeFenced = CodeMirror.getMode(config, {name: "markdown", fencedCodeBlocks: true}); - function FencedTest(name) { test.mode(name, modeFenced, Array.prototype.slice.call(arguments, 1)); } var modeOverrideClasses = CodeMirror.getMode(config, { name: "markdown", strikethrough: true, @@ -97,6 +95,11 @@ FT("formatting_image", "[formatting&formatting-image&image&image-marker !][formatting&formatting-image&image&image-alt-text&link [[][image&image-alt-text&link alt text][formatting&formatting-image&image&image-alt-text&link ]]][formatting&formatting-link-string&string&url (][url&string http://link.to/image.jpg][formatting&formatting-link-string&string&url )]"); + FT("codeBlock", + "[comment&formatting&formatting-code-block ```css]", + "[tag foo]", + "[comment&formatting&formatting-code-block ```]"); + MT("plainText", "foo"); @@ -587,7 +590,7 @@ " [variable-2 de-indented text part of list1 again]", "", " [variable-2&comment ```]", - " [variable-2&comment code]", + " [comment code]", " [variable-2&comment ```]", "", " [variable-2 text after fenced code]"); @@ -1085,18 +1088,28 @@ MT("taskList", "[variable-2 * ][link&variable-2 [[ ]]][variable-2 bar]"); - MT("noFencedCodeBlocks", - "~~~", - "foo", - "~~~"); - - FencedTest("fencedCodeBlocks", + MT("fencedCodeBlocks", "[comment ```]", "[comment foo]", + "", + "[comment bar]", + "[comment ```]", + "baz"); + + MT("fencedCodeBlockModeSwitching", + "[comment ```javascript]", + "[variable foo]", + "", + "[comment ```]", + "bar"); + + MT("fencedCodeBlockModeSwitchingObjc", + "[comment ```objective-c]", + "[keyword @property] [variable NSString] [operator *] [variable foo];", "[comment ```]", "bar"); - FencedTest("fencedCodeBlocksMultipleChars", + MT("fencedCodeBlocksMultipleChars", "[comment `````]", "[comment foo]", "[comment ```]", @@ -1104,20 +1117,20 @@ "[comment `````]", "bar"); - FencedTest("fencedCodeBlocksTildes", + MT("fencedCodeBlocksTildes", "[comment ~~~]", "[comment foo]", "[comment ~~~]", "bar"); - FencedTest("fencedCodeBlocksTildesMultipleChars", + MT("fencedCodeBlocksTildesMultipleChars", "[comment ~~~~~]", "[comment ~~~]", "[comment foo]", "[comment ~~~~~]", "bar"); - FencedTest("fencedCodeBlocksMultipleChars", + MT("fencedCodeBlocksMultipleChars", "[comment `````]", "[comment foo]", "[comment ```]", @@ -1125,14 +1138,14 @@ "[comment `````]", "bar"); - FencedTest("fencedCodeBlocksMixed", + MT("fencedCodeBlocksMixed", "[comment ~~~]", "[comment ```]", "[comment foo]", "[comment ~~~]", "bar"); - FencedTest("fencedCodeBlocksAfterBlockquote", + MT("fencedCodeBlocksAfterBlockquote", "[quote"e-1 > foo]", "[comment ```]", "[comment bar]", @@ -1145,7 +1158,7 @@ " [comment code]", " [comment ```]"); - FencedTest("autoTerminateFencedCodeWhenLeavingList", + MT("autoTerminateFencedCodeWhenLeavingList", "[variable-2 - list1]", " [variable-3 - list2]", " [variable-3&comment ```]", From eb2cdcfa145660092d731ebcb6ceac58fb97869d Mon Sep 17 00:00:00 2001 From: dwelle Date: Tue, 1 Aug 2017 23:45:31 +0200 Subject: [PATCH 1135/2444] [markdown mode] allow to disable xml and fencedCodeBlock highlighting --- mode/markdown/markdown.js | 12 +++++++++--- mode/markdown/test.js | 12 ++++++++++++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/mode/markdown/markdown.js b/mode/markdown/markdown.js index beb29dd1e6..58f1dff8aa 100644 --- a/mode/markdown/markdown.js +++ b/mode/markdown/markdown.js @@ -45,6 +45,12 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) { if (modeCfg.emoji === undefined) modeCfg.emoji = false; + if (modeCfg.fencedCodeBlockHighlighting === undefined) + modeCfg.fencedCodeBlockHighlighting = true; + + if (modeCfg.xml === undefined) + modeCfg.xml = true; + // Allow token types to be overridden by user-provided token types. if (modeCfg.tokenTypeOverrides === undefined) modeCfg.tokenTypeOverrides = {}; @@ -207,7 +213,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) { state.quote = 0; state.fencedChars = match[1] // try switching mode - state.localMode = getMode(match[2]); + state.localMode = modeCfg.fencedCodeBlockHighlighting && getMode(match[2]); if (state.localMode) state.localState = CodeMirror.startState(state.localMode); state.f = state.block = local; if (modeCfg.highlightFormatting) state.formatting = "code-block"; @@ -510,7 +516,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) { return type + tokenTypes.linkEmail; } - if (ch === '<' && stream.match(/^(!--|[a-z]+(?:\s+[a-z_:.\-]+(?:\s*=\s*[^ >]+)?)*\s*>)/i, false)) { + if (modeCfg.xml && ch === '<' && stream.match(/^(!--|[a-z]+(?:\s+[a-z_:.\-]+(?:\s*=\s*[^ >]+)?)*\s*>)/i, false)) { var end = stream.string.indexOf(">", stream.pos); if (end != -1) { var atts = stream.string.substring(stream.start, end); @@ -521,7 +527,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) { return switchBlock(stream, state, htmlBlock); } - if (ch === '<' && stream.match(/^\/\w*?>/)) { + if (modeCfg.xml && ch === '<' && stream.match(/^\/\w*?>/)) { state.md_inside = false; return "tag"; } else if (ch === "*" || ch === "_") { diff --git a/mode/markdown/test.js b/mode/markdown/test.js index eb9d856abe..86935c9587 100644 --- a/mode/markdown/test.js +++ b/mode/markdown/test.js @@ -7,6 +7,10 @@ function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); } var modeHighlightFormatting = CodeMirror.getMode(config, {name: "markdown", highlightFormatting: true}); function FT(name) { test.mode(name, modeHighlightFormatting, Array.prototype.slice.call(arguments, 1)); } + var modeMT_noXml = CodeMirror.getMode(config, {name: "markdown", xml: false}); + function MT_noXml(name) { test.mode(name, modeMT_noXml, Array.prototype.slice.call(arguments, 1)); } + var modeMT_noFencedHighlight = CodeMirror.getMode(config, {name: "markdown", fencedCodeBlockHighlighting: false}); + function MT_noFencedHighlight(name) { test.mode(name, modeMT_noFencedHighlight, Array.prototype.slice.call(arguments, 1)); } var modeAtxNoSpace = CodeMirror.getMode(config, {name: "markdown", allowAtxHeaderWithoutSpace: true}); function AtxNoSpaceTest(name) { test.mode(name, modeAtxNoSpace, Array.prototype.slice.call(arguments, 1)); } var modeOverrideClasses = CodeMirror.getMode(config, { @@ -1103,6 +1107,11 @@ "[comment ```]", "bar"); + MT_noFencedHighlight("fencedCodeBlock_noHighlight", + "[comment ```javascript]", + "[comment foo]", + "[comment ```]"); + MT("fencedCodeBlockModeSwitchingObjc", "[comment ```objective-c]", "[keyword @property] [variable NSString] [operator *] [variable foo];", @@ -1186,4 +1195,7 @@ "[tag&bracket <][tag div][tag&bracket >]", "[tag&bracket ]"); + MT_noXml("xmlHighlightDisabled", + "
      foo
      "); + })(); From ab83c3c80fb19333da876ed0a5eed76675324c33 Mon Sep 17 00:00:00 2001 From: dwelle Date: Tue, 1 Aug 2017 23:48:14 +0200 Subject: [PATCH 1136/2444] [markdown mode] update doc with available options --- mode/gfm/index.html | 28 ++++++++++++++++++++++++++++ mode/markdown/index.html | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) diff --git a/mode/gfm/index.html b/mode/gfm/index.html index bec130ca51..ea4bac15fe 100644 --- a/mode/gfm/index.html +++ b/mode/gfm/index.html @@ -103,6 +103,34 @@

      GFM mode

      Optionally depends on other modes for properly highlighted code blocks.

      +

      Gfm mode supports these options (apart those from base Markdown mode):

      +
        +
      • + +
        gitHubSpice: boolean
        +
        Hashes, issues... (default: true).
        +
        +
      • +
      • + +
        taskLists: boolean
        +
        - [ ] syntax (default: true).
        +
        +
      • +
      • + +
        strikethrough: boolean
        +
        ~~foo~~ syntax (default: true).
        +
        +
      • +
      • + +
        emoji: boolean
        +
        :emoji: syntax (default: true).
        +
        +
      • +
      +

      Parsing/Highlighting Tests: normal, verbose.

      diff --git a/mode/markdown/index.html b/mode/markdown/index.html index 77f56ab200..abb379f61a 100644 --- a/mode/markdown/index.html +++ b/mode/markdown/index.html @@ -364,6 +364,40 @@

      Markdown mode

      Optionally depends on other modes for properly highlighted code blocks, and XML mode for properly highlighted inline XML blocks.

      +

      Markdown mode supports these options:

      +
        +
      • + +
        highlightFormatting: boolean
        +
        Whether to separately highlight markdown meta characterts (*[]()etc.) (default: false).
        +
        +
      • +
      • + +
        maxBlockquoteDepth: boolean
        +
        Maximum allowed blockquote nesting (default: 0 - infinite nesting).
        +
        +
      • +
      • + +
        xml: boolean
        +
        Whether to highlight inline XML (default: true).
        +
        +
      • +
      • + +
        fencedCodeBlockHighlighting: boolean
        +
        Whether to syntax-highlight fenced code blocks, if given mode is included (default: true).
        +
        +
      • +
      • + +
        tokenTypeOverrides: Object
        +
        When you want ot override default token type names (e.g. {code: "code"}).
        +
        +
      • +
      +

      MIME types defined: text/x-markdown.

      Parsing/Highlighting Tests: normal, verbose.

      From f80468537d4c96907bd6489f2ffcb132a90e8056 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Wed, 2 Aug 2017 13:25:30 +0200 Subject: [PATCH 1137/2444] Properly call marker.find when scanning DOM text Issue #4889 --- src/input/ContentEditableInput.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/input/ContentEditableInput.js b/src/input/ContentEditableInput.js index d103d2d08f..67de3b1836 100644 --- a/src/input/ContentEditableInput.js +++ b/src/input/ContentEditableInput.js @@ -420,7 +420,7 @@ function domTextBetween(cm, from, to, fromLine, toLine) { let markerID = node.getAttribute("cm-marker"), range if (markerID) { let found = cm.findMarks(Pos(fromLine, 0), Pos(toLine + 1, 0), recognizeMarker(+markerID)) - if (found.length && (range = found[0].find())) + if (found.length && (range = found[0].find(0))) addText(getBetween(cm.doc, range.from, range.to).join(lineSep)) return } From 4c3d3c79a40fce2b38b4b507d3d0e944b56db9ff Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Thu, 3 Aug 2017 10:58:36 +0200 Subject: [PATCH 1138/2444] Copy over origin when splitting change for read-only spans --- src/model/changes.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/model/changes.js b/src/model/changes.js index 214e0231ab..308dc6b399 100644 --- a/src/model/changes.js +++ b/src/model/changes.js @@ -60,7 +60,7 @@ export function makeChange(doc, change, ignoreReadOnly) { let split = sawReadOnlySpans && !ignoreReadOnly && removeReadOnlyRanges(doc, change.from, change.to) if (split) { for (let i = split.length - 1; i >= 0; --i) - makeChangeInner(doc, {from: split[i].from, to: split[i].to, text: i ? [""] : change.text}) + makeChangeInner(doc, {from: split[i].from, to: split[i].to, text: i ? [""] : change.text, origin: change.origin}) } else { makeChangeInner(doc, change) } From 6e44a5118f105268f7f8979845b1d5269f46c472 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Fri, 4 Aug 2017 08:41:29 +0200 Subject: [PATCH 1139/2444] [css mode] Don't feed comment tokens to the state machine Closes #4892 --- mode/css/css.js | 3 ++- mode/css/test.js | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/mode/css/css.js b/mode/css/css.js index 056c48e680..bfe11d3b05 100644 --- a/mode/css/css.js +++ b/mode/css/css.js @@ -383,7 +383,8 @@ CodeMirror.defineMode("css", function(config, parserConfig) { style = style[0]; } override = style; - state.state = states[state.state](type, stream, state); + if (type != "comment") + state.state = states[state.state](type, stream, state); return override; }, diff --git a/mode/css/test.js b/mode/css/test.js index 7a496fb091..6fc6e33ca5 100644 --- a/mode/css/test.js +++ b/mode/css/test.js @@ -197,4 +197,10 @@ MT("counter-style-symbols", "[tag ol] { [property list-style]: [atom symbols]([atom cyclic] [string \"*\"] [string \"\\2020\"] [string \"\\2021\"] [string \"\\A7\"]); }"); + + MT("comment-does-not-disrupt", + "[def @font-face] [comment /* foo */] {", + " [property src]: [atom url]([string x]);", + " [property font-family]: [variable One];", + "}") })(); From d02b119870a82cfe1aa1bf7ade17d35fae3653d7 Mon Sep 17 00:00:00 2001 From: Yvonnick Esnault Date: Thu, 3 Aug 2017 19:10:56 +0200 Subject: [PATCH 1140/2444] [verilog mode] add .sv and .svh extensions Signed-off-by: Yvonnick Esnault --- mode/meta.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mode/meta.js b/mode/meta.js index d1c42a03a7..c49bd6c737 100644 --- a/mode/meta.js +++ b/mode/meta.js @@ -137,7 +137,7 @@ {name: "Swift", mime: "text/x-swift", mode: "swift", ext: ["swift"]}, {name: "sTeX", mime: "text/x-stex", mode: "stex"}, {name: "LaTeX", mime: "text/x-latex", mode: "stex", ext: ["text", "ltx"], alias: ["tex"]}, - {name: "SystemVerilog", mime: "text/x-systemverilog", mode: "verilog", ext: ["v"]}, + {name: "SystemVerilog", mime: "text/x-systemverilog", mode: "verilog", ext: ["v", "sv", "svh"]}, {name: "Tcl", mime: "text/x-tcl", mode: "tcl", ext: ["tcl"]}, {name: "Textile", mime: "text/x-textile", mode: "textile", ext: ["textile"]}, {name: "TiddlyWiki ", mime: "text/x-tiddlywiki", mode: "tiddlywiki"}, From 2fcce279de70ed80f2c682f16ca1151f0e0e3886 Mon Sep 17 00:00:00 2001 From: Moshe Wajnberg Date: Sun, 6 Aug 2017 16:31:26 +0300 Subject: [PATCH 1141/2444] Fix(bidi): Fix for bug /codemirror/CodeMirror/issues/4897 Fix for bug https://github.com/codemirror/CodeMirror/issues/4897 --- demo/bidi.html | 12 ++++++++++++ lib/codemirror.css | 1 + 2 files changed, 13 insertions(+) diff --git a/demo/bidi.html b/demo/bidi.html index ceaffd32e6..645e648c86 100644 --- a/demo/bidi.html +++ b/demo/bidi.html @@ -60,6 +60,11 @@

      Bi-directional Text Demo

      +
      + HTML document direction: + + +
      @@ -80,6 +85,13 @@

      Bi-directional Text Demo

      editor.setOption("direction", dirRadios["rtl"].checked ? "rtl" : "ltr"); }; +var HtmlDirRadios = {ltr: document.getElementById("htmlltr"), + rtl: document.getElementById("htmlrtl")}; +HtmlDirRadios["ltr"].checked = true; +HtmlDirRadios["rtl"].onchange = HtmlDirRadios["ltr"].onchange = function() { + document.dir = (HtmlDirRadios["rtl"].checked ? "rtl" : "ltr"); +}; + var moveCheckbox = document.getElementById("rtlMoveVisually"); moveCheckbox.checked = editor.getOption("rtlMoveVisually"); moveCheckbox.onchange = function() { diff --git a/lib/codemirror.css b/lib/codemirror.css index f4d3c5f40b..9d8ff0ce66 100644 --- a/lib/codemirror.css +++ b/lib/codemirror.css @@ -5,6 +5,7 @@ font-family: monospace; height: 300px; color: black; + direction: ltr; } /* PADDING */ From 4b0ae027938a6ed83b9a2033db291bff8c0f8967 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Tue, 8 Aug 2017 22:12:49 +0200 Subject: [PATCH 1142/2444] [shell mode] Allow strings to span lines Closes #4902 --- mode/shell/shell.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mode/shell/shell.js b/mode/shell/shell.js index c5619afe7c..9b8b90b305 100644 --- a/mode/shell/shell.js +++ b/mode/shell/shell.js @@ -102,7 +102,7 @@ CodeMirror.defineMode('shell', function() { } escaped = !escaped && next === '\\'; } - if (end || !escaped) state.tokens.shift(); + if (end) state.tokens.shift(); return style; }; }; From 974b698fac730685ec51761338786e6801ae366c Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Tue, 8 Aug 2017 23:07:27 +0200 Subject: [PATCH 1143/2444] [javascript mode] Support typescript-style type params to new Closes #4887 --- mode/javascript/javascript.js | 4 ++++ mode/javascript/test.js | 3 +++ 2 files changed, 7 insertions(+) diff --git a/mode/javascript/javascript.js b/mode/javascript/javascript.js index d77862b1d5..50d33dde31 100644 --- a/mode/javascript/javascript.js +++ b/mode/javascript/javascript.js @@ -468,6 +468,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { function maybeTarget(noComma) { return function(type) { if (type == ".") return cont(noComma ? targetNoComma : target); + else if (type == "variable" && isTS) return cont(maybeTypeArgs, noComma ? maybeoperatorNoComma : maybeoperatorComma) else return pass(noComma ? expressionNoComma : expression); }; } @@ -588,6 +589,9 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { if (type == "[") return cont(expect("]"), afterType) if (value == "extends") return cont(typeexpr) } + function maybeTypeArgs(_, value) { + if (value == "<") return cont(pushlex(">"), commasep(typeexpr, ">"), poplex, afterType) + } function vardef() { return pass(pattern, maybetype, maybeAssign, vardefCont); } diff --git a/mode/javascript/test.js b/mode/javascript/test.js index 8fd13aee49..2632fd1df5 100644 --- a/mode/javascript/test.js +++ b/mode/javascript/test.js @@ -343,6 +343,9 @@ "[keyword function] [def x][operator <][type T] [keyword extends] [keyword keyof] [type X][operator >]([def a]: [type T]) {", " [keyword return]") + TS("typescript_new_typeargs", + "[keyword let] [def x] [operator =] [keyword new] [variable Map][operator <][type string], [type Date][operator >]([string-2 `foo${][variable bar][string-2 }`])") + var jsonld_mode = CodeMirror.getMode( {indentUnit: 2}, {name: "javascript", jsonld: true} From 2add03c7efbbb1c685e7da0c4c3733778c6f35d9 Mon Sep 17 00:00:00 2001 From: Jeff Hanke Date: Wed, 9 Aug 2017 04:13:27 -0700 Subject: [PATCH 1144/2444] [html-line addon] Play more nicely with node/webpack. * Pass in and use the htmlhint module required. * Check for verify() and try HTMLHint.HTMLHint if missing because of module nesting. it's require('htmlhint').HTMLHint in node. --- addon/lint/html-lint.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/addon/lint/html-lint.js b/addon/lint/html-lint.js index 98c36b0b64..23de9bb204 100644 --- a/addon/lint/html-lint.js +++ b/addon/lint/html-lint.js @@ -11,8 +11,8 @@ else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror", "htmlhint"], mod); else // Plain browser env - mod(CodeMirror); -})(function(CodeMirror) { + mod(CodeMirror, window.HTMLHint); +})(function(CodeMirror, HTMLHint) { "use strict"; var defaultRules = { @@ -29,9 +29,11 @@ CodeMirror.registerHelper("lint", "html", function(text, options) { var found = []; - if (!window.HTMLHint) { + if (HTMLHint && !HTMLHint.verify) HTMLHint = HTMLHint.HTMLHint; + if (!HTMLHint) HTMLHint = window.HTMLHint; + if (!HTMLHint) { if (window.console) { - window.console.error("Error: window.HTMLHint not defined, CodeMirror HTML linting cannot run."); + window.console.error("Error: HTMLHint not found, not defined on window, or not available through define/require, CodeMirror HTML linting cannot run."); } return found; } From 616116ba326cf4164df28c62380f15e508f65e9a Mon Sep 17 00:00:00 2001 From: CodeBitt <30704531+CodeBitt@users.noreply.github.com> Date: Mon, 14 Aug 2017 17:32:17 -0400 Subject: [PATCH 1145/2444] [real-world uses] Add CodeBitt --- doc/realworld.html | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/realworld.html b/doc/realworld.html index 3995f93e9d..7c5231ba81 100644 --- a/doc/realworld.html +++ b/doc/realworld.html @@ -43,6 +43,7 @@

      CodeMirror real-world uses

    • Complete.ly playground
    • Codeanywhere (multi-platform cloud editor)
    • Code per Node (Drupal module)
    • +
    • CodeBitt (Code snippet sharing)
    • Codebug (PHP Xdebug front-end)
    • CodeMirror Eclipse (embed CM in Eclipse)
    • CodeMirror movie (scripted editing demos)
    • From c06c273afc78781ed0735c8a27680f35397f3f42 Mon Sep 17 00:00:00 2001 From: Sarah McAlear and Wenlin Zhang Date: Mon, 14 Aug 2017 14:41:01 +0800 Subject: [PATCH 1146/2444] [sql-mode] Add greenplum dialect as gpsql --- mode/sql/index.html | 3 ++- mode/sql/sql.js | 13 +++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/mode/sql/index.html b/mode/sql/index.html index dba069dc81..cd95872820 100644 --- a/mode/sql/index.html +++ b/mode/sql/index.html @@ -58,7 +58,8 @@

      SQL Mode for CodeMirror

      text/x-mssql, text/x-hive, text/x-pgsql, - text/x-gql. + text/x-gql, + text/x-gpsql.

      Demonstration of bi-directional text support. See diff --git a/test/test.js b/test/test.js index 32a6c28080..e61365d690 100644 --- a/test/test.js +++ b/test/test.js @@ -255,7 +255,7 @@ testCM("coordsCharBidi", function(cm) { }, {lineNumbers: true}); testCM("badBidiOptimization", function(cm) { - let coords = cm.charCoords(Pos(0, 34)) + var coords = cm.charCoords(Pos(0, 34)) eqCharPos(cm.coordsChar({left: coords.right, top: coords.top + 2}), Pos(0, 34)) }, {value: "----------

      هل يمكنك اختيار مستوى قسط التأمين الذي ترغب بدفعه؟

      "}) From 4ba596ea5af0a1f13fe0bb45588bbd7a12f48439 Mon Sep 17 00:00:00 2001 From: Aram Shatakhtsyan Date: Wed, 13 Sep 2017 17:50:45 -0700 Subject: [PATCH 1187/2444] Add CodeFights to the list of real-world users --- doc/realworld.html | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/realworld.html b/doc/realworld.html index 7c5231ba81..f0a75abf72 100644 --- a/doc/realworld.html +++ b/doc/realworld.html @@ -45,6 +45,7 @@

      CodeMirror real-world uses

    • Code per Node (Drupal module)
    • CodeBitt (Code snippet sharing)
    • Codebug (PHP Xdebug front-end)
    • +
    • CodeFights (practice programming)
    • CodeMirror Eclipse (embed CM in Eclipse)
    • CodeMirror movie (scripted editing demos)
    • CodeMirror2-GWT (Google Web Toolkit wrapper)
    • From 0506dfc565217bf6e5eed5c2770e2dbf30e1f6b2 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Thu, 14 Sep 2017 09:05:51 +0200 Subject: [PATCH 1188/2444] Remove accidentally committed debug changes --- demo/bidi.html | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/demo/bidi.html b/demo/bidi.html index 349a3dba3e..645e648c86 100644 --- a/demo/bidi.html +++ b/demo/bidi.html @@ -26,9 +26,8 @@

      Bi-directional Text Demo

      -
      -

      MIME types defined: +

      MIME types defined: text/x-sql, text/x-mysql, text/x-mariadb, @@ -60,6 +60,7 @@

      SQL Mode for CodeMirror

      text/x-pgsql, text/x-gql, text/x-gpsql. + text/x-esper.

      MIME types defined: text/x-protobuf.

      diff --git a/mode/protobuf/protobuf.js b/mode/protobuf/protobuf.js index bcae276e8d..93cb3b0e05 100644 --- a/mode/protobuf/protobuf.js +++ b/mode/protobuf/protobuf.js @@ -19,7 +19,8 @@ "package", "message", "import", "syntax", "required", "optional", "repeated", "reserved", "default", "extensions", "packed", "bool", "bytes", "double", "enum", "float", "string", - "int32", "int64", "uint32", "uint64", "sint32", "sint64", "fixed32", "fixed64", "sfixed32", "sfixed64" + "int32", "int64", "uint32", "uint64", "sint32", "sint64", "fixed32", "fixed64", "sfixed32", "sfixed64", + "option", "service", "rpc", "returns" ]; var keywords = wordRegexp(keywordArray); From a073d18ea4b08d2e1aecdc075ecef8712c10e64f Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Mon, 16 Oct 2017 11:19:27 +0200 Subject: [PATCH 1246/2444] Remove mode-mutating kludge in continuecomment --- addon/comment/continuecomment.js | 5 ----- mode/clike/clike.js | 1 + mode/css/css.js | 1 + mode/javascript/javascript.js | 1 + 4 files changed, 3 insertions(+), 5 deletions(-) diff --git a/addon/comment/continuecomment.js b/addon/comment/continuecomment.js index d7385ef223..6552b09bbf 100644 --- a/addon/comment/continuecomment.js +++ b/addon/comment/continuecomment.js @@ -9,11 +9,6 @@ else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { - var modes = ["clike", "css", "javascript"]; - - for (var i = 0; i < modes.length; ++i) - CodeMirror.extendMode(modes[i], {blockCommentContinue: " * "}); - function continueComment(cm) { if (cm.getOption("disableInput")) return CodeMirror.Pass; var ranges = cm.listSelections(), mode, inserts = []; diff --git a/mode/clike/clike.js b/mode/clike/clike.js index 0993ca4c4e..d6d12c7117 100644 --- a/mode/clike/clike.js +++ b/mode/clike/clike.js @@ -244,6 +244,7 @@ CodeMirror.defineMode("clike", function(config, parserConfig) { electricInput: indentSwitch ? /^\s*(?:case .*?:|default:|\{\}?|\})$/ : /^\s*[{}]$/, blockCommentStart: "/*", blockCommentEnd: "*/", + blockCommentContinue: " * ", lineComment: "//", fold: "brace" }; diff --git a/mode/css/css.js b/mode/css/css.js index bfe11d3b05..00e9b3df13 100644 --- a/mode/css/css.js +++ b/mode/css/css.js @@ -410,6 +410,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) { electricChars: "}", blockCommentStart: "/*", blockCommentEnd: "*/", + blockCommentContinue: " * ", lineComment: lineComment, fold: "brace" }; diff --git a/mode/javascript/javascript.js b/mode/javascript/javascript.js index d92f8622d4..d6cc4771bd 100644 --- a/mode/javascript/javascript.js +++ b/mode/javascript/javascript.js @@ -821,6 +821,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { electricInput: /^\s*(?:case .*?:|default:|\{|\})$/, blockCommentStart: jsonMode ? null : "/*", blockCommentEnd: jsonMode ? null : "*/", + blockCommentContinue: jsonMode ? null : " ", lineComment: jsonMode ? null : "//", fold: "brace", closeBrackets: "()[]{}''\"\"``", From ad6635a5b40b20cc3f7ca9a77ef1b42634597790 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Mon, 16 Oct 2017 11:20:11 +0200 Subject: [PATCH 1247/2444] [vim bindings] Show fat cursor even in contentEditable mode Issue #3552 --- demo/vim.html | 3 ++- keymap/vim.js | 51 ++++++++++++++++++++++++++++++++++++++++++++-- lib/codemirror.css | 7 ++++++- 3 files changed, 57 insertions(+), 4 deletions(-) diff --git a/demo/vim.html b/demo/vim.html index f27b8b8e2b..bd704f7583 100644 --- a/demo/vim.html +++ b/demo/vim.html @@ -95,7 +95,8 @@

      Vim bindings demo

      mode: "text/x-csrc", keyMap: "vim", matchBrackets: true, - showCursorWhenSelecting: true + showCursorWhenSelecting: true, + inputStyle: "contenteditable" }); var commandDisplay = document.getElementById('command-display'); var keys = ''; diff --git a/keymap/vim.js b/keymap/vim.js index 13c39a1ea0..7cf5a956e0 100644 --- a/keymap/vim.js +++ b/keymap/vim.js @@ -255,20 +255,67 @@ } function detachVimMap(cm, next) { - if (this == CodeMirror.keyMap.vim) + if (this == CodeMirror.keyMap.vim) { CodeMirror.rmClass(cm.getWrapperElement(), "cm-fat-cursor"); + if (cm.getOption("inputStyle") == "contenteditable" && document.body.style.caretColor != null) { + disableFatCursorMark(cm); + cm.getInputField().style.caretColor = ""; + } + } if (!next || next.attach != attachVimMap) leaveVimMode(cm); } function attachVimMap(cm, prev) { - if (this == CodeMirror.keyMap.vim) + if (this == CodeMirror.keyMap.vim) { CodeMirror.addClass(cm.getWrapperElement(), "cm-fat-cursor"); + if (cm.getOption("inputStyle") == "contenteditable" && document.body.style.caretColor != null) { + enableFatCursorMark(cm); + cm.getInputField().style.caretColor = "transparent"; + } + } if (!prev || prev.attach != attachVimMap) enterVimMode(cm); } + function fatCursorMarks(cm) { + var ranges = cm.listSelections(), result = [] + for (var i = 0; i < ranges.length; i++) { + var range = ranges[i] + if (range.empty()) { + if (range.anchor.ch < cm.getLine(range.anchor.line).length) { + result.push(cm.markText(range.anchor, Pos(range.anchor.line, range.anchor.ch + 1), + {className: "cm-fat-cursor-mark"})) + } else { + var widget = document.createElement("span") + widget.textContent = "\u00a0" + widget.className = "cm-fat-cursor-mark" + result.push(cm.setBookmark(range.anchor, {widget: widget})) + } + } + } + return result + } + + function updateFatCursorMark(cm) { + var marks = cm.state.fatCursorMarks + if (marks) for (var i = 0; i < marks.length; i++) marks[i].clear() + cm.state.fatCursorMarks = fatCursorMarks(cm) + } + + function enableFatCursorMark(cm) { + cm.state.fatCursorMarks = fatCursorMarks(cm) + cm.on("cursorActivity", updateFatCursorMark) + } + + function disableFatCursorMark(cm) { + var marks = cm.state.fatCursorMarks + if (marks) for (var i = 0; i < marks.length; i++) marks[i].clear() + cm.state.fatCursorMarks = null + cm.off("cursorActivity", updateFatCursorMark) + } + // Deprecated, simply setting the keymap works again. CodeMirror.defineOption('vimMode', false, function(cm, val, prev) { if (val && cm.getOption("keyMap") != "vim") diff --git a/lib/codemirror.css b/lib/codemirror.css index 9d8ff0ce66..255de98606 100644 --- a/lib/codemirror.css +++ b/lib/codemirror.css @@ -59,7 +59,12 @@ .cm-fat-cursor div.CodeMirror-cursors { z-index: 1; } - +.cm-fat-cursor-mark { + background-color: rgba(20, 255, 20, 0.5); + -webkit-animation: blink 1.06s steps(1) infinite; + -moz-animation: blink 1.06s steps(1) infinite; + animation: blink 1.06s steps(1) infinite; +} .cm-animate-fat-cursor { width: auto; border: 0; From 43d0324c4452e0d8bbc0782fb775cb4838f1d6cf Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Mon, 16 Oct 2017 11:30:59 +0200 Subject: [PATCH 1248/2444] [continuecomment addon] Fix issue with single-line block comments The addon would think it still was in a block comment when one was opened and closed earlier on the line. Issue codemirror/google-modes#58 --- addon/comment/continuecomment.js | 4 ++-- mode/javascript/javascript.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/addon/comment/continuecomment.js b/addon/comment/continuecomment.js index 6552b09bbf..d92318b345 100644 --- a/addon/comment/continuecomment.js +++ b/addon/comment/continuecomment.js @@ -22,10 +22,10 @@ var insert = null; if (mode.blockCommentStart && mode.blockCommentContinue) { var line = cm.getLine(pos.line).slice(0, pos.ch) - var end = line.indexOf(mode.blockCommentEnd), found + var end = line.lastIndexOf(mode.blockCommentEnd), found if (end != -1 && end == pos.ch - mode.blockCommentEnd.length) { // Comment ended, don't continue it - } else if ((found = line.indexOf(mode.blockCommentStart)) > -1) { + } else if ((found = line.lastIndexOf(mode.blockCommentStart)) > -1 && found > end) { insert = line.slice(0, found) if (/\S/.test(insert)) { insert = "" diff --git a/mode/javascript/javascript.js b/mode/javascript/javascript.js index d6cc4771bd..61a6de4be7 100644 --- a/mode/javascript/javascript.js +++ b/mode/javascript/javascript.js @@ -821,7 +821,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { electricInput: /^\s*(?:case .*?:|default:|\{|\})$/, blockCommentStart: jsonMode ? null : "/*", blockCommentEnd: jsonMode ? null : "*/", - blockCommentContinue: jsonMode ? null : " ", + blockCommentContinue: jsonMode ? null : " * ", lineComment: jsonMode ? null : "//", fold: "brace", closeBrackets: "()[]{}''\"\"``", From 1951460e52e2ec1d3615b5240123fe3c284d2e17 Mon Sep 17 00:00:00 2001 From: mtaran-google Date: Wed, 11 Oct 2017 17:45:53 -0700 Subject: [PATCH 1249/2444] [sublime bindings] Export macSublime & pcSublime keymaps This will make it easier to get programmatic access to the content of these keymaps, per #5020 --- keymap/sublime.js | 247 +++++++++++++++++++++++++++++++--------------- 1 file changed, 169 insertions(+), 78 deletions(-) diff --git a/keymap/sublime.js b/keymap/sublime.js index 98266e44f0..eeccab1721 100644 --- a/keymap/sublime.js +++ b/keymap/sublime.js @@ -14,11 +14,8 @@ })(function(CodeMirror) { "use strict"; - var map = CodeMirror.keyMap.sublime = {fallthrough: "default"}; var cmds = CodeMirror.commands; var Pos = CodeMirror.Pos; - var mac = CodeMirror.keyMap["default"] == CodeMirror.keyMap.macDefault; - var ctrl = mac ? "Cmd-" : "Ctrl-"; // This is not exactly Sublime's algorithm. I couldn't make heads or tails of that. function findPosSubword(doc, start, dir) { @@ -52,16 +49,10 @@ }); } - var goSubwordCombo = mac ? "Ctrl-" : "Alt-"; + cmds.goSubwordLeft = function(cm) { moveSubword(cm, -1); }; + cmds.goSubwordRight = function(cm) { moveSubword(cm, 1); }; - cmds[map[goSubwordCombo + "Left"] = "goSubwordLeft"] = function(cm) { moveSubword(cm, -1); }; - cmds[map[goSubwordCombo + "Right"] = "goSubwordRight"] = function(cm) { moveSubword(cm, 1); }; - - if (mac) map["Cmd-Left"] = "goLineStartSmart"; - - var scrollLineCombo = mac ? "Ctrl-Alt-" : "Ctrl-"; - - cmds[map[scrollLineCombo + "Up"] = "scrollLineUp"] = function(cm) { + cmds.scrollLineUp = function(cm) { var info = cm.getScrollInfo(); if (!cm.somethingSelected()) { var visibleBottomLine = cm.lineAtHeight(info.top + info.clientHeight, "local"); @@ -70,7 +61,7 @@ } cm.scrollTo(null, info.top - cm.defaultTextHeight()); }; - cmds[map[scrollLineCombo + "Down"] = "scrollLineDown"] = function(cm) { + cmds.scrollLineDown = function(cm) { var info = cm.getScrollInfo(); if (!cm.somethingSelected()) { var visibleTopLine = cm.lineAtHeight(info.top, "local")+1; @@ -80,7 +71,7 @@ cm.scrollTo(null, info.top + cm.defaultTextHeight()); }; - cmds[map["Shift-" + ctrl + "L"] = "splitSelectionByLine"] = function(cm) { + cmds.splitSelectionByLine = function(cm) { var ranges = cm.listSelections(), lineRanges = []; for (var i = 0; i < ranges.length; i++) { var from = ranges[i].from(), to = ranges[i].to(); @@ -92,14 +83,12 @@ cm.setSelections(lineRanges, 0); }; - map["Shift-Tab"] = "indentLess"; - - cmds[map["Esc"] = "singleSelectionTop"] = function(cm) { + cmds.singleSelectionTop = function(cm) { var range = cm.listSelections()[0]; cm.setSelection(range.anchor, range.head, {scroll: false}); }; - cmds[map[ctrl + "L"] = "selectLine"] = function(cm) { + cmds.selectLine = function(cm) { var ranges = cm.listSelections(), extended = []; for (var i = 0; i < ranges.length; i++) { var range = ranges[i]; @@ -109,8 +98,6 @@ cm.setSelections(extended); }; - map["Shift-Ctrl-K"] = "deleteLine"; - function insertLine(cm, above) { if (cm.isReadOnly()) return CodeMirror.Pass cm.operation(function() { @@ -129,9 +116,9 @@ cm.execCommand("indentAuto"); } - cmds[map[ctrl + "Enter"] = "insertLineAfter"] = function(cm) { return insertLine(cm, false); }; + cmds.insertLineAfter = function(cm) { return insertLine(cm, false); }; - cmds[map["Shift-" + ctrl + "Enter"] = "insertLineBefore"] = function(cm) { return insertLine(cm, true); }; + cmds.insertLineBefore = function(cm) { return insertLine(cm, true); }; function wordAt(cm, pos) { var start = pos.ch, end = start, line = cm.getLine(pos.line); @@ -140,7 +127,7 @@ return {from: Pos(pos.line, start), to: Pos(pos.line, end), word: line.slice(start, end)}; } - cmds[map[ctrl + "D"] = "selectNextOccurrence"] = function(cm) { + cmds.selectNextOccurrence = function(cm) { var from = cm.getCursor("from"), to = cm.getCursor("to"); var fullWord = cm.state.sublimeFindFullWord == cm.doc.sel; if (CodeMirror.cmpPos(from, to) == 0) { @@ -177,10 +164,8 @@ } cm.setSelections(newRanges); } - - var addCursorToLineCombo = mac ? "Shift-Cmd" : 'Alt-Ctrl'; - cmds[map[addCursorToLineCombo + "Up"] = "addCursorToPrevLine"] = function(cm) { addCursorToSelection(cm, -1); }; - cmds[map[addCursorToLineCombo + "Down"] = "addCursorToNextLine"] = function(cm) { addCursorToSelection(cm, 1); }; + cmds.addCursorToPrevLine = function(cm) { addCursorToSelection(cm, -1); }; + cmds.addCursorToNextLine = function(cm) { addCursorToSelection(cm, 1); }; function isSelectedRange(ranges, from, to) { for (var i = 0; i < ranges.length; i++) @@ -209,14 +194,14 @@ return true; } - cmds[map["Shift-" + ctrl + "Space"] = "selectScope"] = function(cm) { + cmds.selectScope = function(cm) { selectBetweenBrackets(cm) || cm.execCommand("selectAll"); }; - cmds[map["Shift-" + ctrl + "M"] = "selectBetweenBrackets"] = function(cm) { + cmds.selectBetweenBrackets = function(cm) { if (!selectBetweenBrackets(cm)) return CodeMirror.Pass; }; - cmds[map[ctrl + "M"] = "goToBracket"] = function(cm) { + cmds.goToBracket = function(cm) { cm.extendSelectionsBy(function(range) { var next = cm.scanForBracket(range.head, 1); if (next && CodeMirror.cmpPos(next.pos, range.head) != 0) return next.pos; @@ -225,9 +210,7 @@ }); }; - var swapLineCombo = mac ? "Cmd-Ctrl-" : "Shift-Ctrl-"; - - cmds[map[swapLineCombo + "Up"] = "swapLineUp"] = function(cm) { + cmds.swapLineUp = function(cm) { if (cm.isReadOnly()) return CodeMirror.Pass var ranges = cm.listSelections(), linesToMove = [], at = cm.firstLine() - 1, newSels = []; for (var i = 0; i < ranges.length; i++) { @@ -254,7 +237,7 @@ }); }; - cmds[map[swapLineCombo + "Down"] = "swapLineDown"] = function(cm) { + cmds.swapLineDown = function(cm) { if (cm.isReadOnly()) return CodeMirror.Pass var ranges = cm.listSelections(), linesToMove = [], at = cm.lastLine() + 1; for (var i = ranges.length - 1; i >= 0; i--) { @@ -278,11 +261,11 @@ }); }; - cmds[map[ctrl + "/"] = "toggleCommentIndented"] = function(cm) { + cmds.toggleCommentIndented = function(cm) { cm.toggleComment({ indent: true }); } - cmds[map[ctrl + "J"] = "joinLines"] = function(cm) { + cmds.joinLines = function(cm) { var ranges = cm.listSelections(), joined = []; for (var i = 0; i < ranges.length; i++) { var range = ranges[i], from = range.from(); @@ -310,7 +293,7 @@ }); }; - cmds[map["Shift-" + ctrl + "D"] = "duplicateLine"] = function(cm) { + cmds.duplicateLine = function(cm) { cm.operation(function() { var rangeCount = cm.listSelections().length; for (var i = 0; i < rangeCount; i++) { @@ -324,7 +307,6 @@ }); }; - if (!mac) map[ctrl + "T"] = "transposeChars"; function sortLines(cm, caseSensitive) { if (cm.isReadOnly()) return CodeMirror.Pass @@ -362,10 +344,10 @@ }); } - cmds[map["F9"] = "sortLines"] = function(cm) { sortLines(cm, true); }; - cmds[map[ctrl + "F9"] = "sortLinesInsensitive"] = function(cm) { sortLines(cm, false); }; + cmds.sortLines = function(cm) { sortLines(cm, true); }; + cmds.sortLinesInsensitive = function(cm) { sortLines(cm, false); }; - cmds[map["F2"] = "nextBookmark"] = function(cm) { + cmds.nextBookmark = function(cm) { var marks = cm.state.sublimeBookmarks; if (marks) while (marks.length) { var current = marks.shift(); @@ -377,7 +359,7 @@ } }; - cmds[map["Shift-F2"] = "prevBookmark"] = function(cm) { + cmds.prevBookmark = function(cm) { var marks = cm.state.sublimeBookmarks; if (marks) while (marks.length) { marks.unshift(marks.pop()); @@ -389,7 +371,7 @@ } }; - cmds[map[ctrl + "F2"] = "toggleBookmark"] = function(cm) { + cmds.toggleBookmark = function(cm) { var ranges = cm.listSelections(); var marks = cm.state.sublimeBookmarks || (cm.state.sublimeBookmarks = []); for (var i = 0; i < ranges.length; i++) { @@ -409,13 +391,13 @@ } }; - cmds[map["Shift-" + ctrl + "F2"] = "clearBookmarks"] = function(cm) { + cmds.clearBookmarks = function(cm) { var marks = cm.state.sublimeBookmarks; if (marks) for (var i = 0; i < marks.length; i++) marks[i].clear(); marks.length = 0; }; - cmds[map["Alt-F2"] = "selectBookmarks"] = function(cm) { + cmds.selectBookmarks = function(cm) { var marks = cm.state.sublimeBookmarks, ranges = []; if (marks) for (var i = 0; i < marks.length; i++) { var found = marks[i].find(); @@ -428,10 +410,6 @@ cm.setSelections(ranges, 0); }; - map["Alt-Q"] = "wrapLines"; - - var cK = ctrl + "K "; - function modifyWordOrSelection(cm, mod) { cm.operation(function() { var ranges = cm.listSelections(), indices = [], replacements = []; @@ -451,9 +429,7 @@ }); } - map[cK + ctrl + "Backspace"] = "delLineLeft"; - - cmds[map["Backspace"] = "smartBackspace"] = function(cm) { + cmds.smartBackspace = function(cm) { if (cm.somethingSelected()) return CodeMirror.Pass; cm.operation(function() { @@ -481,7 +457,7 @@ }); }; - cmds[map[cK + ctrl + "K"] = "delLineRight"] = function(cm) { + cmds.delLineRight = function(cm) { cm.operation(function() { var ranges = cm.listSelections(); for (var i = ranges.length - 1; i >= 0; i--) @@ -490,22 +466,22 @@ }); }; - cmds[map[cK + ctrl + "U"] = "upcaseAtCursor"] = function(cm) { + cmds.upcaseAtCursor = function(cm) { modifyWordOrSelection(cm, function(str) { return str.toUpperCase(); }); }; - cmds[map[cK + ctrl + "L"] = "downcaseAtCursor"] = function(cm) { + cmds.downcaseAtCursor = function(cm) { modifyWordOrSelection(cm, function(str) { return str.toLowerCase(); }); }; - cmds[map[cK + ctrl + "Space"] = "setSublimeMark"] = function(cm) { + cmds.setSublimeMark = function(cm) { if (cm.state.sublimeMark) cm.state.sublimeMark.clear(); cm.state.sublimeMark = cm.setBookmark(cm.getCursor()); }; - cmds[map[cK + ctrl + "A"] = "selectToSublimeMark"] = function(cm) { + cmds.selectToSublimeMark = function(cm) { var found = cm.state.sublimeMark && cm.state.sublimeMark.find(); if (found) cm.setSelection(cm.getCursor(), found); }; - cmds[map[cK + ctrl + "W"] = "deleteToSublimeMark"] = function(cm) { + cmds.deleteToSublimeMark = function(cm) { var found = cm.state.sublimeMark && cm.state.sublimeMark.find(); if (found) { var from = cm.getCursor(), to = found; @@ -514,7 +490,7 @@ cm.replaceRange("", from, to); } }; - cmds[map[cK + ctrl + "X"] = "swapWithSublimeMark"] = function(cm) { + cmds.swapWithSublimeMark = function(cm) { var found = cm.state.sublimeMark && cm.state.sublimeMark.find(); if (found) { cm.state.sublimeMark.clear(); @@ -522,19 +498,17 @@ cm.setCursor(found); } }; - cmds[map[cK + ctrl + "Y"] = "sublimeYank"] = function(cm) { + cmds.sublimeYank = function(cm) { if (cm.state.sublimeKilled != null) cm.replaceSelection(cm.state.sublimeKilled, null, "paste"); }; - map[cK + ctrl + "G"] = "clearBookmarks"; - cmds[map[cK + ctrl + "C"] = "showInCenter"] = function(cm) { + cmds.showInCenter = function(cm) { var pos = cm.cursorCoords(null, "local"); cm.scrollTo(null, (pos.top + pos.bottom) / 2 - cm.getScrollInfo().clientHeight / 2); }; - var selectLinesCombo = mac ? "Ctrl-Shift-" : "Ctrl-Alt-"; - cmds[map[selectLinesCombo + "Up"] = "selectLinesUpward"] = function(cm) { + cmds.selectLinesUpward = function(cm) { cm.operation(function() { var ranges = cm.listSelections(); for (var i = 0; i < ranges.length; i++) { @@ -544,7 +518,7 @@ } }); }; - cmds[map[selectLinesCombo + "Down"] = "selectLinesDownward"] = function(cm) { + cmds.selectLinesDownward = function(cm) { cm.operation(function() { var ranges = cm.listSelections(); for (var i = 0; i < ranges.length; i++) { @@ -583,9 +557,9 @@ cm.setSelection(target.from, target.to); } }; - cmds[map[ctrl + "F3"] = "findUnder"] = function(cm) { findAndGoTo(cm, true); }; - cmds[map["Shift-" + ctrl + "F3"] = "findUnderPrevious"] = function(cm) { findAndGoTo(cm,false); }; - cmds[map["Alt-F3"] = "findAllUnder"] = function(cm) { + cmds.findUnder = function(cm) { findAndGoTo(cm, true); }; + cmds.findUnderPrevious = function(cm) { findAndGoTo(cm,false); }; + cmds.findAllUnder = function(cm) { var target = getTarget(cm); if (!target) return; var cur = cm.getSearchCursor(target.query); @@ -599,15 +573,132 @@ cm.setSelections(matches, primaryIndex); }; - map["Shift-" + ctrl + "["] = "fold"; - map["Shift-" + ctrl + "]"] = "unfold"; - map[cK + ctrl + "0"] = map[cK + ctrl + "J"] = "unfoldAll"; - - map[ctrl + "I"] = "findIncremental"; - map["Shift-" + ctrl + "I"] = "findIncrementalReverse"; - map[ctrl + "H"] = "replace"; - map["F3"] = "findNext"; - map["Shift-F3"] = "findPrev"; - CodeMirror.normalizeKeyMap(map); + var keyMap = CodeMirror.keyMap; + keyMap.macSublime = { + "Cmd-Left": "goLineStartSmart", + "Shift-Tab": "indentLess", + "Shift-Ctrl-K": "deleteLine", + "Alt-Q": "wrapLines", + "Ctrl-Left": "goSubwordLeft", + "Ctrl-Right": "goSubwordRight", + "Ctrl-Alt-Up": "scrollLineUp", + "Ctrl-Alt-Down": "scrollLineDown", + "Cmd-L": "selectLine", + "Shift-Cmd-L": "splitSelectionByLine", + "Esc": "singleSelectionTop", + "Cmd-Enter": "insertLineAfter", + "Shift-Cmd-Enter": "insertLineBefore", + "Cmd-D": "selectNextOccurrence", + "Shift-Cmd-Up": "addCursorToPrevLine", + "Shift-Cmd-Down": "addCursorToNextLine", + "Shift-Cmd-Space": "selectScope", + "Shift-Cmd-M": "selectBetweenBrackets", + "Cmd-M": "goToBracket", + "Cmd-Ctrl-Up": "swapLineUp", + "Cmd-Ctrl-Down": "swapLineDown", + "Cmd-/": "toggleCommentIndented", + "Cmd-J": "joinLines", + "Shift-Cmd-D": "duplicateLine", + "F9": "sortLines", + "Cmd-F9": "sortLinesInsensitive", + "F2": "nextBookmark", + "Shift-F2": "prevBookmark", + "Cmd-F2": "toggleBookmark", + "Shift-Cmd-F2": "clearBookmarks", + "Alt-F2": "selectBookmarks", + "Backspace": "smartBackspace", + "Cmd-K Cmd-K": "delLineRight", + "Cmd-K Cmd-U": "upcaseAtCursor", + "Cmd-K Cmd-L": "downcaseAtCursor", + "Cmd-K Cmd-Space": "setSublimeMark", + "Cmd-K Cmd-A": "selectToSublimeMark", + "Cmd-K Cmd-W": "deleteToSublimeMark", + "Cmd-K Cmd-X": "swapWithSublimeMark", + "Cmd-K Cmd-Y": "sublimeYank", + "Cmd-K Cmd-C": "showInCenter", + "Cmd-K Cmd-G": "clearBookmarks", + "Cmd-K Cmd-Backspace": "delLineLeft", + "Cmd-K Cmd-0": "unfoldAll", + "Cmd-K Cmd-J": "unfoldAll", + "Ctrl-Shift-Up": "selectLinesUpward", + "Ctrl-Shift-Down": "selectLinesDownward", + "Cmd-F3": "findUnder", + "Shift-Cmd-F3": "findUnderPrevious", + "Alt-F3": "findAllUnder", + "Shift-Cmd-[": "fold", + "Shift-Cmd-]": "unfold", + "Cmd-I": "findIncremental", + "Shift-Cmd-I": "findIncrementalReverse", + "Cmd-H": "replace", + "F3": "findNext", + "Shift-F3": "findPrev", + "fallthrough": "pcDefault" + }; + CodeMirror.normalizeKeyMap(keyMap.macSublime); + + keyMap.pcSublime = { + "Shift-Tab": "indentLess", + "Shift-Ctrl-K": "deleteLine", + "Alt-Q": "wrapLines", + "Ctrl-T": "transposeChars", + "Alt-Left": "goSubwordLeft", + "Alt-Right": "goSubwordRight", + "Ctrl-Up": "scrollLineUp", + "Ctrl-Down": "scrollLineDown", + "Ctrl-L": "selectLine", + "Shift-Ctrl-L": "splitSelectionByLine", + "Esc": "singleSelectionTop", + "Ctrl-Enter": "insertLineAfter", + "Shift-Ctrl-Enter": "insertLineBefore", + "Ctrl-D": "selectNextOccurrence", + "Alt-CtrlUp": "addCursorToPrevLine", + "Alt-CtrlDown": "addCursorToNextLine", + "Shift-Ctrl-Space": "selectScope", + "Shift-Ctrl-M": "selectBetweenBrackets", + "Ctrl-M": "goToBracket", + "Shift-Ctrl-Up": "swapLineUp", + "Shift-Ctrl-Down": "swapLineDown", + "Ctrl-/": "toggleCommentIndented", + "Ctrl-J": "joinLines", + "Shift-Ctrl-D": "duplicateLine", + "F9": "sortLines", + "Ctrl-F9": "sortLinesInsensitive", + "F2": "nextBookmark", + "Shift-F2": "prevBookmark", + "Ctrl-F2": "toggleBookmark", + "Shift-Ctrl-F2": "clearBookmarks", + "Alt-F2": "selectBookmarks", + "Backspace": "smartBackspace", + "Ctrl-K Ctrl-K": "delLineRight", + "Ctrl-K Ctrl-U": "upcaseAtCursor", + "Ctrl-K Ctrl-L": "downcaseAtCursor", + "Ctrl-K Ctrl-Space": "setSublimeMark", + "Ctrl-K Ctrl-A": "selectToSublimeMark", + "Ctrl-K Ctrl-W": "deleteToSublimeMark", + "Ctrl-K Ctrl-X": "swapWithSublimeMark", + "Ctrl-K Ctrl-Y": "sublimeYank", + "Ctrl-K Ctrl-C": "showInCenter", + "Ctrl-K Ctrl-G": "clearBookmarks", + "Ctrl-K Ctrl-Backspace": "delLineLeft", + "Ctrl-K Ctrl-0": "unfoldAll", + "Ctrl-K Ctrl-J": "unfoldAll", + "Ctrl-Alt-Up": "selectLinesUpward", + "Ctrl-Alt-Down": "selectLinesDownward", + "Ctrl-F3": "findUnder", + "Shift-Ctrl-F3": "findUnderPrevious", + "Alt-F3": "findAllUnder", + "Shift-Ctrl-[": "fold", + "Shift-Ctrl-]": "unfold", + "Ctrl-I": "findIncremental", + "Shift-Ctrl-I": "findIncrementalReverse", + "Ctrl-H": "replace", + "F3": "findNext", + "Shift-F3": "findPrev", + "fallthrough": "pcDefault" + }; + CodeMirror.normalizeKeyMap(keyMap.pcSublime); + + var mac = keyMap.default == keyMap.macDefault; + keyMap.sublime = mac ? keyMap.macSublime : keyMap.pcSublime; }); From c1196ebc6260d4652ced5eee254d8c5d3cea10dd Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Mon, 16 Oct 2017 16:17:48 +0200 Subject: [PATCH 1250/2444] [sublime keymap] Fix fallthrough for mac bindings Issue #5022 --- keymap/sublime.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/keymap/sublime.js b/keymap/sublime.js index eeccab1721..08c9ebfb3f 100644 --- a/keymap/sublime.js +++ b/keymap/sublime.js @@ -633,7 +633,7 @@ "Cmd-H": "replace", "F3": "findNext", "Shift-F3": "findPrev", - "fallthrough": "pcDefault" + "fallthrough": "macDefault" }; CodeMirror.normalizeKeyMap(keyMap.macSublime); From e5e2aefd0874463ff5d9aeb955d869e7853658b5 Mon Sep 17 00:00:00 2001 From: Guan Gui Date: Mon, 16 Oct 2017 15:45:34 +1100 Subject: [PATCH 1251/2444] [closebrackets addon] Use editor line separator when exploding lines Issue #5031 --- addon/edit/closebrackets.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addon/edit/closebrackets.js b/addon/edit/closebrackets.js index 36aec0d4b5..7b07f7fd8a 100644 --- a/addon/edit/closebrackets.js +++ b/addon/edit/closebrackets.js @@ -84,7 +84,8 @@ if (!around || explode.indexOf(around) % 2 != 0) return CodeMirror.Pass; } cm.operation(function() { - cm.replaceSelection("\n\n", null); + var linesep = cm.lineSeparator() || "\n"; + cm.replaceSelection(linesep + linesep, null); cm.execCommand("goCharLeft"); ranges = cm.listSelections(); for (var i = 0; i < ranges.length; i++) { From deaa842dc6f1711874c1cacc6b984f7264932f83 Mon Sep 17 00:00:00 2001 From: Markus Olsson Date: Tue, 17 Oct 2017 12:15:40 +0200 Subject: [PATCH 1252/2444] [runmode addon] Include CodeMirror.innerMode in runmode.node.js The markdown mode uses `CodeMirror.innerMode` which isn't defined in the stripped down node runmode. Since markdown is the only mode (AFAICT) that uses it I'm not sure if it would make more sense rewrite it to not use it but this seemed like the least risky option. --- addon/runmode/runmode.node.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/addon/runmode/runmode.node.js b/addon/runmode/runmode.node.js index 093cb30876..21c72696c8 100644 --- a/addon/runmode/runmode.node.js +++ b/addon/runmode/runmode.node.js @@ -163,6 +163,18 @@ exports.getMode = function(options, spec) { return modeObj; }; + +exports.innerMode = function(mode, state) { + var info; + while (mode.innerMode) { + info = mode.innerMode(state); + if (!info || info.mode == mode) break; + state = info.state; + mode = info.mode; + } + return info || {mode: mode, state: state}; +} + exports.registerHelper = exports.registerGlobalHelper = Math.min; exports.runMode = function(string, modespec, callback, options) { From 79d266e60a8d02a865c7cf9340628a0f5d920394 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Thu, 29 Jun 2017 14:20:30 +0200 Subject: [PATCH 1253/2444] Add a baseToken method to string streams That overlay modes can use to access the underlying token info. --- doc/manual.html | 6 ++++++ src/line/highlight.js | 16 +++++++++++++++- src/util/StringStream.js | 4 ++++ test/test.js | 15 +++++++++++++++ 4 files changed, 40 insertions(+), 1 deletion(-) diff --git a/doc/manual.html b/doc/manual.html index 67d5e4258a..0ab9cf0d79 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -3261,6 +3261,12 @@

      Writing CodeMirror Modes

      one, in order to scan ahead across line boundaries. Note that you want to do this carefully, since looking far ahead will make mode state caching much less effective. + +
      baseToken() → ?{type: ?string, size: number}
      +
      Modes added + through addOverlay + (and only such modes) can use this method to inspect + the current token produced by the underlying mode.

      By default, blank lines are simply skipped when diff --git a/src/line/highlight.js b/src/line/highlight.js index 430d86a224..82e2aeee29 100644 --- a/src/line/highlight.js +++ b/src/line/highlight.js @@ -18,6 +18,8 @@ class Context { this.doc = doc this.line = line this.maxLookAhead = lookAhead || 0 + this.baseTokens = null + this.baseTokenPos = 1 } lookAhead(n) { @@ -26,6 +28,15 @@ class Context { return line } + baseToken(n) { + if (!this.baseTokens) return null + while (this.baseTokens[this.baseTokenPos] >= n) + this.baseTokenPos += 2 + let type = this.baseTokens[this.baseTokenPos + 1] + return {type: type && type.replace(/( |^)overlay .*/, ""), + size: this.baseTokens[this.baseTokenPos] - n} + } + nextLine() { this.line++ if (this.maxLookAhead > 0) this.maxLookAhead-- @@ -60,6 +71,7 @@ export function highlightLine(cm, line, context, forceToEnd) { // Run overlays, adjust style array. for (let o = 0; o < cm.state.overlays.length; ++o) { + context.baseTokens = st let overlay = cm.state.overlays[o], i = 1, at = 0 context.state = true runMode(cm, line.text, overlay.mode, context, (end, style) => { @@ -83,8 +95,10 @@ export function highlightLine(cm, line, context, forceToEnd) { } } }, lineClasses) + context.state = state + context.baseTokens = null + context.baseTokenPos = 1 } - context.state = state return {styles: st, classes: lineClasses.bgClass || lineClasses.textClass ? lineClasses : null} } diff --git a/src/util/StringStream.js b/src/util/StringStream.js index ac9555f1ce..a14b1b6430 100644 --- a/src/util/StringStream.js +++ b/src/util/StringStream.js @@ -81,6 +81,10 @@ class StringStream { let oracle = this.lineOracle return oracle && oracle.lookAhead(n) } + baseToken() { + let oracle = this.lineOracle + return oracle && oracle.baseToken(this.pos) + } } export default StringStream diff --git a/test/test.js b/test/test.js index 9c768e3f6b..415dd9f0bc 100644 --- a/test/test.js +++ b/test/test.js @@ -2218,6 +2218,21 @@ testCM("getTokenTypeAt", function(cm) { eq(cm.getTokenTypeAt(Pos(0, 6)), "string"); }, {value: "1 + 'foo'", mode: "javascript"}); +testCM("addOverlay", function(cm) { + cm.addOverlay({ + token: function(stream) { + var base = stream.baseToken() + if (!/comment/.test(base.type) && stream.match(/\d+/)) return "x" + stream.next() + } + }) + var x = byClassName(cm.getWrapperElement(), "cm-x") + is(x.length, 1) + is(x[0].textContent, "233") + cm.replaceRange("", Pos(0, 4), Pos(0, 6)) + is(byClassName(cm.getWrapperElement(), "cm-x").length, 2) +}, {value: "foo /* 100 */\nbar + 233;\nbaz", mode: "javascript"}) + testCM("resizeLineWidget", function(cm) { addDoc(cm, 200, 3); var widget = document.createElement("pre"); From 42a26328333a052583f1bd4623bfb8e42717e1dd Mon Sep 17 00:00:00 2001 From: vtripolitakis Date: Tue, 17 Oct 2017 21:59:21 +0300 Subject: [PATCH 1254/2444] [sql mode] Fix representation of table hinting in demo page --- mode/sql/index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mode/sql/index.html b/mode/sql/index.html index e12b289bfa..b434f0f405 100644 --- a/mode/sql/index.html +++ b/mode/sql/index.html @@ -78,8 +78,8 @@

      SQL Mode for CodeMirror

      autofocus: true, extraKeys: {"Ctrl-Space": "autocomplete"}, hintOptions: {tables: { - users: {name: null, score: null, birthDate: null}, - countries: {name: null, population: null, size: null} + users: ["name", "score", "birthDate"], + countries: ["name", "population", "size"] }} }); }; From d14888a70bb4d172a60d968682f0e28ec5065c96 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Wed, 18 Oct 2017 11:11:11 +0200 Subject: [PATCH 1255/2444] [javascript mode] Fix bug in object literal spread parsing Closes #5036 --- mode/javascript/javascript.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mode/javascript/javascript.js b/mode/javascript/javascript.js index 61a6de4be7..ca9fe8ba86 100644 --- a/mode/javascript/javascript.js +++ b/mode/javascript/javascript.js @@ -514,7 +514,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { } else if (type == "[") { return cont(expression, expect("]"), afterprop); } else if (type == "spread") { - return cont(expression, afterprop); + return cont(expressionNoComma, afterprop); } else if (value == "*") { cx.marked = "keyword"; return cont(objprop); From d323ad7236a4b611b7c0898fe660136df6faaf43 Mon Sep 17 00:00:00 2001 From: Pi Delport Date: Wed, 18 Oct 2017 14:20:24 +0200 Subject: [PATCH 1256/2444] (Update my name) --- AUTHORS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AUTHORS b/AUTHORS index 1264357043..e4206048bf 100644 --- a/AUTHORS +++ b/AUTHORS @@ -529,7 +529,7 @@ Peter Kroon Philipp A Philip Stadermann Pierre Gerold -Piët Delport +Pi Delport Pieter Ouwerkerk Pontus Melke prasanthj From cf799958cf8f7ec89c808b7400fe248494b61674 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Wed, 18 Oct 2017 14:27:02 +0200 Subject: [PATCH 1257/2444] [bin/authors.sh] Make sure changed name doesn't resurface from git history Issue #5037 --- bin/authors.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/authors.sh b/bin/authors.sh index b3ee99c6dd..3f228c1fb0 100755 --- a/bin/authors.sh +++ b/bin/authors.sh @@ -1,6 +1,6 @@ # Combine existing list of authors with everyone known in git, sort, add header. tail --lines=+3 AUTHORS > AUTHORS.tmp -git log --format='%aN' >> AUTHORS.tmp +git log --format='%aN' | grep -v "Piët Delport" >> AUTHORS.tmp echo -e "List of CodeMirror contributors. Updated before every release.\n" > AUTHORS sort -u AUTHORS.tmp >> AUTHORS rm -f AUTHORS.tmp From 40a818295aef34d7fd73e9c036e720334336ae98 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Wed, 18 Oct 2017 17:02:48 +0200 Subject: [PATCH 1258/2444] Fix baseToken method See https://github.com/codemirror/CodeMirror/commit/79d266e60a8d02a865c7cf9340628a0f5d920394#commitcomment-25055107 --- src/line/highlight.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/line/highlight.js b/src/line/highlight.js index 82e2aeee29..13921585a7 100644 --- a/src/line/highlight.js +++ b/src/line/highlight.js @@ -30,7 +30,7 @@ class Context { baseToken(n) { if (!this.baseTokens) return null - while (this.baseTokens[this.baseTokenPos] >= n) + while (this.baseTokens[this.baseTokenPos] < n) this.baseTokenPos += 2 let type = this.baseTokens[this.baseTokenPos + 1] return {type: type && type.replace(/( |^)overlay .*/, ""), From a7f6e9f0a1ab1b1f3e9ca008579a17808e0e417f Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Fri, 20 Oct 2017 16:01:41 +0200 Subject: [PATCH 1259/2444] Fix baseToken to actually return the token ahead when on boundary --- src/line/highlight.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/line/highlight.js b/src/line/highlight.js index 13921585a7..c5e6b8aacc 100644 --- a/src/line/highlight.js +++ b/src/line/highlight.js @@ -30,7 +30,7 @@ class Context { baseToken(n) { if (!this.baseTokens) return null - while (this.baseTokens[this.baseTokenPos] < n) + while (this.baseTokens[this.baseTokenPos] <= n) this.baseTokenPos += 2 let type = this.baseTokens[this.baseTokenPos + 1] return {type: type && type.replace(/( |^)overlay .*/, ""), From f936d89e4a2aa68eee964f57d14f875ee1d71ff4 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Fri, 20 Oct 2017 17:35:00 +0200 Subject: [PATCH 1260/2444] Mark version 5.31.0 --- AUTHORS | 10 +++++++++- CHANGELOG.md | 18 ++++++++++++++++++ doc/manual.html | 4 ++-- doc/releases.html | 11 +++++++++++ index.html | 2 +- package.json | 2 +- src/edit/main.js | 2 +- 7 files changed, 43 insertions(+), 6 deletions(-) diff --git a/AUTHORS b/AUTHORS index e4206048bf..f800b86b7d 100644 --- a/AUTHORS +++ b/AUTHORS @@ -48,6 +48,7 @@ Andreas Reischuck Andres Taylor Andre von Houck Andrew Cheng +Andrew Dassonville Andrey Fedorov Andrey Klyuchnikov Andrey Lushnikov @@ -242,6 +243,7 @@ Grant Skinner greengiant Gregory Koberger Grzegorz Mazur +Guan Gui Guillaume Massé Guillaume Massé guraga @@ -253,6 +255,7 @@ Harshvardhan Gupta Hasan Karahan Hector Oswaldo Caballero Hendrik Wallbaum +Henrik Haugbølle Herculano Campos Hiroyuki Makino hitsthings @@ -308,6 +311,7 @@ jem (graphite) Jeremy Parmenter Jim Jim Avery +jkaplon JobJob jochenberger Jochen Berger @@ -341,6 +345,7 @@ ju1ius Juan Benavides Romero Jucovschi Constantin Juho Vuori +Julien CROUZET Julien Rebetez Justin Andresen Justin Hileman @@ -411,6 +416,7 @@ Mark Lentczner Marko Bonaci Mark Peace Markus Bordihn +Markus Olsson Martin Balek Martín Gaitán Martin Hasoň @@ -528,8 +534,8 @@ peterkroon Peter Kroon Philipp A Philip Stadermann -Pierre Gerold Pi Delport +Pierre Gerold Pieter Ouwerkerk Pontus Melke prasanthj @@ -633,6 +639,7 @@ thanasis TheHowl themrmax think +Thomas Brouard Thomas Dvornik Thomas Kluyver Thomas Schmid @@ -662,6 +669,7 @@ vf Victor Bocharsky Vincent Woo Volker Mische +vtripolitakis Weiyan Shao wenli Wes Cossick diff --git a/CHANGELOG.md b/CHANGELOG.md index ff7d6e2311..409c7234bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,21 @@ +## 5.31.0 (2017-10-20) + +### Bug fixes + +Further improve selection drawing and cursor motion in right-to-left documents. + +[vim bindings](http://codemirror.net/demo/vim.html): Fix ctrl-w behavior, support quote-dot and backtick-dot marks, make the wide cursor visible in contentEditable [input mode](http://codemirror.net/doc/manual.html#option_contentEditable). + +[continuecomment addon](http://codemirror.net/doc/manual.html#addon_continuecomment): Fix bug when pressing enter after a single-line block comment. + +[markdown mode](http://codemirror.net/mode/markdown/): Fix issue with leaving indented fenced code blocks. + +[javascript mode](http://codemirror.net/mode/javascript/): Fix bad parsing of operators without spaces between them. Fix some corner cases around semicolon insertion and regexps. + +### New features + +Modes added with [`addOverlay`](http://codemirror.net/doc/manual.html#addOverlay) now have access to a [`baseToken`](http://codemirror.net/doc/manual.html#baseToken) method on their input stream, giving access to the tokens of the underlying mode. + ## 5.30.0 (2017-09-20) ### Bug fixes diff --git a/doc/manual.html b/doc/manual.html index 0ab9cf0d79..f2f04459b4 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -69,7 +69,7 @@

      User manual and reference guide - version 5.30.0 + version 5.31.0

      CodeMirror is a code-editor component that can be embedded in @@ -3262,7 +3262,7 @@

      Writing CodeMirror Modes

      you want to do this carefully, since looking far ahead will make mode state caching much less effective. -
      baseToken() → ?{type: ?string, size: number}
      +
      baseToken() → ?{type: ?string, size: number}
      Modes added through addOverlay (and only such modes) can use this method to inspect diff --git a/doc/releases.html b/doc/releases.html index e16ab6dd43..23de4c8023 100644 --- a/doc/releases.html +++ b/doc/releases.html @@ -30,6 +30,17 @@

      Release notes and version history

      Version 5.x

      +

      20-10-2017: Version 5.31.0:

      + +
        +
      • Modes added with addOverlay now have access to a baseToken method on their input stream, giving access to the tokens of the underlying mode.
      • +
      • Further improve selection drawing and cursor motion in right-to-left documents.
      • +
      • vim bindings: Fix ctrl-w behavior, support quote-dot and backtick-dot marks, make the wide cursor visible in contentEditable input mode.
      • +
      • continuecomment addon: Fix bug when pressing enter after a single-line block comment.
      • +
      • markdown mode: Fix issue with leaving indented fenced code blocks.
      • +
      • javascript mode: Fix bad parsing of operators without spaces between them. Fix some corner cases around semicolon insertion and regexps.
      • +
      +

      20-09-2017: Version 5.30.0:

        diff --git a/index.html b/index.html index d161e77c6f..555e4804aa 100644 --- a/index.html +++ b/index.html @@ -96,7 +96,7 @@

        This is CodeMirror

    - Get the current version: 5.30.0.
    + Get the current version: 5.31.0.
    You can see the code,
    read the release notes,
    or study the user manual. diff --git a/package.json b/package.json index f251b238fd..2241ad9317 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "codemirror", - "version": "5.30.0", + "version": "5.31.0", "main": "lib/codemirror.js", "style": "lib/codemirror.css", "description": "Full-featured in-browser code editor", diff --git a/src/edit/main.js b/src/edit/main.js index 4298c61ff1..b0fd5de810 100644 --- a/src/edit/main.js +++ b/src/edit/main.js @@ -66,4 +66,4 @@ import { addLegacyProps } from "./legacy" addLegacyProps(CodeMirror) -CodeMirror.version = "5.30.0" +CodeMirror.version = "5.31.0" From d6fea23efc1a9c1e16b18541691893860c653a13 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Fri, 20 Oct 2017 17:36:29 +0200 Subject: [PATCH 1261/2444] Bump version number post-5.30.0 --- doc/manual.html | 2 +- package.json | 2 +- src/edit/main.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/manual.html b/doc/manual.html index f2f04459b4..7666e0df63 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -69,7 +69,7 @@

    User manual and reference guide - version 5.31.0 + version 5.31.1

    CodeMirror is a code-editor component that can be embedded in diff --git a/package.json b/package.json index 2241ad9317..6eda061f17 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "codemirror", - "version": "5.31.0", + "version": "5.31.1", "main": "lib/codemirror.js", "style": "lib/codemirror.css", "description": "Full-featured in-browser code editor", diff --git a/src/edit/main.js b/src/edit/main.js index b0fd5de810..6500e08d05 100644 --- a/src/edit/main.js +++ b/src/edit/main.js @@ -66,4 +66,4 @@ import { addLegacyProps } from "./legacy" addLegacyProps(CodeMirror) -CodeMirror.version = "5.31.0" +CodeMirror.version = "5.31.1" From 070c338b3b6fd07f9f4481cbe661d7ab0253de38 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Mon, 23 Oct 2017 22:22:36 +0200 Subject: [PATCH 1262/2444] [clike mode] Stop treating package as defining in Java mode Closes #5047 --- mode/clike/clike.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mode/clike/clike.js b/mode/clike/clike.js index d6d12c7117..02a85319ff 100644 --- a/mode/clike/clike.js +++ b/mode/clike/clike.js @@ -432,7 +432,7 @@ CodeMirror.defineMode("clike", function(config, parserConfig) { types: words("byte short int long float double boolean char void Boolean Byte Character Double Float " + "Integer Long Number Object Short String StringBuffer StringBuilder Void"), blockKeywords: words("catch class do else finally for if switch try while"), - defKeywords: words("class interface package enum @interface"), + defKeywords: words("class interface enum @interface"), typeFirstDefinitions: true, atoms: words("true false null"), number: /^(?:0x[a-f\d_]+|0b[01_]+|(?:[\d_]+\.?\d*|\.\d+)(?:e[-+]?[\d_]+)?)(u|ll?|l|f)?/i, From 0b1d8183f27fba189e4b06b148203599f223b5d4 Mon Sep 17 00:00:00 2001 From: Jayaprabhakar Date: Mon, 23 Oct 2017 22:06:13 -0700 Subject: [PATCH 1263/2444] Add Codiva.io to realworld usage list Adding Codiva.io Online Java Compiler and IDE to the existing users list. This will highlight some of the advanced usage of Codemirror - Multiple Tabbed editor - Continuous compilation in the backend - Autocompletion - Mobile friendly - Read-only mode --- doc/realworld.html | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/realworld.html b/doc/realworld.html index f0a75abf72..2049bf26fd 100644 --- a/doc/realworld.html +++ b/doc/realworld.html @@ -59,6 +59,7 @@

    CodeMirror real-world uses

  • Codevolve (programming lessons as-a-service)
  • CodeZample (code snippet sharing)
  • Codio (Web IDE)
  • +
  • Codiva.io (Online Java Compiler and IDE with auto-completion and error highlighting)
  • Collaborative CodeMirror demo (CodeMirror + operational transforms)
  • Community Code Camp (code snippet sharing)
  • compilejava.net (online Java sandbox)
  • From edbc598959b1284f49f55f9f29b9fe6beeb8e920 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Sun, 29 Oct 2017 11:10:18 +0100 Subject: [PATCH 1264/2444] [closebrackets addon] Improve start-of-string heuristic To also make sure the last token isn't a string. Issue codemirror/google-modes#74 --- addon/edit/closebrackets.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addon/edit/closebrackets.js b/addon/edit/closebrackets.js index 7b07f7fd8a..7592ef0071 100644 --- a/addon/edit/closebrackets.js +++ b/addon/edit/closebrackets.js @@ -203,6 +203,7 @@ function stringStartsAfter(cm, pos) { var token = cm.getTokenAt(Pos(pos.line, pos.ch + 1)) - return /\bstring/.test(token.type) && token.start == pos.ch + return /\bstring/.test(token.type) && token.start == pos.ch && + (pos.ch == 0 || !/\bstring/.test(cm.getTokenTypeAt(pos))) } }); From e26db631d4f34d844b503ecffafc5d9665ac4e6a Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Sun, 29 Oct 2017 11:28:10 +0100 Subject: [PATCH 1265/2444] [javascript mode] Support TS type parameter defaults Closes #5053 --- mode/javascript/javascript.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/mode/javascript/javascript.js b/mode/javascript/javascript.js index ca9fe8ba86..c838e31628 100644 --- a/mode/javascript/javascript.js +++ b/mode/javascript/javascript.js @@ -607,6 +607,12 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { function maybeTypeArgs(_, value) { if (value == "<") return cont(pushlex(">"), commasep(typeexpr, ">"), poplex, afterType) } + function typeparam() { + return pass(typeexpr, maybeTypeDefault) + } + function maybeTypeDefault(_, value) { + if (value == "=") return cont(typeexpr) + } function vardef() { return pass(pattern, maybetype, maybeAssign, vardefCont); } @@ -661,7 +667,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { if (value == "*") {cx.marked = "keyword"; return cont(functiondef);} if (type == "variable") {register(value); return cont(functiondef);} if (type == "(") return cont(pushcontext, pushlex(")"), commasep(funarg, ")"), poplex, maybetype, statement, popcontext); - if (isTS && value == "<") return cont(pushlex(">"), commasep(typeexpr, ">"), poplex, functiondef) + if (isTS && value == "<") return cont(pushlex(">"), commasep(typeparam, ">"), poplex, functiondef) } function funarg(type, value) { if (value == "@") cont(expression, funarg) @@ -677,7 +683,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { if (type == "variable") {register(value); return cont(classNameAfter);} } function classNameAfter(type, value) { - if (value == "<") return cont(pushlex(">"), commasep(typeexpr, ">"), poplex, classNameAfter) + if (value == "<") return cont(pushlex(">"), commasep(typeparam, ">"), poplex, classNameAfter) if (value == "extends" || value == "implements" || (isTS && type == ",")) return cont(isTS ? typeexpr : expression, classNameAfter); if (type == "{") return cont(pushlex("}"), classBody, poplex); From f841fb779ea5f89fb22ccd48879ff034807dd10f Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Sun, 29 Oct 2017 12:03:28 +0100 Subject: [PATCH 1266/2444] [merge addon] Fix issue where collapsed text markers could get half-cleared Issue #5054 --- addon/merge/merge.js | 3 +++ src/display/update_lines.js | 6 ++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/addon/merge/merge.js b/addon/merge/merge.js index c94b27a7b8..dc2e77c60e 100644 --- a/addon/merge/merge.js +++ b/addon/merge/merge.js @@ -738,6 +738,9 @@ mark.clear(); cm.removeLineClass(from, "wrap", "CodeMirror-merge-collapsed-line"); } + if (mark.explicitlyCleared) clear(); + CodeMirror.on(widget, "click", clear); + mark.on("clear", clear); CodeMirror.on(widget, "click", clear); return {mark: mark, clear: clear}; } diff --git a/src/display/update_lines.js b/src/display/update_lines.js index 7583f3c159..bc8a9c60e4 100644 --- a/src/display/update_lines.js +++ b/src/display/update_lines.js @@ -33,8 +33,10 @@ export function updateHeightsInViewport(cm) { // Read and store the height of line widgets associated with the // given line. function updateWidgetHeight(line) { - if (line.widgets) for (let i = 0; i < line.widgets.length; ++i) - line.widgets[i].height = line.widgets[i].node.parentNode.offsetHeight + if (line.widgets) for (let i = 0; i < line.widgets.length; ++i) { + let w = line.widgets[i], parent = w.node.parentNode; + if (parent) w.height = parent.offsetHeight + } } // Compute the lines that are visible in a given viewport (defaults From 48d2d264d34a2c366af617842c48c0685b641aad Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Sun, 29 Oct 2017 12:30:12 +0100 Subject: [PATCH 1267/2444] Fix lint issue --- src/display/update_lines.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/display/update_lines.js b/src/display/update_lines.js index bc8a9c60e4..6c59188957 100644 --- a/src/display/update_lines.js +++ b/src/display/update_lines.js @@ -34,7 +34,7 @@ export function updateHeightsInViewport(cm) { // given line. function updateWidgetHeight(line) { if (line.widgets) for (let i = 0; i < line.widgets.length; ++i) { - let w = line.widgets[i], parent = w.node.parentNode; + let w = line.widgets[i], parent = w.node.parentNode if (parent) w.height = parent.offsetHeight } } From 97290a687e545bdad23794385b585fd9dfff3e2a Mon Sep 17 00:00:00 2001 From: Jonathan Hart Date: Sat, 21 Oct 2017 19:44:19 +0100 Subject: [PATCH 1268/2444] [continuelist addon] Increment numbers when item is added to the middle Per #5030, when adding new items to the middle of a Markdown list, the remaining list numbers should automatically increment --- addon/edit/continuelist.js | 39 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/addon/edit/continuelist.js b/addon/edit/continuelist.js index 02c8eff9fa..30893965fe 100644 --- a/addon/edit/continuelist.js +++ b/addon/edit/continuelist.js @@ -44,9 +44,48 @@ : (parseInt(match[3], 10) + 1) + match[4]; replacements[i] = "\n" + indent + bullet + after; + + incrementRemainingMarkdownListNumbers(cm, pos); } } cm.replaceSelections(replacements); }; + + // Auto-updating Markdown list numbers when a new item is added to the + // middle of a list + function incrementRemainingMarkdownListNumbers(cm, pos) { + var startLine = pos.line, lookAhead = 0, skipCount = 0; + var startItem = listRE.exec(cm.getLine(startLine)), startIndent = startItem[1]; + + do { + lookAhead += 1; + var nextLineNumber = startLine + lookAhead; + var nextLine = cm.getLine(nextLineNumber), nextItem = listRE.exec(nextLine); + + if (nextItem) { + var nextIndent = nextItem[1]; + var newNumber = (parseInt(startItem[3], 10) + lookAhead - skipCount); + var nextNumber = (parseInt(nextItem[3], 10)), itemNumber = nextNumber; + + if (startIndent === nextIndent) { + if (newNumber === nextNumber) itemNumber = nextNumber + 1; + if (newNumber > nextNumber) itemNumber = newNumber + 1; + cm.replaceRange( + nextLine.replace(listRE, nextIndent + itemNumber + nextItem[4] + nextItem[5]), + { + line: nextLineNumber, ch: 0 + }, { + line: nextLineNumber, ch: nextLine.length + }); + } else { + if (startIndent.length > nextIndent.length) return; + // This doesn't run if the next line immediatley indents, as it is + // not clear of the users intention (new indented item or same level) + if ((startIndent.length < nextIndent.length) && (lookAhead === 1)) return; + skipCount += 1; + } + } + } while (nextItem); + } }); From 7e9190a646869db885ed73b239dc204d8e58a009 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Wed, 1 Nov 2017 11:17:21 +0100 Subject: [PATCH 1269/2444] [comment addon] Don't ignore content on last selected line when block-uncommenting Closes #5059 --- addon/comment/comment.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/addon/comment/comment.js b/addon/comment/comment.js index 568e639dcd..84c67edf78 100644 --- a/addon/comment/comment.js +++ b/addon/comment/comment.js @@ -172,10 +172,6 @@ if (open == -1) return false var endLine = end == start ? startLine : self.getLine(end) var close = endLine.indexOf(endString, end == start ? open + startString.length : 0); - if (close == -1 && start != end) { - endLine = self.getLine(--end); - close = endLine.indexOf(endString); - } var insideStart = Pos(start, open + 1), insideEnd = Pos(end, close + 1) if (close == -1 || !/comment/.test(self.getTokenTypeAt(insideStart)) || From a7907d37b2dcf1067a478bdc02064305461658ef Mon Sep 17 00:00:00 2001 From: Alexander Shvets Date: Tue, 31 Oct 2017 18:27:23 +0200 Subject: [PATCH 1270/2444] [searchcursor addon] Fix bug in case folding --- addon/search/searchcursor.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addon/search/searchcursor.js b/addon/search/searchcursor.js index eccd81aab6..58bc47c2c3 100644 --- a/addon/search/searchcursor.js +++ b/addon/search/searchcursor.js @@ -159,7 +159,7 @@ for (var i = 1; i < lines.length - 1; i++) if (fold(doc.getLine(line + i)) != lines[i]) continue search var end = doc.getLine(line + lines.length - 1), endString = fold(end), lastLine = lines[lines.length - 1] - if (end.slice(0, lastLine.length) != lastLine) continue search + if (endString.slice(0, lastLine.length) != lastLine) continue search return {from: Pos(line, adjustPos(orig, string, cutFrom, fold) + ch), to: Pos(line + lines.length - 1, adjustPos(end, endString, lastLine.length, fold))} } From 66107010e9e34372c6736e6ca9379cf6ac044abc Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Wed, 1 Nov 2017 11:52:12 +0100 Subject: [PATCH 1271/2444] Re-dispatch non-matching multi-key-strokes without their prefix Issue #5061 --- src/edit/key_events.js | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/edit/key_events.js b/src/edit/key_events.js index 2955e4ae0c..06f37be078 100644 --- a/src/edit/key_events.js +++ b/src/edit/key_events.js @@ -44,18 +44,26 @@ function lookupKeyForEditor(cm, name, handle) { // for bound mouse clicks. let stopSeq = new Delayed + export function dispatchKey(cm, name, e, handle) { let seq = cm.state.keySeq if (seq) { if (isModifierKey(name)) return "handled" - stopSeq.set(50, () => { - if (cm.state.keySeq == seq) { - cm.state.keySeq = null - cm.display.input.reset() - } - }) - name = seq + " " + name + if (/\'$/.test(name)) + cm.state.keySeq = null + else + stopSeq.set(50, () => { + if (cm.state.keySeq == seq) { + cm.state.keySeq = null + cm.display.input.reset() + } + }) + if (dispatchKeyInner(cm, seq + " " + name, e, handle)) return true } + return dispatchKeyInner(cm, name, e, handle) +} + +function dispatchKeyInner(cm, name, e, handle) { let result = lookupKeyForEditor(cm, name, handle) if (result == "multi") @@ -68,10 +76,6 @@ export function dispatchKey(cm, name, e, handle) { restartBlink(cm) } - if (seq && !result && /\'$/.test(name)) { - e_preventDefault(e) - return true - } return !!result } From 659cb7f3690a9e2b066faeba73143f291932aa30 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Thu, 2 Nov 2017 09:22:28 +0100 Subject: [PATCH 1272/2444] [javascript mode] Make TypeScript module/enum contextual keywords Closes #5064 --- mode/javascript/javascript.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mode/javascript/javascript.js b/mode/javascript/javascript.js index c838e31628..5c772526f2 100644 --- a/mode/javascript/javascript.js +++ b/mode/javascript/javascript.js @@ -47,8 +47,6 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { "interface": kw("class"), "implements": C, "namespace": C, - "module": kw("module"), - "enum": kw("module"), // scope modifiers "public": kw("modifier"), @@ -372,9 +370,12 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { if (isTS && value == "type") { cx.marked = "keyword" return cont(typeexpr, expect("operator"), typeexpr, expect(";")); - } if (isTS && value == "declare") { + } else if (isTS && value == "declare") { cx.marked = "keyword" return cont(statement) + } else if (isTS && (value == "module" || value == "enum") && cx.stream.match(/^\s*\w/, false)) { + cx.marked = "keyword" + return cont(pushlex("form"), pattern, expect("{"), pushlex("}"), block, poplex, poplex) } else { return cont(pushlex("stat"), maybelabel); } @@ -388,7 +389,6 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { if (type == "class") return cont(pushlex("form"), className, poplex); if (type == "export") return cont(pushlex("stat"), afterExport, poplex); if (type == "import") return cont(pushlex("stat"), afterImport, poplex); - if (type == "module") return cont(pushlex("form"), pattern, expect("{"), pushlex("}"), block, poplex, poplex) if (type == "async") return cont(statement) if (value == "@") return cont(expression, statement) return pass(pushlex("stat"), expression, expect(";"), poplex); From c83e94a6412b9293362e59980d7ca26f58b4b9da Mon Sep 17 00:00:00 2001 From: Jayaprabhakar Date: Sun, 5 Nov 2017 19:02:03 -0800 Subject: [PATCH 1273/2444] Remove broken links in the realworld users page Removing the broken links in the realworld users list. I checked the backlinks using, https://www.deadlinkchecker.com/website-dead-link-checker.asp and manually verified these urls to be invalid. --- doc/realworld.html | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/doc/realworld.html b/doc/realworld.html index 2049bf26fd..da0f4e4e61 100644 --- a/doc/realworld.html +++ b/doc/realworld.html @@ -28,7 +28,6 @@

    CodeMirror real-world uses

  • Adobe Brackets (code editor)
  • ALM Tools (TypeScript powered IDE)
  • Amber (JavaScript-based Smalltalk system)
  • -
  • Apache GUI
  • APEye (tool for testing & documenting APIs)
  • Appengine Codiad
  • Better Text Viewer (plain text reader app for Chrome)
  • @@ -60,7 +59,6 @@

    CodeMirror real-world uses

  • CodeZample (code snippet sharing)
  • Codio (Web IDE)
  • Codiva.io (Online Java Compiler and IDE with auto-completion and error highlighting)
  • -
  • Collaborative CodeMirror demo (CodeMirror + operational transforms)
  • Community Code Camp (code snippet sharing)
  • compilejava.net (online Java sandbox)
  • CKWNC (UML editor)
  • @@ -70,7 +68,6 @@

    CodeMirror real-world uses

  • CSSDeck (CSS showcase)
  • Deck.js integration (slides with editors)
  • DbNinja (MySQL access interface)
  • -
  • Echoplexus (chat and collaborative coding)
  • eCSSpert (CSS demos and experiments)
  • Elm language examples
  • Eloquent JavaScript (book)
  • @@ -79,7 +76,6 @@

    CodeMirror real-world uses

  • Fastfig (online computation/math tool)
  • Farabi (modern Perl IDE)
  • FathomJS integration (slides with editors, again)
  • -
  • Phantomus (blogging platform)
  • Fiddle Salad (web development environment)
  • Filemanager
  • Firefox Developer Tools
  • @@ -101,7 +97,7 @@

    CodeMirror real-world uses

  • Homegenie (home automation server)
  • ICEcoder (web IDE)
  • IPython (interactive computing shell)
  • -
  • iTrading (Algorithmic Trading)
  • +
  • iTrading (Algorithmic Trading)
  • i-MOS (modeling and simulation platform)
  • Janvas (vector graphics editor)
  • Joomla plugin
  • @@ -116,18 +112,14 @@

    CodeMirror real-world uses

  • Kodit
  • Kodtest (HTML/JS/CSS playground)
  • Kotlin (web-based mini-IDE for Kotlin)
  • -
  • Laborate (collaborative coding)
  • Light Table (experimental IDE)
  • Liveweave (HTML/CSS/JS scratchpad)
  • Markdown Delight Editor (extensible markdown editor polymer component)
  • Marklight editor (lightweight markup editor)
  • Mergely (interactive diffing)
  • MIHTool (iOS web-app debugging tool)
  • -
  • Mongo MapReduce WebBrowser
  • -
  • Montage Studio (web app creator suite)
  • mscgen_js (online sequence chart editor)
  • MVC Playground
  • -
  • My2ndGeneration (social coding)
  • Navigate CMS
  • nodeMirror (IDE project)
  • NoTex (rST authoring)
  • @@ -143,8 +135,6 @@

    CodeMirror real-world uses

  • PubliForge (online publishing system)
  • Puzzlescript (puzzle game engine)
  • Quantum (code editor for Chrome OS)
  • -
  • ql.io (http API query helper)
  • -
  • QiYun web app platform
  • Qt+Webkit integration (building a desktop CodeMirror app)
  • Quivive File Manager
  • Rascal (tiny computer)
  • @@ -172,7 +162,6 @@

    CodeMirror real-world uses

  • TileMill (map design tool)
  • Tiki (wiki CMS groupware)
  • Toolsverse Data Explorer (database management)
  • -
  • Tributary (augmented editing)
  • Tumblr code highlighting shim
  • TurboPY (web publishing framework)
  • UmpleOnline (model-oriented programming tool)
  • From f02225b9ca000ddb098053b21acf3165d1e34beb Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Mon, 6 Nov 2017 11:33:40 +0100 Subject: [PATCH 1274/2444] Make the default colors for bracket matching more constrasting Issue #5063 --- lib/codemirror.css | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/codemirror.css b/lib/codemirror.css index 255de98606..8f4f22f5d6 100644 --- a/lib/codemirror.css +++ b/lib/codemirror.css @@ -145,8 +145,8 @@ /* Default styles for common addons */ -div.CodeMirror span.CodeMirror-matchingbracket {color: #0f0;} -div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;} +div.CodeMirror span.CodeMirror-matchingbracket {color: #0b0;} +div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #a22;} .CodeMirror-matchingtag { background: rgba(255, 150, 0, .3); } .CodeMirror-activeline-background {background: #e8f2ff;} From 36d7c7291fe7ecac442588a3a3c5c25a27e91455 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Tue, 7 Nov 2017 11:47:07 +0100 Subject: [PATCH 1275/2444] [closebrackets addon] Adjust check for when to insert two quotes Stop relying on mode tokens, use simple heuristic of not being after a word char Issue #5058 Issue #2657 --- addon/edit/closebrackets.js | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/addon/edit/closebrackets.js b/addon/edit/closebrackets.js index 7592ef0071..460f662f80 100644 --- a/addon/edit/closebrackets.js +++ b/addon/edit/closebrackets.js @@ -133,7 +133,8 @@ (cur.ch <= 2 || cm.getRange(Pos(cur.line, cur.ch - 3), Pos(cur.line, cur.ch - 2)) != ch)) { curType = "addFour"; } else if (identical) { - if (!CodeMirror.isWordChar(next) && enteringString(cm, cur, ch)) curType = "both"; + var prev = cur.ch == 0 ? " " : cm.getRange(Pos(cur.line, cur.ch - 1), cur) + if (!CodeMirror.isWordChar(next) && prev != ch && !CodeMirror.isWordChar(prev)) curType = "both"; else return CodeMirror.Pass; } else if (opening && (cm.getLine(cur.line).length == cur.ch || isClosingBracket(next, pairs) || @@ -185,22 +186,6 @@ return str.length == 2 ? str : null; } - // Project the token type that will exists after the given char is - // typed, and use it to determine whether it would cause the start - // of a string token. - function enteringString(cm, pos, ch) { - var line = cm.getLine(pos.line); - var token = cm.getTokenAt(pos); - if (/\bstring2?\b/.test(token.type) || stringStartsAfter(cm, pos)) return false; - var stream = new CodeMirror.StringStream(line.slice(0, pos.ch) + ch + line.slice(pos.ch), 4); - stream.pos = stream.start = token.start; - for (;;) { - var type1 = cm.getMode().token(stream, token.state); - if (stream.pos >= pos.ch + 1) return /\bstring2?\b/.test(type1); - stream.start = stream.pos; - } - } - function stringStartsAfter(cm, pos) { var token = cm.getTokenAt(Pos(pos.line, pos.ch + 1)) return /\bstring/.test(token.type) && token.start == pos.ch && From b6bfb4d09d14fa64d0993280c2761281d52ff958 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Wed, 8 Nov 2017 09:49:18 +0100 Subject: [PATCH 1276/2444] [solarized theme] Remove overly low-contrast color for cm-strong Closes #5075 --- theme/solarized.css | 1 - 1 file changed, 1 deletion(-) diff --git a/theme/solarized.css b/theme/solarized.css index d95f6c1b27..fcd1d70de6 100644 --- a/theme/solarized.css +++ b/theme/solarized.css @@ -87,7 +87,6 @@ http://ethanschoonover.com/solarized/img/solarized-palette.png text-decoration: underline; text-decoration-style: dotted; } -.cm-s-solarized .cm-strong { color: #eee; } .cm-s-solarized .cm-error, .cm-s-solarized .cm-invalidchar { color: #586e75; From 2c741bd6742678f67e812307b2f78db4f4566d9d Mon Sep 17 00:00:00 2001 From: Casey Klebba Date: Tue, 7 Nov 2017 17:12:57 -0800 Subject: [PATCH 1277/2444] Fully qualify import paths --- src/codemirror.js | 2 +- src/display/Display.js | 6 +-- src/display/focus.js | 8 ++-- src/display/gutters.js | 6 +-- src/display/highlight_worker.js | 10 ++--- src/display/line_numbers.js | 8 ++-- src/display/mode_state.js | 6 +-- src/display/operations.js | 26 ++++++------- src/display/scroll_events.js | 8 ++-- src/display/scrollbars.js | 16 ++++---- src/display/scrolling.js | 18 ++++----- src/display/selection.js | 12 +++--- src/display/update_display.js | 30 +++++++-------- src/display/update_line.js | 10 ++--- src/display/update_lines.js | 8 ++-- src/display/view_tracking.js | 10 ++--- src/edit/CodeMirror.js | 50 ++++++++++++------------- src/edit/commands.js | 22 +++++------ src/edit/deleteNearSelection.js | 10 ++--- src/edit/drop_events.js | 26 ++++++------- src/edit/fromTextArea.js | 8 ++-- src/edit/global_events.js | 4 +- src/edit/key_events.js | 22 +++++------ src/edit/legacy.js | 34 ++++++++--------- src/edit/main.js | 24 ++++++------ src/edit/methods.js | 48 ++++++++++++------------ src/edit/mouse_events.js | 40 ++++++++++---------- src/edit/options.js | 36 +++++++++--------- src/edit/utils.js | 2 +- src/input/ContentEditableInput.js | 30 +++++++-------- src/input/TextareaInput.js | 24 ++++++------ src/input/indent.js | 14 +++---- src/input/input.js | 22 +++++------ src/input/keymap.js | 6 +-- src/input/movement.js | 8 ++-- src/line/highlight.js | 10 ++--- src/line/line_data.js | 18 ++++----- src/line/pos.js | 2 +- src/line/spans.js | 8 ++-- src/line/utils_line.js | 2 +- src/measurement/position_measurement.js | 26 ++++++------- src/measurement/widgets.js | 4 +- src/model/Doc.js | 40 ++++++++++---------- src/model/change_measurement.js | 6 +-- src/model/changes.js | 36 +++++++++--------- src/model/chunk.js | 6 +-- src/model/document_data.js | 20 +++++----- src/model/history.js | 18 ++++----- src/model/line_widget.js | 18 ++++----- src/model/mark_text.js | 30 +++++++-------- src/model/selection.js | 4 +- src/model/selection_updates.js | 18 ++++----- src/modes.js | 2 +- src/util/StringStream.js | 2 +- src/util/bidi.js | 2 +- src/util/dom.js | 2 +- src/util/event.js | 4 +- src/util/feature_detection.js | 4 +- src/util/operation_group.js | 2 +- 59 files changed, 449 insertions(+), 449 deletions(-) diff --git a/src/codemirror.js b/src/codemirror.js index 3c16cc875e..2a2f54e4c9 100644 --- a/src/codemirror.js +++ b/src/codemirror.js @@ -1,3 +1,3 @@ -import { CodeMirror } from "./edit/main" +import { CodeMirror } from "./edit/main.js" export default CodeMirror diff --git a/src/display/Display.js b/src/display/Display.js index ad0256bdfd..54b228a9b3 100644 --- a/src/display/Display.js +++ b/src/display/Display.js @@ -1,6 +1,6 @@ -import { gecko, ie, ie_version, mobile, webkit } from "../util/browser" -import { elt, eltP } from "../util/dom" -import { scrollerGap } from "../util/misc" +import { gecko, ie, ie_version, mobile, webkit } from "../util/browser.js" +import { elt, eltP } from "../util/dom.js" +import { scrollerGap } from "../util/misc.js" // The display handles the DOM integration, both for input reading // and content drawing. It holds references to DOM nodes and diff --git a/src/display/focus.js b/src/display/focus.js index ee52daffac..aa731b4353 100644 --- a/src/display/focus.js +++ b/src/display/focus.js @@ -1,7 +1,7 @@ -import { restartBlink } from "./selection" -import { webkit } from "../util/browser" -import { addClass, rmClass } from "../util/dom" -import { signal } from "../util/event" +import { restartBlink } from "./selection.js" +import { webkit } from "../util/browser.js" +import { addClass, rmClass } from "../util/dom.js" +import { signal } from "../util/event.js" export function ensureFocus(cm) { if (!cm.state.focused) { cm.display.input.focus(); onFocus(cm) } diff --git a/src/display/gutters.js b/src/display/gutters.js index 7ccf119e80..37405b6d8c 100644 --- a/src/display/gutters.js +++ b/src/display/gutters.js @@ -1,7 +1,7 @@ -import { elt, removeChildren } from "../util/dom" -import { indexOf } from "../util/misc" +import { elt, removeChildren } from "../util/dom.js" +import { indexOf } from "../util/misc.js" -import { updateGutterSpace } from "./update_display" +import { updateGutterSpace } from "./update_display.js" // Rebuild the gutter elements, ensure the margin to the left of the // code matches their width. diff --git a/src/display/highlight_worker.js b/src/display/highlight_worker.js index e868c42f3c..6069815719 100644 --- a/src/display/highlight_worker.js +++ b/src/display/highlight_worker.js @@ -1,9 +1,9 @@ -import { getContextBefore, highlightLine, processLine } from "../line/highlight" -import { copyState } from "../modes" -import { bind } from "../util/misc" +import { getContextBefore, highlightLine, processLine } from "../line/highlight.js" +import { copyState } from "../modes.js" +import { bind } from "../util/misc.js" -import { runInOp } from "./operations" -import { regLineChange } from "./view_tracking" +import { runInOp } from "./operations.js" +import { regLineChange } from "./view_tracking.js" // HIGHLIGHT WORKER diff --git a/src/display/line_numbers.js b/src/display/line_numbers.js index c48f2204d5..3ab957509c 100644 --- a/src/display/line_numbers.js +++ b/src/display/line_numbers.js @@ -1,8 +1,8 @@ -import { lineNumberFor } from "../line/utils_line" -import { compensateForHScroll } from "../measurement/position_measurement" -import { elt } from "../util/dom" +import { lineNumberFor } from "../line/utils_line.js" +import { compensateForHScroll } from "../measurement/position_measurement.js" +import { elt } from "../util/dom.js" -import { updateGutterSpace } from "./update_display" +import { updateGutterSpace } from "./update_display.js" // Re-align line numbers and gutter marks to compensate for // horizontal scrolling. diff --git a/src/display/mode_state.js b/src/display/mode_state.js index ca0a534ca4..5d8ebf250e 100644 --- a/src/display/mode_state.js +++ b/src/display/mode_state.js @@ -1,7 +1,7 @@ -import { getMode } from "../modes" +import { getMode } from "../modes.js" -import { startWorker } from "./highlight_worker" -import { regChange } from "./view_tracking" +import { startWorker } from "./highlight_worker.js" +import { regChange } from "./view_tracking.js" // Used to get the editor into a consistent state again when options change. diff --git a/src/display/operations.js b/src/display/operations.js index c3004508e7..5cc26d265d 100644 --- a/src/display/operations.js +++ b/src/display/operations.js @@ -1,16 +1,16 @@ -import { clipPos } from "../line/pos" -import { findMaxLine } from "../line/spans" -import { displayWidth, measureChar, scrollGap } from "../measurement/position_measurement" -import { signal } from "../util/event" -import { activeElt } from "../util/dom" -import { finishOperation, pushOperation } from "../util/operation_group" - -import { ensureFocus } from "./focus" -import { measureForScrollbars, updateScrollbars } from "./scrollbars" -import { restartBlink } from "./selection" -import { maybeScrollWindow, scrollPosIntoView, setScrollLeft, setScrollTop } from "./scrolling" -import { DisplayUpdate, maybeClipScrollbars, postUpdateDisplay, setDocumentHeight, updateDisplayIfNeeded } from "./update_display" -import { updateHeightsInViewport } from "./update_lines" +import { clipPos } from "../line/pos.js" +import { findMaxLine } from "../line/spans.js" +import { displayWidth, measureChar, scrollGap } from "../measurement/position_measurement.js" +import { signal } from "../util/event.js" +import { activeElt } from "../util/dom.js" +import { finishOperation, pushOperation } from "../util/operation_group.js" + +import { ensureFocus } from "./focus.js" +import { measureForScrollbars, updateScrollbars } from "./scrollbars.js" +import { restartBlink } from "./selection.js" +import { maybeScrollWindow, scrollPosIntoView, setScrollLeft, setScrollTop } from "./scrolling.js" +import { DisplayUpdate, maybeClipScrollbars, postUpdateDisplay, setDocumentHeight, updateDisplayIfNeeded } from "./update_display.js" +import { updateHeightsInViewport } from "./update_lines.js" // Operations are used to wrap a series of changes to the editor // state in such a way that each change won't have to update the diff --git a/src/display/scroll_events.js b/src/display/scroll_events.js index d3902809e7..fbed426637 100644 --- a/src/display/scroll_events.js +++ b/src/display/scroll_events.js @@ -1,8 +1,8 @@ -import { chrome, gecko, ie, mac, presto, safari, webkit } from "../util/browser" -import { e_preventDefault } from "../util/event" +import { chrome, gecko, ie, mac, presto, safari, webkit } from "../util/browser.js" +import { e_preventDefault } from "../util/event.js" -import { updateDisplaySimple } from "./update_display" -import { setScrollLeft, updateScrollTop } from "./scrolling" +import { updateDisplaySimple } from "./update_display.js" +import { setScrollLeft, updateScrollTop } from "./scrolling.js" // Since the delta values reported on mouse wheel events are // unstandardized between browsers and even browser versions, and diff --git a/src/display/scrollbars.js b/src/display/scrollbars.js index 27060d18ef..7308c5e272 100644 --- a/src/display/scrollbars.js +++ b/src/display/scrollbars.js @@ -1,11 +1,11 @@ -import { addClass, elt, rmClass } from "../util/dom" -import { on } from "../util/event" -import { scrollGap, paddingVert } from "../measurement/position_measurement" -import { ie, ie_version, mac, mac_geMountainLion } from "../util/browser" -import { updateHeightsInViewport } from "./update_lines" -import { Delayed } from "../util/misc" - -import { setScrollLeft, updateScrollTop } from "./scrolling" +import { addClass, elt, rmClass } from "../util/dom.js" +import { on } from "../util/event.js" +import { scrollGap, paddingVert } from "../measurement/position_measurement.js" +import { ie, ie_version, mac, mac_geMountainLion } from "../util/browser.js" +import { updateHeightsInViewport } from "./update_lines.js" +import { Delayed } from "../util/misc.js" + +import { setScrollLeft, updateScrollTop } from "./scrolling.js" // SCROLLBARS diff --git a/src/display/scrolling.js b/src/display/scrolling.js index e16cf9ecac..26ec993b0f 100644 --- a/src/display/scrolling.js +++ b/src/display/scrolling.js @@ -1,12 +1,12 @@ -import { Pos } from "../line/pos" -import { cursorCoords, displayHeight, displayWidth, estimateCoords, paddingTop, paddingVert, scrollGap, textHeight } from "../measurement/position_measurement" -import { gecko, phantom } from "../util/browser" -import { elt } from "../util/dom" -import { signalDOMEvent } from "../util/event" - -import { startWorker } from "./highlight_worker" -import { alignHorizontally } from "./line_numbers" -import { updateDisplaySimple } from "./update_display" +import { Pos } from "../line/pos.js" +import { cursorCoords, displayHeight, displayWidth, estimateCoords, paddingTop, paddingVert, scrollGap, textHeight } from "../measurement/position_measurement.js" +import { gecko, phantom } from "../util/browser.js" +import { elt } from "../util/dom.js" +import { signalDOMEvent } from "../util/event.js" + +import { startWorker } from "./highlight_worker.js" +import { alignHorizontally } from "./line_numbers.js" +import { updateDisplaySimple } from "./update_display.js" // SCROLLING THINGS INTO VIEW diff --git a/src/display/selection.js b/src/display/selection.js index dca96a442b..c658c0a272 100644 --- a/src/display/selection.js +++ b/src/display/selection.js @@ -1,9 +1,9 @@ -import { Pos } from "../line/pos" -import { visualLine } from "../line/spans" -import { getLine } from "../line/utils_line" -import { charCoords, cursorCoords, displayWidth, paddingH, wrappedLineExtentChar } from "../measurement/position_measurement" -import { getOrder, iterateBidiSections } from "../util/bidi" -import { elt } from "../util/dom" +import { Pos } from "../line/pos.js" +import { visualLine } from "../line/spans.js" +import { getLine } from "../line/utils_line.js" +import { charCoords, cursorCoords, displayWidth, paddingH, wrappedLineExtentChar } from "../measurement/position_measurement.js" +import { getOrder, iterateBidiSections } from "../util/bidi.js" +import { elt } from "../util/dom.js" export function updateSelection(cm) { cm.display.input.showSelection(cm.display.input.prepareSelection()) diff --git a/src/display/update_display.js b/src/display/update_display.js index e58db48a51..86c7132131 100644 --- a/src/display/update_display.js +++ b/src/display/update_display.js @@ -1,19 +1,19 @@ -import { sawCollapsedSpans } from "../line/saw_special_spans" -import { heightAtLine, visualLineEndNo, visualLineNo } from "../line/spans" -import { getLine, lineNumberFor } from "../line/utils_line" -import { displayHeight, displayWidth, getDimensions, paddingVert, scrollGap } from "../measurement/position_measurement" -import { mac, webkit } from "../util/browser" -import { activeElt, removeChildren, contains } from "../util/dom" -import { hasHandler, signal } from "../util/event" -import { indexOf } from "../util/misc" +import { sawCollapsedSpans } from "../line/saw_special_spans.js" +import { heightAtLine, visualLineEndNo, visualLineNo } from "../line/spans.js" +import { getLine, lineNumberFor } from "../line/utils_line.js" +import { displayHeight, displayWidth, getDimensions, paddingVert, scrollGap } from "../measurement/position_measurement.js" +import { mac, webkit } from "../util/browser.js" +import { activeElt, removeChildren, contains } from "../util/dom.js" +import { hasHandler, signal } from "../util/event.js" +import { indexOf } from "../util/misc.js" -import { buildLineElement, updateLineForChanges } from "./update_line" -import { startWorker } from "./highlight_worker" -import { maybeUpdateLineNumberWidth } from "./line_numbers" -import { measureForScrollbars, updateScrollbars } from "./scrollbars" -import { updateSelection } from "./selection" -import { updateHeightsInViewport, visibleLines } from "./update_lines" -import { adjustView, countDirtyView, resetView } from "./view_tracking" +import { buildLineElement, updateLineForChanges } from "./update_line.js" +import { startWorker } from "./highlight_worker.js" +import { maybeUpdateLineNumberWidth } from "./line_numbers.js" +import { measureForScrollbars, updateScrollbars } from "./scrollbars.js" +import { updateSelection } from "./selection.js" +import { updateHeightsInViewport, visibleLines } from "./update_lines.js" +import { adjustView, countDirtyView, resetView } from "./view_tracking.js" // DISPLAY DRAWING diff --git a/src/display/update_line.js b/src/display/update_line.js index 15a2394257..db9df26d92 100644 --- a/src/display/update_line.js +++ b/src/display/update_line.js @@ -1,8 +1,8 @@ -import { buildLineContent } from "../line/line_data" -import { lineNumberFor } from "../line/utils_line" -import { ie, ie_version } from "../util/browser" -import { elt } from "../util/dom" -import { signalLater } from "../util/operation_group" +import { buildLineContent } from "../line/line_data.js" +import { lineNumberFor } from "../line/utils_line.js" +import { ie, ie_version } from "../util/browser.js" +import { elt } from "../util/dom.js" +import { signalLater } from "../util/operation_group.js" // When an aspect of a line changes, a string is added to // lineView.changes. This updates the relevant part of the line's diff --git a/src/display/update_lines.js b/src/display/update_lines.js index 6c59188957..7f06018d04 100644 --- a/src/display/update_lines.js +++ b/src/display/update_lines.js @@ -1,7 +1,7 @@ -import { heightAtLine } from "../line/spans" -import { getLine, lineAtHeight, updateLineHeight } from "../line/utils_line" -import { paddingTop, textHeight } from "../measurement/position_measurement" -import { ie, ie_version } from "../util/browser" +import { heightAtLine } from "../line/spans.js" +import { getLine, lineAtHeight, updateLineHeight } from "../line/utils_line.js" +import { paddingTop, textHeight } from "../measurement/position_measurement.js" +import { ie, ie_version } from "../util/browser.js" // Read the actual heights of the rendered lines, and update their // stored heights to match. diff --git a/src/display/view_tracking.js b/src/display/view_tracking.js index b9abd2fc40..41464f2350 100644 --- a/src/display/view_tracking.js +++ b/src/display/view_tracking.js @@ -1,8 +1,8 @@ -import { buildViewArray } from "../line/line_data" -import { sawCollapsedSpans } from "../line/saw_special_spans" -import { visualLineEndNo, visualLineNo } from "../line/spans" -import { findViewIndex } from "../measurement/position_measurement" -import { indexOf } from "../util/misc" +import { buildViewArray } from "../line/line_data.js" +import { sawCollapsedSpans } from "../line/saw_special_spans.js" +import { visualLineEndNo, visualLineNo } from "../line/spans.js" +import { findViewIndex } from "../measurement/position_measurement.js" +import { indexOf } from "../util/misc.js" // Updates the display.view data structure for a given change to the // document. From and to are in pre-change coordinates. Lendiff is diff --git a/src/edit/CodeMirror.js b/src/edit/CodeMirror.js index 0f0e58900c..4759209cf2 100644 --- a/src/edit/CodeMirror.js +++ b/src/edit/CodeMirror.js @@ -1,28 +1,28 @@ -import { Display } from "../display/Display" -import { onFocus, onBlur } from "../display/focus" -import { setGuttersForLineNumbers, updateGutters } from "../display/gutters" -import { maybeUpdateLineNumberWidth } from "../display/line_numbers" -import { endOperation, operation, startOperation } from "../display/operations" -import { initScrollbars } from "../display/scrollbars" -import { onScrollWheel } from "../display/scroll_events" -import { setScrollLeft, updateScrollTop } from "../display/scrolling" -import { clipPos, Pos } from "../line/pos" -import { posFromMouse } from "../measurement/position_measurement" -import { eventInWidget } from "../measurement/widgets" -import Doc from "../model/Doc" -import { attachDoc } from "../model/document_data" -import { Range } from "../model/selection" -import { extendSelection } from "../model/selection_updates" -import { captureRightClick, ie, ie_version, mobile, webkit } from "../util/browser" -import { e_preventDefault, e_stop, on, signal, signalDOMEvent } from "../util/event" -import { bind, copyObj, Delayed } from "../util/misc" - -import { clearDragCursor, onDragOver, onDragStart, onDrop } from "./drop_events" -import { ensureGlobalHandlers } from "./global_events" -import { onKeyDown, onKeyPress, onKeyUp } from "./key_events" -import { clickInGutter, onContextMenu, onMouseDown } from "./mouse_events" -import { themeChanged } from "./utils" -import { defaults, optionHandlers, Init } from "./options" +import { Display } from "../display/Display.js" +import { onFocus, onBlur } from "../display/focus.js" +import { setGuttersForLineNumbers, updateGutters } from "../display/gutters.js" +import { maybeUpdateLineNumberWidth } from "../display/line_numbers.js" +import { endOperation, operation, startOperation } from "../display/operations.js" +import { initScrollbars } from "../display/scrollbars.js" +import { onScrollWheel } from "../display/scroll_events.js" +import { setScrollLeft, updateScrollTop } from "../display/scrolling.js" +import { clipPos, Pos } from "../line/pos.js" +import { posFromMouse } from "../measurement/position_measurement.js" +import { eventInWidget } from "../measurement/widgets.js" +import Doc from "../model/Doc.js" +import { attachDoc } from "../model/document_data.js" +import { Range } from "../model/selection.js" +import { extendSelection } from "../model/selection_updates.js" +import { captureRightClick, ie, ie_version, mobile, webkit } from "../util/browser.js" +import { e_preventDefault, e_stop, on, signal, signalDOMEvent } from "../util/event.js" +import { bind, copyObj, Delayed } from "../util/misc.js" + +import { clearDragCursor, onDragOver, onDragStart, onDrop } from "./drop_events.js" +import { ensureGlobalHandlers } from "./global_events.js" +import { onKeyDown, onKeyPress, onKeyUp } from "./key_events.js" +import { clickInGutter, onContextMenu, onMouseDown } from "./mouse_events.js" +import { themeChanged } from "./utils.js" +import { defaults, optionHandlers, Init } from "./options.js" // A CodeMirror instance represents an editor. This is the object // that user code is usually dealing with. diff --git a/src/edit/commands.js b/src/edit/commands.js index e1a4327c8f..3916b129fb 100644 --- a/src/edit/commands.js +++ b/src/edit/commands.js @@ -1,14 +1,14 @@ -import { deleteNearSelection } from "./deleteNearSelection" -import { runInOp } from "../display/operations" -import { ensureCursorVisible } from "../display/scrolling" -import { endOfLine } from "../input/movement" -import { clipPos, Pos } from "../line/pos" -import { visualLine, visualLineEnd } from "../line/spans" -import { getLine, lineNo } from "../line/utils_line" -import { Range } from "../model/selection" -import { selectAll } from "../model/selection_updates" -import { countColumn, sel_dontScroll, sel_move, spaceStr } from "../util/misc" -import { getOrder } from "../util/bidi" +import { deleteNearSelection } from "./deleteNearSelection.js" +import { runInOp } from "../display/operations.js" +import { ensureCursorVisible } from "../display/scrolling.js" +import { endOfLine } from "../input/movement.js" +import { clipPos, Pos } from "../line/pos.js" +import { visualLine, visualLineEnd } from "../line/spans.js" +import { getLine, lineNo } from "../line/utils_line.js" +import { Range } from "../model/selection.js" +import { selectAll } from "../model/selection_updates.js" +import { countColumn, sel_dontScroll, sel_move, spaceStr } from "../util/misc.js" +import { getOrder } from "../util/bidi.js" // Commands are parameter-less actions that can be performed on an // editor, mostly used for keybindings. diff --git a/src/edit/deleteNearSelection.js b/src/edit/deleteNearSelection.js index 5a9bd2cfd5..82e331a5ff 100644 --- a/src/edit/deleteNearSelection.js +++ b/src/edit/deleteNearSelection.js @@ -1,8 +1,8 @@ -import { runInOp } from "../display/operations" -import { ensureCursorVisible } from "../display/scrolling" -import { cmp } from "../line/pos" -import { replaceRange } from "../model/changes" -import { lst } from "../util/misc" +import { runInOp } from "../display/operations.js" +import { ensureCursorVisible } from "../display/scrolling.js" +import { cmp } from "../line/pos.js" +import { replaceRange } from "../model/changes.js" +import { lst } from "../util/misc.js" // Helper for deleting text near the selection(s), used to implement // backspace, delete, and similar functionality. diff --git a/src/edit/drop_events.js b/src/edit/drop_events.js index 43e996fb68..12c760f0d6 100644 --- a/src/edit/drop_events.js +++ b/src/edit/drop_events.js @@ -1,16 +1,16 @@ -import { drawSelectionCursor } from "../display/selection" -import { operation } from "../display/operations" -import { clipPos } from "../line/pos" -import { posFromMouse } from "../measurement/position_measurement" -import { eventInWidget } from "../measurement/widgets" -import { makeChange, replaceRange } from "../model/changes" -import { changeEnd } from "../model/change_measurement" -import { simpleSelection } from "../model/selection" -import { setSelectionNoUndo, setSelectionReplaceHistory } from "../model/selection_updates" -import { ie, presto, safari } from "../util/browser" -import { elt, removeChildrenAndAdd } from "../util/dom" -import { e_preventDefault, e_stop, signalDOMEvent } from "../util/event" -import { indexOf } from "../util/misc" +import { drawSelectionCursor } from "../display/selection.js" +import { operation } from "../display/operations.js" +import { clipPos } from "../line/pos.js" +import { posFromMouse } from "../measurement/position_measurement.js" +import { eventInWidget } from "../measurement/widgets.js" +import { makeChange, replaceRange } from "../model/changes.js" +import { changeEnd } from "../model/change_measurement.js" +import { simpleSelection } from "../model/selection.js" +import { setSelectionNoUndo, setSelectionReplaceHistory } from "../model/selection_updates.js" +import { ie, presto, safari } from "../util/browser.js" +import { elt, removeChildrenAndAdd } from "../util/dom.js" +import { e_preventDefault, e_stop, signalDOMEvent } from "../util/event.js" +import { indexOf } from "../util/misc.js" // Kludge to work around strange IE behavior where it'll sometimes // re-fire a series of drag-related events right after the drop (#1551) diff --git a/src/edit/fromTextArea.js b/src/edit/fromTextArea.js index 5d920830b3..92498c1045 100644 --- a/src/edit/fromTextArea.js +++ b/src/edit/fromTextArea.js @@ -1,7 +1,7 @@ -import { CodeMirror } from "./CodeMirror" -import { activeElt } from "../util/dom" -import { off, on } from "../util/event" -import { copyObj } from "../util/misc" +import { CodeMirror } from "./CodeMirror.js" +import { activeElt } from "../util/dom.js" +import { off, on } from "../util/event.js" +import { copyObj } from "../util/misc.js" export function fromTextArea(textarea, options) { options = options ? copyObj(options) : {} diff --git a/src/edit/global_events.js b/src/edit/global_events.js index b2ab7d57c1..269e870ef1 100644 --- a/src/edit/global_events.js +++ b/src/edit/global_events.js @@ -1,5 +1,5 @@ -import { onBlur } from "../display/focus" -import { on } from "../util/event" +import { onBlur } from "../display/focus.js" +import { on } from "../util/event.js" // These must be handled carefully, because naively registering a // handler for each editor will cause the editors to never be diff --git a/src/edit/key_events.js b/src/edit/key_events.js index 06f37be078..f0521d070a 100644 --- a/src/edit/key_events.js +++ b/src/edit/key_events.js @@ -1,14 +1,14 @@ -import { signalLater } from "../util/operation_group" -import { restartBlink } from "../display/selection" -import { isModifierKey, keyName, lookupKey } from "../input/keymap" -import { eventInWidget } from "../measurement/widgets" -import { ie, ie_version, mac, presto } from "../util/browser" -import { activeElt, addClass, rmClass } from "../util/dom" -import { e_preventDefault, off, on, signalDOMEvent } from "../util/event" -import { hasCopyEvent } from "../util/feature_detection" -import { Delayed, Pass } from "../util/misc" - -import { commands } from "./commands" +import { signalLater } from "../util/operation_group.js" +import { restartBlink } from "../display/selection.js" +import { isModifierKey, keyName, lookupKey } from "../input/keymap.js" +import { eventInWidget } from "../measurement/widgets.js" +import { ie, ie_version, mac, presto } from "../util/browser.js" +import { activeElt, addClass, rmClass } from "../util/dom.js" +import { e_preventDefault, off, on, signalDOMEvent } from "../util/event.js" +import { hasCopyEvent } from "../util/feature_detection.js" +import { Delayed, Pass } from "../util/misc.js" + +import { commands } from "./commands.js" // Run a handler that was bound to a key. function doHandleBinding(cm, bound, dropShift) { diff --git a/src/edit/legacy.js b/src/edit/legacy.js index bc3df6c8f1..889badbe59 100644 --- a/src/edit/legacy.js +++ b/src/edit/legacy.js @@ -1,21 +1,21 @@ -import { scrollbarModel } from "../display/scrollbars" -import { wheelEventPixels } from "../display/scroll_events" -import { keyMap, keyName, isModifierKey, lookupKey, normalizeKeyMap } from "../input/keymap" -import { keyNames } from "../input/keynames" -import { Line } from "../line/line_data" -import { cmp, Pos } from "../line/pos" -import { changeEnd } from "../model/change_measurement" -import Doc from "../model/Doc" -import { LineWidget } from "../model/line_widget" -import { SharedTextMarker, TextMarker } from "../model/mark_text" -import { copyState, extendMode, getMode, innerMode, mimeModes, modeExtensions, modes, resolveMode, startState } from "../modes" -import { addClass, contains, rmClass } from "../util/dom" -import { e_preventDefault, e_stop, e_stopPropagation, off, on, signal } from "../util/event" -import { splitLinesAuto } from "../util/feature_detection" -import { countColumn, findColumn, isWordCharBasic, Pass } from "../util/misc" -import StringStream from "../util/StringStream" +import { scrollbarModel } from "../display/scrollbars.js" +import { wheelEventPixels } from "../display/scroll_events.js" +import { keyMap, keyName, isModifierKey, lookupKey, normalizeKeyMap } from "../input/keymap.js" +import { keyNames } from "../input/keynames.js" +import { Line } from "../line/line_data.js" +import { cmp, Pos } from "../line/pos.js" +import { changeEnd } from "../model/change_measurement.js" +import Doc from "../model/Doc.js" +import { LineWidget } from "../model/line_widget.js" +import { SharedTextMarker, TextMarker } from "../model/mark_text.js" +import { copyState, extendMode, getMode, innerMode, mimeModes, modeExtensions, modes, resolveMode, startState } from "../modes.js" +import { addClass, contains, rmClass } from "../util/dom.js" +import { e_preventDefault, e_stop, e_stopPropagation, off, on, signal } from "../util/event.js" +import { splitLinesAuto } from "../util/feature_detection.js" +import { countColumn, findColumn, isWordCharBasic, Pass } from "../util/misc.js" +import StringStream from "../util/StringStream.js" -import { commands } from "./commands" +import { commands } from "./commands.js" export function addLegacyProps(CodeMirror) { CodeMirror.off = off diff --git a/src/edit/main.js b/src/edit/main.js index 6500e08d05..6d9eb8790b 100644 --- a/src/edit/main.js +++ b/src/edit/main.js @@ -1,20 +1,20 @@ // EDITOR CONSTRUCTOR -import { CodeMirror } from "./CodeMirror" -export { CodeMirror } from "./CodeMirror" +import { CodeMirror } from "./CodeMirror.js" +export { CodeMirror } from "./CodeMirror.js" -import { eventMixin } from "../util/event" -import { indexOf } from "../util/misc" +import { eventMixin } from "../util/event.js" +import { indexOf } from "../util/misc.js" -import { defineOptions } from "./options" +import { defineOptions } from "./options.js" defineOptions(CodeMirror) -import addEditorMethods from "./methods" +import addEditorMethods from "./methods.js" addEditorMethods(CodeMirror) -import Doc from "../model/Doc" +import Doc from "../model/Doc.js" // Set up methods on CodeMirror's prototype to redirect to the editor's document. let dontDelegate = "iter insert remove copy getEditor constructor".split(" ") @@ -27,13 +27,13 @@ eventMixin(Doc) // INPUT HANDLING -import ContentEditableInput from "../input/ContentEditableInput" -import TextareaInput from "../input/TextareaInput" +import ContentEditableInput from "../input/ContentEditableInput.js" +import TextareaInput from "../input/TextareaInput.js" CodeMirror.inputStyles = {"textarea": TextareaInput, "contenteditable": ContentEditableInput} // MODE DEFINITION AND QUERYING -import { defineMIME, defineMode } from "../modes" +import { defineMIME, defineMode } from "../modes.js" // Extra arguments are stored as the mode's dependencies, which is // used by (legacy) mechanisms like loadmode.js to automatically @@ -58,11 +58,11 @@ CodeMirror.defineDocExtension = (name, func) => { Doc.prototype[name] = func } -import { fromTextArea } from "./fromTextArea" +import { fromTextArea } from "./fromTextArea.js" CodeMirror.fromTextArea = fromTextArea -import { addLegacyProps } from "./legacy" +import { addLegacyProps } from "./legacy.js" addLegacyProps(CodeMirror) diff --git a/src/edit/methods.js b/src/edit/methods.js index 8dc692529e..5cefed7c18 100644 --- a/src/edit/methods.js +++ b/src/edit/methods.js @@ -1,27 +1,27 @@ -import { deleteNearSelection } from "./deleteNearSelection" -import { commands } from "./commands" -import { attachDoc } from "../model/document_data" -import { activeElt, addClass, rmClass } from "../util/dom" -import { eventMixin, signal } from "../util/event" -import { getLineStyles, getContextBefore, takeToken } from "../line/highlight" -import { indentLine } from "../input/indent" -import { triggerElectric } from "../input/input" -import { onKeyDown, onKeyPress, onKeyUp } from "./key_events" -import { onMouseDown } from "./mouse_events" -import { getKeyMap } from "../input/keymap" -import { endOfLine, moveLogically, moveVisually } from "../input/movement" -import { endOperation, methodOp, operation, runInOp, startOperation } from "../display/operations" -import { clipLine, clipPos, equalCursorPos, Pos } from "../line/pos" -import { charCoords, charWidth, clearCaches, clearLineMeasurementCache, coordsChar, cursorCoords, displayHeight, displayWidth, estimateLineHeights, fromCoordSystem, intoCoordSystem, scrollGap, textHeight } from "../measurement/position_measurement" -import { Range } from "../model/selection" -import { replaceOneSelection, skipAtomic } from "../model/selection_updates" -import { addToScrollTop, ensureCursorVisible, scrollIntoView, scrollToCoords, scrollToCoordsRange, scrollToRange } from "../display/scrolling" -import { heightAtLine } from "../line/spans" -import { updateGutterSpace } from "../display/update_display" -import { indexOf, insertSorted, isWordChar, sel_dontScroll, sel_move } from "../util/misc" -import { signalLater } from "../util/operation_group" -import { getLine, isLine, lineAtHeight } from "../line/utils_line" -import { regChange, regLineChange } from "../display/view_tracking" +import { deleteNearSelection } from "./deleteNearSelection.js" +import { commands } from "./commands.js" +import { attachDoc } from "../model/document_data.js" +import { activeElt, addClass, rmClass } from "../util/dom.js" +import { eventMixin, signal } from "../util/event.js" +import { getLineStyles, getContextBefore, takeToken } from "../line/highlight.js" +import { indentLine } from "../input/indent.js" +import { triggerElectric } from "../input/input.js" +import { onKeyDown, onKeyPress, onKeyUp } from "./key_events.js" +import { onMouseDown } from "./mouse_events.js" +import { getKeyMap } from "../input/keymap.js" +import { endOfLine, moveLogically, moveVisually } from "../input/movement.js" +import { endOperation, methodOp, operation, runInOp, startOperation } from "../display/operations.js" +import { clipLine, clipPos, equalCursorPos, Pos } from "../line/pos.js" +import { charCoords, charWidth, clearCaches, clearLineMeasurementCache, coordsChar, cursorCoords, displayHeight, displayWidth, estimateLineHeights, fromCoordSystem, intoCoordSystem, scrollGap, textHeight } from "../measurement/position_measurement.js" +import { Range } from "../model/selection.js" +import { replaceOneSelection, skipAtomic } from "../model/selection_updates.js" +import { addToScrollTop, ensureCursorVisible, scrollIntoView, scrollToCoords, scrollToCoordsRange, scrollToRange } from "../display/scrolling.js" +import { heightAtLine } from "../line/spans.js" +import { updateGutterSpace } from "../display/update_display.js" +import { indexOf, insertSorted, isWordChar, sel_dontScroll, sel_move } from "../util/misc.js" +import { signalLater } from "../util/operation_group.js" +import { getLine, isLine, lineAtHeight } from "../line/utils_line.js" +import { regChange, regLineChange } from "../display/view_tracking.js" // The publicly visible API. Note that methodOp(f) means // 'wrap f in an operation, performed on its `this` parameter'. diff --git a/src/edit/mouse_events.js b/src/edit/mouse_events.js index 57159e3a14..696a4bbfa2 100644 --- a/src/edit/mouse_events.js +++ b/src/edit/mouse_events.js @@ -1,23 +1,23 @@ -import { delayBlurEvent, ensureFocus } from "../display/focus" -import { operation } from "../display/operations" -import { visibleLines } from "../display/update_lines" -import { clipPos, cmp, maxPos, minPos, Pos } from "../line/pos" -import { getLine, lineAtHeight } from "../line/utils_line" -import { posFromMouse } from "../measurement/position_measurement" -import { eventInWidget } from "../measurement/widgets" -import { normalizeSelection, Range, Selection } from "../model/selection" -import { extendRange, extendSelection, replaceOneSelection, setSelection } from "../model/selection_updates" -import { captureRightClick, chromeOS, ie, ie_version, mac, webkit } from "../util/browser" -import { getOrder, getBidiPartAt } from "../util/bidi" -import { activeElt } from "../util/dom" -import { e_button, e_defaultPrevented, e_preventDefault, e_target, hasHandler, off, on, signal, signalDOMEvent } from "../util/event" -import { dragAndDrop } from "../util/feature_detection" -import { bind, countColumn, findColumn, sel_mouse } from "../util/misc" -import { addModifierNames } from "../input/keymap" -import { Pass } from "../util/misc" - -import { dispatchKey } from "./key_events" -import { commands } from "./commands" +import { delayBlurEvent, ensureFocus } from "../display/focus.js" +import { operation } from "../display/operations.js" +import { visibleLines } from "../display/update_lines.js" +import { clipPos, cmp, maxPos, minPos, Pos } from "../line/pos.js" +import { getLine, lineAtHeight } from "../line/utils_line.js" +import { posFromMouse } from "../measurement/position_measurement.js" +import { eventInWidget } from "../measurement/widgets.js" +import { normalizeSelection, Range, Selection } from "../model/selection.js" +import { extendRange, extendSelection, replaceOneSelection, setSelection } from "../model/selection_updates.js" +import { captureRightClick, chromeOS, ie, ie_version, mac, webkit } from "../util/browser.js" +import { getOrder, getBidiPartAt } from "../util/bidi.js" +import { activeElt } from "../util/dom.js" +import { e_button, e_defaultPrevented, e_preventDefault, e_target, hasHandler, off, on, signal, signalDOMEvent } from "../util/event.js" +import { dragAndDrop } from "../util/feature_detection.js" +import { bind, countColumn, findColumn, sel_mouse } from "../util/misc.js" +import { addModifierNames } from "../input/keymap.js" +import { Pass } from "../util/misc.js" + +import { dispatchKey } from "./key_events.js" +import { commands } from "./commands.js" const DOUBLECLICK_DELAY = 400 diff --git a/src/edit/options.js b/src/edit/options.js index 0601a83c3c..28f8bb60c6 100644 --- a/src/edit/options.js +++ b/src/edit/options.js @@ -1,21 +1,21 @@ -import { onBlur } from "../display/focus" -import { setGuttersForLineNumbers, updateGutters } from "../display/gutters" -import { alignHorizontally } from "../display/line_numbers" -import { loadMode, resetModeState } from "../display/mode_state" -import { initScrollbars, updateScrollbars } from "../display/scrollbars" -import { updateSelection } from "../display/selection" -import { regChange } from "../display/view_tracking" -import { getKeyMap } from "../input/keymap" -import { defaultSpecialCharPlaceholder } from "../line/line_data" -import { Pos } from "../line/pos" -import { findMaxLine } from "../line/spans" -import { clearCaches, compensateForHScroll, estimateLineHeights } from "../measurement/position_measurement" -import { replaceRange } from "../model/changes" -import { mobile, windows } from "../util/browser" -import { addClass, rmClass } from "../util/dom" -import { off, on } from "../util/event" - -import { themeChanged } from "./utils" +import { onBlur } from "../display/focus.js" +import { setGuttersForLineNumbers, updateGutters } from "../display/gutters.js" +import { alignHorizontally } from "../display/line_numbers.js" +import { loadMode, resetModeState } from "../display/mode_state.js" +import { initScrollbars, updateScrollbars } from "../display/scrollbars.js" +import { updateSelection } from "../display/selection.js" +import { regChange } from "../display/view_tracking.js" +import { getKeyMap } from "../input/keymap.js" +import { defaultSpecialCharPlaceholder } from "../line/line_data.js" +import { Pos } from "../line/pos.js" +import { findMaxLine } from "../line/spans.js" +import { clearCaches, compensateForHScroll, estimateLineHeights } from "../measurement/position_measurement.js" +import { replaceRange } from "../model/changes.js" +import { mobile, windows } from "../util/browser.js" +import { addClass, rmClass } from "../util/dom.js" +import { off, on } from "../util/event.js" + +import { themeChanged } from "./utils.js" export let Init = {toString: function(){return "CodeMirror.Init"}} diff --git a/src/edit/utils.js b/src/edit/utils.js index 61f795572d..fda0be7412 100644 --- a/src/edit/utils.js +++ b/src/edit/utils.js @@ -1,4 +1,4 @@ -import { clearCaches } from "../measurement/position_measurement" +import { clearCaches } from "../measurement/position_measurement.js" export function themeChanged(cm) { cm.display.wrapper.className = cm.display.wrapper.className.replace(/\s*cm-s-\S+/g, "") + diff --git a/src/input/ContentEditableInput.js b/src/input/ContentEditableInput.js index 67de3b1836..e3af520a04 100644 --- a/src/input/ContentEditableInput.js +++ b/src/input/ContentEditableInput.js @@ -1,18 +1,18 @@ -import { operation, runInOp } from "../display/operations" -import { prepareSelection } from "../display/selection" -import { regChange } from "../display/view_tracking" -import { applyTextInput, copyableRanges, disableBrowserMagic, handlePaste, hiddenTextarea, lastCopied, setLastCopied } from "./input" -import { cmp, maxPos, minPos, Pos } from "../line/pos" -import { getBetween, getLine, lineNo } from "../line/utils_line" -import { findViewForLine, findViewIndex, mapFromLineView, nodeAndOffsetInLineMap } from "../measurement/position_measurement" -import { replaceRange } from "../model/changes" -import { simpleSelection } from "../model/selection" -import { setSelection } from "../model/selection_updates" -import { getBidiPartAt, getOrder } from "../util/bidi" -import { android, chrome, gecko, ie_version } from "../util/browser" -import { contains, range, removeChildrenAndAdd, selectInput } from "../util/dom" -import { on, signalDOMEvent } from "../util/event" -import { Delayed, lst, sel_dontScroll } from "../util/misc" +import { operation, runInOp } from "../display/operations.js" +import { prepareSelection } from "../display/selection.js" +import { regChange } from "../display/view_tracking.js" +import { applyTextInput, copyableRanges, disableBrowserMagic, handlePaste, hiddenTextarea, lastCopied, setLastCopied } from "./input.js" +import { cmp, maxPos, minPos, Pos } from "../line/pos.js" +import { getBetween, getLine, lineNo } from "../line/utils_line.js" +import { findViewForLine, findViewIndex, mapFromLineView, nodeAndOffsetInLineMap } from "../measurement/position_measurement.js" +import { replaceRange } from "../model/changes.js" +import { simpleSelection } from "../model/selection.js" +import { setSelection } from "../model/selection_updates.js" +import { getBidiPartAt, getOrder } from "../util/bidi.js" +import { android, chrome, gecko, ie_version } from "../util/browser.js" +import { contains, range, removeChildrenAndAdd, selectInput } from "../util/dom.js" +import { on, signalDOMEvent } from "../util/event.js" +import { Delayed, lst, sel_dontScroll } from "../util/misc.js" // CONTENTEDITABLE INPUT STYLE diff --git a/src/input/TextareaInput.js b/src/input/TextareaInput.js index 3262ea1ba6..c0f04aaaf2 100644 --- a/src/input/TextareaInput.js +++ b/src/input/TextareaInput.js @@ -1,15 +1,15 @@ -import { operation, runInOp } from "../display/operations" -import { prepareSelection } from "../display/selection" -import { applyTextInput, copyableRanges, handlePaste, hiddenTextarea, setLastCopied } from "./input" -import { cursorCoords, posFromMouse } from "../measurement/position_measurement" -import { eventInWidget } from "../measurement/widgets" -import { simpleSelection } from "../model/selection" -import { selectAll, setSelection } from "../model/selection_updates" -import { captureRightClick, ie, ie_version, ios, mac, mobile, presto, webkit } from "../util/browser" -import { activeElt, removeChildrenAndAdd, selectInput } from "../util/dom" -import { e_preventDefault, e_stop, off, on, signalDOMEvent } from "../util/event" -import { hasSelection } from "../util/feature_detection" -import { Delayed, sel_dontScroll } from "../util/misc" +import { operation, runInOp } from "../display/operations.js" +import { prepareSelection } from "../display/selection.js" +import { applyTextInput, copyableRanges, handlePaste, hiddenTextarea, setLastCopied } from "./input.js" +import { cursorCoords, posFromMouse } from "../measurement/position_measurement.js" +import { eventInWidget } from "../measurement/widgets.js" +import { simpleSelection } from "../model/selection.js" +import { selectAll, setSelection } from "../model/selection_updates.js" +import { captureRightClick, ie, ie_version, ios, mac, mobile, presto, webkit } from "../util/browser.js" +import { activeElt, removeChildrenAndAdd, selectInput } from "../util/dom.js" +import { e_preventDefault, e_stop, off, on, signalDOMEvent } from "../util/event.js" +import { hasSelection } from "../util/feature_detection.js" +import { Delayed, sel_dontScroll } from "../util/misc.js" // TEXTAREA INPUT STYLE diff --git a/src/input/indent.js b/src/input/indent.js index 024f5f9254..c88772cb6b 100644 --- a/src/input/indent.js +++ b/src/input/indent.js @@ -1,10 +1,10 @@ -import { getContextBefore } from "../line/highlight" -import { Pos } from "../line/pos" -import { getLine } from "../line/utils_line" -import { replaceRange } from "../model/changes" -import { Range } from "../model/selection" -import { replaceOneSelection } from "../model/selection_updates" -import { countColumn, Pass, spaceStr } from "../util/misc" +import { getContextBefore } from "../line/highlight.js" +import { Pos } from "../line/pos.js" +import { getLine } from "../line/utils_line.js" +import { replaceRange } from "../model/changes.js" +import { Range } from "../model/selection.js" +import { replaceOneSelection } from "../model/selection_updates.js" +import { countColumn, Pass, spaceStr } from "../util/misc.js" // Indent the given line. The how parameter can be "smart", // "add"/null, "subtract", or "prev". When aggressive is false diff --git a/src/input/input.js b/src/input/input.js index fa85209ee8..ff86c39d31 100644 --- a/src/input/input.js +++ b/src/input/input.js @@ -1,15 +1,15 @@ -import { runInOp } from "../display/operations" -import { ensureCursorVisible } from "../display/scrolling" -import { Pos } from "../line/pos" -import { getLine } from "../line/utils_line" -import { makeChange } from "../model/changes" -import { ios, webkit } from "../util/browser" -import { elt } from "../util/dom" -import { lst, map } from "../util/misc" -import { signalLater } from "../util/operation_group" -import { splitLinesAuto } from "../util/feature_detection" +import { runInOp } from "../display/operations.js" +import { ensureCursorVisible } from "../display/scrolling.js" +import { Pos } from "../line/pos.js" +import { getLine } from "../line/utils_line.js" +import { makeChange } from "../model/changes.js" +import { ios, webkit } from "../util/browser.js" +import { elt } from "../util/dom.js" +import { lst, map } from "../util/misc.js" +import { signalLater } from "../util/operation_group.js" +import { splitLinesAuto } from "../util/feature_detection.js" -import { indentLine } from "./indent" +import { indentLine } from "./indent.js" // This will be set to a {lineWise: bool, text: [string]} object, so // that, when pasting, we know what kind of selections the copied diff --git a/src/input/keymap.js b/src/input/keymap.js index 36ac3e61b9..1dfcf8aff6 100644 --- a/src/input/keymap.js +++ b/src/input/keymap.js @@ -1,7 +1,7 @@ -import { flipCtrlCmd, mac, presto } from "../util/browser" -import { map } from "../util/misc" +import { flipCtrlCmd, mac, presto } from "../util/browser.js" +import { map } from "../util/misc.js" -import { keyNames } from "./keynames" +import { keyNames } from "./keynames.js" export let keyMap = {} diff --git a/src/input/movement.js b/src/input/movement.js index 927ed6e14d..8d50fd2a04 100644 --- a/src/input/movement.js +++ b/src/input/movement.js @@ -1,7 +1,7 @@ -import { Pos } from "../line/pos" -import { prepareMeasureForLine, measureCharPrepared, wrappedLineExtentChar } from "../measurement/position_measurement" -import { getBidiPartAt, getOrder } from "../util/bidi" -import { findFirst, lst, skipExtendingChars } from "../util/misc" +import { Pos } from "../line/pos.js" +import { prepareMeasureForLine, measureCharPrepared, wrappedLineExtentChar } from "../measurement/position_measurement.js" +import { getBidiPartAt, getOrder } from "../util/bidi.js" +import { findFirst, lst, skipExtendingChars } from "../util/misc.js" function moveCharLogically(line, ch, dir) { let target = skipExtendingChars(line.text, ch + dir, dir) diff --git a/src/line/highlight.js b/src/line/highlight.js index c5e6b8aacc..79f0884511 100644 --- a/src/line/highlight.js +++ b/src/line/highlight.js @@ -1,9 +1,9 @@ -import { countColumn } from "../util/misc" -import { copyState, innerMode, startState } from "../modes" -import StringStream from "../util/StringStream" +import { countColumn } from "../util/misc.js" +import { copyState, innerMode, startState } from "../modes.js" +import StringStream from "../util/StringStream.js" -import { getLine, lineNo } from "./utils_line" -import { clipPos } from "./pos" +import { getLine, lineNo } from "./utils_line.js" +import { clipPos } from "./pos.js" class SavedContext { constructor(state, lookAhead) { diff --git a/src/line/line_data.js b/src/line/line_data.js index e444184bb0..74acdaffc0 100644 --- a/src/line/line_data.js +++ b/src/line/line_data.js @@ -1,13 +1,13 @@ -import { getOrder } from "../util/bidi" -import { ie, ie_version, webkit } from "../util/browser" -import { elt, eltP, joinClasses } from "../util/dom" -import { eventMixin, signal } from "../util/event" -import { hasBadBidiRects, zeroWidthElement } from "../util/feature_detection" -import { lst, spaceStr } from "../util/misc" +import { getOrder } from "../util/bidi.js" +import { ie, ie_version, webkit } from "../util/browser.js" +import { elt, eltP, joinClasses } from "../util/dom.js" +import { eventMixin, signal } from "../util/event.js" +import { hasBadBidiRects, zeroWidthElement } from "../util/feature_detection.js" +import { lst, spaceStr } from "../util/misc.js" -import { getLineStyles } from "./highlight" -import { attachMarkedSpans, compareCollapsedMarkers, detachMarkedSpans, lineIsHidden, visualLineContinued } from "./spans" -import { getLine, lineNo, updateLineHeight } from "./utils_line" +import { getLineStyles } from "./highlight.js" +import { attachMarkedSpans, compareCollapsedMarkers, detachMarkedSpans, lineIsHidden, visualLineContinued } from "./spans.js" +import { getLine, lineNo, updateLineHeight } from "./utils_line.js" // LINE DATA STRUCTURE diff --git a/src/line/pos.js b/src/line/pos.js index 4f5e4c5594..2a498f8f3c 100644 --- a/src/line/pos.js +++ b/src/line/pos.js @@ -1,4 +1,4 @@ -import { getLine } from "./utils_line" +import { getLine } from "./utils_line.js" // A Pos instance represents a position within the text. export function Pos(line, ch, sticky = null) { diff --git a/src/line/spans.js b/src/line/spans.js index 6c413d2fc2..f7e5f4b6e9 100644 --- a/src/line/spans.js +++ b/src/line/spans.js @@ -1,8 +1,8 @@ -import { indexOf, lst } from "../util/misc" +import { indexOf, lst } from "../util/misc.js" -import { cmp } from "./pos" -import { sawCollapsedSpans } from "./saw_special_spans" -import { getLine, isLine, lineNo } from "./utils_line" +import { cmp } from "./pos.js" +import { sawCollapsedSpans } from "./saw_special_spans.js" +import { getLine, isLine, lineNo } from "./utils_line.js" // TEXTMARKER SPANS diff --git a/src/line/utils_line.js b/src/line/utils_line.js index e4e6943f55..c886294353 100644 --- a/src/line/utils_line.js +++ b/src/line/utils_line.js @@ -1,4 +1,4 @@ -import { indexOf } from "../util/misc" +import { indexOf } from "../util/misc.js" // Find the line object corresponding to the given line number. export function getLine(doc, n) { diff --git a/src/measurement/position_measurement.js b/src/measurement/position_measurement.js index 78986e03db..aeff0e5b8d 100644 --- a/src/measurement/position_measurement.js +++ b/src/measurement/position_measurement.js @@ -1,16 +1,16 @@ -import { buildLineContent, LineView } from "../line/line_data" -import { clipPos, Pos } from "../line/pos" -import { collapsedSpanAtEnd, heightAtLine, lineIsHidden, visualLine } from "../line/spans" -import { getLine, lineAtHeight, lineNo, updateLineHeight } from "../line/utils_line" -import { bidiOther, getBidiPartAt, getOrder } from "../util/bidi" -import { chrome, android, ie, ie_version } from "../util/browser" -import { elt, removeChildren, range, removeChildrenAndAdd } from "../util/dom" -import { e_target } from "../util/event" -import { hasBadZoomedRects } from "../util/feature_detection" -import { countColumn, findFirst, isExtendingChar, scrollerGap, skipExtendingChars } from "../util/misc" -import { updateLineForChanges } from "../display/update_line" - -import { widgetHeight } from "./widgets" +import { buildLineContent, LineView } from "../line/line_data.js" +import { clipPos, Pos } from "../line/pos.js" +import { collapsedSpanAtEnd, heightAtLine, lineIsHidden, visualLine } from "../line/spans.js" +import { getLine, lineAtHeight, lineNo, updateLineHeight } from "../line/utils_line.js" +import { bidiOther, getBidiPartAt, getOrder } from "../util/bidi.js" +import { chrome, android, ie, ie_version } from "../util/browser.js" +import { elt, removeChildren, range, removeChildrenAndAdd } from "../util/dom.js" +import { e_target } from "../util/event.js" +import { hasBadZoomedRects } from "../util/feature_detection.js" +import { countColumn, findFirst, isExtendingChar, scrollerGap, skipExtendingChars } from "../util/misc.js" +import { updateLineForChanges } from "../display/update_line.js" + +import { widgetHeight } from "./widgets.js" // POSITION MEASUREMENT diff --git a/src/measurement/widgets.js b/src/measurement/widgets.js index 554cf80977..39d7553d1f 100644 --- a/src/measurement/widgets.js +++ b/src/measurement/widgets.js @@ -1,5 +1,5 @@ -import { contains, elt, removeChildrenAndAdd } from "../util/dom" -import { e_target } from "../util/event" +import { contains, elt, removeChildrenAndAdd } from "../util/dom.js" +import { e_target } from "../util/event.js" export function widgetHeight(widget) { if (widget.height != null) return widget.height diff --git a/src/model/Doc.js b/src/model/Doc.js index c3da76d74e..b64ac84373 100644 --- a/src/model/Doc.js +++ b/src/model/Doc.js @@ -1,23 +1,23 @@ -import CodeMirror from "../edit/CodeMirror" -import { docMethodOp } from "../display/operations" -import { Line } from "../line/line_data" -import { clipPos, clipPosArray, Pos } from "../line/pos" -import { visualLine } from "../line/spans" -import { getBetween, getLine, getLines, isLine, lineNo } from "../line/utils_line" -import { classTest } from "../util/dom" -import { splitLinesAuto } from "../util/feature_detection" -import { createObj, map, isEmpty, sel_dontScroll } from "../util/misc" -import { ensureCursorVisible, scrollToCoords } from "../display/scrolling" - -import { changeLine, makeChange, makeChangeFromHistory, replaceRange } from "./changes" -import { computeReplacedSel } from "./change_measurement" -import { BranchChunk, LeafChunk } from "./chunk" -import { directionChanged, linkedDocs, updateDoc } from "./document_data" -import { copyHistoryArray, History } from "./history" -import { addLineWidget } from "./line_widget" -import { copySharedMarkers, detachSharedMarkers, findSharedMarkers, markText } from "./mark_text" -import { normalizeSelection, Range, simpleSelection } from "./selection" -import { extendSelection, extendSelections, setSelection, setSelectionReplaceHistory, setSimpleSelection } from "./selection_updates" +import CodeMirror from "../edit/CodeMirror.js" +import { docMethodOp } from "../display/operations.js" +import { Line } from "../line/line_data.js" +import { clipPos, clipPosArray, Pos } from "../line/pos.js" +import { visualLine } from "../line/spans.js" +import { getBetween, getLine, getLines, isLine, lineNo } from "../line/utils_line.js" +import { classTest } from "../util/dom.js" +import { splitLinesAuto } from "../util/feature_detection.js" +import { createObj, map, isEmpty, sel_dontScroll } from "../util/misc.js" +import { ensureCursorVisible, scrollToCoords } from "../display/scrolling.js" + +import { changeLine, makeChange, makeChangeFromHistory, replaceRange } from "./changes.js" +import { computeReplacedSel } from "./change_measurement.js" +import { BranchChunk, LeafChunk } from "./chunk.js" +import { directionChanged, linkedDocs, updateDoc } from "./document_data.js" +import { copyHistoryArray, History } from "./history.js" +import { addLineWidget } from "./line_widget.js" +import { copySharedMarkers, detachSharedMarkers, findSharedMarkers, markText } from "./mark_text.js" +import { normalizeSelection, Range, simpleSelection } from "./selection.js" +import { extendSelection, extendSelections, setSelection, setSelectionReplaceHistory, setSimpleSelection } from "./selection_updates.js" let nextDocId = 0 let Doc = function(text, mode, firstLine, lineSep, direction) { diff --git a/src/model/change_measurement.js b/src/model/change_measurement.js index 881f39eb46..4d45313dee 100644 --- a/src/model/change_measurement.js +++ b/src/model/change_measurement.js @@ -1,7 +1,7 @@ -import { cmp, Pos } from "../line/pos" -import { lst } from "../util/misc" +import { cmp, Pos } from "../line/pos.js" +import { lst } from "../util/misc.js" -import { normalizeSelection, Range, Selection } from "./selection" +import { normalizeSelection, Range, Selection } from "./selection.js" // Compute the position of the end of a change (its 'to' property // refers to the pre-change end). diff --git a/src/model/changes.js b/src/model/changes.js index cfad529c68..b00e29b13d 100644 --- a/src/model/changes.js +++ b/src/model/changes.js @@ -1,21 +1,21 @@ -import { retreatFrontier } from "../line/highlight" -import { startWorker } from "../display/highlight_worker" -import { operation } from "../display/operations" -import { regChange, regLineChange } from "../display/view_tracking" -import { clipLine, clipPos, cmp, Pos } from "../line/pos" -import { sawReadOnlySpans } from "../line/saw_special_spans" -import { lineLength, removeReadOnlyRanges, stretchSpansOverChange, visualLine } from "../line/spans" -import { getBetween, getLine, lineNo } from "../line/utils_line" -import { estimateHeight } from "../measurement/position_measurement" -import { hasHandler, signal, signalCursorActivity } from "../util/event" -import { indexOf, lst, map, sel_dontScroll } from "../util/misc" -import { signalLater } from "../util/operation_group" - -import { changeEnd, computeSelAfterChange } from "./change_measurement" -import { isWholeLineUpdate, linkedDocs, updateDoc } from "./document_data" -import { addChangeToHistory, historyChangeFromChange, mergeOldSpans, pushSelectionToHistory } from "./history" -import { Range, Selection } from "./selection" -import { setSelection, setSelectionNoUndo } from "./selection_updates" +import { retreatFrontier } from "../line/highlight.js" +import { startWorker } from "../display/highlight_worker.js" +import { operation } from "../display/operations.js" +import { regChange, regLineChange } from "../display/view_tracking.js" +import { clipLine, clipPos, cmp, Pos } from "../line/pos.js" +import { sawReadOnlySpans } from "../line/saw_special_spans.js" +import { lineLength, removeReadOnlyRanges, stretchSpansOverChange, visualLine } from "../line/spans.js" +import { getBetween, getLine, lineNo } from "../line/utils_line.js" +import { estimateHeight } from "../measurement/position_measurement.js" +import { hasHandler, signal, signalCursorActivity } from "../util/event.js" +import { indexOf, lst, map, sel_dontScroll } from "../util/misc.js" +import { signalLater } from "../util/operation_group.js" + +import { changeEnd, computeSelAfterChange } from "./change_measurement.js" +import { isWholeLineUpdate, linkedDocs, updateDoc } from "./document_data.js" +import { addChangeToHistory, historyChangeFromChange, mergeOldSpans, pushSelectionToHistory } from "./history.js" +import { Range, Selection } from "./selection.js" +import { setSelection, setSelectionNoUndo } from "./selection_updates.js" // UPDATING diff --git a/src/model/chunk.js b/src/model/chunk.js index 056ef91bb9..d82716ded4 100644 --- a/src/model/chunk.js +++ b/src/model/chunk.js @@ -1,6 +1,6 @@ -import { cleanUpLine } from "../line/line_data" -import { indexOf } from "../util/misc" -import { signalLater } from "../util/operation_group" +import { cleanUpLine } from "../line/line_data.js" +import { indexOf } from "../util/misc.js" +import { signalLater } from "../util/operation_group.js" // The document is represented as a BTree consisting of leaves, with // chunk of lines in them, and branches, with up to ten leaves or diff --git a/src/model/document_data.js b/src/model/document_data.js index 7f6e3367d1..d946e7af10 100644 --- a/src/model/document_data.js +++ b/src/model/document_data.js @@ -1,13 +1,13 @@ -import { loadMode } from "../display/mode_state" -import { runInOp } from "../display/operations" -import { regChange } from "../display/view_tracking" -import { Line, updateLine } from "../line/line_data" -import { findMaxLine } from "../line/spans" -import { getLine } from "../line/utils_line" -import { estimateLineHeights } from "../measurement/position_measurement" -import { addClass, rmClass } from "../util/dom" -import { lst } from "../util/misc" -import { signalLater } from "../util/operation_group" +import { loadMode } from "../display/mode_state.js" +import { runInOp } from "../display/operations.js" +import { regChange } from "../display/view_tracking.js" +import { Line, updateLine } from "../line/line_data.js" +import { findMaxLine } from "../line/spans.js" +import { getLine } from "../line/utils_line.js" +import { estimateLineHeights } from "../measurement/position_measurement.js" +import { addClass, rmClass } from "../util/dom.js" +import { lst } from "../util/misc.js" +import { signalLater } from "../util/operation_group.js" // DOCUMENT DATA STRUCTURE diff --git a/src/model/history.js b/src/model/history.js index 83938cf4c1..753a89da92 100644 --- a/src/model/history.js +++ b/src/model/history.js @@ -1,12 +1,12 @@ -import { cmp, copyPos } from "../line/pos" -import { stretchSpansOverChange } from "../line/spans" -import { getBetween } from "../line/utils_line" -import { signal } from "../util/event" -import { indexOf, lst } from "../util/misc" - -import { changeEnd } from "./change_measurement" -import { linkedDocs } from "./document_data" -import { Selection } from "./selection" +import { cmp, copyPos } from "../line/pos.js" +import { stretchSpansOverChange } from "../line/spans.js" +import { getBetween } from "../line/utils_line.js" +import { signal } from "../util/event.js" +import { indexOf, lst } from "../util/misc.js" + +import { changeEnd } from "./change_measurement.js" +import { linkedDocs } from "./document_data.js" +import { Selection } from "./selection.js" export function History(startGen) { // Arrays of change events and selections. Doing something adds an diff --git a/src/model/line_widget.js b/src/model/line_widget.js index a11f9c2742..4a82d5389e 100644 --- a/src/model/line_widget.js +++ b/src/model/line_widget.js @@ -1,12 +1,12 @@ -import { runInOp } from "../display/operations" -import { addToScrollTop } from "../display/scrolling" -import { regLineChange } from "../display/view_tracking" -import { heightAtLine, lineIsHidden } from "../line/spans" -import { lineNo, updateLineHeight } from "../line/utils_line" -import { widgetHeight } from "../measurement/widgets" -import { changeLine } from "./changes" -import { eventMixin } from "../util/event" -import { signalLater } from "../util/operation_group" +import { runInOp } from "../display/operations.js" +import { addToScrollTop } from "../display/scrolling.js" +import { regLineChange } from "../display/view_tracking.js" +import { heightAtLine, lineIsHidden } from "../line/spans.js" +import { lineNo, updateLineHeight } from "../line/utils_line.js" +import { widgetHeight } from "../measurement/widgets.js" +import { changeLine } from "./changes.js" +import { eventMixin } from "../util/event.js" +import { signalLater } from "../util/operation_group.js" // Line widgets are block elements displayed above or below a line. diff --git a/src/model/mark_text.js b/src/model/mark_text.js index ccdcc9d3b8..955c72c4a7 100644 --- a/src/model/mark_text.js +++ b/src/model/mark_text.js @@ -1,19 +1,19 @@ -import { eltP } from "../util/dom" -import { eventMixin, hasHandler, on } from "../util/event" -import { endOperation, operation, runInOp, startOperation } from "../display/operations" -import { clipPos, cmp, Pos } from "../line/pos" -import { lineNo, updateLineHeight } from "../line/utils_line" -import { clearLineMeasurementCacheFor, findViewForLine, textHeight } from "../measurement/position_measurement" -import { seeReadOnlySpans, seeCollapsedSpans } from "../line/saw_special_spans" -import { addMarkedSpan, conflictingCollapsedRange, getMarkedSpanFor, lineIsHidden, lineLength, MarkedSpan, removeMarkedSpan, visualLine } from "../line/spans" -import { copyObj, indexOf, lst } from "../util/misc" -import { signalLater } from "../util/operation_group" -import { widgetHeight } from "../measurement/widgets" -import { regChange, regLineChange } from "../display/view_tracking" +import { eltP } from "../util/dom.js" +import { eventMixin, hasHandler, on } from "../util/event.js" +import { endOperation, operation, runInOp, startOperation } from "../display/operations.js" +import { clipPos, cmp, Pos } from "../line/pos.js" +import { lineNo, updateLineHeight } from "../line/utils_line.js" +import { clearLineMeasurementCacheFor, findViewForLine, textHeight } from "../measurement/position_measurement.js" +import { seeReadOnlySpans, seeCollapsedSpans } from "../line/saw_special_spans.js" +import { addMarkedSpan, conflictingCollapsedRange, getMarkedSpanFor, lineIsHidden, lineLength, MarkedSpan, removeMarkedSpan, visualLine } from "../line/spans.js" +import { copyObj, indexOf, lst } from "../util/misc.js" +import { signalLater } from "../util/operation_group.js" +import { widgetHeight } from "../measurement/widgets.js" +import { regChange, regLineChange } from "../display/view_tracking.js" -import { linkedDocs } from "./document_data" -import { addChangeToHistory } from "./history" -import { reCheckSelection } from "./selection_updates" +import { linkedDocs } from "./document_data.js" +import { addChangeToHistory } from "./history.js" +import { reCheckSelection } from "./selection_updates.js" // TEXTMARKERS diff --git a/src/model/selection.js b/src/model/selection.js index 97084fbc15..2e374aa822 100644 --- a/src/model/selection.js +++ b/src/model/selection.js @@ -1,5 +1,5 @@ -import { cmp, copyPos, equalCursorPos, maxPos, minPos } from "../line/pos" -import { indexOf } from "../util/misc" +import { cmp, copyPos, equalCursorPos, maxPos, minPos } from "../line/pos.js" +import { indexOf } from "../util/misc.js" // Selection objects are immutable. A new one is created every time // the selection changes. A selection is one or more non-overlapping diff --git a/src/model/selection_updates.js b/src/model/selection_updates.js index bf5ad8c76f..77986a9e9a 100644 --- a/src/model/selection_updates.js +++ b/src/model/selection_updates.js @@ -1,12 +1,12 @@ -import { signalLater } from "../util/operation_group" -import { ensureCursorVisible } from "../display/scrolling" -import { clipPos, cmp, Pos } from "../line/pos" -import { getLine } from "../line/utils_line" -import { hasHandler, signal, signalCursorActivity } from "../util/event" -import { lst, sel_dontScroll } from "../util/misc" - -import { addSelectionToHistory } from "./history" -import { normalizeSelection, Range, Selection, simpleSelection } from "./selection" +import { signalLater } from "../util/operation_group.js" +import { ensureCursorVisible } from "../display/scrolling.js" +import { clipPos, cmp, Pos } from "../line/pos.js" +import { getLine } from "../line/utils_line.js" +import { hasHandler, signal, signalCursorActivity } from "../util/event.js" +import { lst, sel_dontScroll } from "../util/misc.js" + +import { addSelectionToHistory } from "./history.js" +import { normalizeSelection, Range, Selection, simpleSelection } from "./selection.js" // The 'scroll' parameter given to many of these indicated whether // the new cursor position should be scrolled into view after diff --git a/src/modes.js b/src/modes.js index 065a463b5b..8384517027 100644 --- a/src/modes.js +++ b/src/modes.js @@ -1,4 +1,4 @@ -import { copyObj, createObj } from "./util/misc" +import { copyObj, createObj } from "./util/misc.js" // Known modes, by name and by MIME export let modes = {}, mimeModes = {} diff --git a/src/util/StringStream.js b/src/util/StringStream.js index a14b1b6430..022c4bc209 100644 --- a/src/util/StringStream.js +++ b/src/util/StringStream.js @@ -1,4 +1,4 @@ -import { countColumn } from "./misc" +import { countColumn } from "./misc.js" // STRING STREAM diff --git a/src/util/bidi.js b/src/util/bidi.js index 3d13dd86d2..33ab854d88 100644 --- a/src/util/bidi.js +++ b/src/util/bidi.js @@ -1,4 +1,4 @@ -import { lst } from "./misc" +import { lst } from "./misc.js" // BIDI HELPERS diff --git a/src/util/dom.js b/src/util/dom.js index 94823c21b9..04d2569d28 100644 --- a/src/util/dom.js +++ b/src/util/dom.js @@ -1,4 +1,4 @@ -import { ie, ios } from "./browser" +import { ie, ios } from "./browser.js" export function classTest(cls) { return new RegExp("(^|\\s)" + cls + "(?:$|\\s)\\s*") } diff --git a/src/util/event.js b/src/util/event.js index 29fd4c5981..4b6c770578 100644 --- a/src/util/event.js +++ b/src/util/event.js @@ -1,5 +1,5 @@ -import { mac } from "./browser" -import { indexOf } from "./misc" +import { mac } from "./browser.js" +import { indexOf } from "./misc.js" // EVENT HANDLING diff --git a/src/util/feature_detection.js b/src/util/feature_detection.js index e65881d4ca..c33734ebb9 100644 --- a/src/util/feature_detection.js +++ b/src/util/feature_detection.js @@ -1,5 +1,5 @@ -import { elt, range, removeChildren, removeChildrenAndAdd } from "./dom" -import { ie, ie_version } from "./browser" +import { elt, range, removeChildren, removeChildrenAndAdd } from "./dom.js" +import { ie, ie_version } from "./browser.js" // Detect drag-and-drop export let dragAndDrop = function() { diff --git a/src/util/operation_group.js b/src/util/operation_group.js index b8fa78ac48..f6815949d8 100644 --- a/src/util/operation_group.js +++ b/src/util/operation_group.js @@ -1,4 +1,4 @@ -import { getHandlers } from "./event" +import { getHandlers } from "./event.js" let operationGroup = null From 85fb7510976c8e0d443d44b7788c3066541fc470 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Thu, 9 Nov 2017 09:49:42 +0100 Subject: [PATCH 1278/2444] [javascript mode] Recognize async when in front of single-line block comment Closes #5078 --- mode/javascript/javascript.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mode/javascript/javascript.js b/mode/javascript/javascript.js index 5c772526f2..139e53dfe4 100644 --- a/mode/javascript/javascript.js +++ b/mode/javascript/javascript.js @@ -153,7 +153,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { var kw = keywords[word] return ret(kw.type, kw.style, word) } - if (word == "async" && stream.match(/^\s*[\(\w]/, false)) + if (word == "async" && stream.match(/^(\s|\/\*.*?\*\/)*[\(\w]/, false)) return ret("async", "keyword", word) } return ret("variable", "variable", word) From 1ba861a09f01f7205c36fb467660ed970a1c0054 Mon Sep 17 00:00:00 2001 From: Joel Einbinder Date: Wed, 8 Nov 2017 15:56:23 -0800 Subject: [PATCH 1279/2444] [javascript mode] Test for comments between async and function keywords --- mode/javascript/test.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mode/javascript/test.js b/mode/javascript/test.js index 213bab06a8..d560fdbacb 100644 --- a/mode/javascript/test.js +++ b/mode/javascript/test.js @@ -230,6 +230,9 @@ "[keyword const] [def async] [operator =] {[property a]: [number 1]};", "[keyword const] [def foo] [operator =] [string-2 `bar ${][variable async].[property a][string-2 }`];") + MT("async_comment", + "[keyword async] [comment /**/] [keyword function] [def foo]([def args]) { [keyword return] [atom true]; }"); + MT("indent_switch", "[keyword switch] ([variable x]) {", " [keyword default]:", From a29e048d20e5a256dd48bc49e1afae6f9d1a252a Mon Sep 17 00:00:00 2001 From: Jakub Vrana Date: Fri, 10 Nov 2017 14:29:19 +0100 Subject: [PATCH 1280/2444] [soy mode] Support comments in all contexts --- mode/soy/soy.js | 46 ++++++++++++++++++++++------------------------ 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/mode/soy/soy.js b/mode/soy/soy.js index 0e24457042..98f308658e 100644 --- a/mode/soy/soy.js +++ b/mode/soy/soy.js @@ -137,6 +137,25 @@ } return "comment"; + case "string": + var match = stream.match(/^.*?(["']|\\[\s\S])/); + if (!match) { + stream.skipToEnd(); + } else if (match[1] == state.quoteKind) { + state.quoteKind = null; + state.soyState.pop(); + } + return "string"; + } + + if (stream.match(/^\/\*/)) { + state.soyState.push("comment"); + return "comment"; + } else if (stream.match(stream.sol() || (state.soyState.length && last(state.soyState) != "literal") ? /^\s*\/\/.*/ : /^\s+\/\/.*/)) { + return "comment"; + } + + switch (last(state.soyState)) { case "templ-def": if (match = stream.match(/^\.?([\w]+(?!\.[\w]+)*)/)) { state.templates = prepend(state.templates, match[1]); @@ -242,36 +261,15 @@ return this.token(stream, state); } return tokenUntil(stream, state, /\{\/literal}/); - - case "string": - var match = stream.match(/^.*?(["']|\\[\s\S])/); - if (!match) { - stream.skipToEnd(); - } else if (match[1] == state.quoteKind) { - state.quoteKind = null; - state.soyState.pop(); - } - return "string"; } - if (stream.match(/^\/\*/)) { - state.soyState.push("comment"); - if (!state.scopes) { - state.variables = prepend(null, 'ij'); - } - return "comment"; - } else if (stream.match(stream.sol() ? /^\s*\/\/.*/ : /^\s+\/\/.*/)) { - if (!state.scopes) { - state.variables = prepend(null, 'ij'); - } - return "comment"; - } else if (stream.match(/^\{literal}/)) { + if (stream.match(/^\{literal}/)) { state.indent += config.indentUnit; state.soyState.push("literal"); return "keyword"; - // A tag-keyword must be followed by whitespace or a closing tag. - } else if (match = stream.match(/^\{([\/@\\]?\w+\??)(?=[\s\}])/)) { + // A tag-keyword must be followed by whitespace, comment or a closing tag. + } else if (match = stream.match(/^\{([\/@\\]?\w+\??)(?=[\s\}]|\/[/*])/)) { if (match[1] != "/switch") state.indent += (/^(\/|(else|elseif|ifempty|case|fallbackmsg|default)$)/.test(match[1]) && state.tag != "switch" ? 1 : 2) * config.indentUnit; state.tag = match[1]; From b881f2520461c7fc98ca1673071d0eb74ddd7c39 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Mon, 13 Nov 2017 09:40:40 +0100 Subject: [PATCH 1281/2444] [emacs mode] Prevent backspace/delete/etc from adding to the kill ring Closes #5084 --- keymap/emacs.js | 42 +++++++++++++++++++++--------------------- test/emacs_test.js | 2 ++ 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/keymap/emacs.js b/keymap/emacs.js index 33db0c15a2..3160453283 100644 --- a/keymap/emacs.js +++ b/keymap/emacs.js @@ -30,16 +30,16 @@ var lastKill = null; - function kill(cm, from, to, mayGrow, text) { + function kill(cm, from, to, ring, text) { if (text == null) text = cm.getRange(from, to); - if (mayGrow && lastKill && lastKill.cm == cm && posEq(from, lastKill.pos) && cm.isClean(lastKill.gen)) + if (ring == "grow" && lastKill && lastKill.cm == cm && posEq(from, lastKill.pos) && cm.isClean(lastKill.gen)) growRingTop(text); - else + else if (ring !== false) addToRing(text); cm.replaceRange("", from, to, "+delete"); - if (mayGrow) lastKill = {cm: cm, pos: from, gen: cm.changeGeneration()}; + if (ring == "grow") lastKill = {cm: cm, pos: from, gen: cm.changeGeneration()}; else lastKill = null; } @@ -151,22 +151,22 @@ return f; } - function killTo(cm, by, dir) { + function killTo(cm, by, dir, ring) { var selections = cm.listSelections(), cursor; var i = selections.length; while (i--) { cursor = selections[i].head; - kill(cm, cursor, findEnd(cm, cursor, by, dir), true); + kill(cm, cursor, findEnd(cm, cursor, by, dir), ring); } } - function killRegion(cm) { + function killRegion(cm, ring) { if (cm.somethingSelected()) { var selections = cm.listSelections(), selection; var i = selections.length; while (i--) { selection = selections[i]; - kill(cm, selection.anchor, selection.head); + kill(cm, selection.anchor, selection.head, ring); } return true; } @@ -276,7 +276,7 @@ // Actual keymap var keyMap = CodeMirror.keyMap.emacs = CodeMirror.normalizeKeyMap({ - "Ctrl-W": function(cm) {kill(cm, cm.getCursor("start"), cm.getCursor("end"));}, + "Ctrl-W": function(cm) {kill(cm, cm.getCursor("start"), cm.getCursor("end"), true);}, "Ctrl-K": repeated(function(cm) { var start = cm.getCursor(), end = cm.clipPos(Pos(start.line)); var text = cm.getRange(start, end); @@ -284,7 +284,7 @@ text += "\n"; end = Pos(start.line + 1, 0); } - kill(cm, start, end, true, text); + kill(cm, start, end, "grow", text); }), "Alt-W": function(cm) { addToRing(cm.getSelection()); @@ -301,14 +301,14 @@ "Ctrl-F": move(byChar, 1), "Ctrl-B": move(byChar, -1), "Right": move(byChar, 1), "Left": move(byChar, -1), - "Ctrl-D": function(cm) { killTo(cm, byChar, 1); }, - "Delete": function(cm) { killRegion(cm) || killTo(cm, byChar, 1); }, - "Ctrl-H": function(cm) { killTo(cm, byChar, -1); }, - "Backspace": function(cm) { killRegion(cm) || killTo(cm, byChar, -1); }, + "Ctrl-D": function(cm) { killTo(cm, byChar, 1, false); }, + "Delete": function(cm) { killRegion(cm, false) || killTo(cm, byChar, 1, false); }, + "Ctrl-H": function(cm) { killTo(cm, byChar, -1, false); }, + "Backspace": function(cm) { killRegion(cm, false) || killTo(cm, byChar, -1, false); }, "Alt-F": move(byWord, 1), "Alt-B": move(byWord, -1), - "Alt-D": function(cm) { killTo(cm, byWord, 1); }, - "Alt-Backspace": function(cm) { killTo(cm, byWord, -1); }, + "Alt-D": function(cm) { killTo(cm, byWord, 1, "grow"); }, + "Alt-Backspace": function(cm) { killTo(cm, byWord, -1, "grow"); }, "Ctrl-N": move(byLine, 1), "Ctrl-P": move(byLine, -1), "Down": move(byLine, 1), "Up": move(byLine, -1), @@ -321,11 +321,11 @@ "Ctrl-Up": move(byParagraph, -1), "Ctrl-Down": move(byParagraph, 1), "Alt-A": move(bySentence, -1), "Alt-E": move(bySentence, 1), - "Alt-K": function(cm) { killTo(cm, bySentence, 1); }, + "Alt-K": function(cm) { killTo(cm, bySentence, 1, "grow"); }, - "Ctrl-Alt-K": function(cm) { killTo(cm, byExpr, 1); }, - "Ctrl-Alt-Backspace": function(cm) { killTo(cm, byExpr, -1); }, - "Ctrl-Alt-F": move(byExpr, 1), "Ctrl-Alt-B": move(byExpr, -1), + "Ctrl-Alt-K": function(cm) { killTo(cm, byExpr, 1, "grow"); }, + "Ctrl-Alt-Backspace": function(cm) { killTo(cm, byExpr, -1, "grow"); }, + "Ctrl-Alt-F": move(byExpr, 1), "Ctrl-Alt-B": move(byExpr, -1, "grow"), "Shift-Ctrl-Alt-2": function(cm) { var cursor = cm.getCursor(); @@ -398,7 +398,7 @@ "Ctrl-X F": "open", "Ctrl-X U": repeated("undo"), "Ctrl-X K": "close", - "Ctrl-X Delete": function(cm) { kill(cm, cm.getCursor(), bySentence(cm, cm.getCursor(), 1), true); }, + "Ctrl-X Delete": function(cm) { kill(cm, cm.getCursor(), bySentence(cm, cm.getCursor(), 1), "grow"); }, "Ctrl-X H": "selectAll", "Ctrl-Q Tab": repeated("insertTab"), diff --git a/test/emacs_test.js b/test/emacs_test.js index b73eedaa6a..412dba4b42 100644 --- a/test/emacs_test.js +++ b/test/emacs_test.js @@ -131,6 +131,8 @@ sim("delRegion", "abcde", "Ctrl-Space", "Ctrl-F", "Ctrl-F", "Delete", txt("cde")); sim("backspaceRegion", "abcde", "Ctrl-Space", "Ctrl-F", "Ctrl-F", "Backspace", txt("cde")); + sim("backspaceDoesntAddToRing", "foobar", "Ctrl-F", "Ctrl-F", "Ctrl-F", "Ctrl-K", "Backspace", "Backspace", "Ctrl-Y", txt("fbar")); + testCM("save", function(cm) { var saved = false; CodeMirror.commands.save = function(cm) { saved = cm.getValue(); }; From 2cb90ecdce8e7814b0b45a10e3bf6aed48d9a2a7 Mon Sep 17 00:00:00 2001 From: Adrian Heine Date: Fri, 17 Nov 2017 20:45:01 +0100 Subject: [PATCH 1282/2444] [javascript mode] Highlight type in generic call Closes #5048. --- mode/javascript/javascript.js | 1 + mode/javascript/test.js | 3 +++ 2 files changed, 4 insertions(+) diff --git a/mode/javascript/javascript.js b/mode/javascript/javascript.js index 139e53dfe4..e43543dd3c 100644 --- a/mode/javascript/javascript.js +++ b/mode/javascript/javascript.js @@ -438,6 +438,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { if (type == "=>") return cont(pushcontext, noComma ? arrowBodyNoComma : arrowBody, popcontext); if (type == "operator") { if (/\+\+|--/.test(value) || isTS && value == "!") return cont(me); + if (isTS && value == "<") return cont(pushlex(">"), commasep(typeexpr, ">"), poplex, maybeoperatorNoComma); if (value == "?") return cont(expression, expect(":"), expr); return cont(expr); } diff --git a/mode/javascript/test.js b/mode/javascript/test.js index d560fdbacb..972a345651 100644 --- a/mode/javascript/test.js +++ b/mode/javascript/test.js @@ -371,6 +371,9 @@ TS("arrow prop", "({[property a]: [def p] [operator =>] [variable-2 p]})") + TS("generic in function call", + "[keyword this].[property a][operator <][type Type][operator >]([variable foo]);") + var jsonld_mode = CodeMirror.getMode( {indentUnit: 2}, {name: "javascript", jsonld: true} From 490653454aa985feb60918eeddde823c550e416e Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Mon, 20 Nov 2017 10:36:30 +0100 Subject: [PATCH 1283/2444] [javascript mode] Resolve ambiguity for type parameters vs less-than See https://github.com/Microsoft/TypeScript/blob/6c4c10c7cf294dc71f943314e29a7dd1b6e88c6a/doc/spec.md#4.15.3 Issue #5090 Issue #5048 --- mode/javascript/javascript.js | 3 ++- mode/javascript/test.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/mode/javascript/javascript.js b/mode/javascript/javascript.js index e43543dd3c..0dcd8af391 100644 --- a/mode/javascript/javascript.js +++ b/mode/javascript/javascript.js @@ -438,7 +438,8 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { if (type == "=>") return cont(pushcontext, noComma ? arrowBodyNoComma : arrowBody, popcontext); if (type == "operator") { if (/\+\+|--/.test(value) || isTS && value == "!") return cont(me); - if (isTS && value == "<") return cont(pushlex(">"), commasep(typeexpr, ">"), poplex, maybeoperatorNoComma); + if (isTS && value == "<" && cx.stream.match(/^([^>]|<.*?>)*>\s*\(/, false)) + return cont(pushlex(">"), commasep(typeexpr, ">"), poplex, me); if (value == "?") return cont(expression, expect(":"), expr); return cont(expr); } diff --git a/mode/javascript/test.js b/mode/javascript/test.js index 972a345651..2437edcca5 100644 --- a/mode/javascript/test.js +++ b/mode/javascript/test.js @@ -372,7 +372,8 @@ "({[property a]: [def p] [operator =>] [variable-2 p]})") TS("generic in function call", - "[keyword this].[property a][operator <][type Type][operator >]([variable foo]);") + "[keyword this].[property a][operator <][type Type][operator >]([variable foo]);", + "[keyword this].[property a][operator <][variable Type][operator >][variable foo];") var jsonld_mode = CodeMirror.getMode( {indentUnit: 2}, From e51b94ff4890d01d0ee1b97da575440b65429edf Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Mon, 20 Nov 2017 12:16:06 +0100 Subject: [PATCH 1284/2444] [show-hint addon] Drop suspicious-looking logic Issue #4792 --- addon/hint/show-hint.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/addon/hint/show-hint.js b/addon/hint/show-hint.js index f72a0a9c69..62c683cb8c 100644 --- a/addon/hint/show-hint.js +++ b/addon/hint/show-hint.js @@ -121,7 +121,6 @@ var picked = (this.widget && this.widget.picked) || (first && this.options.completeSingle); if (this.widget) this.widget.close(); - if (data && this.data && isNewCompletion(this.data, data)) return; this.data = data; if (data && data.list.length) { @@ -135,11 +134,6 @@ } }; - function isNewCompletion(old, nw) { - var moved = CodeMirror.cmpPos(nw.from, old.from) - return moved > 0 && old.to.ch - old.from.ch != nw.to.ch - nw.from.ch - } - function parseOptions(cm, pos, options) { var editor = cm.options.hintOptions; var out = {}; From 66414ce35ba441b766117b5f8cf53a1850a7362e Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Wed, 22 Nov 2017 09:59:21 +0100 Subject: [PATCH 1285/2444] [javascript mode] Recognize TypeScript type guards Closes #5093 --- mode/javascript/javascript.js | 14 +++++++++++++- mode/javascript/test.js | 8 ++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/mode/javascript/javascript.js b/mode/javascript/javascript.js index 0dcd8af391..4978d8d1e7 100644 --- a/mode/javascript/javascript.js +++ b/mode/javascript/javascript.js @@ -566,6 +566,18 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { if (value == "?") return cont(maybetype); } } + function mayberettype(type, value) { + if (isTS && type == ":") { + if (cx.stream.match(/^\s*\w+\s+is\b/, false)) return cont(expression, isKW, typeexpr) + else return cont(typeexpr) + } + } + function isKW(_, value) { + if (value == "is") { + cx.marked = "keyword" + return cont() + } + } function typeexpr(type, value) { if (type == "variable" || value == "void") { if (value == "keyof") { @@ -668,7 +680,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { function functiondef(type, value) { if (value == "*") {cx.marked = "keyword"; return cont(functiondef);} if (type == "variable") {register(value); return cont(functiondef);} - if (type == "(") return cont(pushcontext, pushlex(")"), commasep(funarg, ")"), poplex, maybetype, statement, popcontext); + if (type == "(") return cont(pushcontext, pushlex(")"), commasep(funarg, ")"), poplex, mayberettype, statement, popcontext); if (isTS && value == "<") return cont(pushlex(">"), commasep(typeparam, ">"), poplex, functiondef) } function funarg(type, value) { diff --git a/mode/javascript/test.js b/mode/javascript/test.js index 2437edcca5..167e6d0165 100644 --- a/mode/javascript/test.js +++ b/mode/javascript/test.js @@ -375,6 +375,14 @@ "[keyword this].[property a][operator <][type Type][operator >]([variable foo]);", "[keyword this].[property a][operator <][variable Type][operator >][variable foo];") + TS("type guard", + "[keyword class] [def Appler] {", + " [keyword static] [property assertApple]([def fruit]: [type Fruit]): [variable-2 fruit] [keyword is] [type Apple] {", + " [keyword if] ([operator !]([variable-2 fruit] [keyword instanceof] [variable Apple]))", + " [keyword throw] [keyword new] [variable Error]();", + " }", + "}") + var jsonld_mode = CodeMirror.getMode( {indentUnit: 2}, {name: "javascript", jsonld: true} From d98aac7b948ef36d0611e5d50f461e3848b925b2 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Wed, 22 Nov 2017 10:01:54 +0100 Subject: [PATCH 1286/2444] Please linter, remove unused arg --- CHANGELOG.md | 4 ++++ mode/javascript/javascript.js | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 409c7234bb..1fa5781617 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 5.32.0 (2017-11-22) + + + ## 5.31.0 (2017-10-20) ### Bug fixes diff --git a/mode/javascript/javascript.js b/mode/javascript/javascript.js index 4978d8d1e7..514de1c8da 100644 --- a/mode/javascript/javascript.js +++ b/mode/javascript/javascript.js @@ -566,7 +566,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { if (value == "?") return cont(maybetype); } } - function mayberettype(type, value) { + function mayberettype(type) { if (isTS && type == ":") { if (cx.stream.match(/^\s*\w+\s+is\b/, false)) return cont(expression, isKW, typeexpr) else return cont(typeexpr) From 89595f55b19ea0584e4721128c149f918795a384 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Wed, 22 Nov 2017 10:10:50 +0100 Subject: [PATCH 1287/2444] Mark version 5.32.0 --- AUTHORS | 3 +++ CHANGELOG.md | 16 ++++++++++++++++ doc/manual.html | 2 +- doc/releases.html | 12 ++++++++++++ index.html | 2 +- package.json | 2 +- src/edit/main.js | 2 +- 7 files changed, 35 insertions(+), 4 deletions(-) diff --git a/AUTHORS b/AUTHORS index f800b86b7d..65d8480893 100644 --- a/AUTHORS +++ b/AUTHORS @@ -118,6 +118,7 @@ Caitlin Potter Calin Barbat callodacity Camilo Roca +Casey Klebba Chad Jolly Chandra Sekhar Pydi Charles Skelton @@ -300,6 +301,7 @@ Jason Grout Jason Johnston Jason San Jose Jason Siefken +Jayaprabhakar Jaydeep Solanki Jean Boussier Jeff Blaisdell @@ -327,6 +329,7 @@ John Van Der Loo Jon Ander Peñalba Jonas Döbertin Jonas Helfer +Jonathan Hart Jonathan Malmaud Jon Gacnik jongalloway diff --git a/CHANGELOG.md b/CHANGELOG.md index 1fa5781617..f81fcdd07b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,22 @@ ## 5.32.0 (2017-11-22) +### Bug fixes + +Increase contrast on default bracket-matching colors. + +[javascript mode](http://codemirror.net/mode/javascript/): Recognize TypeScript type parameters for calls, type guards, and type parameter defaults. Improve handling of `enum` and `module` keywords. + +[comment addon](http://codemirror.net/doc/manual.html#addon_comment): Fix bug when uncommenting a comment that spans all but the last selected line. + +[searchcursor addon](http://codemirror.net/doc/manual.html#addon_searchcursor): Fix bug in case folding. + +[emacs bindings](http://codemirror.net/demo/emacs.html): Prevent single-character deletions from resetting the kill ring. + +[closebrackets addon](http://codemirror.net/doc/manual.html#addon_closebrackets): Tweak quote matching behavior. + +### New features +[continuelist addon](http://codemirror.net/doc/manual.html#addon_continuelist): Increment ordered list numbers when adding one. ## 5.31.0 (2017-10-20) diff --git a/doc/manual.html b/doc/manual.html index 7666e0df63..f46e6bd5ab 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -69,7 +69,7 @@

    User manual and reference guide - version 5.31.1 + version 5.32.0

    CodeMirror is a code-editor component that can be embedded in diff --git a/doc/releases.html b/doc/releases.html index 23de4c8023..7fb8eebef1 100644 --- a/doc/releases.html +++ b/doc/releases.html @@ -30,6 +30,18 @@

    Release notes and version history

    Version 5.x

    +

    22-11-2017: Version 5.32.0:

    + +
      +
    • Increase contrast on default bracket-matching colors.
    • +
    • javascript mode: Recognize TypeScript type parameters for calls, type guards, and type parameter defaults. Improve handling of enum and module keywords.
    • +
    • comment addon: Fix bug when uncommenting a comment that spans all but the last selected line.
    • +
    • searchcursor addon: Fix bug in case folding.
    • +
    • emacs bindings: Prevent single-character deletions from resetting the kill ring.
    • +
    • closebrackets addon: Tweak quote matching behavior.
    • +
    • continuelist addon: Increment ordered list numbers when adding one.
    • +
    +

    20-10-2017: Version 5.31.0:

      diff --git a/index.html b/index.html index 555e4804aa..d62ab84a39 100644 --- a/index.html +++ b/index.html @@ -96,7 +96,7 @@

      This is CodeMirror

    - Get the current version: 5.31.0.
    + Get the current version: 5.32.0.
    You can see the code,
    read the release notes,
    or study the user manual. diff --git a/package.json b/package.json index 6eda061f17..3e9f20c650 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "codemirror", - "version": "5.31.1", + "version": "5.32.0", "main": "lib/codemirror.js", "style": "lib/codemirror.css", "description": "Full-featured in-browser code editor", diff --git a/src/edit/main.js b/src/edit/main.js index 6d9eb8790b..c89e5d8792 100644 --- a/src/edit/main.js +++ b/src/edit/main.js @@ -66,4 +66,4 @@ import { addLegacyProps } from "./legacy.js" addLegacyProps(CodeMirror) -CodeMirror.version = "5.31.1" +CodeMirror.version = "5.32.0" From 2e857fa36604aebe0a7c1955a9ca5137ee00e3f5 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Wed, 22 Nov 2017 10:12:55 +0100 Subject: [PATCH 1288/2444] Bump version number post-5.32 --- doc/manual.html | 2 +- package.json | 2 +- src/edit/main.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/manual.html b/doc/manual.html index f46e6bd5ab..ea5642cdf9 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -69,7 +69,7 @@

    User manual and reference guide - version 5.32.0 + version 5.32.1

    CodeMirror is a code-editor component that can be embedded in diff --git a/package.json b/package.json index 3e9f20c650..3ffad1d5d1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "codemirror", - "version": "5.32.0", + "version": "5.32.1", "main": "lib/codemirror.js", "style": "lib/codemirror.css", "description": "Full-featured in-browser code editor", diff --git a/src/edit/main.js b/src/edit/main.js index c89e5d8792..260f7d0af5 100644 --- a/src/edit/main.js +++ b/src/edit/main.js @@ -66,4 +66,4 @@ import { addLegacyProps } from "./legacy.js" addLegacyProps(CodeMirror) -CodeMirror.version = "5.32.0" +CodeMirror.version = "5.32.1" From 058e8219b2d040b131eb99ca7ad00b53bafe9886 Mon Sep 17 00:00:00 2001 From: satamas Date: Thu, 23 Nov 2017 16:32:43 +0300 Subject: [PATCH 1289/2444] Add new kotlin keywords. --- mode/clike/clike.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mode/clike/clike.js b/mode/clike/clike.js index 02a85319ff..ff00cf5002 100644 --- a/mode/clike/clike.js +++ b/mode/clike/clike.js @@ -578,7 +578,7 @@ CodeMirror.defineMode("clike", function(config, parserConfig) { "file import where by get set abstract enum open inner override private public internal " + "protected catch finally out final vararg reified dynamic companion constructor init " + "sealed field property receiver param sparam lateinit data inline noinline tailrec " + - "external annotation crossinline const operator infix suspend" + "external annotation crossinline const operator infix suspend actual expect" ), types: words( /* package java.lang */ From d60e0ccaadaaa2f9bc967594909def5f80231a22 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Mon, 27 Nov 2017 11:19:46 +0100 Subject: [PATCH 1290/2444] [tern addon] Guard against relatedTarget being null Closes #5095 --- addon/tern/tern.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addon/tern/tern.js b/addon/tern/tern.js index a80dc7e4b8..70202c6fc5 100644 --- a/addon/tern/tern.js +++ b/addon/tern/tern.js @@ -614,7 +614,8 @@ var mouseOnTip = false, old = false; CodeMirror.on(tip, "mousemove", function() { mouseOnTip = true; }); CodeMirror.on(tip, "mouseout", function(e) { - if (!CodeMirror.contains(tip, e.relatedTarget || e.toElement)) { + let related = e.relatedTarget || e.toElement + if (!related || !CodeMirror.contains(tip, related)) { if (old) clear(); else mouseOnTip = false; } From 95b64d1a1c8004aab0f9e9ea39a0c48689d4e028 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Mon, 27 Nov 2017 11:23:17 +0100 Subject: [PATCH 1291/2444] Fix es6-ism in addon --- addon/tern/tern.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addon/tern/tern.js b/addon/tern/tern.js index 70202c6fc5..6276b53893 100644 --- a/addon/tern/tern.js +++ b/addon/tern/tern.js @@ -614,7 +614,7 @@ var mouseOnTip = false, old = false; CodeMirror.on(tip, "mousemove", function() { mouseOnTip = true; }); CodeMirror.on(tip, "mouseout", function(e) { - let related = e.relatedTarget || e.toElement + var related = e.relatedTarget || e.toElement if (!related || !CodeMirror.contains(tip, related)) { if (old) clear(); else mouseOnTip = false; From 8bb35c475f0dfc05c4b2617e778fed1acf3f3a68 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Fri, 1 Dec 2017 10:24:21 +0100 Subject: [PATCH 1292/2444] [lint addon] Wrap display updates in an operation Closes #5106 --- addon/lint/lint.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addon/lint/lint.js b/addon/lint/lint.js index a9eb8fa66b..e00e77a20c 100644 --- a/addon/lint/lint.js +++ b/addon/lint/lint.js @@ -132,7 +132,7 @@ cm.off("change", abort) if (state.waitingFor != id) return if (arg2 && annotations instanceof CodeMirror) annotations = arg2 - updateLinting(cm, annotations) + cm.operation(function() {updateLinting(cm, annotations)}) }, passOptions, cm); } @@ -151,9 +151,9 @@ var annotations = getAnnotations(cm.getValue(), passOptions, cm); if (!annotations) return; if (annotations.then) annotations.then(function(issues) { - updateLinting(cm, issues); + cm.operation(function() {updateLinting(cm, issues)}) }); - else updateLinting(cm, annotations); + else cm.operation(function() {updateLinting(cm, annotations)}) } } From b1bf7b3ad53941dc81351de2a28896daf293d739 Mon Sep 17 00:00:00 2001 From: tophf Date: Fri, 1 Dec 2017 06:01:55 +0300 Subject: [PATCH 1293/2444] [css mode] Case-insensitive parsing of grammar tokens as per https://www.w3.org/TR/css-syntax-3/#rule-defs --- mode/css/css.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/mode/css/css.js b/mode/css/css.js index 00e9b3df13..f5f3a41ba8 100644 --- a/mode/css/css.js +++ b/mode/css/css.js @@ -77,9 +77,9 @@ CodeMirror.defineMode("css", function(config, parserConfig) { return ret("qualifier", "qualifier"); } else if (/[:;{}\[\]\(\)]/.test(ch)) { return ret(null, ch); - } else if ((ch == "u" && stream.match(/rl(-prefix)?\(/)) || - (ch == "d" && stream.match("omain(")) || - (ch == "r" && stream.match("egexp("))) { + } else if (((ch == "u" || ch == "U") && stream.match(/rl(-prefix)?\(/i)) || + ((ch == "d" || ch == "D") && stream.match("omain(", true, true)) || + ((ch == "r" || ch == "R") && stream.match("egexp(", true, true))) { stream.backUp(1); state.tokenize = tokenParenthesized; return ret("property", "word"); @@ -162,16 +162,16 @@ CodeMirror.defineMode("css", function(config, parserConfig) { return pushContext(state, stream, "block"); } else if (type == "}" && state.context.prev) { return popContext(state); - } else if (supportsAtComponent && /@component/.test(type)) { + } else if (supportsAtComponent && /@component/i.test(type)) { return pushContext(state, stream, "atComponentBlock"); - } else if (/^@(-moz-)?document$/.test(type)) { + } else if (/^@(-moz-)?document$/i.test(type)) { return pushContext(state, stream, "documentTypes"); - } else if (/^@(media|supports|(-moz-)?document|import)$/.test(type)) { + } else if (/^@(media|supports|(-moz-)?document|import)$/i.test(type)) { return pushContext(state, stream, "atBlock"); - } else if (/^@(font-face|counter-style)/.test(type)) { + } else if (/^@(font-face|counter-style)/i.test(type)) { state.stateArg = type; return "restricted_atBlock_before"; - } else if (/^@(-(moz|ms|o|webkit)-)?keyframes$/.test(type)) { + } else if (/^@(-(moz|ms|o|webkit)-)?keyframes$/i.test(type)) { return "keyframes"; } else if (type && type.charAt(0) == "@") { return pushContext(state, stream, "at"); @@ -793,7 +793,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) { }, "@": function(stream) { if (stream.eat("{")) return [null, "interpolation"]; - if (stream.match(/^(charset|document|font-face|import|(-(moz|ms|o|webkit)-)?keyframes|media|namespace|page|supports)\b/, false)) return false; + if (stream.match(/^(charset|document|font-face|import|(-(moz|ms|o|webkit)-)?keyframes|media|namespace|page|supports)\b/i, false)) return false; stream.eatWhile(/[\w\\\-]/); if (stream.match(/^\s*:/, false)) return ["variable-2", "variable-definition"]; From 74e7447cf72205189e01eefced32fd2f2a7c79b9 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Fri, 1 Dec 2017 10:45:55 +0100 Subject: [PATCH 1294/2444] [css mode] Add a test for an upper-case @-block Issue #5107 --- mode/css/test.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mode/css/test.js b/mode/css/test.js index 6fc6e33ca5..e5c55d3999 100644 --- a/mode/css/test.js +++ b/mode/css/test.js @@ -24,6 +24,9 @@ MT("atMediaUnknownFeatureValueKeyword", "[def @media] ([property orientation]: [error upsidedown]) { }"); + MT("atMediaUppercase", + "[def @MEDIA] ([property orienTAtion]: [keyword landScape]) { }"); + MT("tagSelector", "[tag foo] { }"); From c7853a989c77bb9f520c9c530cbe1497856e96fc Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Sun, 3 Dec 2017 12:00:32 +0100 Subject: [PATCH 1295/2444] [continuelist addon] Fix handling of unordered lists --- addon/edit/continuelist.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/addon/edit/continuelist.js b/addon/edit/continuelist.js index 30893965fe..b83dc505ff 100644 --- a/addon/edit/continuelist.js +++ b/addon/edit/continuelist.js @@ -39,13 +39,11 @@ replacements[i] = "\n"; } else { var indent = match[1], after = match[5]; - var bullet = unorderedListRE.test(match[2]) || match[2].indexOf(">") >= 0 - ? match[2].replace("x", " ") - : (parseInt(match[3], 10) + 1) + match[4]; - + var numbered = !(unorderedListRE.test(match[2]) || match[2].indexOf(">") >= 0); + var bullet = numbered ? (parseInt(match[3], 10) + 1) + match[4] : match[2].replace("x", " "); replacements[i] = "\n" + indent + bullet + after; - incrementRemainingMarkdownListNumbers(cm, pos); + if (numbered) incrementRemainingMarkdownListNumbers(cm, pos); } } From 6353583cdf780aaa74d9afd88df404b34a4c31ad Mon Sep 17 00:00:00 2001 From: Stephane Moore Date: Mon, 4 Dec 2017 16:56:18 -0800 Subject: [PATCH 1296/2444] =?UTF-8?q?[languages]=20Fix=20the=20name=20of?= =?UTF-8?q?=20Objective-C=20=F0=9F=93=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The language is named "Objective-C" rather than "Objective C". Reference: https://en.wikipedia.org/wiki/Objective-C --- mode/meta.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mode/meta.js b/mode/meta.js index 34da269f33..91a925268e 100644 --- a/mode/meta.js +++ b/mode/meta.js @@ -94,7 +94,7 @@ {name: "NSIS", mime: "text/x-nsis", mode: "nsis", ext: ["nsh", "nsi"]}, {name: "NTriples", mimes: ["application/n-triples", "application/n-quads", "text/n-triples"], mode: "ntriples", ext: ["nt", "nq"]}, - {name: "Objective C", mime: "text/x-objectivec", mode: "clike", ext: ["m", "mm"], alias: ["objective-c", "objc"]}, + {name: "Objective-C", mime: "text/x-objectivec", mode: "clike", ext: ["m", "mm"], alias: ["objective-c", "objc"]}, {name: "OCaml", mime: "text/x-ocaml", mode: "mllike", ext: ["ml", "mli", "mll", "mly"]}, {name: "Octave", mime: "text/x-octave", mode: "octave", ext: ["m"]}, {name: "Oz", mime: "text/x-oz", mode: "oz", ext: ["oz"]}, From 04d39f236a541104c3fccdfdf6ea164d6e4c74e7 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Tue, 5 Dec 2017 10:03:37 +0100 Subject: [PATCH 1297/2444] [htmlembedded mode] Support %-style comments Closes #5102 --- mode/htmlembedded/htmlembedded.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/mode/htmlembedded/htmlembedded.js b/mode/htmlembedded/htmlembedded.js index 464dc57f83..8099d370be 100644 --- a/mode/htmlembedded/htmlembedded.js +++ b/mode/htmlembedded/htmlembedded.js @@ -14,7 +14,16 @@ "use strict"; CodeMirror.defineMode("htmlembedded", function(config, parserConfig) { + var closeComment = parserConfig.closeComment || "--%>" return CodeMirror.multiplexingMode(CodeMirror.getMode(config, "htmlmixed"), { + open: parserConfig.openComment || "<%--", + close: closeComment, + delimStyle: "comment", + mode: {token: function(stream) { + stream.skipTo(closeComment) || stream.skipToEnd() + return "comment" + }} + }, { open: parserConfig.open || parserConfig.scriptStartRegex || "<%", close: parserConfig.close || parserConfig.scriptEndRegex || "%>", mode: CodeMirror.getMode(config, parserConfig.scriptingModeSpec) From 7e480de547d7b87690c654522d603d7aa213e64b Mon Sep 17 00:00:00 2001 From: Adrian Heine Date: Tue, 5 Dec 2017 22:43:37 +0100 Subject: [PATCH 1298/2444] [vim] Support more bases for increment and decrement Closes #5110. --- keymap/vim.js | 21 ++-- test/vim_test.js | 246 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 260 insertions(+), 7 deletions(-) diff --git a/keymap/vim.js b/keymap/vim.js index 7cf5a956e0..b082268183 100644 --- a/keymap/vim.js +++ b/keymap/vim.js @@ -2637,25 +2637,32 @@ incrementNumberToken: function(cm, actionArgs) { var cur = cm.getCursor(); var lineStr = cm.getLine(cur.line); - var re = /-?\d+/g; + var re = /(-?)(?:(0x)([\da-f]+)|(0b|0|)(\d+))/gi; var match; var start; var end; var numberStr; - var token; while ((match = re.exec(lineStr)) !== null) { - token = match[0]; start = match.index; - end = start + token.length; + end = start + match[0].length; if (cur.ch < end)break; } if (!actionArgs.backtrack && (end <= cur.ch))return; - if (token) { + if (match) { + var baseStr = match[2] || match[4] + var digits = match[3] || match[5] var increment = actionArgs.increase ? 1 : -1; - var number = parseInt(token) + (increment * actionArgs.repeat); + var base = {'0b': 2, '0': 8, '': 10, '0x': 16}[baseStr.toLowerCase()]; + var number = parseInt(match[1] + digits, base) + (increment * actionArgs.repeat); + numberStr = number.toString(base); + var zeroPadding = baseStr ? new Array(digits.length - numberStr.length + 1 + match[1].length).join('0') : '' + if (numberStr.charAt(0) === '-') { + numberStr = '-' + baseStr + zeroPadding + numberStr.substr(1); + } else { + numberStr = baseStr + zeroPadding + numberStr; + } var from = Pos(cur.line, start); var to = Pos(cur.line, end); - numberStr = number.toString(); cm.replaceRange(numberStr, from, to); } else { return; diff --git a/test/vim_test.js b/test/vim_test.js index 18268ee789..5a42b90fa8 100644 --- a/test/vim_test.js +++ b/test/vim_test.js @@ -4235,4 +4235,250 @@ testVim('beforeSelectionChange', function(cm, vim, helpers) { eqCursorPos(cm.getCursor('head'), cm.getCursor('anchor')); }, { value: 'abc' }); +testVim('increment_binary', function(cm, vim, helpers) { + cm.setCursor(0, 4); + helpers.doKeys(''); + eq('0b001', cm.getValue()); + helpers.doKeys(''); + eq('0b010', cm.getValue()); + helpers.doKeys(''); + eq('0b001', cm.getValue()); + helpers.doKeys(''); + eq('0b000', cm.getValue()); + cm.setCursor(0, 0); + helpers.doKeys(''); + eq('0b001', cm.getValue()); + helpers.doKeys(''); + eq('0b010', cm.getValue()); + helpers.doKeys(''); + eq('0b001', cm.getValue()); + helpers.doKeys(''); + eq('0b000', cm.getValue()); +}, { value: '0b000' }); + +testVim('increment_octal', function(cm, vim, helpers) { + cm.setCursor(0, 2); + helpers.doKeys(''); + eq('001', cm.getValue()); + helpers.doKeys(''); + eq('002', cm.getValue()); + helpers.doKeys(''); + eq('003', cm.getValue()); + helpers.doKeys(''); + eq('004', cm.getValue()); + helpers.doKeys(''); + eq('005', cm.getValue()); + helpers.doKeys(''); + eq('006', cm.getValue()); + helpers.doKeys(''); + eq('007', cm.getValue()); + helpers.doKeys(''); + eq('010', cm.getValue()); + helpers.doKeys(''); + eq('007', cm.getValue()); + helpers.doKeys(''); + eq('006', cm.getValue()); + helpers.doKeys(''); + eq('005', cm.getValue()); + helpers.doKeys(''); + eq('004', cm.getValue()); + helpers.doKeys(''); + eq('003', cm.getValue()); + helpers.doKeys(''); + eq('002', cm.getValue()); + helpers.doKeys(''); + eq('001', cm.getValue()); + helpers.doKeys(''); + eq('000', cm.getValue()); + cm.setCursor(0, 0); + helpers.doKeys(''); + eq('001', cm.getValue()); + helpers.doKeys(''); + eq('002', cm.getValue()); + helpers.doKeys(''); + eq('001', cm.getValue()); + helpers.doKeys(''); + eq('000', cm.getValue()); +}, { value: '000' }); + +testVim('increment_decimal', function(cm, vim, helpers) { + cm.setCursor(0, 2); + helpers.doKeys(''); + eq('101', cm.getValue()); + helpers.doKeys(''); + eq('102', cm.getValue()); + helpers.doKeys(''); + eq('103', cm.getValue()); + helpers.doKeys(''); + eq('104', cm.getValue()); + helpers.doKeys(''); + eq('105', cm.getValue()); + helpers.doKeys(''); + eq('106', cm.getValue()); + helpers.doKeys(''); + eq('107', cm.getValue()); + helpers.doKeys(''); + eq('108', cm.getValue()); + helpers.doKeys(''); + eq('109', cm.getValue()); + helpers.doKeys(''); + eq('110', cm.getValue()); + helpers.doKeys(''); + eq('109', cm.getValue()); + helpers.doKeys(''); + eq('108', cm.getValue()); + helpers.doKeys(''); + eq('107', cm.getValue()); + helpers.doKeys(''); + eq('106', cm.getValue()); + helpers.doKeys(''); + eq('105', cm.getValue()); + helpers.doKeys(''); + eq('104', cm.getValue()); + helpers.doKeys(''); + eq('103', cm.getValue()); + helpers.doKeys(''); + eq('102', cm.getValue()); + helpers.doKeys(''); + eq('101', cm.getValue()); + helpers.doKeys(''); + eq('100', cm.getValue()); + cm.setCursor(0, 0); + helpers.doKeys(''); + eq('101', cm.getValue()); + helpers.doKeys(''); + eq('102', cm.getValue()); + helpers.doKeys(''); + eq('101', cm.getValue()); + helpers.doKeys(''); + eq('100', cm.getValue()); +}, { value: '100' }); + +testVim('increment_decimal_single_zero', function(cm, vim, helpers) { + helpers.doKeys(''); + eq('1', cm.getValue()); + helpers.doKeys(''); + eq('2', cm.getValue()); + helpers.doKeys(''); + eq('3', cm.getValue()); + helpers.doKeys(''); + eq('4', cm.getValue()); + helpers.doKeys(''); + eq('5', cm.getValue()); + helpers.doKeys(''); + eq('6', cm.getValue()); + helpers.doKeys(''); + eq('7', cm.getValue()); + helpers.doKeys(''); + eq('8', cm.getValue()); + helpers.doKeys(''); + eq('9', cm.getValue()); + helpers.doKeys(''); + eq('10', cm.getValue()); + helpers.doKeys(''); + eq('9', cm.getValue()); + helpers.doKeys(''); + eq('8', cm.getValue()); + helpers.doKeys(''); + eq('7', cm.getValue()); + helpers.doKeys(''); + eq('6', cm.getValue()); + helpers.doKeys(''); + eq('5', cm.getValue()); + helpers.doKeys(''); + eq('4', cm.getValue()); + helpers.doKeys(''); + eq('3', cm.getValue()); + helpers.doKeys(''); + eq('2', cm.getValue()); + helpers.doKeys(''); + eq('1', cm.getValue()); + helpers.doKeys(''); + eq('0', cm.getValue()); + cm.setCursor(0, 0); + helpers.doKeys(''); + eq('1', cm.getValue()); + helpers.doKeys(''); + eq('2', cm.getValue()); + helpers.doKeys(''); + eq('1', cm.getValue()); + helpers.doKeys(''); + eq('0', cm.getValue()); +}, { value: '0' }); +testVim('increment_hexadecimal', function(cm, vim, helpers) { + cm.setCursor(0, 2); + helpers.doKeys(''); + eq('0x1', cm.getValue()); + helpers.doKeys(''); + eq('0x2', cm.getValue()); + helpers.doKeys(''); + eq('0x3', cm.getValue()); + helpers.doKeys(''); + eq('0x4', cm.getValue()); + helpers.doKeys(''); + eq('0x5', cm.getValue()); + helpers.doKeys(''); + eq('0x6', cm.getValue()); + helpers.doKeys(''); + eq('0x7', cm.getValue()); + helpers.doKeys(''); + eq('0x8', cm.getValue()); + helpers.doKeys(''); + eq('0x9', cm.getValue()); + helpers.doKeys(''); + eq('0xa', cm.getValue()); + helpers.doKeys(''); + eq('0xb', cm.getValue()); + helpers.doKeys(''); + eq('0xc', cm.getValue()); + helpers.doKeys(''); + eq('0xd', cm.getValue()); + helpers.doKeys(''); + eq('0xe', cm.getValue()); + helpers.doKeys(''); + eq('0xf', cm.getValue()); + helpers.doKeys(''); + eq('0x10', cm.getValue()); + helpers.doKeys(''); + eq('0x0f', cm.getValue()); + helpers.doKeys(''); + eq('0x0e', cm.getValue()); + helpers.doKeys(''); + eq('0x0d', cm.getValue()); + helpers.doKeys(''); + eq('0x0c', cm.getValue()); + helpers.doKeys(''); + eq('0x0b', cm.getValue()); + helpers.doKeys(''); + eq('0x0a', cm.getValue()); + helpers.doKeys(''); + eq('0x09', cm.getValue()); + helpers.doKeys(''); + eq('0x08', cm.getValue()); + helpers.doKeys(''); + eq('0x07', cm.getValue()); + helpers.doKeys(''); + eq('0x06', cm.getValue()); + helpers.doKeys(''); + eq('0x05', cm.getValue()); + helpers.doKeys(''); + eq('0x04', cm.getValue()); + helpers.doKeys(''); + eq('0x03', cm.getValue()); + helpers.doKeys(''); + eq('0x02', cm.getValue()); + helpers.doKeys(''); + eq('0x01', cm.getValue()); + helpers.doKeys(''); + eq('0x00', cm.getValue()); + cm.setCursor(0, 0); + helpers.doKeys(''); + eq('0x01', cm.getValue()); + helpers.doKeys(''); + eq('0x02', cm.getValue()); + helpers.doKeys(''); + eq('0x01', cm.getValue()); + helpers.doKeys(''); + eq('0x00', cm.getValue()); +}, { value: '0x0' }); From a4a75b1c7c1ab4733df852eaba303cd47d46ec2e Mon Sep 17 00:00:00 2001 From: Adrian Heine Date: Wed, 6 Dec 2017 19:47:02 +0100 Subject: [PATCH 1299/2444] Escape all occurences of & and < in mode test output --- test/mode_test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/mode_test.js b/test/mode_test.js index 9773f80126..f4c4dbfe0c 100644 --- a/test/mode_test.js +++ b/test/mode_test.js @@ -67,7 +67,7 @@ }; function esc(str) { - return str.replace('&', '&').replace('<', '<').replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'"); + return str.replace(/&/g, '&').replace(//g, ">").replace(/"/g, """).replace(/'/g, "'"); } function compare(text, expected, mode) { From 7cefd7dacb53b71f6cfe14479a4f3fb4fa0c92b3 Mon Sep 17 00:00:00 2001 From: Adrian Heine Date: Wed, 6 Dec 2017 19:46:20 +0100 Subject: [PATCH 1300/2444] [jsx mode] Add support for JSXFragments Closes #5101. --- mode/jsx/jsx.js | 2 +- mode/jsx/test.js | 3 +++ mode/xml/xml.js | 7 +++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/mode/jsx/jsx.js b/mode/jsx/jsx.js index 45c3024aba..039e37bb5e 100644 --- a/mode/jsx/jsx.js +++ b/mode/jsx/jsx.js @@ -26,7 +26,7 @@ } CodeMirror.defineMode("jsx", function(config, modeConfig) { - var xmlMode = CodeMirror.getMode(config, {name: "xml", allowMissing: true, multilineTagIndentPastTag: false}) + var xmlMode = CodeMirror.getMode(config, {name: "xml", allowMissing: true, multilineTagIndentPastTag: false, allowMissingTagName: true}) var jsMode = CodeMirror.getMode(config, modeConfig && modeConfig.base || "javascript") function flatXMLIndent(state) { diff --git a/mode/jsx/test.js b/mode/jsx/test.js index 61f84ebe82..891f98830d 100644 --- a/mode/jsx/test.js +++ b/mode/jsx/test.js @@ -11,6 +11,9 @@ MT("openclose", "([bracket&tag <][tag foo][bracket&tag >]hello [atom &][bracket&tag ][operator ++])") + MT("openclosefragment", + "([bracket&tag <><][tag foo][bracket&tag >]hello [atom &][bracket&tag ][operator ++])") + MT("attr", "([bracket&tag <][tag foo] [attribute abc]=[string 'value'][bracket&tag >]hello [atom &][bracket&tag ][operator ++])") diff --git a/mode/xml/xml.js b/mode/xml/xml.js index f987a3a3ce..0f1c9b175e 100644 --- a/mode/xml/xml.js +++ b/mode/xml/xml.js @@ -52,6 +52,7 @@ var xmlConfig = { doNotIndent: {}, allowUnquoted: false, allowMissing: false, + allowMissingTagName: false, caseFold: false } @@ -226,6 +227,9 @@ CodeMirror.defineMode("xml", function(editorConf, config_) { state.tagName = stream.current(); setStyle = "tag"; return attrState; + } else if (config.allowMissingTagName && type == "endTag") { + setStyle = "tag bracket"; + return attrState(type, stream, state); } else { setStyle = "error"; return tagNameState; @@ -244,6 +248,9 @@ CodeMirror.defineMode("xml", function(editorConf, config_) { setStyle = "tag error"; return closeStateErr; } + } else if (config.allowMissingTagName && type == "endTag") { + setStyle = "tag bracket"; + return closeState(type, stream, state); } else { setStyle = "error"; return closeStateErr; From 32f63fc31de851699f5189d7701e0c06a2520b00 Mon Sep 17 00:00:00 2001 From: Cristian Prieto Date: Wed, 6 Dec 2017 16:14:49 +0100 Subject: [PATCH 1301/2444] [mllike mode] Improve OCaml support * Add reserved words for OCaml * Add {| |} string literal type * Add support for binary numbers * Add support for hex number literals * Add support for floats * Add octal and long integer literals --- mode/mllike/index.html | 19 ++++++++++++++++++ mode/mllike/mllike.js | 44 ++++++++++++++++++++++++++++++++++++------ 2 files changed, 57 insertions(+), 6 deletions(-) diff --git a/mode/mllike/index.html b/mode/mllike/index.html index 5923af8f87..b1ed6c7d78 100644 --- a/mode/mllike/index.html +++ b/mode/mllike/index.html @@ -132,6 +132,25 @@

    OCaml mode

    (* A Hundred Lines of Caml - http://caml.inria.fr/about/taste.en.html *) (* OCaml page on Wikipedia - http://en.wikipedia.org/wiki/OCaml *) + +module type S = sig type t end + +let x = {| + this is a long string + with many lines and stuff + |} + +let b = 0b00110 +let h = 0x123abcd +let e = 1e-10 +let i = 1. +let x = 30_000 +let o = 0o1234 + +[1; 2; 3] (* lists *) + +1 @ 2 +1. +. 2.

    F# mode

    diff --git a/mode/mllike/mllike.js b/mode/mllike/mllike.js index 4d0be609c4..90e5b41a63 100644 --- a/mode/mllike/mllike.js +++ b/mode/mllike/mllike.js @@ -54,6 +54,13 @@ CodeMirror.defineMode('mllike', function(_config, parserConfig) { state.tokenize = tokenString; return state.tokenize(stream, state); } + if (ch === '{') { + if (stream.eat('|')) { + state.longString = true; + state.tokenize = tokenLongString; + return state.tokenize(stream, state); + } + } if (ch === '(') { if (stream.eat('*')) { state.commentLevel++; @@ -74,13 +81,24 @@ CodeMirror.defineMode('mllike', function(_config, parserConfig) { return 'comment'; } if (/\d/.test(ch)) { - stream.eatWhile(/[\d]/); - if (stream.eat('.')) { - stream.eatWhile(/[\d]/); + if (ch === '0' && stream.eat(/[bB]/)) { + stream.eatWhile(/[01]/); + } if (ch === '0' && stream.eat(/[xX]/)) { + stream.eatWhile(/[0-9a-fA-F]/) + } if (ch === '0' && stream.eat(/[oO]/)) { + stream.eatWhile(/[0-7]/); + } else { + stream.eatWhile(/[\d_]/); + if (stream.eat('.')) { + stream.eatWhile(/[\d]/); + } + if (stream.eat(/[eE]/)) { + stream.eatWhile(/[\d\-+]/); + } } return 'number'; } - if ( /[+\-*&%=<>!?|]/.test(ch)) { + if ( /[+\-*&%=<>!?|@]/.test(ch)) { return 'operator'; } if (/[\w\xa1-\uffff]/.test(ch)) { @@ -119,8 +137,20 @@ CodeMirror.defineMode('mllike', function(_config, parserConfig) { return 'comment'; } + function tokenLongString(stream, state) { + var prev, next; + while (state.longString && (next = stream.next()) != null) { + if (prev === '|' && next === '}') state.longString = false; + prev = next; + } + if (!state.longString) { + state.tokenize = tokenBase; + } + return 'string'; + } + return { - startState: function() {return {tokenize: tokenBase, commentLevel: 0};}, + startState: function() {return {tokenize: tokenBase, commentLevel: 0, longString: false};}, token: function(stream, state) { if (stream.eatSpace()) return null; return state.tokenize(stream, state); @@ -142,7 +172,9 @@ CodeMirror.defineMIME('text/x-ocaml', { 'print_endline': 'builtin', 'true': 'atom', 'false': 'atom', - 'raise': 'keyword' + 'raise': 'keyword', + 'module': 'keyword', + 'sig': 'keyword' } }); From ecad7206ef2458bcb22bcaf13263178e2bb3a0dc Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Thu, 7 Dec 2017 12:03:15 +0100 Subject: [PATCH 1302/2444] Document lineSeparator argument do Doc constructor Issue #5112 --- doc/manual.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/manual.html b/doc/manual.html index ea5642cdf9..9d95e39c75 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -1523,8 +1523,8 @@

    Document management methods

    represents the editor content, plus a selection, an undo history, and a mode. A document can only be associated with a single editor at a time. You can create new - documents by calling the CodeMirror.Doc(text, mode, - firstLineNumber) constructor. The last two arguments are + documents by calling the CodeMirror.Doc(text: string, mode: Object, + firstLineNumber: ?number, lineSeparator: ?string) constructor. The last two arguments are optional and can be used to set a mode for the document and make it start at a line number other than 0, respectively.

    From c05c5956ef5ed327cfdb32d23a92c6786b6ac629 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Fri, 8 Dec 2017 09:56:44 +0100 Subject: [PATCH 1303/2444] Fix documentation of Doc constructor Issue #5112 --- doc/manual.html | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/doc/manual.html b/doc/manual.html index 9d95e39c75..5500b9904b 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -1523,10 +1523,11 @@

    Document management methods

    represents the editor content, plus a selection, an undo history, and a mode. A document can only be associated with a single editor at a time. You can create new - documents by calling the CodeMirror.Doc(text: string, mode: Object, - firstLineNumber: ?number, lineSeparator: ?string) constructor. The last two arguments are - optional and can be used to set a mode for the document and make - it start at a line number other than 0, respectively.

    + documents by calling the CodeMirror.Doc(text: string, mode: + Object, firstLineNumber: ?number, lineSeparator: ?string) + constructor. The last three arguments are optional and can be used + to set a mode for the document, make it start at a line number + other than 0, and set a specific line separator respectively.

    cm.getDoc() → Doc
    From a7e29eee89aed63727e46d1e422cfa95b1200859 Mon Sep 17 00:00:00 2001 From: Adrian Heine Date: Sun, 10 Dec 2017 20:57:37 +0100 Subject: [PATCH 1304/2444] [swift mode] Correctly highlight nested comments --- mode/swift/swift.js | 13 +++++++++++-- mode/swift/test.js | 7 +++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/mode/swift/swift.js b/mode/swift/swift.js index 43ab7c8fb4..1795d86e94 100644 --- a/mode/swift/swift.js +++ b/mode/swift/swift.js @@ -138,8 +138,17 @@ } function tokenComment(stream, state) { - stream.match(/^(?:[^*]|\*(?!\/))*/) - if (stream.match("*/")) state.tokenize.pop() + var ch + while (true) { + stream.match(/^[^/*]+/, true) + ch = stream.next() + if (!ch) break + if (ch === "/" && stream.eat("*")) { + state.tokenize.push(tokenComment) + } else if (ch === "*" && stream.eat("/")) { + state.tokenize.pop() + } + } return "comment" } diff --git a/mode/swift/test.js b/mode/swift/test.js index 786b89e299..4091ac6f4c 100644 --- a/mode/swift/test.js +++ b/mode/swift/test.js @@ -142,6 +142,13 @@ "[variable print][punctuation (][variable foo][property ._123][punctuation )]", "[variable print][punctuation (]") + MT("nested_comments", + "[comment /*]", + "[comment But wait /* this is a nested comment */ for real]", + "[comment /**** let * me * show * you ****/]", + "[comment ///// let / me / show / you /////]", + "[comment */]"); + // TODO: correctly identify when multiple variables are being declared // by use of a comma-separated list. // TODO: correctly identify when variables are being declared in a tuple. From ff21fec1a71e9c5de3c9faec84c3c61eaef60104 Mon Sep 17 00:00:00 2001 From: Adrian Heine Date: Sun, 10 Dec 2017 21:08:36 +0100 Subject: [PATCH 1305/2444] [scala mode] Correctly highlight nested comments The implementation is mostly copied from dart as implemented in d4dbbcef22e3aadf25dad811a9faa988a50a0df4. --- mode/clike/clike.js | 27 +++++++++++++++++++++++++++ mode/clike/test.js | 10 ++++++++++ 2 files changed, 37 insertions(+) diff --git a/mode/clike/clike.js b/mode/clike/clike.js index ff00cf5002..7706429063 100644 --- a/mode/clike/clike.js +++ b/mode/clike/clike.js @@ -489,6 +489,27 @@ CodeMirror.defineMode("clike", function(config, parserConfig) { return "string"; } + function tokenNestedComment(depth) { + return function (stream, state) { + var ch + while (ch = stream.next()) { + if (ch == "*" && stream.eat("/")) { + if (depth == 1) { + state.tokenize = null + break + } else { + state.tokenize = tokenNestedComment(depth - 1) + return state.tokenize(stream, state) + } + } else if (ch == "/" && stream.eat("*")) { + state.tokenize = tokenNestedComment(depth + 1) + return state.tokenize(stream, state) + } + } + return "comment" + } + } + def("text/x-scala", { name: "clike", keywords: words( @@ -544,6 +565,12 @@ CodeMirror.defineMode("clike", function(config, parserConfig) { } else { return false } + }, + + "/": function(stream, state) { + if (!stream.eat("*")) return false + state.tokenize = tokenNestedComment(1) + return state.tokenize(stream, state) } }, modeProps: {closeBrackets: {triples: '"'}} diff --git a/mode/clike/test.js b/mode/clike/test.js index dad2e246ae..e3bde772a5 100644 --- a/mode/clike/test.js +++ b/mode/clike/test.js @@ -56,4 +56,14 @@ MTCPP("ctor_dtor", "[def Foo::Foo]() {}", "[def Foo::~Foo]() {}"); + + var mode_scala = CodeMirror.getMode({indentUnit: 2}, "text/x-scala"); + function MTSCALA(name) { test.mode("scala_" + name, mode_scala, Array.prototype.slice.call(arguments, 1)); } + MTSCALA("nested_comments", + "[comment /*]", + "[comment But wait /* this is a nested comment */ for real]", + "[comment /**** let * me * show * you ****/]", + "[comment ///// let / me / show / you /////]", + "[comment */]"); + })(); From edc74c3ef360132afc69b2f22d51f7c6a711c305 Mon Sep 17 00:00:00 2001 From: Lior Goldberg Date: Thu, 7 Dec 2017 14:54:27 +0200 Subject: [PATCH 1306/2444] [sublime keymap] Support expanding brackets selection in selectBetweenBrackets --- keymap/sublime.js | 12 +++++++++--- test/sublime_test.js | 4 +++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/keymap/sublime.js b/keymap/sublime.js index 08c9ebfb3f..37ae6fec27 100644 --- a/keymap/sublime.js +++ b/keymap/sublime.js @@ -183,9 +183,15 @@ var closing = cm.scanForBracket(pos, 1); if (!closing) return false; if (closing.ch == mirror.charAt(mirror.indexOf(opening.ch) + 1)) { - newRanges.push({anchor: Pos(opening.pos.line, opening.pos.ch + 1), - head: closing.pos}); - break; + var startPos = Pos(opening.pos.line, opening.pos.ch + 1); + if (CodeMirror.cmpPos(startPos, range.from()) == 0 && + CodeMirror.cmpPos(closing.pos, range.to()) == 0) { + opening = cm.scanForBracket(opening.pos, -1); + if (!opening) return false; + } else { + newRanges.push({anchor: startPos, head: closing.pos}); + break; + } } pos = Pos(closing.pos.line, closing.pos.ch + 1); } diff --git a/test/sublime_test.js b/test/sublime_test.js index e9cd342ff4..27132d16a7 100644 --- a/test/sublime_test.js +++ b/test/sublime_test.js @@ -152,7 +152,9 @@ Pos(0, 8), "selectScope", hasSel(0, 8, 2, 0), Pos(1, 2), "selectScope", hasSel(0, 8, 2, 0), Pos(1, 6), "selectScope", hasSel(1, 6, 1, 10), - Pos(1, 9), "selectScope", hasSel(1, 6, 1, 10)); + Pos(1, 9), "selectScope", hasSel(1, 6, 1, 10), + "selectScope", hasSel(0, 8, 2, 0), + "selectScope", hasSel(0, 0, 2, 1)); stTest("goToBracket", "foo(a) {\n bar[1, 2];\n}", Pos(0, 0), "goToBracket", at(0, 0), From b3cdfee46a320e646a298141861b4e80dc6f1bd0 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Tue, 12 Dec 2017 22:16:41 +0100 Subject: [PATCH 1307/2444] Drop bin/compress Leave compression up to people's own custom build setups Closes #5127 --- bin/compress | 92 ---------------------------------------------------- 1 file changed, 92 deletions(-) delete mode 100755 bin/compress diff --git a/bin/compress b/bin/compress deleted file mode 100755 index d358f9c3a0..0000000000 --- a/bin/compress +++ /dev/null @@ -1,92 +0,0 @@ -#!/usr/bin/env node - -// Compression helper for CodeMirror -// -// Example: -// -// bin/compress codemirror runmode javascript xml -// -// Will take lib/codemirror.js, addon/runmode/runmode.js, -// mode/javascript/javascript.js, and mode/xml/xml.js, run them though -// the online minifier at http://marijnhaverbeke.nl/uglifyjs, and spit -// out the result. -// -// bin/compress codemirror --local /path/to/bin/UglifyJS -// -// Will use a local minifier instead of the online default one. -// -// Script files are specified without .js ending. Prefixing them with -// their full (local) path is optional. So you may say lib/codemirror -// or mode/xml/xml to be more precise. In fact, even the .js suffix -// may be specified, if wanted. - -"use strict"; - -var fs = require("fs"); - -function help(ok) { - console.log("usage: " + process.argv[1] + " [--local /path/to/uglifyjs] files..."); - process.exit(ok ? 0 : 1); -} - -var local = null, args = [], extraArgs = null, files = [], blob = ""; - -for (var i = 2; i < process.argv.length; ++i) { - var arg = process.argv[i]; - if (arg == "--local" && i + 1 < process.argv.length) { - var parts = process.argv[++i].split(/\s+/); - local = parts[0]; - extraArgs = parts.slice(1); - if (!extraArgs.length) extraArgs = ["-c", "-m"]; - } else if (arg == "--help") { - help(true); - } else if (arg[0] != "-") { - files.push({name: arg, re: new RegExp("(?:\\/|^)" + arg + (/\.js$/.test(arg) ? "$" : "\\.js$"))}); - } else help(false); -} - -function walk(dir) { - fs.readdirSync(dir).forEach(function(fname) { - if (/^[_\.]/.test(fname)) return; - var file = dir + fname; - if (fs.statSync(file).isDirectory()) return walk(file + "/"); - if (files.some(function(spec, i) { - var match = spec.re.test(file); - if (match) files.splice(i, 1); - return match; - })) { - if (local) args.push(file); - else blob += fs.readFileSync(file, "utf8"); - } - }); -} - -walk("lib/"); -walk("addon/"); -walk("mode/"); - -if (!local && !blob) help(false); - -if (files.length) { - console.log("Some specified files were not found: " + - files.map(function(a){return a.name;}).join(", ")); - process.exit(1); -} - -if (local) { - require("child_process").spawn(local, args.concat(extraArgs), {stdio: ["ignore", process.stdout, process.stderr]}); -} else { - var data = new Buffer("js_code=" + require("querystring").escape(blob), "utf8"); - var req = require("http").request({ - host: "marijnhaverbeke.nl", - port: 80, - method: "POST", - path: "/uglifyjs", - headers: {"content-type": "application/x-www-form-urlencoded", - "content-length": data.length} - }); - req.on("response", function(resp) { - resp.on("data", function (chunk) { process.stdout.write(chunk); }); - }); - req.end(data); -} From d9f05c90a1f6e07faf4ec3cf239621f1cce44f32 Mon Sep 17 00:00:00 2001 From: Sorab Bisht Date: Mon, 11 Dec 2017 19:44:15 +0530 Subject: [PATCH 1308/2444] [closetag addon] Add an option to disable auto indenting --- addon/edit/closetag.js | 16 +++++++++++----- src/edit/options.js | 1 + 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/addon/edit/closetag.js b/addon/edit/closetag.js index a518da3ec1..83f133a5e7 100644 --- a/addon/edit/closetag.js +++ b/addon/edit/closetag.js @@ -53,13 +53,14 @@ function autoCloseGT(cm) { if (cm.getOption("disableInput")) return CodeMirror.Pass; var ranges = cm.listSelections(), replacements = []; + var opt = cm.getOption("autoCloseTags"); for (var i = 0; i < ranges.length; i++) { if (!ranges[i].empty()) return CodeMirror.Pass; var pos = ranges[i].head, tok = cm.getTokenAt(pos); var inner = CodeMirror.innerMode(cm.getMode(), tok.state), state = inner.state; if (inner.mode.name != "xml" || !state.tagName) return CodeMirror.Pass; - var opt = cm.getOption("autoCloseTags"), html = inner.mode.configuration == "html"; + var html = inner.mode.configuration == "html"; var dontCloseTags = (typeof opt == "object" && opt.dontCloseTags) || (html && htmlDontClose); var indentTags = (typeof opt == "object" && opt.indentTags) || (html && htmlIndent); @@ -81,13 +82,14 @@ newPos: indent ? CodeMirror.Pos(pos.line + 1, 0) : CodeMirror.Pos(pos.line, pos.ch + 1)}; } + var dontIndentOnAutoClose = (typeof opt == "object" && opt.dontIndentOnAutoClose); for (var i = ranges.length - 1; i >= 0; i--) { var info = replacements[i]; cm.replaceRange(info.text, ranges[i].head, ranges[i].anchor, "+insert"); var sel = cm.listSelections().slice(0); sel[i] = {head: info.newPos, anchor: info.newPos}; cm.setSelections(sel); - if (info.indent) { + if (!dontIndentOnAutoClose && info.indent) { cm.indentLine(info.newPos.line, null, true); cm.indentLine(info.newPos.line + 1, null, true); } @@ -97,6 +99,8 @@ function autoCloseCurrent(cm, typingSlash) { var ranges = cm.listSelections(), replacements = []; var head = typingSlash ? "/" : " { cm.doc.lineSep = val if (!val) return From 56c271ff88efbf3726a4f0fa0a131942ebf804ff Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Sat, 16 Dec 2017 18:47:06 +0100 Subject: [PATCH 1309/2444] [javascript mode] Stop treating TS contextual keywords as regular keywords Closes #5133 --- mode/javascript/javascript.js | 68 +++++++++++++---------------------- 1 file changed, 25 insertions(+), 43 deletions(-) diff --git a/mode/javascript/javascript.js b/mode/javascript/javascript.js index 514de1c8da..edab99f3d7 100644 --- a/mode/javascript/javascript.js +++ b/mode/javascript/javascript.js @@ -26,7 +26,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { var A = kw("keyword a"), B = kw("keyword b"), C = kw("keyword c"), D = kw("keyword d"); var operator = kw("operator"), atom = {type: "atom", style: "atom"}; - var jsKeywords = { + return { "if": kw("if"), "while": A, "with": A, "else": B, "do": B, "try": B, "finally": B, "return": D, "break": D, "continue": D, "new": kw("new"), "delete": C, "void": C, "throw": C, "debugger": kw("debugger"), "var": kw("var"), "const": kw("var"), "let": kw("var"), @@ -38,33 +38,6 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { "yield": C, "export": kw("export"), "import": kw("import"), "extends": C, "await": C }; - - // Extend the 'normal' keywords with the TypeScript language extensions - if (isTS) { - var type = {type: "variable", style: "type"}; - var tsKeywords = { - // object-like things - "interface": kw("class"), - "implements": C, - "namespace": C, - - // scope modifiers - "public": kw("modifier"), - "private": kw("modifier"), - "protected": kw("modifier"), - "abstract": kw("modifier"), - "readonly": kw("modifier"), - - // types - "string": type, "number": type, "boolean": type, "any": type - }; - - for (var attr in tsKeywords) { - jsKeywords[attr] = tsKeywords[attr]; - } - } - - return jsKeywords; }(); var isOperatorChar = /[+\-*&%=<>!?|~^@]/; @@ -310,6 +283,10 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { } } + function isModifier(name) { + return name == "public" || name == "private" || name == "protected" || name == "abstract" || name == "readonly" + } + // Combinators var defaultVars = {name: "this", next: {name: "arguments"}}; @@ -366,6 +343,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { } if (type == "function") return cont(functiondef); if (type == "for") return cont(pushlex("form"), forspec, statement, poplex); + if (type == "class" || (isTS && value == "interface")) { cx.marked = "keyword"; return cont(pushlex("form"), className, poplex); } if (type == "variable") { if (isTS && value == "type") { cx.marked = "keyword" @@ -376,6 +354,9 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { } else if (isTS && (value == "module" || value == "enum") && cx.stream.match(/^\s*\w/, false)) { cx.marked = "keyword" return cont(pushlex("form"), pattern, expect("{"), pushlex("}"), block, poplex, poplex) + } else if (isTS && value == "namespace") { + cx.marked = "keyword" + return cont(pushlex("form"), expression, block, poplex) } else { return cont(pushlex("stat"), maybelabel); } @@ -386,24 +367,23 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { if (type == "default") return cont(expect(":")); if (type == "catch") return cont(pushlex("form"), pushcontext, expect("("), funarg, expect(")"), statement, poplex, popcontext); - if (type == "class") return cont(pushlex("form"), className, poplex); if (type == "export") return cont(pushlex("stat"), afterExport, poplex); if (type == "import") return cont(pushlex("stat"), afterImport, poplex); if (type == "async") return cont(statement) if (value == "@") return cont(expression, statement) return pass(pushlex("stat"), expression, expect(";"), poplex); } - function expression(type) { - return expressionInner(type, false); + function expression(type, value) { + return expressionInner(type, value, false); } - function expressionNoComma(type) { - return expressionInner(type, true); + function expressionNoComma(type, value) { + return expressionInner(type, value, true); } function parenExpr(type) { if (type != "(") return pass() return cont(pushlex(")"), expression, expect(")"), poplex) } - function expressionInner(type, noComma) { + function expressionInner(type, value, noComma) { if (cx.state.fatArrowAt == cx.stream.start) { var body = noComma ? arrowBodyNoComma : arrowBody; if (type == "(") return cont(pushcontext, pushlex(")"), commasep(funarg, ")"), poplex, expect("=>"), body, popcontext); @@ -413,7 +393,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { var maybeop = noComma ? maybeoperatorNoComma : maybeoperatorComma; if (atomicTypes.hasOwnProperty(type)) return cont(maybeop); if (type == "function") return cont(functiondef, maybeop); - if (type == "class") return cont(pushlex("form"), classExpression, poplex); + if (type == "class" || (isTS && value == "interface")) { cx.marked = "keyword"; return cont(pushlex("form"), classExpression, poplex); } if (type == "keyword c" || type == "async") return cont(noComma ? expressionNoComma : expression); if (type == "(") return cont(pushlex(")"), maybeexpression, expect(")"), poplex, maybeop); if (type == "operator" || type == "spread") return cont(noComma ? expressionNoComma : expression); @@ -511,10 +491,11 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { return cont(afterprop); } else if (type == "jsonld-keyword") { return cont(afterprop); - } else if (type == "modifier") { + } else if (isTS && isModifier(value)) { + cx.marked = "keyword" return cont(objprop) } else if (type == "[") { - return cont(expression, expect("]"), afterprop); + return cont(expression, maybetype, expect("]"), afterprop); } else if (type == "spread") { return cont(expressionNoComma, afterprop); } else if (value == "*") { @@ -616,7 +597,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { if (value == "<") return cont(pushlex(">"), commasep(typeexpr, ">"), poplex, afterType) if (value == "|" || type == ".") return cont(typeexpr) if (type == "[") return cont(expect("]"), afterType) - if (value == "extends") return cont(typeexpr) + if (value == "extends" || value == "implements") { cx.marked = "keyword"; return cont(typeexpr) } } function maybeTypeArgs(_, value) { if (value == "<") return cont(pushlex(">"), commasep(typeexpr, ">"), poplex, afterType) @@ -631,7 +612,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { return pass(pattern, maybetype, maybeAssign, vardefCont); } function pattern(type, value) { - if (type == "modifier") return cont(pattern) + if (isTS && isModifier(value)) { cx.marked = "keyword"; return cont(pattern) } if (type == "variable") { register(value); return cont(); } if (type == "spread") return cont(pattern); if (type == "[") return contCommasep(pattern, "]"); @@ -685,7 +666,8 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { } function funarg(type, value) { if (value == "@") cont(expression, funarg) - if (type == "spread" || type == "modifier") return cont(funarg); + if (type == "spread") return cont(funarg); + if (isTS && isModifier(value)) { cx.marked = "keyword"; return cont(funarg); } return pass(pattern, maybetype, maybeAssign); } function classExpression(type, value) { @@ -703,9 +685,9 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { if (type == "{") return cont(pushlex("}"), classBody, poplex); } function classBody(type, value) { - if (type == "modifier" || type == "async" || + if (type == "async" || (type == "variable" && - (value == "static" || value == "get" || value == "set") && + (value == "static" || value == "get" || value == "set" || (isTS && isModifier(value))) && cx.stream.match(/^\s+[\w$\xa1-\uffff]/, false))) { cx.marked = "keyword"; return cont(classBody); @@ -715,7 +697,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { return cont(isTS ? classfield : functiondef, classBody); } if (type == "[") - return cont(expression, expect("]"), isTS ? classfield : functiondef, classBody) + return cont(expression, maybetype, expect("]"), isTS ? classfield : functiondef, classBody) if (value == "*") { cx.marked = "keyword"; return cont(classBody); From 9e3665211ac2427b55acf8006bd7f783a640f16b Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Wed, 20 Dec 2017 10:22:33 +0100 Subject: [PATCH 1310/2444] Use a different way to force line widget margins to stay inside container Issue #5137 --- lib/codemirror.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/codemirror.css b/lib/codemirror.css index 8f4f22f5d6..c7a8ae7047 100644 --- a/lib/codemirror.css +++ b/lib/codemirror.css @@ -270,7 +270,7 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #a22;} .CodeMirror-linewidget { position: relative; z-index: 2; - overflow: auto; + padding: 0.1px; /* Force widget margins to stay inside of the container */ } .CodeMirror-widget {} From 40570ddc5ba1410c7bf2c38f1b1e8ac6a502fa2f Mon Sep 17 00:00:00 2001 From: Tobias Bertelsen Date: Wed, 6 Dec 2017 22:52:31 +0100 Subject: [PATCH 1311/2444] [sublime keymap] Fixing hotkeys for addCursorTo(Prev|Next)Line Fix for issue #5109 --- keymap/sublime.js | 33 ++++----------------------------- test/sublime_test.js | 25 ------------------------- 2 files changed, 4 insertions(+), 54 deletions(-) diff --git a/keymap/sublime.js b/keymap/sublime.js index 37ae6fec27..5925b7c51f 100644 --- a/keymap/sublime.js +++ b/keymap/sublime.js @@ -514,27 +514,6 @@ cm.scrollTo(null, (pos.top + pos.bottom) / 2 - cm.getScrollInfo().clientHeight / 2); }; - cmds.selectLinesUpward = function(cm) { - cm.operation(function() { - var ranges = cm.listSelections(); - for (var i = 0; i < ranges.length; i++) { - var range = ranges[i]; - if (range.head.line > cm.firstLine()) - cm.addSelection(Pos(range.head.line - 1, range.head.ch)); - } - }); - }; - cmds.selectLinesDownward = function(cm) { - cm.operation(function() { - var ranges = cm.listSelections(); - for (var i = 0; i < ranges.length; i++) { - var range = ranges[i]; - if (range.head.line < cm.lastLine()) - cm.addSelection(Pos(range.head.line + 1, range.head.ch)); - } - }); - }; - function getTarget(cm) { var from = cm.getCursor("from"), to = cm.getCursor("to"); if (CodeMirror.cmpPos(from, to) == 0) { @@ -596,8 +575,6 @@ "Cmd-Enter": "insertLineAfter", "Shift-Cmd-Enter": "insertLineBefore", "Cmd-D": "selectNextOccurrence", - "Shift-Cmd-Up": "addCursorToPrevLine", - "Shift-Cmd-Down": "addCursorToNextLine", "Shift-Cmd-Space": "selectScope", "Shift-Cmd-M": "selectBetweenBrackets", "Cmd-M": "goToBracket", @@ -627,8 +604,8 @@ "Cmd-K Cmd-Backspace": "delLineLeft", "Cmd-K Cmd-0": "unfoldAll", "Cmd-K Cmd-J": "unfoldAll", - "Ctrl-Shift-Up": "selectLinesUpward", - "Ctrl-Shift-Down": "selectLinesDownward", + "Ctrl-Shift-Up": "addCursorToPrevLine", + "Ctrl-Shift-Down": "addCursorToNextLine", "Cmd-F3": "findUnder", "Shift-Cmd-F3": "findUnderPrevious", "Alt-F3": "findAllUnder", @@ -658,8 +635,6 @@ "Ctrl-Enter": "insertLineAfter", "Shift-Ctrl-Enter": "insertLineBefore", "Ctrl-D": "selectNextOccurrence", - "Alt-CtrlUp": "addCursorToPrevLine", - "Alt-CtrlDown": "addCursorToNextLine", "Shift-Ctrl-Space": "selectScope", "Shift-Ctrl-M": "selectBetweenBrackets", "Ctrl-M": "goToBracket", @@ -689,8 +664,8 @@ "Ctrl-K Ctrl-Backspace": "delLineLeft", "Ctrl-K Ctrl-0": "unfoldAll", "Ctrl-K Ctrl-J": "unfoldAll", - "Ctrl-Alt-Up": "selectLinesUpward", - "Ctrl-Alt-Down": "selectLinesDownward", + "Ctrl-Alt-Up": "addCursorToPrevLine", + "Ctrl-Alt-Down": "addCursorToNextLine", "Ctrl-F3": "findUnder", "Shift-Ctrl-F3": "findUnderPrevious", "Alt-F3": "findAllUnder", diff --git a/test/sublime_test.js b/test/sublime_test.js index 27132d16a7..09bb951247 100644 --- a/test/sublime_test.js +++ b/test/sublime_test.js @@ -221,31 +221,6 @@ 2, 4, 2, 6, 2, 7, 2, 7)); - stTest("selectLinesUpward", "123\n345\n789\n012", - setSel(0, 1, 0, 1, - 1, 1, 1, 3, - 2, 0, 2, 0, - 3, 0, 3, 0), - "selectLinesUpward", - hasSel(0, 1, 0, 1, - 0, 3, 0, 3, - 1, 0, 1, 0, - 1, 1, 1, 3, - 2, 0, 2, 0, - 3, 0, 3, 0)); - - stTest("selectLinesDownward", "123\n345\n789\n012", - setSel(0, 1, 0, 1, - 1, 1, 1, 3, - 2, 0, 2, 0, - 3, 0, 3, 0), - "selectLinesDownward", - hasSel(0, 1, 0, 1, - 1, 1, 1, 3, - 2, 0, 2, 0, - 2, 3, 2, 3, - 3, 0, 3, 0)); - stTest("sortLines", "c\nb\na\nC\nB\nA", "sortLines", val("A\nB\nC\na\nb\nc"), "undo", From 2f4fb8053021c01d1f246de2e663ac3719877610 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Thu, 21 Dec 2017 14:59:33 +0100 Subject: [PATCH 1312/2444] Mark version 5.33.0 --- AUTHORS | 6 ++++++ CHANGELOG.md | 22 ++++++++++++++++++++++ doc/manual.html | 2 +- doc/releases.html | 13 +++++++++++++ index.html | 2 +- package.json | 2 +- src/edit/main.js | 2 +- 7 files changed, 45 insertions(+), 4 deletions(-) diff --git a/AUTHORS b/AUTHORS index 65d8480893..47c79d1577 100644 --- a/AUTHORS +++ b/AUTHORS @@ -144,6 +144,7 @@ CodeBitt coderaiser Cole R Lawrence ComFreek +Cristian Prieto Curtis Gagliardi dagsta daines @@ -385,6 +386,7 @@ Leon Sorokin Leonya Khachaturov Liam Newman Libo Cannici +Lior Goldberg LloydMilligan LM lochel @@ -611,6 +613,7 @@ sinkuu snasa soliton4 sonson +Sorab Bisht spastorelli srajanpaliwal Stanislav Oaserele @@ -619,6 +622,7 @@ Stefan Borsje Steffen Beyer Steffen Bruchmann Steffen Kowalski +Stephane Moore Stephen Lavelle Steve Champagne Steve Hoover @@ -651,6 +655,7 @@ Tim Baumann Timothy Farrell Timothy Gu Timothy Hatcher +Tobias Bertelsen TobiasBg Todd Berman Todd Kennedy @@ -660,6 +665,7 @@ Tom Erik Støwer Tom Klancer Tom MacWright Tony Jian +tophf Travis Heppe Triangle717 Tristan Tarrant diff --git a/CHANGELOG.md b/CHANGELOG.md index f81fcdd07b..855e6e4d9a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,25 @@ +## 5.33.0 (2017-12-21) + +### Bug fixes + +[lint addon](http://codemirror.net/doc/manual.html#addon_lint): Make updates more efficient. + +[css mode](http://codemirror.net/mode/css/): The mode is now properly case-insensitive. + +[continuelist addon](http://codemirror.net/doc/manual.html#addon_continuelist): Fix broken handling of unordered lists introduced in previous release. + +[swift](http://codemirror.net/mode/swift) and [scala](http://codemirror.net/mode/clike/) modes: Support nested block comments. + +[mllike mode](http://codemirror.net/mode/mllike/index.html): Improve OCaml support. + +[sublime bindings](http://codemirror.net/demo/sublime.html): Use the proper key bindings for `addCursorToNextLine` and `addCursorToPrevLine`. + +### New features + +[jsx mode](http://codemirror.net/mode/jsx/index.html): Support JSX fragments. + +[closetag addon](http://codemirror.net/demo/closetag.html): Add an option to disable auto-indenting. + ## 5.32.0 (2017-11-22) ### Bug fixes diff --git a/doc/manual.html b/doc/manual.html index 5500b9904b..37275fd9d7 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -69,7 +69,7 @@

    User manual and reference guide - version 5.32.1 + version 5.33.0

    CodeMirror is a code-editor component that can be embedded in diff --git a/doc/releases.html b/doc/releases.html index 7fb8eebef1..4051a32c55 100644 --- a/doc/releases.html +++ b/doc/releases.html @@ -30,6 +30,19 @@

    Release notes and version history

    Version 5.x

    +

    21-12-2017: Version 5.33.0:

    + +
      +
    • lint addon: Make updates more efficient.
    • +
    • css mode: The mode is now properly case-insensitive.
    • +
    • continuelist addon: Fix broken handling of unordered lists introduced in previous release.
    • +
    • swift and scala modes: Support nested block comments.
    • +
    • mllike mode: Improve OCaml support.
    • +
    • sublime bindings: Use the proper key bindings for addCursorToNextLine and addCursorToPrevLine.
    • +
    • jsx mode: Support JSX fragments.
    • +
    • closetag addon: Add an option to disable auto-indenting.
    • +
    +

    22-11-2017: Version 5.32.0:

      diff --git a/index.html b/index.html index d62ab84a39..1e4df9328a 100644 --- a/index.html +++ b/index.html @@ -96,7 +96,7 @@

      This is CodeMirror

    - Get the current version: 5.32.0.
    + Get the current version: 5.33.0.
    You can see the code,
    read the release notes,
    or study the user manual. diff --git a/package.json b/package.json index 3ffad1d5d1..9894b4f0d3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "codemirror", - "version": "5.32.1", + "version": "5.33.0", "main": "lib/codemirror.js", "style": "lib/codemirror.css", "description": "Full-featured in-browser code editor", diff --git a/src/edit/main.js b/src/edit/main.js index 260f7d0af5..a49a7c2f39 100644 --- a/src/edit/main.js +++ b/src/edit/main.js @@ -66,4 +66,4 @@ import { addLegacyProps } from "./legacy.js" addLegacyProps(CodeMirror) -CodeMirror.version = "5.32.1" +CodeMirror.version = "5.33.0" From c727c997264451a11573ec121889bc76b071bfe2 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Thu, 21 Dec 2017 15:01:04 +0100 Subject: [PATCH 1313/2444] Bump version number post-5.33.0 --- doc/manual.html | 2 +- package.json | 2 +- src/edit/main.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/manual.html b/doc/manual.html index 37275fd9d7..01721009d7 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -69,7 +69,7 @@

    User manual and reference guide - version 5.33.0 + version 5.33.1

    CodeMirror is a code-editor component that can be embedded in diff --git a/package.json b/package.json index 9894b4f0d3..28a2925884 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "codemirror", - "version": "5.33.0", + "version": "5.33.1", "main": "lib/codemirror.js", "style": "lib/codemirror.css", "description": "Full-featured in-browser code editor", diff --git a/src/edit/main.js b/src/edit/main.js index a49a7c2f39..a12e4e3bb7 100644 --- a/src/edit/main.js +++ b/src/edit/main.js @@ -66,4 +66,4 @@ import { addLegacyProps } from "./legacy.js" addLegacyProps(CodeMirror) -CodeMirror.version = "5.33.0" +CodeMirror.version = "5.33.1" From b36cf986c7288e6019d11338867a5730fee70b95 Mon Sep 17 00:00:00 2001 From: tophf Date: Fri, 22 Dec 2017 10:32:36 +0300 Subject: [PATCH 1314/2444] [stylus mode] parse CSS4 hex colors - #RGBA and #RRGGBBAA --- mode/stylus/stylus.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mode/stylus/stylus.js b/mode/stylus/stylus.js index b83be16f42..a9f50c05d1 100644 --- a/mode/stylus/stylus.js +++ b/mode/stylus/stylus.js @@ -76,7 +76,7 @@ if (ch == "#") { stream.next(); // Hex color - if (stream.match(/^[0-9a-f]{6}|[0-9a-f]{3}/i)) { + if (stream.match(/^[0-9a-f]{3}([0-9a-f]([0-9a-f]{2}){0,2})?\b/i)) { return ["atom", "atom"]; } // ID selector From 9ed3674fbb8bb35726e73d63732b011cb4facf5f Mon Sep 17 00:00:00 2001 From: tophf Date: Sun, 24 Dec 2017 12:10:50 +0300 Subject: [PATCH 1315/2444] Recognize ScrollLock and Pause with Ctrl modifier --- src/input/keymap.js | 3 +++ src/input/keynames.js | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/input/keymap.js b/src/input/keymap.js index 1dfcf8aff6..63f18b58a9 100644 --- a/src/input/keymap.js +++ b/src/input/keymap.js @@ -137,6 +137,9 @@ export function keyName(event, noShift) { if (presto && event.keyCode == 34 && event["char"]) return false let name = keyNames[event.keyCode] if (name == null || event.altGraphKey) return false + // Ctrl-ScrollLock has keyCode 3, same as Ctrl-Pause, + // so we'll use event.code when available (Chrome 48+, FF 38+, Safari 10.1+) + if (event.keyCode == 3 && event.code) name = event.code return addModifierNames(name, event, noShift) } diff --git a/src/input/keynames.js b/src/input/keynames.js index 66bc80010c..9a61d152b8 100644 --- a/src/input/keynames.js +++ b/src/input/keynames.js @@ -1,9 +1,9 @@ export let keyNames = { - 3: "Enter", 8: "Backspace", 9: "Tab", 13: "Enter", 16: "Shift", 17: "Ctrl", 18: "Alt", + 3: "Pause", 8: "Backspace", 9: "Tab", 13: "Enter", 16: "Shift", 17: "Ctrl", 18: "Alt", 19: "Pause", 20: "CapsLock", 27: "Esc", 32: "Space", 33: "PageUp", 34: "PageDown", 35: "End", 36: "Home", 37: "Left", 38: "Up", 39: "Right", 40: "Down", 44: "PrintScrn", 45: "Insert", 46: "Delete", 59: ";", 61: "=", 91: "Mod", 92: "Mod", 93: "Mod", - 106: "*", 107: "=", 109: "-", 110: ".", 111: "/", 127: "Delete", + 106: "*", 107: "=", 109: "-", 110: ".", 111: "/", 127: "Delete", 145: "ScrollLock", 173: "-", 186: ";", 187: "=", 188: ",", 189: "-", 190: ".", 191: "/", 192: "`", 219: "[", 220: "\\", 221: "]", 222: "'", 63232: "Up", 63233: "Down", 63234: "Left", 63235: "Right", 63272: "Delete", 63273: "Home", 63275: "End", 63276: "PageUp", 63277: "PageDown", 63302: "Insert" From d096403f470630c9019c4bf847aa8bab57ccc8d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9lio?= Date: Thu, 28 Dec 2017 18:18:16 -0300 Subject: [PATCH 1316/2444] [markdown mode] Support for the official mimetype MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit tl;dr: `text/markdown` since March 2016 --- In March 2016, `text/markdown` was registered as [RFC7763 at IETF](https://tools.ietf.org/html/rfc7763). Previously, it should have been `text/x-markdown`. The text below describes the situation before March 2016, when RFC7763 was still a draft. --- There is no official recommendation on [Gruber’s definition](http://daringfireball.net/projects/markdown/), but the topic was discussed quite heavily on the [official mailing-list](http://six.pairlist.net/pipermail/markdown-discuss/2007-June/thread.html#640), and reached the choice of `text/x-markdown`. This conclusion was [challenged later](http://six.pairlist.net/pipermail/markdown-discuss/2008-February/000960.html), has been confirmed and can be, IMO, considered consensus. This is the only logical conclusion in the lack of an official mime type: `text/` will provide proper default almost everywhere, `x-` because we're not using an official type, `markdown` and not `gruber.` or whatever because the type is now so common. There are still [unknowns](http://six.pairlist.net/pipermail/markdown-discuss/2007-June/000652.html) regarding the different “flavors” of Markdown, though. I guess someone should register an official type, which is supposedly [easy](http://tools.ietf.org/html/rfc4288#section-3.4), but I doubt anyone dares do it beyond John Gruber, as he very recently [proved](http://blog.codinghorror.com/standard-markdown-is-now-common-markdown/) his attachment to Markdown. There is a [draft](https://datatracker.ietf.org/doc/draft-ietf-appsawg-text-markdown/) on the IETF for `text/markdown`, but the contents do not seem to describe Markdown at all, so I wouldn't use it until it gets more complete. --- mode/markdown/markdown.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mode/markdown/markdown.js b/mode/markdown/markdown.js index b2f79fc302..60f1b30026 100644 --- a/mode/markdown/markdown.js +++ b/mode/markdown/markdown.js @@ -856,6 +856,8 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) { return mode; }, "xml"); +CodeMirror.defineMIME("text/markdown", "markdown"); + CodeMirror.defineMIME("text/x-markdown", "markdown"); }); From 865102a071e79ea2301bcb710f6051f593deddc9 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Fri, 29 Dec 2017 13:18:43 +0100 Subject: [PATCH 1317/2444] [nginx mode] Fix documented mime type Issue #5148 --- mode/nginx/index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mode/nginx/index.html b/mode/nginx/index.html index 03cf671498..dde54574d5 100644 --- a/mode/nginx/index.html +++ b/mode/nginx/index.html @@ -1,4 +1,4 @@ - + CodeMirror: NGINX mode @@ -176,6 +176,6 @@

    NGINX mode

    var editor = CodeMirror.fromTextArea(document.getElementById("code"), {}); -

    MIME types defined: text/nginx.

    +

    MIME types defined: text/x-nginx-conf.

    From b045bfa732c2ec44a66dde944dd9be1ef5da99df Mon Sep 17 00:00:00 2001 From: 4oo4 <4oo4@users.noreply.github.com> Date: Sat, 30 Dec 2017 15:52:33 +0000 Subject: [PATCH 1318/2444] [mode/meta] Add .ino to C --- mode/meta.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mode/meta.js b/mode/meta.js index 91a925268e..89b2ced87c 100644 --- a/mode/meta.js +++ b/mode/meta.js @@ -17,7 +17,7 @@ {name: "ASN.1", mime: "text/x-ttcn-asn", mode: "asn.1", ext: ["asn", "asn1"]}, {name: "Asterisk", mime: "text/x-asterisk", mode: "asterisk", file: /^extensions\.conf$/i}, {name: "Brainfuck", mime: "text/x-brainfuck", mode: "brainfuck", ext: ["b", "bf"]}, - {name: "C", mime: "text/x-csrc", mode: "clike", ext: ["c", "h"]}, + {name: "C", mime: "text/x-csrc", mode: "clike", ext: ["c", "h", "ino"]}, {name: "C++", mime: "text/x-c++src", mode: "clike", ext: ["cpp", "c++", "cc", "cxx", "hpp", "h++", "hh", "hxx"], alias: ["cpp"]}, {name: "Cobol", mime: "text/x-cobol", mode: "cobol", ext: ["cob", "cpy"]}, {name: "C#", mime: "text/x-csharp", mode: "clike", ext: ["cs"], alias: ["csharp"]}, From 8b9d8e337eb7c1d48d42589a5caee0a2215f620c Mon Sep 17 00:00:00 2001 From: Takuya Matsuyama Date: Mon, 1 Jan 2018 20:51:12 +0900 Subject: [PATCH 1319/2444] [php mode] Fix invalid mime definition --- mode/meta.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mode/meta.js b/mode/meta.js index 89b2ced87c..4ab3e08e3e 100644 --- a/mode/meta.js +++ b/mode/meta.js @@ -101,7 +101,7 @@ {name: "Pascal", mime: "text/x-pascal", mode: "pascal", ext: ["p", "pas"]}, {name: "PEG.js", mime: "null", mode: "pegjs", ext: ["jsonld"]}, {name: "Perl", mime: "text/x-perl", mode: "perl", ext: ["pl", "pm"]}, - {name: "PHP", mime: ["application/x-httpd-php", "text/x-php"], mode: "php", ext: ["php", "php3", "php4", "php5", "php7", "phtml"]}, + {name: "PHP", mimes: ["text/x-php", "application/x-httpd-php", "application/x-httpd-php-open"], mode: "php", ext: ["php", "php3", "php4", "php5", "php7", "phtml"]}, {name: "Pig", mime: "text/x-pig", mode: "pig", ext: ["pig"]}, {name: "Plain Text", mime: "text/plain", mode: "null", ext: ["txt", "text", "conf", "def", "list", "log"]}, {name: "PLSQL", mime: "text/x-plsql", mode: "sql", ext: ["pls"]}, From cacaa54596272e6ffadf24322123f773bc3c2d80 Mon Sep 17 00:00:00 2001 From: Shane Liesegang Date: Tue, 2 Jan 2018 18:01:27 -0500 Subject: [PATCH 1320/2444] [makdown mode] Don't let inline styles persist across list items --- mode/markdown/markdown.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mode/markdown/markdown.js b/mode/markdown/markdown.js index 60f1b30026..7dfddccd39 100644 --- a/mode/markdown/markdown.js +++ b/mode/markdown/markdown.js @@ -113,6 +113,8 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) { function blankLine(state) { // Reset linkTitle state state.linkTitle = false; + state.linkHref = false; + state.linkText = false; // Reset EM state state.em = false; // Reset STRONG state @@ -151,6 +153,12 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) { if (state.indentationDiff === null) { state.indentationDiff = state.indentation; if (prevLineIsList) { + // Reset inline styles which shouldn't propagate aross list items + state.em = false; + state.strong = false; + state.code = false; + state.strikethrough = false; + state.list = null; // While this list item's marker's indentation is less than the deepest // list item's content's indentation,pop the deepest list item From d2798d22509e33f3aeb79bb7f7437ba0de4605bf Mon Sep 17 00:00:00 2001 From: Neil Anderson Date: Sat, 6 Jan 2018 13:16:31 -0500 Subject: [PATCH 1321/2444] [sql mode] Include LC_CTYPE and LC_COLLATE keywords in x-pgsql The CREATE DATABASE command supports LC_CTYPE and LC_COLLATE keywords as per https://www.postgresql.org/docs/10/static/sql-createdatabase.html. This commit adds them to the postgres sql mode. --- mode/sql/sql.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mode/sql/sql.js b/mode/sql/sql.js index da416f2048..63e87733bf 100644 --- a/mode/sql/sql.js +++ b/mode/sql/sql.js @@ -400,7 +400,7 @@ CodeMirror.defineMode("sql", function(config, parserConfig) { name: "sql", client: set("source"), // https://www.postgresql.org/docs/10/static/sql-keywords-appendix.html - keywords: set(sqlKeywords + "a abort abs absent absolute access according action ada add admin after aggregate all allocate also always analyse analyze any are array array_agg array_max_cardinality asensitive assertion assignment asymmetric at atomic attribute attributes authorization avg backward base64 before begin begin_frame begin_partition bernoulli binary bit_length blob blocked bom both breadth c cache call called cardinality cascade cascaded case cast catalog catalog_name ceil ceiling chain characteristics characters character_length character_set_catalog character_set_name character_set_schema char_length check checkpoint class class_origin clob close cluster coalesce cobol collate collation collation_catalog collation_name collation_schema collect column columns column_name command_function command_function_code comment comments commit committed concurrently condition condition_number configuration conflict connect connection connection_name constraint constraints constraint_catalog constraint_name constraint_schema constructor contains content continue control conversion convert copy corr corresponding cost covar_pop covar_samp cross csv cube cume_dist current current_catalog current_date current_default_transform_group current_path current_role current_row current_schema current_time current_timestamp current_transform_group_for_type current_user cursor cursor_name cycle data database datalink datetime_interval_code datetime_interval_precision day db deallocate dec declare default defaults deferrable deferred defined definer degree delimiter delimiters dense_rank depth deref derived describe descriptor deterministic diagnostics dictionary disable discard disconnect dispatch dlnewcopy dlpreviouscopy dlurlcomplete dlurlcompleteonly dlurlcompletewrite dlurlpath dlurlpathonly dlurlpathwrite dlurlscheme dlurlserver dlvalue do document domain dynamic dynamic_function dynamic_function_code each element else empty enable encoding encrypted end end-exec end_frame end_partition enforced enum equals escape event every except exception exclude excluding exclusive exec execute exists exp explain expression extension external extract false family fetch file filter final first first_value flag float floor following for force foreign fortran forward found frame_row free freeze fs full function functions fusion g general generated get global go goto grant granted greatest grouping groups handler header hex hierarchy hold hour id identity if ignore ilike immediate immediately immutable implementation implicit import including increment indent index indexes indicator inherit inherits initially inline inner inout input insensitive instance instantiable instead integrity intersect intersection invoker isnull isolation k key key_member key_type label lag language large last last_value lateral lead leading leakproof least left length level library like_regex link listen ln load local localtime localtimestamp location locator lock locked logged lower m map mapping match matched materialized max maxvalue max_cardinality member merge message_length message_octet_length message_text method min minute minvalue mod mode modifies module month more move multiset mumps name names namespace national natural nchar nclob nesting new next nfc nfd nfkc nfkd nil no none normalize normalized nothing notify notnull nowait nth_value ntile null nullable nullif nulls number object occurrences_regex octets octet_length of off offset oids old only open operator option options ordering ordinality others out outer output over overlaps overlay overriding owned owner p pad parallel parameter parameter_mode parameter_name parameter_ordinal_position parameter_specific_catalog parameter_specific_name parameter_specific_schema parser partial partition pascal passing passthrough password percent percentile_cont percentile_disc percent_rank period permission placing plans pli policy portion position position_regex power precedes preceding prepare prepared preserve primary prior privileges procedural procedure program public quote range rank read reads reassign recheck recovery recursive ref references referencing refresh regr_avgx regr_avgy regr_count regr_intercept regr_r2 regr_slope regr_sxx regr_sxy regr_syy reindex relative release rename repeatable replace replica requiring reset respect restart restore restrict restricted result return returned_cardinality returned_length returned_octet_length returned_sqlstate returning returns revoke right role rollback rollup routine routine_catalog routine_name routine_schema row rows row_count row_number rule savepoint scale schema schema_name scope scope_catalog scope_name scope_schema scroll search second section security selective self sensitive sequence sequences serializable server server_name session session_user setof sets share show similar simple size skip snapshot some source space specific specifictype specific_name sql sqlcode sqlerror sqlexception sqlstate sqlwarning sqrt stable standalone start state statement static statistics stddev_pop stddev_samp stdin stdout storage strict strip structure style subclass_origin submultiset substring substring_regex succeeds sum symmetric sysid system system_time system_user t tables tablesample tablespace table_name temp template temporary then ties timezone_hour timezone_minute to token top_level_count trailing transaction transactions_committed transactions_rolled_back transaction_active transform transforms translate translate_regex translation treat trigger trigger_catalog trigger_name trigger_schema trim trim_array true truncate trusted type types uescape unbounded uncommitted under unencrypted unique unknown unlink unlisten unlogged unnamed unnest until untyped upper uri usage user user_defined_type_catalog user_defined_type_code user_defined_type_name user_defined_type_schema using vacuum valid validate validator value value_of varbinary variadic var_pop var_samp verbose version versioning view views volatile when whenever whitespace width_bucket window within work wrapper write xmlagg xmlattributes xmlbinary xmlcast xmlcomment xmlconcat xmldeclaration xmldocument xmlelement xmlexists xmlforest xmliterate xmlnamespaces xmlparse xmlpi xmlquery xmlroot xmlschema xmlserialize xmltable xmltext xmlvalidate year yes loop repeat attach path depends detach zone"), + keywords: set(sqlKeywords + "a abort abs absent absolute access according action ada add admin after aggregate all allocate also always analyse analyze any are array array_agg array_max_cardinality asensitive assertion assignment asymmetric at atomic attribute attributes authorization avg backward base64 before begin begin_frame begin_partition bernoulli binary bit_length blob blocked bom both breadth c cache call called cardinality cascade cascaded case cast catalog catalog_name ceil ceiling chain characteristics characters character_length character_set_catalog character_set_name character_set_schema char_length check checkpoint class class_origin clob close cluster coalesce cobol collate collation collation_catalog collation_name collation_schema collect column columns column_name command_function command_function_code comment comments commit committed concurrently condition condition_number configuration conflict connect connection connection_name constraint constraints constraint_catalog constraint_name constraint_schema constructor contains content continue control conversion convert copy corr corresponding cost covar_pop covar_samp cross csv cube cume_dist current current_catalog current_date current_default_transform_group current_path current_role current_row current_schema current_time current_timestamp current_transform_group_for_type current_user cursor cursor_name cycle data database datalink datetime_interval_code datetime_interval_precision day db deallocate dec declare default defaults deferrable deferred defined definer degree delimiter delimiters dense_rank depth deref derived describe descriptor deterministic diagnostics dictionary disable discard disconnect dispatch dlnewcopy dlpreviouscopy dlurlcomplete dlurlcompleteonly dlurlcompletewrite dlurlpath dlurlpathonly dlurlpathwrite dlurlscheme dlurlserver dlvalue do document domain dynamic dynamic_function dynamic_function_code each element else empty enable encoding encrypted end end-exec end_frame end_partition enforced enum equals escape event every except exception exclude excluding exclusive exec execute exists exp explain expression extension external extract false family fetch file filter final first first_value flag float floor following for force foreign fortran forward found frame_row free freeze fs full function functions fusion g general generated get global go goto grant granted greatest grouping groups handler header hex hierarchy hold hour id identity if ignore ilike immediate immediately immutable implementation implicit import including increment indent index indexes indicator inherit inherits initially inline inner inout input insensitive instance instantiable instead integrity intersect intersection invoker isnull isolation k key key_member key_type label lag language large last last_value lateral lc_collate lc_ctype lead leading leakproof least left length level library like_regex link listen ln load local localtime localtimestamp location locator lock locked logged lower m map mapping match matched materialized max maxvalue max_cardinality member merge message_length message_octet_length message_text method min minute minvalue mod mode modifies module month more move multiset mumps name names namespace national natural nchar nclob nesting new next nfc nfd nfkc nfkd nil no none normalize normalized nothing notify notnull nowait nth_value ntile null nullable nullif nulls number object occurrences_regex octets octet_length of off offset oids old only open operator option options ordering ordinality others out outer output over overlaps overlay overriding owned owner p pad parallel parameter parameter_mode parameter_name parameter_ordinal_position parameter_specific_catalog parameter_specific_name parameter_specific_schema parser partial partition pascal passing passthrough password percent percentile_cont percentile_disc percent_rank period permission placing plans pli policy portion position position_regex power precedes preceding prepare prepared preserve primary prior privileges procedural procedure program public quote range rank read reads reassign recheck recovery recursive ref references referencing refresh regr_avgx regr_avgy regr_count regr_intercept regr_r2 regr_slope regr_sxx regr_sxy regr_syy reindex relative release rename repeatable replace replica requiring reset respect restart restore restrict restricted result return returned_cardinality returned_length returned_octet_length returned_sqlstate returning returns revoke right role rollback rollup routine routine_catalog routine_name routine_schema row rows row_count row_number rule savepoint scale schema schema_name scope scope_catalog scope_name scope_schema scroll search second section security selective self sensitive sequence sequences serializable server server_name session session_user setof sets share show similar simple size skip snapshot some source space specific specifictype specific_name sql sqlcode sqlerror sqlexception sqlstate sqlwarning sqrt stable standalone start state statement static statistics stddev_pop stddev_samp stdin stdout storage strict strip structure style subclass_origin submultiset substring substring_regex succeeds sum symmetric sysid system system_time system_user t tables tablesample tablespace table_name temp template temporary then ties timezone_hour timezone_minute to token top_level_count trailing transaction transactions_committed transactions_rolled_back transaction_active transform transforms translate translate_regex translation treat trigger trigger_catalog trigger_name trigger_schema trim trim_array true truncate trusted type types uescape unbounded uncommitted under unencrypted unique unknown unlink unlisten unlogged unnamed unnest until untyped upper uri usage user user_defined_type_catalog user_defined_type_code user_defined_type_name user_defined_type_schema using vacuum valid validate validator value value_of varbinary variadic var_pop var_samp verbose version versioning view views volatile when whenever whitespace width_bucket window within work wrapper write xmlagg xmlattributes xmlbinary xmlcast xmlcomment xmlconcat xmldeclaration xmldocument xmlelement xmlexists xmlforest xmliterate xmlnamespaces xmlparse xmlpi xmlquery xmlroot xmlschema xmlserialize xmltable xmltext xmlvalidate year yes loop repeat attach path depends detach zone"), // https://www.postgresql.org/docs/10/static/datatype.html builtin: set("bigint int8 bigserial serial8 bit varying varbit boolean bool box bytea character char varchar cidr circle date double precision float8 inet integer int int4 interval json jsonb line lseg macaddr macaddr8 money numeric decimal path pg_lsn point polygon real float4 smallint int2 smallserial serial2 serial serial4 text time without zone with timetz timestamp timestamptz tsquery tsvector txid_snapshot uuid xml"), atoms: set("false true null unknown"), From ce2fb7c8ebd31df403264fda8640bf8a1c22df02 Mon Sep 17 00:00:00 2001 From: Shane Liesegang Date: Sun, 7 Jan 2018 11:31:49 -0500 Subject: [PATCH 1322/2444] [markdown mode] xlinkHref status should get copied along with the rest of the state. --- mode/markdown/markdown.js | 1 + 1 file changed, 1 insertion(+) diff --git a/mode/markdown/markdown.js b/mode/markdown/markdown.js index 7dfddccd39..24e2468026 100644 --- a/mode/markdown/markdown.js +++ b/mode/markdown/markdown.js @@ -785,6 +785,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) { formatting: false, linkText: s.linkText, linkTitle: s.linkTitle, + linkHref: s.linkHref, code: s.code, em: s.em, strong: s.strong, From ed9f4e3901bdece6d756ef8c167c026665778005 Mon Sep 17 00:00:00 2001 From: Cristian Prieto Date: Sun, 7 Jan 2018 20:20:42 +0100 Subject: [PATCH 1323/2444] [mllike mode] Add additional OCaml types, ML keywords --- mode/mllike/mllike.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/mode/mllike/mllike.js b/mode/mllike/mllike.js index 90e5b41a63..e25e6627af 100644 --- a/mode/mllike/mllike.js +++ b/mode/mllike/mllike.js @@ -37,7 +37,9 @@ CodeMirror.defineMode('mllike', function(_config, parserConfig) { 'open': 'builtin', 'ignore': 'builtin', 'begin': 'keyword', - 'end': 'keyword' + 'end': 'keyword', + 'when': 'keyword', + 'as': 'keyword' }; var extraWords = parserConfig.extraWords || {}; @@ -174,7 +176,14 @@ CodeMirror.defineMIME('text/x-ocaml', { 'false': 'atom', 'raise': 'keyword', 'module': 'keyword', - 'sig': 'keyword' + 'sig': 'keyword', + 'exception': 'keyword', + 'int': 'builtin', + 'float': 'builtin', + 'char': 'builtin', + 'string': 'builtin', + 'bool': 'builtin', + 'unit': 'builtin' } }); From 45345505a5c16171889aa4f7d3162cee9f806165 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Tue, 9 Jan 2018 12:13:24 +0100 Subject: [PATCH 1324/2444] [sublime bindings] Fix toggleBookMark This had been broken since 5.12 due to a change in the behavior of findMarksAt. Closes #5171 --- keymap/sublime.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/keymap/sublime.js b/keymap/sublime.js index 5925b7c51f..7a9aadd330 100644 --- a/keymap/sublime.js +++ b/keymap/sublime.js @@ -382,7 +382,7 @@ var marks = cm.state.sublimeBookmarks || (cm.state.sublimeBookmarks = []); for (var i = 0; i < ranges.length; i++) { var from = ranges[i].from(), to = ranges[i].to(); - var found = cm.findMarks(from, to); + var found = ranges[i].empty() ? cm.findMarksAt(from) : cm.findMarks(from, to); for (var j = 0; j < found.length; j++) { if (found[j].sublimeBookmark) { found[j].clear(); From 774575d6f05f94cab0ec922f11c2e819906f2d11 Mon Sep 17 00:00:00 2001 From: Cristian Prieto Date: Tue, 9 Jan 2018 16:50:16 +0100 Subject: [PATCH 1325/2444] [mllike mode[ Refactor, add SML MIME * Add common keywords for ML languages * Add builtins for OCaml and F# * Add Standard ML as ML language --- mode/meta.js | 1 + mode/mllike/mllike.js | 202 ++++++++++++++++++++++++++++++++---------- 2 files changed, 154 insertions(+), 49 deletions(-) diff --git a/mode/meta.js b/mode/meta.js index 4ab3e08e3e..298074db21 100644 --- a/mode/meta.js +++ b/mode/meta.js @@ -128,6 +128,7 @@ {name: "Smalltalk", mime: "text/x-stsrc", mode: "smalltalk", ext: ["st"]}, {name: "Smarty", mime: "text/x-smarty", mode: "smarty", ext: ["tpl"]}, {name: "Solr", mime: "text/x-solr", mode: "solr"}, + {name: "SML", mime: "text/x-sml", mode: "mllike", ext: ["sml", "sig", "fun", "smackspec"]}, {name: "Soy", mime: "text/x-soy", mode: "soy", ext: ["soy"], alias: ["closure template"]}, {name: "SPARQL", mime: "application/sparql-query", mode: "sparql", ext: ["rq", "sparql"], alias: ["sparul"]}, {name: "Spreadsheet", mime: "text/x-spreadsheet", mode: "spreadsheet", alias: ["excel", "formula"]}, diff --git a/mode/mllike/mllike.js b/mode/mllike/mllike.js index e25e6627af..7038a33992 100644 --- a/mode/mllike/mllike.js +++ b/mode/mllike/mllike.js @@ -13,33 +13,26 @@ CodeMirror.defineMode('mllike', function(_config, parserConfig) { var words = { - 'let': 'keyword', - 'rec': 'keyword', + 'as': 'keyword', + 'do': 'keyword', + 'else': 'keyword', + 'end': 'keyword', + 'exception': 'keyword', + 'fun': 'keyword', + 'functor': 'keyword', + 'if': 'keyword', 'in': 'keyword', + 'include': 'keyword', + 'let': 'keyword', 'of': 'keyword', - 'and': 'keyword', - 'if': 'keyword', + 'open': 'keyword', + 'rec': 'keyword', + 'struct': 'keyword', 'then': 'keyword', - 'else': 'keyword', - 'for': 'keyword', - 'to': 'keyword', - 'while': 'keyword', - 'do': 'keyword', - 'done': 'keyword', - 'fun': 'keyword', - 'function': 'keyword', - 'val': 'keyword', 'type': 'keyword', - 'mutable': 'keyword', - 'match': 'keyword', - 'with': 'keyword', - 'try': 'keyword', - 'open': 'builtin', - 'ignore': 'builtin', - 'begin': 'keyword', - 'end': 'keyword', - 'when': 'keyword', - 'as': 'keyword' + 'val': 'keyword', + 'while': 'keyword', + 'with': 'keyword' }; var extraWords = parserConfig.extraWords || {}; @@ -70,7 +63,7 @@ CodeMirror.defineMode('mllike', function(_config, parserConfig) { return state.tokenize(stream, state); } } - if (ch === '~') { + if (ch === '~' || ch === '?') { stream.eatWhile(/\w/); return 'variable-2'; } @@ -100,7 +93,7 @@ CodeMirror.defineMode('mllike', function(_config, parserConfig) { } return 'number'; } - if ( /[+\-*&%=<>!?|@]/.test(ch)) { + if ( /[+\-*&%=<>!?|@]?\./.test(ch)) { return 'operator'; } if (/[\w\xa1-\uffff]/.test(ch)) { @@ -167,23 +160,61 @@ CodeMirror.defineMode('mllike', function(_config, parserConfig) { CodeMirror.defineMIME('text/x-ocaml', { name: 'mllike', extraWords: { - 'succ': 'keyword', + 'and': 'keyword', + 'assert': 'keyword', + 'begin': 'keyword', + 'class': 'keyword', + 'constraint': 'keyword', + 'done': 'keyword', + 'downto': 'keyword', + 'external': 'keyword', + 'initializer': 'keyword', + 'lazy': 'keyword', + 'match': 'keyword', + 'method': 'keyword', + 'module': 'keyword', + 'mutable': 'keyword', + 'new': 'keyword', + 'nonrec': 'keyword', + 'object': 'keyword', + 'private': 'keyword', + 'sig': 'keyword', + 'to': 'keyword', + 'try': 'keyword', + 'value': 'keyword', + 'virtual': 'keyword', + 'when': 'keyword', + + // builtins + 'raise': 'builtin', + 'failwith': 'builtin', + 'true': 'builtin', + 'false': 'builtin', + + // Pervasives builtins + 'asr': 'builtin', + 'land': 'builtin', + 'lor': 'builtin', + 'lsl': 'builtin', + 'lsr': 'builtin', + 'lxor': 'builtin', + 'mod': 'builtin', + 'or': 'builtin', + + // More Pervasives + 'raise_notrace': 'builtin', 'trace': 'builtin', 'exit': 'builtin', 'print_string': 'builtin', 'print_endline': 'builtin', - 'true': 'atom', - 'false': 'atom', - 'raise': 'keyword', - 'module': 'keyword', - 'sig': 'keyword', - 'exception': 'keyword', - 'int': 'builtin', - 'float': 'builtin', - 'char': 'builtin', - 'string': 'builtin', - 'bool': 'builtin', - 'unit': 'builtin' + + // Types + 'int': 'atom', + 'float': 'atom', + 'bool': 'atom', + 'char': 'atom', + 'string': 'atom', + 'unit': 'atom', } }); @@ -191,18 +222,21 @@ CodeMirror.defineMIME('text/x-fsharp', { name: 'mllike', extraWords: { 'abstract': 'keyword', - 'as': 'keyword', 'assert': 'keyword', 'base': 'keyword', + 'begin': 'keyword', 'class': 'keyword', 'default': 'keyword', 'delegate': 'keyword', + 'do!': 'keyword', + 'done': 'keyword', 'downcast': 'keyword', 'downto': 'keyword', 'elif': 'keyword', - 'exception': 'keyword', 'extern': 'keyword', 'finally': 'keyword', + 'for': 'keyword', + 'function': 'keyword', 'global': 'keyword', 'inherit': 'keyword', 'inline': 'keyword', @@ -210,38 +244,108 @@ CodeMirror.defineMIME('text/x-fsharp', { 'internal': 'keyword', 'lazy': 'keyword', 'let!': 'keyword', - 'member' : 'keyword', + 'match': 'keyword', + 'member': 'keyword', 'module': 'keyword', + 'mutable': 'keyword', 'namespace': 'keyword', 'new': 'keyword', 'null': 'keyword', 'override': 'keyword', 'private': 'keyword', 'public': 'keyword', - 'return': 'keyword', 'return!': 'keyword', + 'return': 'keyword', 'select': 'keyword', 'static': 'keyword', - 'struct': 'keyword', + 'to': 'keyword', + 'try': 'keyword', 'upcast': 'keyword', - 'use': 'keyword', 'use!': 'keyword', - 'val': 'keyword', + 'use': 'keyword', + 'void': 'keyword', 'when': 'keyword', - 'yield': 'keyword', 'yield!': 'keyword', + 'yield': 'keyword', + + // Reserved words + 'atomic': 'keyword', + 'break': 'keyword', + 'checked': 'keyword', + 'component': 'keyword', + 'const': 'keyword', + 'constraint': 'keyword', + 'constructor': 'keyword', + 'continue': 'keyword', + 'eager': 'keyword', + 'event': 'keyword', + 'external': 'keyword', + 'fixed': 'keyword', + 'method': 'keyword', + 'mixin': 'keyword', + 'object': 'keyword', + 'parallel': 'keyword', + 'process': 'keyword', + 'protected': 'keyword', + 'pure': 'keyword', + 'sealed': 'keyword', + 'tailcall': 'keyword', + 'trait': 'keyword', + 'virtual': 'keyword', + 'volatile': 'keyword', + // builtins 'List': 'builtin', 'Seq': 'builtin', 'Map': 'builtin', 'Set': 'builtin', + 'Option': 'builtin', 'int': 'builtin', 'string': 'builtin', - 'raise': 'builtin', - 'failwith': 'builtin', 'not': 'builtin', 'true': 'builtin', - 'false': 'builtin' + 'false': 'builtin', + + 'raise': 'builtin', + 'failwith': 'builtin' + }, + slashComments: true +}); + + +CodeMirror.defineMIME('text/x-sml', { + name: 'mllike', + extraWords: { + 'abstype': 'keyword', + 'and': 'keyword', + 'andalso': 'keyword', + 'case': 'keyword', + 'datatype': 'keyword', + 'fn': 'keyword', + 'handle': 'keyword', + 'infix': 'keyword', + 'infixr': 'keyword', + 'local': 'keyword', + 'nonfix': 'keyword', + 'op': 'keyword', + 'orelse': 'keyword', + 'raise': 'keyword', + 'withtype': 'keyword', + 'eqtype': 'keyword', + 'sharing': 'keyword', + 'sig': 'keyword', + 'signature': 'keyword', + 'structure': 'keyword', + 'where': 'keyword', + 'true': 'keyword', + 'false': 'keyword', + + // types + 'int': 'builtin', + 'real': 'builtin', + 'string': 'builtin', + 'char': 'builtin', + 'bool': 'builtin' }, slashComments: true }); From e35f5bbc0c147c15460a189e0a8f291020a9ba8c Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Wed, 10 Jan 2018 09:39:04 +0100 Subject: [PATCH 1326/2444] [placeholder plugin] Use editor direction Closes #5174 --- addon/display/placeholder.js | 1 + 1 file changed, 1 insertion(+) diff --git a/addon/display/placeholder.js b/addon/display/placeholder.js index 2f8b1f84ae..65753ebf3f 100644 --- a/addon/display/placeholder.js +++ b/addon/display/placeholder.js @@ -38,6 +38,7 @@ clearPlaceholder(cm); var elt = cm.state.placeholder = document.createElement("pre"); elt.style.cssText = "height: 0; overflow: visible"; + elt.style.direction = cm.getOption("direction"); elt.className = "CodeMirror-placeholder"; var placeHolder = cm.getOption("placeholder") if (typeof placeHolder == "string") placeHolder = document.createTextNode(placeHolder) From 2786ff0a86f32911429351a6aca4cec65e1a5b85 Mon Sep 17 00:00:00 2001 From: neon-dev <1169307+neon-dev@users.noreply.github.com> Date: Mon, 8 Jan 2018 12:55:04 +0100 Subject: [PATCH 1327/2444] [sql-hint addon] Switch order of hints Show column hints (if a defaultTable is set) above table hints, since you are far more often in clauses where you need those. --- addon/hint/sql-hint.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addon/hint/sql-hint.js b/addon/hint/sql-hint.js index f5ec2cac1f..5600c8390d 100644 --- a/addon/hint/sql-hint.js +++ b/addon/hint/sql-hint.js @@ -273,8 +273,8 @@ if (search.charAt(0) == "." || search.charAt(0) == identifierQuote) { start = nameCompletion(cur, token, result, editor); } else { - addMatches(result, search, tables, function(w) {return w;}); addMatches(result, search, defaultTable, function(w) {return w;}); + addMatches(result, search, tables, function(w) {return w;}); if (!disableKeywords) addMatches(result, search, keywords, function(w) {return w.toUpperCase();}); } From 350f71b09d166f1a149514503dc86ff00963faa1 Mon Sep 17 00:00:00 2001 From: neon-dev <1169307+neon-dev@users.noreply.github.com> Date: Mon, 8 Jan 2018 12:50:23 +0100 Subject: [PATCH 1328/2444] [sql-hint addon] Fix nullpointer If you try to autocomplete at line 0, column 0 after previoulsy having edited for example a WHERE clause, the autocompletion triggers with an invalid position, since prevItem is null. Maybe my fix isn't the best solution, and you could even avoid to enter findTableByAlias enitrely, I don't know. --- addon/hint/sql-hint.js | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/addon/hint/sql-hint.js b/addon/hint/sql-hint.js index 5600c8390d..5d20eea625 100644 --- a/addon/hint/sql-hint.js +++ b/addon/hint/sql-hint.js @@ -222,18 +222,20 @@ prevItem = separator[i]; } - var query = doc.getRange(validRange.start, validRange.end, false); - - for (var i = 0; i < query.length; i++) { - var lineText = query[i]; - eachWord(lineText, function(word) { - var wordUpperCase = word.toUpperCase(); - if (wordUpperCase === aliasUpperCase && getTable(previousWord)) - table = previousWord; - if (wordUpperCase !== CONS.ALIAS_KEYWORD) - previousWord = word; - }); - if (table) break; + if (validRange.start) { + var query = doc.getRange(validRange.start, validRange.end, false); + + for (var i = 0; i < query.length; i++) { + var lineText = query[i]; + eachWord(lineText, function(word) { + var wordUpperCase = word.toUpperCase(); + if (wordUpperCase === aliasUpperCase && getTable(previousWord)) + table = previousWord; + if (wordUpperCase !== CONS.ALIAS_KEYWORD) + previousWord = word; + }); + if (table) break; + } } return table; } From dccaafe5200267dc9a2d605c6caee592bfb0408b Mon Sep 17 00:00:00 2001 From: Filype Pereira Date: Sat, 30 Dec 2017 09:52:02 +1300 Subject: [PATCH 1329/2444] [oceanic-next theme] Add --- demo/theme.html | 2 ++ theme/oceanic-next.css | 44 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 theme/oceanic-next.css diff --git a/demo/theme.html b/demo/theme.html index 9194dcea8b..0c52d256d9 100644 --- a/demo/theme.html +++ b/demo/theme.html @@ -34,6 +34,7 @@ + @@ -119,6 +120,7 @@

    Theme Demo

    + diff --git a/theme/oceanic-next.css b/theme/oceanic-next.css new file mode 100644 index 0000000000..296277ba04 --- /dev/null +++ b/theme/oceanic-next.css @@ -0,0 +1,44 @@ +/* + + Name: oceanic-next + Author: Filype Pereira (https://github.com/fpereira1) + + Original oceanic-next color scheme by Dmitri Voronianski (https://github.com/voronianski/oceanic-next-color-scheme) + +*/ + +.cm-s-oceanic-next.CodeMirror { background: #304148; color: #f8f8f2; } +.cm-s-oceanic-next div.CodeMirror-selected { background: rgba(101, 115, 126, 0.33); } +.cm-s-oceanic-next .CodeMirror-line::selection, .cm-s-oceanic-next .CodeMirror-line > span::selection, .cm-s-oceanic-next .CodeMirror-line > span > span::selection { background: rgba(101, 115, 126, 0.33); } +.cm-s-oceanic-next .CodeMirror-line::-moz-selection, .cm-s-oceanic-next .CodeMirror-line > span::-moz-selection, .cm-s-oceanic-next .CodeMirror-line > span > span::-moz-selection { background: rgba(101, 115, 126, 0.33); } +.cm-s-oceanic-next .CodeMirror-gutters { background: #304148; border-right: 10px; } +.cm-s-oceanic-next .CodeMirror-guttermarker { color: white; } +.cm-s-oceanic-next .CodeMirror-guttermarker-subtle { color: #d0d0d0; } +.cm-s-oceanic-next .CodeMirror-linenumber { color: #d0d0d0; } +.cm-s-oceanic-next .CodeMirror-cursor { border-left: 1px solid #f8f8f0; } + +.cm-s-oceanic-next span.cm-comment { color: #65737E; } +.cm-s-oceanic-next span.cm-atom { color: #C594C5; } +.cm-s-oceanic-next span.cm-number { color: #F99157; } + +.cm-s-oceanic-next span.cm-property { color: #99C794; } +.cm-s-oceanic-next span.cm-attribute, +.cm-s-oceanic-next span.cm-keyword { color: #C594C5; } +.cm-s-oceanic-next span.cm-builtin { color: #66d9ef; } +.cm-s-oceanic-next span.cm-string { color: #99C794; } + +.cm-s-oceanic-next span.cm-variable, +.cm-s-oceanic-next span.cm-variable-2, +.cm-s-oceanic-next span.cm-variable-3 { color: #f8f8f2; } +.cm-s-oceanic-next span.cm-def { color: #6699CC; } +.cm-s-oceanic-next span.cm-bracket { color: #5FB3B3; } +.cm-s-oceanic-next span.cm-tag { color: #C594C5; } +.cm-s-oceanic-next span.cm-header { color: #C594C5; } +.cm-s-oceanic-next span.cm-link { color: #C594C5; } +.cm-s-oceanic-next span.cm-error { background: #C594C5; color: #f8f8f0; } + +.cm-s-oceanic-next .CodeMirror-activeline-background { background: rgba(101, 115, 126, 0.33); } +.cm-s-oceanic-next .CodeMirror-matchingbracket { + text-decoration: underline; + color: white !important; +} From e9e5f23b81ec86f84680d8b13ff422408e1a9428 Mon Sep 17 00:00:00 2001 From: overdodactyl Date: Sat, 6 Jan 2018 21:28:00 -0700 Subject: [PATCH 1330/2444] [shadowfox theme] Add --- demo/theme.html | 2 ++ theme/shadowfox.css | 52 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 theme/shadowfox.css diff --git a/demo/theme.html b/demo/theme.html index 0c52d256d9..e01f79a70f 100644 --- a/demo/theme.html +++ b/demo/theme.html @@ -42,6 +42,7 @@ + @@ -128,6 +129,7 @@

    Theme Demo

    + diff --git a/theme/shadowfox.css b/theme/shadowfox.css new file mode 100644 index 0000000000..32d59b139a --- /dev/null +++ b/theme/shadowfox.css @@ -0,0 +1,52 @@ +/* + + Name: shadowfox + Author: overdodactyl (http://github.com/overdodactyl) + + Original shadowfox color scheme by Firefox + +*/ + +.cm-s-shadowfox.CodeMirror { background: #2a2a2e; color: #b1b1b3; } +.cm-s-shadowfox div.CodeMirror-selected { background: #353B48; } +.cm-s-shadowfox .CodeMirror-line::selection, .cm-s-shadowfox .CodeMirror-line > span::selection, .cm-s-shadowfox .CodeMirror-line > span > span::selection { background: #353B48; } +.cm-s-shadowfox .CodeMirror-line::-moz-selection, .cm-s-shadowfox .CodeMirror-line > span::-moz-selection, .cm-s-shadowfox .CodeMirror-line > span > span::-moz-selection { background: #353B48; } +.cm-s-shadowfox .CodeMirror-gutters { background: #0c0c0d ; border-right: 1px solid #0c0c0d; } +.cm-s-shadowfox .CodeMirror-guttermarker { color: #555; } +.cm-s-shadowfox .CodeMirror-linenumber { color: #939393; } +.cm-s-shadowfox .CodeMirror-cursor { border-left: 1px solid #fff; } + +.cm-s-shadowfox span.cm-comment { color: #939393; } +.cm-s-shadowfox span.cm-atom { color: #FF7DE9; } +.cm-s-shadowfox span.cm-quote { color: #FF7DE9; } +.cm-s-shadowfox span.cm-builtin { color: #FF7DE9; } +.cm-s-shadowfox span.cm-attribute { color: #FF7DE9; } +.cm-s-shadowfox span.cm-keyword { color: #FF7DE9; } +.cm-s-shadowfox span.cm-error { color: #FF7DE9; } + +.cm-s-shadowfox span.cm-number { color: #6B89FF; } +.cm-s-shadowfox span.cm-string { color: #6B89FF; } +.cm-s-shadowfox span.cm-string-2 { color: #6B89FF; } + +.cm-s-shadowfox span.cm-meta { color: #939393; } +.cm-s-shadowfox span.cm-hr { color: #939393; } + +.cm-s-shadowfox span.cm-header { color: #75BFFF; } +.cm-s-shadowfox span.cm-qualifier { color: #75BFFF; } +.cm-s-shadowfox span.cm-variable-2 { color: #75BFFF; } + +.cm-s-shadowfox span.cm-property { color: #86DE74; } + +.cm-s-shadowfox span.cm-def { color: #75BFFF; } +.cm-s-shadowfox span.cm-bracket { color: #75BFFF; } +.cm-s-shadowfox span.cm-tag { color: #75BFFF; } +.cm-s-shadowfox span.cm-link:visited { color: #75BFFF; } + +.cm-s-shadowfox span.cm-variable { color: #B98EFF; } +.cm-s-shadowfox span.cm-variable-3 { color: #d7d7db; } +.cm-s-shadowfox span.cm-link { color: #737373; } +.cm-s-shadowfox span.cm-operator { color: #b1b1b3; } +.cm-s-shadowfox span.cm-special { color: #d7d7db; } + +.cm-s-shadowfox .CodeMirror-activeline-background { background: rgba(185, 215, 253, .15) } +.cm-s-shadowfox .CodeMirror-matchingbracket { outline: solid 1px rgba(255, 255, 255, .25); color: white !important; } From e4bf8dff42d80a4bfab366733dfd992b62a66880 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Thu, 11 Jan 2018 08:56:15 +0100 Subject: [PATCH 1331/2444] [closebrackets addon] Avoid annoying behavior when closing a triple-quoted string Issue #5177 --- addon/edit/closebrackets.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addon/edit/closebrackets.js b/addon/edit/closebrackets.js index 460f662f80..86b2fe1c95 100644 --- a/addon/edit/closebrackets.js +++ b/addon/edit/closebrackets.js @@ -129,8 +129,8 @@ else curType = "skip"; } else if (identical && cur.ch > 1 && triples.indexOf(ch) >= 0 && - cm.getRange(Pos(cur.line, cur.ch - 2), cur) == ch + ch && - (cur.ch <= 2 || cm.getRange(Pos(cur.line, cur.ch - 3), Pos(cur.line, cur.ch - 2)) != ch)) { + cm.getRange(Pos(cur.line, cur.ch - 2), cur) == ch + ch) { + if (cur.ch > 2 && /\bstring/.test(cm.getTokenTypeAt(Pos(cur.line, cur.ch - 2)))) return CodeMirror.Pass; curType = "addFour"; } else if (identical) { var prev = cur.ch == 0 ? " " : cm.getRange(Pos(cur.line, cur.ch - 1), cur) From 2a168994fba2a6c9250edb59b7dc56dc46767053 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Fri, 12 Jan 2018 08:26:55 +0100 Subject: [PATCH 1332/2444] [javascript mode] Fix highlighting of TS implements keyword Closes #5178 --- mode/javascript/javascript.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mode/javascript/javascript.js b/mode/javascript/javascript.js index edab99f3d7..29085a21c4 100644 --- a/mode/javascript/javascript.js +++ b/mode/javascript/javascript.js @@ -680,8 +680,10 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { } function classNameAfter(type, value) { if (value == "<") return cont(pushlex(">"), commasep(typeparam, ">"), poplex, classNameAfter) - if (value == "extends" || value == "implements" || (isTS && type == ",")) + if (value == "extends" || value == "implements" || (isTS && type == ",")) { + cx.marked = "keyword"; return cont(isTS ? typeexpr : expression, classNameAfter); + } if (type == "{") return cont(pushlex("}"), classBody, poplex); } function classBody(type, value) { From d89267681d21f46a78a90002a9b18dc95acac1f4 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Fri, 12 Jan 2018 08:36:22 +0100 Subject: [PATCH 1333/2444] [javascript mode] Fix previous patch --- mode/javascript/javascript.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mode/javascript/javascript.js b/mode/javascript/javascript.js index 29085a21c4..64c910d849 100644 --- a/mode/javascript/javascript.js +++ b/mode/javascript/javascript.js @@ -681,7 +681,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { function classNameAfter(type, value) { if (value == "<") return cont(pushlex(">"), commasep(typeparam, ">"), poplex, classNameAfter) if (value == "extends" || value == "implements" || (isTS && type == ",")) { - cx.marked = "keyword"; + if (value == "implements") cx.marked = "keyword"; return cont(isTS ? typeexpr : expression, classNameAfter); } if (type == "{") return cont(pushlex("}"), classBody, poplex); From 4fa785ea875aade5beb64ebc317969f3fb653125 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Sat, 13 Jan 2018 10:34:10 +0100 Subject: [PATCH 1334/2444] [xml-fold addon] Handle line-broken opening tags better No longer creates a fold spot for both lines of a line-broken tag. Closes #5179 --- addon/fold/xml-fold.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addon/fold/xml-fold.js b/addon/fold/xml-fold.js index 08e2149553..3acf952d9d 100644 --- a/addon/fold/xml-fold.js +++ b/addon/fold/xml-fold.js @@ -138,7 +138,7 @@ var iter = new Iter(cm, start.line, 0); for (;;) { var openTag = toNextTag(iter), end; - if (!openTag || iter.line != start.line || !(end = toTagEnd(iter))) return; + if (!openTag || !(end = toTagEnd(iter)) || iter.line != start.line) return; if (!openTag[1] && end != "selfClose") { var startPos = Pos(iter.line, iter.ch); var endPos = findMatchingClose(iter, openTag[2]); From e03ef21df390753eb35ff8426dd99b1be4d29d74 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Sat, 13 Jan 2018 17:52:27 +0100 Subject: [PATCH 1335/2444] [javascript mode] Further improve handling of TS contextual keywords Closes #5180 Closes #5181 --- mode/javascript/javascript.js | 20 +++++++++++++------- mode/javascript/test.js | 10 ++++++++++ 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/mode/javascript/javascript.js b/mode/javascript/javascript.js index 64c910d849..9eb50ba974 100644 --- a/mode/javascript/javascript.js +++ b/mode/javascript/javascript.js @@ -345,15 +345,14 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { if (type == "for") return cont(pushlex("form"), forspec, statement, poplex); if (type == "class" || (isTS && value == "interface")) { cx.marked = "keyword"; return cont(pushlex("form"), className, poplex); } if (type == "variable") { - if (isTS && value == "type") { - cx.marked = "keyword" - return cont(typeexpr, expect("operator"), typeexpr, expect(";")); - } else if (isTS && value == "declare") { + if (isTS && value == "declare") { cx.marked = "keyword" return cont(statement) - } else if (isTS && (value == "module" || value == "enum") && cx.stream.match(/^\s*\w/, false)) { + } else if (isTS && (value == "module" || value == "enum" || value == "type") && cx.stream.match(/^\s*\w/, false)) { cx.marked = "keyword" - return cont(pushlex("form"), pattern, expect("{"), pushlex("}"), block, poplex, poplex) + if (value == "enum") return cont(enumdef); + else if (value == "type") return cont(typeexpr, expect("operator"), typeexpr, expect(";")); + else return cont(pushlex("form"), pattern, expect("{"), pushlex("}"), block, poplex, poplex) } else if (isTS && value == "namespace") { cx.marked = "keyword" return cont(pushlex("form"), expression, block, poplex) @@ -608,7 +607,8 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { function maybeTypeDefault(_, value) { if (value == "=") return cont(typeexpr) } - function vardef() { + function vardef(_, value) { + if (value == "enum") {cx.marked = "keyword"; return cont(enumdef)} return pass(pattern, maybetype, maybeAssign, vardefCont); } function pattern(type, value) { @@ -747,6 +747,12 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { if (type == "]") return cont(); return pass(commasep(expressionNoComma, "]")); } + function enumdef() { + return pass(pushlex("form"), pattern, expect("{"), pushlex("}"), commasep(enummember, "}"), poplex, poplex) + } + function enummember() { + return pass(pattern, maybeAssign); + } function isContinuedStatement(state, textAfter) { return state.lastType == "operator" || state.lastType == "," || diff --git a/mode/javascript/test.js b/mode/javascript/test.js index 167e6d0165..14a5183cab 100644 --- a/mode/javascript/test.js +++ b/mode/javascript/test.js @@ -383,6 +383,16 @@ " }", "}") + TS("type as variable", + "[variable type] [operator =] [variable x] [keyword as] [type Bar];"); + + TS("enum body", + "[keyword export] [keyword const] [keyword enum] [def CodeInspectionResultType] {", + " [def ERROR] [operator =] [string 'problem_type_error'],", + " [def WARNING] [operator =] [string 'problem_type_warning'],", + " [def META],", + "}") + var jsonld_mode = CodeMirror.getMode( {indentUnit: 2}, {name: "javascript", jsonld: true} From 974182466ba8165f15ccc6b5b07b785bcbc39c63 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Wed, 17 Jan 2018 09:37:55 +0100 Subject: [PATCH 1336/2444] [shell mode] Improve handling of quotes inside parentheses Closes #5187 --- mode/shell/shell.js | 23 ++++++++++++++++------- mode/shell/test.js | 3 +++ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/mode/shell/shell.js b/mode/shell/shell.js index 9b8b90b305..9fcd671cf5 100644 --- a/mode/shell/shell.js +++ b/mode/shell/shell.js @@ -84,29 +84,38 @@ CodeMirror.defineMode('shell', function() { function tokenString(quote, style) { var close = quote == "(" ? ")" : quote == "{" ? "}" : quote return function(stream, state) { - var next, end = false, escaped = false; + var next, escaped = false; while ((next = stream.next()) != null) { if (next === close && !escaped) { - end = true; + state.tokens.shift(); break; - } - if (next === '$' && !escaped && quote !== "'") { + } else if (next === '$' && !escaped && quote !== "'") { escaped = true; stream.backUp(1); state.tokens.unshift(tokenDollar); break; - } - if (!escaped && next === quote && quote !== close) { + } else if (!escaped && quote !== close && next === quote) { state.tokens.unshift(tokenString(quote, style)) return tokenize(stream, state) + } else if (!escaped && /['"]/.test(next) && !/['"]/.test(quote)) { + state.tokens.unshift(tokenStringStart(next, "string")); + stream.backUp(1); + break; } escaped = !escaped && next === '\\'; } - if (end) state.tokens.shift(); return style; }; }; + function tokenStringStart(quote, style) { + return function(stream, state) { + state.tokens[0] = tokenString(quote, style) + stream.next() + return tokenize(stream, state) + } + } + var tokenDollar = function(stream, state) { if (state.tokens.length > 1) stream.eat('$'); var ch = stream.next() diff --git a/mode/shell/test.js b/mode/shell/test.js index 86e344c572..05f07d22b1 100644 --- a/mode/shell/test.js +++ b/mode/shell/test.js @@ -61,4 +61,7 @@ MT("nested braces", "[builtin echo] [def ${A[${B}]]}]") + + MT("strings in parens", + "[def FOO][operator =]([quote $(<][string \"][def $MYDIR][string \"][quote /myfile grep ][string 'hello$'][quote )])") })(); From d8d68a8a86cce37fd3b19d0c3025e1a38df20ead Mon Sep 17 00:00:00 2001 From: neon-dev <1169307+neon-dev@users.noreply.github.com> Date: Tue, 16 Jan 2018 14:16:47 +0100 Subject: [PATCH 1337/2444] [javascript-lint addon] Fix incorrect severity When enabling strict equality checks via `lint: {options: {eqeqeq: true}}`, found problems showed up as errors instead of warnings. To fix it, the `fixWith()` logic had to be changed since simply adding the phrase to the warnings array would not have worked. This is because both the warnings and errors array matched this exact error and therefore the severity could never be "warning" (errors were checked after warnings). I didn't include "Missing property name" and "Unmatched " in the new error array since they already are errors with the new logic. "Stopping, unable to continue" also got removed since it didn't appear anywhere in the current jshint.js. For now I've implemented everything to not break previous behavior/hinting, except the strict equality hint severity. Although I want to suggest removing the following codes from the new error array (so they can stay warnings): - W033 (Missing semicolon) - since erroneous missing semicolons have their own code: E058 - W084 (Expected a conditional expression and instead saw an assignment) - since something like `switch (var2 = var1 + 42)` is valid js code, though not recommendable - maybe W023/24/30/90, since there are many more " and instead saw an" hints that are already errors with their own codes, so I think they should be pretty accurate. Unfortunately I couldn't force these warnings so I couldn't check. --- addon/lint/javascript-lint.js | 49 +++++++++++++++++++++++------------ 1 file changed, 32 insertions(+), 17 deletions(-) diff --git a/addon/lint/javascript-lint.js b/addon/lint/javascript-lint.js index c58f785025..f73aaa51a0 100644 --- a/addon/lint/javascript-lint.js +++ b/addon/lint/javascript-lint.js @@ -14,12 +14,20 @@ var bogus = [ "Dangerous comment" ]; - var warnings = [ [ "Expected '{'", + var replacements = [ [ "Expected '{'", "Statement body should be inside '{ }' braces." ] ]; - var errors = [ "Missing semicolon", "Extra comma", "Missing property name", - "Unmatched ", " and instead saw", " is not defined", - "Unclosed string", "Stopping, unable to continue" ]; + var forcedErrorCodes = [ + "W033", // Missing semicolon. + "W070", // Extra comma. (it breaks older versions of IE) + "W112", // Unclosed string. + "W117", // '{a}' is not defined. + "W023", // Expected an identifier in an assignment and instead saw a function invocation. + "W024", // Expected an identifier and instead saw '{a}' (a reserved word). + "W030", // Expected an assignment or function call and instead saw an expression. + "W084", // Expected a conditional expression and instead saw an assignment. + "W095" // Expected a string and instead saw {a}. + ]; function validator(text, options) { if (!window.JSHINT) { @@ -37,29 +45,35 @@ CodeMirror.registerHelper("lint", "javascript", validator); function cleanup(error) { - // All problems are warnings by default - fixWith(error, warnings, "warning", true); - fixWith(error, errors, "error"); + fixWith(error, forcedErrorCodes, replacements); return isBogus(error) ? null : error; } - function fixWith(error, fixes, severity, force) { - var description, fix, find, replace, found; + function fixWith(error, forcedErrorCodes, replacements) { + var errorCode, description, i, fix, find, replace, found; + errorCode = error.code; description = error.description; - for ( var i = 0; i < fixes.length; i++) { - fix = fixes[i]; - find = (typeof fix === "string" ? fix : fix[0]); - replace = (typeof fix === "string" ? null : fix[1]); + if (error.severity !== "error") { + for (i = 0; i < forcedErrorCodes.length; i++) { + if (errorCode === forcedErrorCodes[i]) { + error.severity = "error"; + break; + } + } + } + + for (i = 0; i < replacements.length; i++) { + fix = replacements[i]; + find = fix[0]; found = description.indexOf(find) !== -1; - if (force || found) { - error.severity = severity; - } - if (found && replace) { + if (found) { + replace = fix[1]; error.description = replace; + break; } } } @@ -128,6 +142,7 @@ error.description = error.reason;// + "(jshint)"; error.start = error.character; error.end = end; + error.severity = error.code.startsWith('W') ? "warning" : "error"; error = cleanup(error); if (error) From dac3bdec7a5678c9adedfe3d8f2ce86f9823361c Mon Sep 17 00:00:00 2001 From: neon-dev <1169307+neon-dev@users.noreply.github.com> Date: Tue, 16 Jan 2018 16:08:53 +0100 Subject: [PATCH 1338/2444] [javascript-lint addon] Remove obsolete function --- addon/lint/javascript-lint.js | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/addon/lint/javascript-lint.js b/addon/lint/javascript-lint.js index f73aaa51a0..a6d31210a2 100644 --- a/addon/lint/javascript-lint.js +++ b/addon/lint/javascript-lint.js @@ -12,8 +12,6 @@ "use strict"; // declare global: JSHINT - var bogus = [ "Dangerous comment" ]; - var replacements = [ [ "Expected '{'", "Statement body should be inside '{ }' braces." ] ]; @@ -46,8 +44,6 @@ function cleanup(error) { fixWith(error, forcedErrorCodes, replacements); - - return isBogus(error) ? null : error; } function fixWith(error, forcedErrorCodes, replacements) { @@ -78,16 +74,6 @@ } } - function isBogus(error) { - var description = error.description; - for ( var i = 0; i < bogus.length; i++) { - if (description.indexOf(bogus[i]) !== -1) { - return true; - } - } - return false; - } - function parseErrors(errors, output) { for ( var i = 0; i < errors.length; i++) { var error = errors[i]; @@ -143,7 +129,7 @@ error.start = error.character; error.end = end; error.severity = error.code.startsWith('W') ? "warning" : "error"; - error = cleanup(error); + cleanup(error); if (error) output.push({message: error.description, From 81391e6ad9b30d1238d10843325ef375e5f91356 Mon Sep 17 00:00:00 2001 From: neon-dev <1169307+neon-dev@users.noreply.github.com> Date: Wed, 17 Jan 2018 11:37:47 +0100 Subject: [PATCH 1339/2444] [lint demo] Use a more recent version of JSHint --- demo/lint.html | 2 +- demo/widget.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/demo/lint.html b/demo/lint.html index 96009b4e1f..2a1c30b47d 100644 --- a/demo/lint.html +++ b/demo/lint.html @@ -9,7 +9,7 @@ - + diff --git a/demo/widget.html b/demo/widget.html index da39a9297a..58ebb4d97a 100644 --- a/demo/widget.html +++ b/demo/widget.html @@ -7,7 +7,7 @@ - +
    From c8c4565d09f240afc33a31561e42943dfeee4784 Mon Sep 17 00:00:00 2001 From: Bin Ni Date: Mon, 20 Jul 2020 13:09:25 -0700 Subject: [PATCH 1980/2444] [show-hint addon] Introduced option 'scrollMargin' --- addon/hint/show-hint.js | 12 +++++++----- doc/manual.html | 3 +++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/addon/hint/show-hint.js b/addon/hint/show-hint.js index c55deab3a6..cd0d6a7bd5 100644 --- a/addon/hint/show-hint.js +++ b/addon/hint/show-hint.js @@ -379,12 +379,14 @@ }, scrollToActive: function() { - var node = this.hints.childNodes[this.selectedHint] + var margin = this.completion.options.scrollMargin || 0; + var node1 = this.hints.childNodes[Math.max(0, this.selectedHint - margin)]; + var node2 = this.hints.childNodes[Math.min(this.data.list.length - 1, this.selectedHint + margin)]; var firstNode = this.hints.firstChild; - if (node.offsetTop < this.hints.scrollTop) - this.hints.scrollTop = node.offsetTop - firstNode.offsetTop; - else if (node.offsetTop + node.offsetHeight > this.hints.scrollTop + this.hints.clientHeight) - this.hints.scrollTop = node.offsetTop + node.offsetHeight - this.hints.clientHeight + firstNode.offsetTop; + if (node1.offsetTop < this.hints.scrollTop) + this.hints.scrollTop = node1.offsetTop - firstNode.offsetTop; + else if (node2.offsetTop + node2.offsetHeight > this.hints.scrollTop + this.hints.clientHeight) + this.hints.scrollTop = node2.offsetTop + node2.offsetHeight - this.hints.clientHeight + firstNode.offsetTop; }, screenAmount: function() { diff --git a/doc/manual.html b/doc/manual.html index a76378470d..1bcd395e63 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -2790,6 +2790,9 @@

    Addons

    Like customKeys above, but the bindings will be added to the set of default bindings, instead of replacing them.
    +
    scrollMargin: integer
    +
    Show this many lines before and after the selected item. + Default is 0.
    The following events will be fired on the completions object during completion: From 772d09e697612889ec5dbed2cc058e754232c29d Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Mon, 20 Jul 2020 22:28:58 +0200 Subject: [PATCH 1981/2444] Mark version 5.56.0 --- AUTHORS | 2 ++ CHANGELOG.md | 20 +++++++++++++++++++- doc/manual.html | 2 +- doc/releases.html | 12 ++++++++++++ index.html | 2 +- package.json | 2 +- src/edit/main.js | 2 +- 7 files changed, 37 insertions(+), 5 deletions(-) diff --git a/AUTHORS b/AUTHORS index f041a0572a..a9e79126b6 100644 --- a/AUTHORS +++ b/AUTHORS @@ -441,6 +441,7 @@ jwallers@gmail.com kaniga karevn Karol +Kaushik Kulkarni Kayur Patel Kazuhito Hokamura kcwiakala @@ -657,6 +658,7 @@ Patrick Strawderman Paul Garvin Paul Ivanov Paul Masson +Paul Schmidt Pavel Pavel Feldman Pavel Petržela diff --git a/CHANGELOG.md b/CHANGELOG.md index b87340b524..13039b9701 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,22 @@ -## 5.55.0 (2020-05-20) +## 5.56.0 (2020-07-20) + +### Bug fixes + +Line-wise pasting was fixed on Chrome Windows. + +[wast mode](https://codemirror.net/mode/wast/): Follow standard changes. + +[soy mode](https://codemirror.net/mode/soy/): Support import expressions, template type, and loop indices. + +[sql-hint addon](https://codemirror.net/doc/manual.html#addon_sql-hint): Improve handling of double quotes. + +### New features + +[show-hint addon](https://codemirror.net/doc/manual.html#addon_show-hint): New option `scrollMargin` to control how many options are visible beyond the selected one. + +[hardwrap addon](https://codemirror.net/doc/manual.html#addon_hardwrap): New option `forceBreak` to disable breaking of words that are longer than a line. + +## 5.55.0 (2020-06-21) ### Bug fixes diff --git a/doc/manual.html b/doc/manual.html index 1bcd395e63..ba46c099f0 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -70,7 +70,7 @@

    User manual and reference guide - version 5.55.0 + version 5.56.0

    CodeMirror is a code-editor component that can be embedded in diff --git a/doc/releases.html b/doc/releases.html index fd02a7fbd9..6ab175a7b3 100644 --- a/doc/releases.html +++ b/doc/releases.html @@ -30,6 +30,18 @@

    Release notes and version history

    Version 5.x

    +

    20-07-2020: Version 5.56.0:

    + +
      +
    • Line-wise pasting was fixed on Chrome Windows.
    • +
    • wast mode: Follow standard changes.
    • +
    • soy mode: Support import expressions, template type, and loop indices.
    • +
    • sql-hint addon: Improve handling of double quotes.
    • +
    • New features

    • +
    • show-hint addon: New option scrollMargin to control how many options are visible beyond the selected one.
    • +
    • hardwrap addon: New option forceBreak to disable breaking of words that are longer than a line.
    • +
    +

    21-06-2020: Version 5.55.0:

      diff --git a/index.html b/index.html index 27cf8fc7fe..8ee9b384b2 100644 --- a/index.html +++ b/index.html @@ -99,7 +99,7 @@

      This is CodeMirror

    - Get the current version: 5.55.0.
    + Get the current version: 5.56.0.
    You can see the code,
    read the release notes,
    or study the user manual. diff --git a/package.json b/package.json index dcffa6d998..374bd877d2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "codemirror", - "version": "5.55.0", + "version": "5.56.0", "main": "lib/codemirror.js", "style": "lib/codemirror.css", "author": { diff --git a/src/edit/main.js b/src/edit/main.js index 04efb81564..3b378e8f33 100644 --- a/src/edit/main.js +++ b/src/edit/main.js @@ -66,4 +66,4 @@ import { addLegacyProps } from "./legacy.js" addLegacyProps(CodeMirror) -CodeMirror.version = "5.55.0" +CodeMirror.version = "5.56.0" From fdbc04a94a3b0064b896effa6da6544f1c2bb39a Mon Sep 17 00:00:00 2001 From: Howard Date: Thu, 23 Jul 2020 14:45:56 -0400 Subject: [PATCH 1982/2444] [vim bindings] Support tag text objects in xml / htmlmixed mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit User can use `t` to operate on tag text objects. For example, given the following html: ```
    hello world!
    ``` If the user's cursor (denoted by █) is inside "hello world!": ```
    hello█world!
    ``` And they enter `dit` (delete inner tag), then the text inside the enclosing tag is deleted -- the following is the expected result: ```
    ``` If they enter `dat` (delete around tag), then the surrounding tags are deleted as well: ```
    ``` This logic depends on the following: - mode/xml/xml.js - addon/fold/xml-fold.js - editor is in htmlmixedmode / xml mode Caveats This is _NOT_ a 100% accurate implementation of vim tag text objects. For example, the following cases noop / are inconsistent with vim behavior: - Does not work inside comments: ``` ``` - Does not work when tags have different cases: ```
    broken
    ``` - Does not work when inside a broken tag: ```
    ``` This addresses #3828. --- keymap/vim.js | 47 ++++++++++++++++++++++++++++++++++++++++++++++- test/index.html | 1 + test/vim_test.js | 30 ++++++++++++++++++++++++++++-- 3 files changed, 75 insertions(+), 3 deletions(-) diff --git a/keymap/vim.js b/keymap/vim.js index bca6d46d72..5a4860c65a 100644 --- a/keymap/vim.js +++ b/keymap/vim.js @@ -2069,6 +2069,8 @@ if (operatorArgs) { operatorArgs.linewise = true; } tmp.end.line--; } + } else if (character === 't') { + tmp = expandTagUnderCursor(cm, head, inclusive); } else { // No text object defined for this, don't move. return null; @@ -3295,6 +3297,49 @@ return { start: Pos(cur.line, start), end: Pos(cur.line, end) }; } + /** + * Depends on the following: + * + * - editor mode should be htmlmixedmode / xml + * - mode/xml/xml.js should be loaded + * - addon/fold/xml-fold.js should be loaded + * + * If any of the above requirements are not true, this function noops. + * + * This is _NOT_ a 100% accurate implementation of vim tag text objects. + * The following caveats apply (based off cursory testing, I'm sure there + * are other discrepancies): + * + * - Does not work inside comments: + * ``` + * + * ``` + * - Does not work when tags have different cases: + * ``` + *
    broken
    + * ``` + * - Does not work when cursor is inside a broken tag: + * ``` + *
    + * ``` + */ + function expandTagUnderCursor(cm, head, inclusive) { + var cur = head; + if (!CodeMirror.findMatchingTag || !CodeMirror.findEnclosingTag) { + return { start: cur, end: cur }; + } + + var tags = CodeMirror.findMatchingTag(cm, head) || CodeMirror.findEnclosingTag(cm, head); + if (!tags || !tags.open || !tags.close) { + return { start: cur, end: cur }; + } + + if (inclusive) { + return { start: tags.open.from, end: tags.close.to }; + } + return { start: tags.open.to, end: tags.close.from }; + } + function recordJumpPosition(cm, oldCur, newCur) { if (!cursorEqual(oldCur, newCur)) { vimGlobalState.jumpList.add(cm, oldCur, newCur); @@ -3836,7 +3881,7 @@ return Pos(curr_index.ln, curr_index.pos); } - // TODO: perhaps this finagling of start and end positions belonds + // TODO: perhaps this finagling of start and end positions belongs // in codemirror/replaceRange? function selectCompanionObject(cm, head, symb, inclusive) { var cur = head, start, end; diff --git a/test/index.html b/test/index.html index b68ce18964..6566fc436e 100644 --- a/test/index.html +++ b/test/index.html @@ -156,6 +156,7 @@

    Test Suite

    + diff --git a/test/vim_test.js b/test/vim_test.js index 71284bdf59..57d276e871 100644 --- a/test/vim_test.js +++ b/test/vim_test.js @@ -1317,9 +1317,13 @@ testVim('=', function(cm, vim, helpers) { eq(expectedValue, cm.getValue()); }, { value: ' word1\n word2\n word3', indentUnit: 2 }); -// Edit tests -function testEdit(name, before, pos, edit, after) { +// Edit tests - configureCm is an optional argument that gives caller +// access to the cm object. +function testEdit(name, before, pos, edit, after, configureCm) { return testVim(name, function(cm, vim, helpers) { + if (configureCm) { + configureCm(cm); + } var ch = before.search(pos) var line = before.substring(0, ch).split('\n').length - 1; if (line) { @@ -1424,6 +1428,28 @@ testEdit('di>_middle_spc', 'a\t<\n\tbar\n>b', /r/, 'di>', 'a\t<>b'); testEdit('da<_middle_spc', 'a\t<\n\tbar\n>b', /r/, 'da<', 'a\tb'); testEdit('da>_middle_spc', 'a\t<\n\tbar\n>b', /r/, 'da>', 'a\tb'); +// deleting tag objects +testEdit('dat_noop', 'hello', /n/, 'dat', 'hello'); +testEdit('dat_open_tag', 'hello', /n/, 'dat', '', function(cm) { + cm.setOption('mode', 'xml'); +}); +testEdit('dat_inside_tag', 'hello', /l/, 'dat', '', function(cm) { + cm.setOption('mode', 'xml'); +}); +testEdit('dat_close_tag', 'hello', /\//, 'dat', '', function(cm) { + cm.setOption('mode', 'xml'); +}); + +testEdit('dit_open_tag', 'hello', /n/, 'dit', '', function(cm) { + cm.setOption('mode', 'xml'); +}); +testEdit('dit_inside_tag', 'hello', /l/, 'dit', '', function(cm) { + cm.setOption('mode', 'xml'); +}); +testEdit('dit_close_tag', 'hello', /\//, 'dit', '', function(cm) { + cm.setOption('mode', 'xml'); +}); + function testSelection(name, before, pos, keys, sel) { return testVim(name, function(cm, vim, helpers) { var ch = before.search(pos) From 3e3c21cbe5d10ac14ab69c16da5a0fa035a22b33 Mon Sep 17 00:00:00 2001 From: Haoran Yu Date: Thu, 30 Jul 2020 15:42:44 +0800 Subject: [PATCH 1983/2444] [real-world uses] Add CodeMirror-Record (#6360) --- doc/realworld.html | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/realworld.html b/doc/realworld.html index a08d754550..1cde8ace62 100644 --- a/doc/realworld.html +++ b/doc/realworld.html @@ -52,6 +52,7 @@

    CodeMirror real-world uses

  • CodeFights (practice programming)
  • CodeMirror Eclipse (embed CM in Eclipse)
  • CodeMirror movie (scripted editing demos)
  • +
  • CodeMirror Record (codemirror activity recording and playback)
  • CodeMirror2-GWT (Google Web Toolkit wrapper)
  • Code Monster & Code Maven (learning environment)
  • Codepen (gallery of animations)
  • From 68d4da261d1e24b744773467b4d06c62c965b34a Mon Sep 17 00:00:00 2001 From: orionlee Date: Thu, 30 Jul 2020 21:32:35 -0700 Subject: [PATCH 1984/2444] [real-world uses] Add Violentmonkey --- doc/realworld.html | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/realworld.html b/doc/realworld.html index 1cde8ace62..bb2dc7f8b3 100644 --- a/doc/realworld.html +++ b/doc/realworld.html @@ -182,6 +182,7 @@

    CodeMirror real-world uses

  • TurboPY (web publishing framework)
  • UmpleOnline (model-oriented programming tool)
  • Upsource (code browser and review tool)
  • +
  • Violentmonkey (userscript manager / editor)
  • Waliki (wiki engine)
  • Wamer (web application builder)
  • webappfind (windows file bindings for webapps)
  • From 5bff5502c813ef773c0a6a47a7c761d017f0361d Mon Sep 17 00:00:00 2001 From: orionlee Date: Thu, 30 Jul 2020 20:52:29 -0700 Subject: [PATCH 1985/2444] [css] add missing 1) property all, 2) media feature prefers-color-scheme --- mode/css/css.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mode/css/css.js b/mode/css/css.js index 441ba4abfd..85f1bdc767 100644 --- a/mode/css/css.js +++ b/mode/css/css.js @@ -442,17 +442,18 @@ CodeMirror.defineMode("css", function(config, parserConfig) { "monochrome", "min-monochrome", "max-monochrome", "resolution", "min-resolution", "max-resolution", "scan", "grid", "orientation", "device-pixel-ratio", "min-device-pixel-ratio", "max-device-pixel-ratio", - "pointer", "any-pointer", "hover", "any-hover" + "pointer", "any-pointer", "hover", "any-hover", "prefers-color-scheme" ], mediaFeatures = keySet(mediaFeatures_); var mediaValueKeywords_ = [ "landscape", "portrait", "none", "coarse", "fine", "on-demand", "hover", - "interlace", "progressive" + "interlace", "progressive", + "dark", "light" ], mediaValueKeywords = keySet(mediaValueKeywords_); var propertyKeywords_ = [ "align-content", "align-items", "align-self", "alignment-adjust", - "alignment-baseline", "anchor-point", "animation", "animation-delay", + "alignment-baseline", "all", "anchor-point", "animation", "animation-delay", "animation-direction", "animation-duration", "animation-fill-mode", "animation-iteration-count", "animation-name", "animation-play-state", "animation-timing-function", "appearance", "azimuth", "backdrop-filter", From fd3e439fd07121b58e2efd4b7c92ee1201d9be64 Mon Sep 17 00:00:00 2001 From: Lucas Buchala Date: Thu, 6 Aug 2020 03:38:54 -0300 Subject: [PATCH 1986/2444] [mode meta] Escape dot in mode's filename regex --- mode/meta.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mode/meta.js b/mode/meta.js index 9f64f41048..d3efdc172f 100644 --- a/mode/meta.js +++ b/mode/meta.js @@ -24,7 +24,7 @@ {name: "Clojure", mime: "text/x-clojure", mode: "clojure", ext: ["clj", "cljc", "cljx"]}, {name: "ClojureScript", mime: "text/x-clojurescript", mode: "clojure", ext: ["cljs"]}, {name: "Closure Stylesheets (GSS)", mime: "text/x-gss", mode: "css", ext: ["gss"]}, - {name: "CMake", mime: "text/x-cmake", mode: "cmake", ext: ["cmake", "cmake.in"], file: /^CMakeLists.txt$/}, + {name: "CMake", mime: "text/x-cmake", mode: "cmake", ext: ["cmake", "cmake.in"], file: /^CMakeLists\.txt$/}, {name: "CoffeeScript", mimes: ["application/vnd.coffeescript", "text/coffeescript", "text/x-coffeescript"], mode: "coffeescript", ext: ["coffee"], alias: ["coffee", "coffee-script"]}, {name: "Common Lisp", mime: "text/x-common-lisp", mode: "commonlisp", ext: ["cl", "lisp", "el"], alias: ["lisp"]}, {name: "Cypher", mime: "application/x-cypher-query", mode: "cypher", ext: ["cyp", "cypher"]}, @@ -55,7 +55,7 @@ {name: "F#", mime: "text/x-fsharp", mode: "mllike", ext: ["fs"], alias: ["fsharp"]}, {name: "Gas", mime: "text/x-gas", mode: "gas", ext: ["s"]}, {name: "Gherkin", mime: "text/x-feature", mode: "gherkin", ext: ["feature"]}, - {name: "GitHub Flavored Markdown", mime: "text/x-gfm", mode: "gfm", file: /^(readme|contributing|history).md$/i}, + {name: "GitHub Flavored Markdown", mime: "text/x-gfm", mode: "gfm", file: /^(readme|contributing|history)\.md$/i}, {name: "Go", mime: "text/x-go", mode: "go", ext: ["go"]}, {name: "Groovy", mime: "text/x-groovy", mode: "groovy", ext: ["groovy", "gradle"], file: /^Jenkinsfile$/}, {name: "HAML", mime: "text/x-haml", mode: "haml", ext: ["haml"]}, From 26b739ffef2187ce942474cef4a636e9c65f9294 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Fri, 7 Aug 2020 17:44:41 +0200 Subject: [PATCH 1987/2444] [comment addon] Keep selection in front of closing marker when block-commenting ... with fullLines==false when the end of the selection is directly on the closing marker. Closes #6375 --- addon/comment/comment.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addon/comment/comment.js b/addon/comment/comment.js index 8394e85a4d..dac48d0387 100644 --- a/addon/comment/comment.js +++ b/addon/comment/comment.js @@ -13,7 +13,7 @@ var noOptions = {}; var nonWS = /[^\s\u00a0]/; - var Pos = CodeMirror.Pos; + var Pos = CodeMirror.Pos, cmp = CodeMirror.cmpPos; function firstNonWS(str) { var found = str.search(nonWS); @@ -126,7 +126,9 @@ if (i != end || lastLineHasText) self.replaceRange(lead + pad, Pos(i, 0)); } else { + var atCursor = cmp(self.getCursor("to"), to) == 0, empty = !self.somethingSelected() self.replaceRange(endString, to); + if (atCursor) self.setSelection(empty ? to : self.getCursor("from"), to) self.replaceRange(startString, from); } }); From def6f5b125a77607085ce17c371e0995be96832a Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Sat, 8 Aug 2020 10:15:34 +0200 Subject: [PATCH 1988/2444] [julia mode] Make sure dedent tokens end in a word boundary Closes #6376 --- mode/julia/julia.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mode/julia/julia.js b/mode/julia/julia.js index 2aadf36724..f1d2cd5c4b 100644 --- a/mode/julia/julia.js +++ b/mode/julia/julia.js @@ -401,8 +401,8 @@ CodeMirror.defineMode("julia", function(config, parserConf) { indent: function(state, textAfter) { var delta = 0; - if ( textAfter === ']' || textAfter === ')' || /^end/.test(textAfter) || - /^else/.test(textAfter) || /^catch/.test(textAfter) || /^elseif/.test(textAfter) || + if ( textAfter === ']' || textAfter === ')' || /^end\b/.test(textAfter) || + /^else/.test(textAfter) || /^catch\b/.test(textAfter) || /^elseif\b/.test(textAfter) || /^finally/.test(textAfter) ) { delta = -1; } From a2e86b6211518abd2bd1820e4810edf461fdee9a Mon Sep 17 00:00:00 2001 From: orionlee Date: Sat, 1 Aug 2020 13:14:49 -0700 Subject: [PATCH 1989/2444] [css mode] Add missing standard property names per MDN --- mode/css/css.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/mode/css/css.js b/mode/css/css.js index 85f1bdc767..e7e5dca837 100644 --- a/mode/css/css.js +++ b/mode/css/css.js @@ -504,7 +504,9 @@ CodeMirror.defineMode("css", function(config, parserConfig) { "list-style-image", "list-style-position", "list-style-type", "margin", "margin-bottom", "margin-left", "margin-right", "margin-top", "marks", "marquee-direction", "marquee-loop", "marquee-play-count", "marquee-speed", - "marquee-style", "max-block-size", "max-height", "max-inline-size", + "marquee-style", "mask-clip", "mask-composite", "mask-image", "mask-mode", + "mask-origin", "mask-position", "mask-repeat", "mask-size","mask-type", + "max-block-size", "max-height", "max-inline-size", "max-width", "min-block-size", "min-height", "min-inline-size", "min-width", "mix-blend-mode", "move-to", "nav-down", "nav-index", "nav-left", "nav-right", "nav-up", "object-fit", "object-position", "offset", "offset-anchor", @@ -541,7 +543,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) { "text-height", "text-indent", "text-justify", "text-orientation", "text-outline", "text-overflow", "text-rendering", "text-shadow", "text-size-adjust", "text-space-collapse", "text-transform", - "text-underline-position", "text-wrap", "top", "transform", "transform-origin", + "text-underline-position", "text-wrap", "top", "touch-action", "transform", "transform-origin", "transform-style", "transition", "transition-delay", "transition-duration", "transition-property", "transition-timing-function", "translate", "unicode-bidi", "user-select", "vertical-align", "visibility", "voice-balance", @@ -553,11 +555,11 @@ CodeMirror.defineMode("css", function(config, parserConfig) { "flood-opacity", "lighting-color", "stop-color", "stop-opacity", "pointer-events", "color-interpolation", "color-interpolation-filters", "color-rendering", "fill", "fill-opacity", "fill-rule", "image-rendering", - "marker", "marker-end", "marker-mid", "marker-start", "shape-rendering", "stroke", + "marker", "marker-end", "marker-mid", "marker-start", "paint-order", "shape-rendering", "stroke", "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin", "stroke-miterlimit", "stroke-opacity", "stroke-width", "text-rendering", "baseline-shift", "dominant-baseline", "glyph-orientation-horizontal", - "glyph-orientation-vertical", "text-anchor", "writing-mode" + "glyph-orientation-vertical", "text-anchor", "writing-mode", ], propertyKeywords = keySet(propertyKeywords_); var nonStandardPropertyKeywords_ = [ @@ -725,8 +727,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) { var maybeEnd = false, ch; while ((ch = stream.next()) != null) { if (maybeEnd && ch == "/") { - state.tokenize = null; - break; + state.tokenize = null; break; } maybeEnd = (ch == "*"); } From 1ac4e320224eb00643129e29f4800edbe77d9f49 Mon Sep 17 00:00:00 2001 From: orionlee Date: Sat, 1 Aug 2020 14:00:07 -0700 Subject: [PATCH 1990/2444] [css] missing CSS property values - for mask-image, mask-origin, touch-action just added --- mode/css/css.js | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/mode/css/css.js b/mode/css/css.js index e7e5dca837..77ca0c10e2 100644 --- a/mode/css/css.js +++ b/mode/css/css.js @@ -626,7 +626,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) { "after-white-space", "ahead", "alias", "all", "all-scroll", "alphabetic", "alternate", "always", "amharic", "amharic-abegede", "antialiased", "appworkspace", "arabic-indic", "armenian", "asterisks", "attr", "auto", "auto-flow", "avoid", "avoid-column", "avoid-page", - "avoid-region", "background", "backwards", "baseline", "below", "bidi-override", "binary", + "avoid-region", "axis-pan", "background", "backwards", "baseline", "below", "bidi-override", "binary", "bengali", "blink", "block", "block-axis", "bold", "bolder", "border", "border-box", "both", "bottom", "break", "break-all", "break-word", "bullets", "button", "button-bevel", "buttonface", "buttonhighlight", "buttonshadow", "buttontext", "calc", "cambodian", @@ -650,7 +650,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) { "ethiopic-halehame-sid-et", "ethiopic-halehame-so-et", "ethiopic-halehame-ti-er", "ethiopic-halehame-ti-et", "ethiopic-halehame-tig", "ethiopic-numeric", "ew-resize", "exclusion", "expanded", "extends", "extra-condensed", - "extra-expanded", "fantasy", "fast", "fill", "fixed", "flat", "flex", "flex-end", "flex-start", "footnotes", + "extra-expanded", "fantasy", "fast", "fill", "fill-box", "fixed", "flat", "flex", "flex-end", "flex-start", "footnotes", "forwards", "from", "geometricPrecision", "georgian", "graytext", "grid", "groove", "gujarati", "gurmukhi", "hand", "hangul", "hangul-consonant", "hard-light", "hebrew", "help", "hidden", "hide", "higher", "highlight", "highlighttext", @@ -665,7 +665,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) { "line-through", "linear", "linear-gradient", "lines", "list-item", "listbox", "listitem", "local", "logical", "loud", "lower", "lower-alpha", "lower-armenian", "lower-greek", "lower-hexadecimal", "lower-latin", "lower-norwegian", - "lower-roman", "lowercase", "ltr", "luminosity", "malayalam", "match", "matrix", "matrix3d", + "lower-roman", "lowercase", "ltr", "luminosity", "malayalam", "manipulation", "match", "matrix", "matrix3d", "media-controls-background", "media-current-time-display", "media-fullscreen-button", "media-mute-button", "media-play-button", "media-return-to-realtime-button", "media-rewind-button", @@ -674,13 +674,13 @@ CodeMirror.defineMode("css", function(config, parserConfig) { "media-volume-slider-container", "media-volume-sliderthumb", "medium", "menu", "menulist", "menulist-button", "menulist-text", "menulist-textfield", "menutext", "message-box", "middle", "min-intrinsic", - "mix", "mongolian", "monospace", "move", "multiple", "multiply", "myanmar", "n-resize", + "mix", "mongolian", "monospace", "move", "multiple", "multiple_mask_images", "multiply", "myanmar", "n-resize", "narrower", "ne-resize", "nesw-resize", "no-close-quote", "no-drop", "no-open-quote", "no-repeat", "none", "normal", "not-allowed", "nowrap", "ns-resize", "numbers", "numeric", "nw-resize", "nwse-resize", "oblique", "octal", "opacity", "open-quote", "optimizeLegibility", "optimizeSpeed", "oriya", "oromo", "outset", "outside", "outside-shape", "overlay", "overline", "padding", "padding-box", - "painted", "page", "paused", "persian", "perspective", "plus-darker", "plus-lighter", + "painted", "page", "paused", "persian", "perspective", "pinch-zoom", "plus-darker", "plus-lighter", "pointer", "polygon", "portrait", "pre", "pre-line", "pre-wrap", "preserve-3d", "progress", "push-button", "radial-gradient", "radio", "read-only", "read-write", "read-write-plaintext-only", "rectangle", "region", @@ -698,8 +698,8 @@ CodeMirror.defineMode("css", function(config, parserConfig) { "slider-vertical", "sliderthumb-horizontal", "sliderthumb-vertical", "slow", "small", "small-caps", "small-caption", "smaller", "soft-light", "solid", "somali", "source-atop", "source-in", "source-out", "source-over", "space", "space-around", "space-between", "space-evenly", "spell-out", "square", - "square-button", "start", "static", "status-bar", "stretch", "stroke", "sub", - "subpixel-antialiased", "super", "sw-resize", "symbolic", "symbols", "system-ui", "table", + "square-button", "start", "static", "status-bar", "stretch", "stroke", "stroke-box", "sub", + "subpixel-antialiased", "svg_masks", "super", "sw-resize", "symbolic", "symbols", "system-ui", "table", "table-caption", "table-cell", "table-column", "table-column-group", "table-footer-group", "table-header-group", "table-row", "table-row-group", "tamil", @@ -709,10 +709,10 @@ CodeMirror.defineMode("css", function(config, parserConfig) { "tigrinya-er-abegede", "tigrinya-et", "tigrinya-et-abegede", "to", "top", "trad-chinese-formal", "trad-chinese-informal", "transform", "translate", "translate3d", "translateX", "translateY", "translateZ", - "transparent", "ultra-condensed", "ultra-expanded", "underline", "unset", "up", + "transparent", "ultra-condensed", "ultra-expanded", "underline", "unidirectional-pan", "unset", "up", "upper-alpha", "upper-armenian", "upper-greek", "upper-hexadecimal", "upper-latin", "upper-norwegian", "upper-roman", "uppercase", "urdu", "url", - "var", "vertical", "vertical-text", "visible", "visibleFill", "visiblePainted", + "var", "vertical", "vertical-text", "view-box", "visible", "visibleFill", "visiblePainted", "visibleStroke", "visual", "w-resize", "wait", "wave", "wider", "window", "windowframe", "windowtext", "words", "wrap", "wrap-reverse", "x-large", "x-small", "xor", "xx-large", "xx-small" @@ -727,7 +727,8 @@ CodeMirror.defineMode("css", function(config, parserConfig) { var maybeEnd = false, ch; while ((ch = stream.next()) != null) { if (maybeEnd && ch == "/") { - state.tokenize = null; break; + state.tokenize = null; + break; } maybeEnd = (ch == "*"); } From 43822831dc670ab1ee18eeb54f4d57ac44b080fc Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Thu, 13 Aug 2020 08:33:21 +0200 Subject: [PATCH 1991/2444] Document the scrollpastend addon Closes #6381 --- doc/manual.html | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/manual.html b/doc/manual.html index ba46c099f0..9c04d7fadf 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -3147,6 +3147,11 @@

    Addons

    A demo of the addon is available here. +
    scroll/scrollpastend.js
    +
    Defines an option `"scrollPastEnd"` that, when set to a + truthy value, allows the user to scroll one editor height of + empty space into view at the bottom of the editor.
    +
    merge/merge.js
    Implements an interface for merging changes, using either a 2-way or a 3-way view. The CodeMirror.MergeView From 50cd959fe7939eba01d4647d9081976f48df9bb7 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Thu, 13 Aug 2020 09:10:52 +0200 Subject: [PATCH 1992/2444] Add issue and pr templates that warn about common problems --- .github/ISSUE_TEMPLATE.md | 5 +++++ .github/PULL_REQUEST_TEMPLATE.md | 5 +++++ 2 files changed, 10 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE.md create mode 100644 .github/PULL_REQUEST_TEMPLATE.md diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 0000000000..49e2dcb09d --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,5 @@ + \ No newline at end of file diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000000..ea7cbc75db --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,5 @@ + From 83b9f82f411274407755f80f403a48448faf81d0 Mon Sep 17 00:00:00 2001 From: "Jan T. Sott" Date: Fri, 14 Aug 2020 10:12:06 +0200 Subject: [PATCH 1993/2444] [nsis mode] Add NSIS 3.06 commands --- mode/nsis/nsis.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mode/nsis/nsis.js b/mode/nsis/nsis.js index 10816608c1..636940f502 100644 --- a/mode/nsis/nsis.js +++ b/mode/nsis/nsis.js @@ -31,7 +31,7 @@ CodeMirror.defineSimpleMode("nsis",{ {regex: /^\s*(?:\!(else|endif|macroend))\b/, token: "keyword", dedent: true}, // Runtime Commands - {regex: /^\s*(?:Abort|AddBrandingImage|AddSize|AllowRootDirInstall|AllowSkipFiles|AutoCloseWindow|BGFont|BGGradient|BrandingText|BringToFront|Call|CallInstDLL|Caption|ChangeUI|CheckBitmap|ClearErrors|CompletedText|ComponentText|CopyFiles|CRCCheck|CreateDirectory|CreateFont|CreateShortCut|Delete|DeleteINISec|DeleteINIStr|DeleteRegKey|DeleteRegValue|DetailPrint|DetailsButtonText|DirText|DirVar|DirVerify|EnableWindow|EnumRegKey|EnumRegValue|Exch|Exec|ExecShell|ExecShellWait|ExecWait|ExpandEnvStrings|File|FileBufSize|FileClose|FileErrorText|FileOpen|FileRead|FileReadByte|FileReadUTF16LE|FileReadWord|FileWriteUTF16LE|FileSeek|FileWrite|FileWriteByte|FileWriteWord|FindClose|FindFirst|FindNext|FindWindow|FlushINI|GetCurInstType|GetCurrentAddress|GetDlgItem|GetDLLVersion|GetDLLVersionLocal|GetErrorLevel|GetFileTime|GetFileTimeLocal|GetFullPathName|GetFunctionAddress|GetInstDirError|GetLabelAddress|GetTempFileName|Goto|HideWindow|Icon|IfAbort|IfErrors|IfFileExists|IfRebootFlag|IfSilent|InitPluginsDir|InstallButtonText|InstallColors|InstallDir|InstallDirRegKey|InstProgressFlags|InstType|InstTypeGetText|InstTypeSetText|Int64Cmp|Int64CmpU|Int64Fmt|IntCmp|IntCmpU|IntFmt|IntOp|IntPtrCmp|IntPtrCmpU|IntPtrOp|IsWindow|LangString|LicenseBkColor|LicenseData|LicenseForceSelection|LicenseLangString|LicenseText|LoadAndSetImage|LoadLanguageFile|LockWindow|LogSet|LogText|ManifestDPIAware|ManifestLongPathAware|ManifestMaxVersionTested|ManifestSupportedOS|MessageBox|MiscButtonText|Name|Nop|OutFile|Page|PageCallbacks|PEAddResource|PEDllCharacteristics|PERemoveResource|PESubsysVer|Pop|Push|Quit|ReadEnvStr|ReadINIStr|ReadRegDWORD|ReadRegStr|Reboot|RegDLL|Rename|RequestExecutionLevel|ReserveFile|Return|RMDir|SearchPath|SectionGetFlags|SectionGetInstTypes|SectionGetSize|SectionGetText|SectionIn|SectionSetFlags|SectionSetInstTypes|SectionSetSize|SectionSetText|SendMessage|SetAutoClose|SetBrandingImage|SetCompress|SetCompressor|SetCompressorDictSize|SetCtlColors|SetCurInstType|SetDatablockOptimize|SetDateSave|SetDetailsPrint|SetDetailsView|SetErrorLevel|SetErrors|SetFileAttributes|SetFont|SetOutPath|SetOverwrite|SetRebootFlag|SetRegView|SetShellVarContext|SetSilent|ShowInstDetails|ShowUninstDetails|ShowWindow|SilentInstall|SilentUnInstall|Sleep|SpaceTexts|StrCmp|StrCmpS|StrCpy|StrLen|SubCaption|Unicode|UninstallButtonText|UninstallCaption|UninstallIcon|UninstallSubCaption|UninstallText|UninstPage|UnRegDLL|Var|VIAddVersionKey|VIFileVersion|VIProductVersion|WindowIcon|WriteINIStr|WriteRegBin|WriteRegDWORD|WriteRegExpandStr|WriteRegMultiStr|WriteRegNone|WriteRegStr|WriteUninstaller|XPStyle)\b/, token: "keyword"}, + {regex: /^\s*(?:Abort|AddBrandingImage|AddSize|AllowRootDirInstall|AllowSkipFiles|AutoCloseWindow|BGFont|BGGradient|BrandingText|BringToFront|Call|CallInstDLL|Caption|ChangeUI|CheckBitmap|ClearErrors|CompletedText|ComponentText|CopyFiles|CRCCheck|CreateDirectory|CreateFont|CreateShortCut|Delete|DeleteINISec|DeleteINIStr|DeleteRegKey|DeleteRegValue|DetailPrint|DetailsButtonText|DirText|DirVar|DirVerify|EnableWindow|EnumRegKey|EnumRegValue|Exch|Exec|ExecShell|ExecShellWait|ExecWait|ExpandEnvStrings|File|FileBufSize|FileClose|FileErrorText|FileOpen|FileRead|FileReadByte|FileReadUTF16LE|FileReadWord|FileWriteUTF16LE|FileSeek|FileWrite|FileWriteByte|FileWriteWord|FindClose|FindFirst|FindNext|FindWindow|FlushINI|GetCurInstType|GetCurrentAddress|GetDlgItem|GetDLLVersion|GetDLLVersionLocal|GetErrorLevel|GetFileTime|GetFileTimeLocal|GetFullPathName|GetFunctionAddress|GetInstDirError|GetKnownFolderPath|GetLabelAddress|GetTempFileName|Goto|HideWindow|Icon|IfAbort|IfErrors|IfFileExists|IfRebootFlag|IfRtlLanguage|IfShellVarContextAll|IfSilent|InitPluginsDir|InstallButtonText|InstallColors|InstallDir|InstallDirRegKey|InstProgressFlags|InstType|InstTypeGetText|InstTypeSetText|Int64Cmp|Int64CmpU|Int64Fmt|IntCmp|IntCmpU|IntFmt|IntOp|IntPtrCmp|IntPtrCmpU|IntPtrOp|IsWindow|LangString|LicenseBkColor|LicenseData|LicenseForceSelection|LicenseLangString|LicenseText|LoadAndSetImage|LoadLanguageFile|LockWindow|LogSet|LogText|ManifestDPIAware|ManifestLongPathAware|ManifestMaxVersionTested|ManifestSupportedOS|MessageBox|MiscButtonText|Name|Nop|OutFile|Page|PageCallbacks|PEAddResource|PEDllCharacteristics|PERemoveResource|PESubsysVer|Pop|Push|Quit|ReadEnvStr|ReadINIStr|ReadRegDWORD|ReadRegStr|Reboot|RegDLL|Rename|RequestExecutionLevel|ReserveFile|Return|RMDir|SearchPath|SectionGetFlags|SectionGetInstTypes|SectionGetSize|SectionGetText|SectionIn|SectionSetFlags|SectionSetInstTypes|SectionSetSize|SectionSetText|SendMessage|SetAutoClose|SetBrandingImage|SetCompress|SetCompressor|SetCompressorDictSize|SetCtlColors|SetCurInstType|SetDatablockOptimize|SetDateSave|SetDetailsPrint|SetDetailsView|SetErrorLevel|SetErrors|SetFileAttributes|SetFont|SetOutPath|SetOverwrite|SetRebootFlag|SetRegView|SetShellVarContext|SetSilent|ShowInstDetails|ShowUninstDetails|ShowWindow|SilentInstall|SilentUnInstall|Sleep|SpaceTexts|StrCmp|StrCmpS|StrCpy|StrLen|SubCaption|Unicode|UninstallButtonText|UninstallCaption|UninstallIcon|UninstallSubCaption|UninstallText|UninstPage|UnRegDLL|Var|VIAddVersionKey|VIFileVersion|VIProductVersion|WindowIcon|WriteINIStr|WriteRegBin|WriteRegDWORD|WriteRegExpandStr|WriteRegMultiStr|WriteRegNone|WriteRegStr|WriteUninstaller|XPStyle)\b/, token: "keyword"}, {regex: /^\s*(?:Function|PageEx|Section(?:Group)?)\b/, token: "keyword", indent: true}, {regex: /^\s*(?:(Function|PageEx|Section(?:Group)?)End)\b/, token: "keyword", dedent: true}, From 55d04842e2abeeb305d722859cfb8ba18eadd47a Mon Sep 17 00:00:00 2001 From: tokafew420 Date: Tue, 18 Aug 2020 23:05:37 -0400 Subject: [PATCH 1994/2444] Annotate scrollbar when matches are folded --- addon/scroll/annotatescrollbar.js | 12 ++++++- test/annotatescrollbar.js | 55 +++++++++++++++++++++++++++++++ test/index.html | 2 ++ 3 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 test/annotatescrollbar.js diff --git a/addon/scroll/annotatescrollbar.js b/addon/scroll/annotatescrollbar.js index 9fe61ec1ff..0eb9e84fa2 100644 --- a/addon/scroll/annotatescrollbar.js +++ b/addon/scroll/annotatescrollbar.js @@ -72,10 +72,20 @@ var wrapping = cm.getOption("lineWrapping"); var singleLineH = wrapping && cm.defaultTextHeight() * 1.5; var curLine = null, curLineObj = null; + + function getFoldLineHandle(pos) { + var marks = cm.findMarksAt(pos); + for (var i = 0; i < marks.length; ++i) { + if (marks[i].collapsed) + return marks[i].lines[0]; + } + } + function getY(pos, top) { if (curLine != pos.line) { curLine = pos.line; - curLineObj = cm.getLineHandle(curLine); + if(!(curLineObj = getFoldLineHandle(pos))) + curLineObj = cm.getLineHandle(curLine); } if ((curLineObj.widgets && curLineObj.widgets.length) || (wrapping && curLineObj.height > singleLineH)) diff --git a/test/annotatescrollbar.js b/test/annotatescrollbar.js new file mode 100644 index 0000000000..4a4d05333c --- /dev/null +++ b/test/annotatescrollbar.js @@ -0,0 +1,55 @@ +namespace = "annotatescrollbar_"; + +(function () { + function test(name, run, content, query, expected) { + return testCM(name, function (cm) { + var annotation = cm.annotateScrollbar({ + listenForChanges: false, + className: "CodeMirror-search-match" + }); + var matches = []; + var cursor = cm.getSearchCursor(query, CodeMirror.Pos(0, 0)); + while (cursor.findNext()) { + var match = { + from: cursor.from(), + to: cursor.to() + }; + matches.push(match) + } + + if (run) run(cm); + + cm.display.barWidth = 5; + annotation.update(matches); + + var annotations = cm.getWrapperElement().getElementsByClassName(annotation.options.className); + eq(annotations.length, expected, "Expected " + expected + " annotations on the scrollbar.") + }, { + value: content, + mode: "javascript", + foldOptions: { + rangeFinder: CodeMirror.fold.brace + } + }); + } + + function doFold(cm) { + cm.foldCode(cm.getCursor()); + } + var simpleProg = "function foo() {\n\n return \"foo\";\n\n}\n\nfoo();\n"; + var consecutiveLineMatches = "function foo() {\n return \"foo\";\n}\nfoo();\n"; + var singleLineMatches = "function foo() { return \"foo\"; }foo();\n"; + + // Base case - expect 3 matches and 3 annotations + test("simple", null, simpleProg, "foo", 3); + // Consecutive line matches are combines into a single annotation - expect 3 matches and 2 annotations + test("combineConsecutiveLine", null, consecutiveLineMatches, "foo", 2); + // Matches on a single line get a single annotation - expect 3 matches and 1 annotation + test("combineSingleLine", null, singleLineMatches, "foo", 1); + // Matches within a fold are annotated on the folded line - expect 3 matches and 2 annotations + test("simpleFold", doFold, simpleProg, "foo", 2); + // Combination of combineConsecutiveLine and simpleFold cases - expect 3 matches and 1 annotation + test("foldedMatch", doFold, consecutiveLineMatches, "foo", 1); + // Hidden matches within a fold are annotated on the folded line - expect 1 match and 1 annotation + test("hiddenMatch", doFold, simpleProg, "return", 1); +})(); \ No newline at end of file diff --git a/test/index.html b/test/index.html index 6566fc436e..3369beac1f 100644 --- a/test/index.html +++ b/test/index.html @@ -157,12 +157,14 @@

    Test Suite

    + + diff --git a/keymap/vim.js b/keymap/vim.js index aca99cfbbe..789e1e55b3 100644 --- a/keymap/vim.js +++ b/keymap/vim.js @@ -141,6 +141,8 @@ { keys: 'gU', type: 'operator', operator: 'changeCase', operatorArgs: {toLower: false}, isEdit: true }, { keys: 'n', type: 'motion', motion: 'findNext', motionArgs: { forward: true, toJumplist: true }}, { keys: 'N', type: 'motion', motion: 'findNext', motionArgs: { forward: false, toJumplist: true }}, + { keys: 'gn', type: 'motion', motion: 'findAndSelectNextInclusive', motionArgs: { forward: true }}, + { keys: 'gN', type: 'motion', motion: 'findAndSelectNextInclusive', motionArgs: { forward: false }}, // Operator-Motion dual commands { keys: 'x', type: 'operatorMotion', operator: 'delete', motion: 'moveByCharacters', motionArgs: { forward: true }, operatorMotionArgs: { visualLine: false }}, { keys: 'X', type: 'operatorMotion', operator: 'delete', motion: 'moveByCharacters', motionArgs: { forward: false }, operatorMotionArgs: { visualLine: true }}, @@ -1576,7 +1578,7 @@ motionArgs.repeat = repeat; clearInputState(cm); if (motion) { - var motionResult = motions[motion](cm, origHead, motionArgs, vim); + var motionResult = motions[motion](cm, origHead, motionArgs, vim, inputState); vim.lastMotion = motions[motion]; if (!motionResult) { return; @@ -1774,6 +1776,87 @@ highlightSearchMatches(cm, query); return findNext(cm, prev/** prev */, query, motionArgs.repeat); }, + /** + * Find and select the next occurrence of the search query. If the cursor is currently + * within a match, then find and select the current match. Otherwise, find the next occurrence in the + * appropriate direction. + * + * This differs from `findNext` in the following ways: + * + * 1. Instead of only returning the "from", this returns a "from", "to" range. + * 2. If the cursor is currently inside a search match, this selects the current match + * instead of the next match. + * 3. If there is no associated operator, this will turn on visual mode. + */ + findAndSelectNextInclusive: function(cm, _head, motionArgs, vim, prevInputState) { + var state = getSearchState(cm); + var query = state.getQuery(); + + if (!query) { + return; + } + + var prev = !motionArgs.forward; + prev = (state.isReversed()) ? !prev : prev; + + // next: [from, to] | null + var next = findNextFromAndToInclusive(cm, prev, query, motionArgs.repeat, vim); + + // No matches. + if (!next) { + return; + } + + // If there's an operator that will be executed, return the selection. + if (prevInputState.operator) { + return next; + } + + // At this point, we know that there is no accompanying operator -- let's + // deal with visual mode in order to select an appropriate match. + + var from = next[0]; + // For whatever reason, when we use the "to" as returned by searchcursor.js directly, + // the resulting selection is extended by 1 char. Let's shrink it so that only the + // match is selected. + var to = Pos(next[1].line, next[1].ch - 1); + + if (vim.visualMode) { + // If we were in visualLine or visualBlock mode, get out of it. + if (vim.visualLine || vim.visualBlock) { + vim.visualLine = false; + vim.visualBlock = false; + CodeMirror.signal(cm, "vim-mode-change", {mode: "visual", subMode: ""}); + } + + // If we're currently in visual mode, we should extend the selection to include + // the search result. + var anchor = vim.sel.anchor; + if (anchor) { + if (state.isReversed()) { + if (motionArgs.forward) { + return [anchor, from]; + } + + return [anchor, to]; + } else { + if (motionArgs.forward) { + return [anchor, to]; + } + + return [anchor, from]; + } + } + } else { + // Let's turn visual mode on. + vim.visualMode = true; + vim.visualLine = false; + vim.visualBlock = false; + CodeMirror.signal(cm, "vim-mode-change", {mode: "visual", subMode: ""}); + } + + return prev ? [to, from] : [from, to]; + }, goToMark: function(cm, _head, motionArgs, vim) { var pos = getMarkPos(cm, vim, motionArgs.selectedCharacter); if (pos) { @@ -1869,8 +1952,8 @@ // move to previous/next line is triggered. if (line < first && cur.line == first){ return this.moveToStartOfLine(cm, head, motionArgs, vim); - }else if (line > last && cur.line == last){ - return this.moveToEol(cm, head, motionArgs, vim, true); + } else if (line > last && cur.line == last){ + return moveToEol(cm, head, motionArgs, vim, true); } if (motionArgs.toFirstChar){ endCh=findFirstNonWhiteSpaceCharacter(cm.getLine(line)); @@ -1972,16 +2055,8 @@ vim.lastHSPos = cm.charCoords(head,'div').left; return moveToColumn(cm, repeat); }, - moveToEol: function(cm, head, motionArgs, vim, keepHPos) { - var cur = head; - var retval= Pos(cur.line + motionArgs.repeat - 1, Infinity); - var end=cm.clipPos(retval); - end.ch--; - if (!keepHPos) { - vim.lastHPos = Infinity; - vim.lastHSPos = cm.charCoords(end,'div').left; - } - return retval; + moveToEol: function(cm, head, motionArgs, vim) { + return moveToEol(cm, head, motionArgs, vim, false); }, moveToFirstNonWhiteSpaceCharacter: function(cm, head) { // Go to the start of the line where the text begins, or the end for @@ -3609,6 +3684,18 @@ } } + function moveToEol(cm, head, motionArgs, vim, keepHPos) { + var cur = head; + var retval= Pos(cur.line + motionArgs.repeat - 1, Infinity); + var end=cm.clipPos(retval); + end.ch--; + if (!keepHPos) { + vim.lastHPos = Infinity; + vim.lastHSPos = cm.charCoords(end,'div').left; + } + return retval; + } + function moveToCharacter(cm, repeat, forward, character) { var cur = cm.getCursor(); var start = cur.ch; @@ -4350,6 +4437,42 @@ return cursor.from(); }); } + /** + * Pretty much the same as `findNext`, except for the following differences: + * + * 1. Before starting the search, move to the previous search. This way if our cursor is + * already inside a match, we should return the current match. + * 2. Rather than only returning the cursor's from, we return the cursor's from and to as a tuple. + */ + function findNextFromAndToInclusive(cm, prev, query, repeat, vim) { + if (repeat === undefined) { repeat = 1; } + return cm.operation(function() { + var pos = cm.getCursor(); + var cursor = cm.getSearchCursor(query, pos); + + // Go back one result to ensure that if the cursor is currently a match, we keep it. + var found = cursor.find(!prev); + + // If we haven't moved, go back one more (similar to if i==0 logic in findNext). + if (!vim.visualMode && found && cursorEqual(cursor.from(), pos)) { + cursor.find(!prev); + } + + for (var i = 0; i < repeat; i++) { + found = cursor.find(prev); + if (!found) { + // SearchCursor may have returned null because it hit EOF, wrap + // around and try again. + cursor = cm.getSearchCursor(query, + (prev) ? Pos(cm.lastLine()) : Pos(cm.firstLine(), 0) ); + if (!cursor.find(prev)) { + return; + } + } + } + return [cursor.from(), cursor.to()]; + }); + } function clearSearchHighlight(cm) { var state = getSearchState(cm); cm.removeOverlay(getSearchState(cm).getOverlay()); diff --git a/test/vim_test.js b/test/vim_test.js index 9743041404..c75a1646cf 100644 --- a/test/vim_test.js +++ b/test/vim_test.js @@ -2579,6 +2579,91 @@ testVim('/ and n/N', function(cm, vim, helpers) { helpers.doKeys('2', '/'); helpers.assertCursorAt(1, 6); }, { value: 'match nope match \n nope Match' }); +testVim('/ and gn selects the appropriate word', function(cm, vim, helpers) { + cm.openDialog = helpers.fakeOpenDialog('match'); + helpers.doKeys('/'); + helpers.assertCursorAt(0, 11); + + // gn should highlight the the current word while it is within a match. + + // gn when cursor is in beginning of match + helpers.doKeys('gn', ''); + helpers.assertCursorAt(0, 15); + + // gn when cursor is at end of match + helpers.doKeys('gn', ''); + helpers.doKeys(''); + helpers.assertCursorAt(0, 15); + + // consecutive gns should extend the selection + helpers.doKeys('gn'); + helpers.assertCursorAt(0, 16); + helpers.doKeys('gn'); + helpers.assertCursorAt(1, 11); + + // we should have selected the second and third "match" + helpers.doKeys('d'); + eq('match nope ', cm.getValue()); +}, { value: 'match nope match \n nope Match' }); +testVim('/ and gN selects the appropriate word', function(cm, vim, helpers) { + cm.openDialog = helpers.fakeOpenDialog('match'); + helpers.doKeys('/'); + helpers.assertCursorAt(0, 11); + + // gN when cursor is at beginning of match + helpers.doKeys('gN', ''); + helpers.assertCursorAt(0, 11); + + // gN when cursor is at end of match + helpers.doKeys('e', 'gN', ''); + helpers.assertCursorAt(0, 11); + + // consecutive gNs should extend the selection + helpers.doKeys('gN'); + helpers.assertCursorAt(0, 11); + helpers.doKeys('gN'); + helpers.assertCursorAt(0, 0); + + // we should have selected the first and second "match" + helpers.doKeys('d'); + eq(' \n nope Match', cm.getValue()); +}, { value: 'match nope match \n nope Match' }) +testVim('/ and gn with an associated operator', function(cm, vim, helpers) { + cm.openDialog = helpers.fakeOpenDialog('match'); + helpers.doKeys('/'); + helpers.assertCursorAt(0, 11); + + helpers.doKeys('c', 'gn', 'changed', ''); + + // change the current match. + eq('match nope changed \n nope Match', cm.getValue()); + + // change the next match. + helpers.doKeys('.'); + eq('match nope changed \n nope changed', cm.getValue()); + + // change the final match. + helpers.doKeys('.'); + eq('changed nope changed \n nope changed', cm.getValue()); +}, { value: 'match nope match \n nope Match' }); +testVim('/ and gN with an associated operator', function(cm, vim, helpers) { + cm.openDialog = helpers.fakeOpenDialog('match'); + helpers.doKeys('/'); + helpers.assertCursorAt(0, 11); + + helpers.doKeys('c', 'gN', 'changed', ''); + + // change the current match. + eq('match nope changed \n nope Match', cm.getValue()); + + // change the next match. + helpers.doKeys('.'); + eq('changed nope changed \n nope Match', cm.getValue()); + + // change the final match. + helpers.doKeys('.'); + eq('changed nope changed \n nope changed', cm.getValue()); +}, { value: 'match nope match \n nope Match' }); testVim('/_case', function(cm, vim, helpers) { cm.openDialog = helpers.fakeOpenDialog('Match'); helpers.doKeys('/'); @@ -2679,6 +2764,90 @@ testVim('? and n/N', function(cm, vim, helpers) { helpers.doKeys('2', '?'); helpers.assertCursorAt(0, 11); }, { value: 'match nope match \n nope Match' }); +testVim('? and gn selects the appropriate word', function(cm, vim, helpers) { + cm.openDialog = helpers.fakeOpenDialog('match'); + helpers.doKeys('?', 'n'); + helpers.assertCursorAt(0, 11); + + // gn should highlight the the current word while it is within a match. + + // gn when cursor is in beginning of match + helpers.doKeys('gn', ''); + helpers.assertCursorAt(0, 11); + + // gn when cursor is at end of match + helpers.doKeys('e', 'gn', ''); + helpers.assertCursorAt(0, 11); + + // consecutive gns should extend the selection + helpers.doKeys('gn'); + helpers.assertCursorAt(0, 11); + helpers.doKeys('gn'); + helpers.assertCursorAt(0, 0); + + // we should have selected the first and second "match" + helpers.doKeys('d'); + eq(' \n nope Match', cm.getValue()); +}, { value: 'match nope match \n nope Match' }); +testVim('? and gN selects the appropriate word', function(cm, vim, helpers) { + cm.openDialog = helpers.fakeOpenDialog('match'); + helpers.doKeys('?', 'n'); + helpers.assertCursorAt(0, 11); + + // gN when cursor is at beginning of match + helpers.doKeys('gN', ''); + helpers.assertCursorAt(0, 15); + + // gN when cursor is at end of match + helpers.doKeys('gN', ''); + helpers.assertCursorAt(0, 15); + + // consecutive gNs should extend the selection + helpers.doKeys('gN'); + helpers.assertCursorAt(0, 16); + helpers.doKeys('gN'); + helpers.assertCursorAt(1, 11); + + // we should have selected the second and third "match" + helpers.doKeys('d'); + eq('match nope ', cm.getValue()); +}, { value: 'match nope match \n nope Match' }) +testVim('? and gn with an associated operator', function(cm, vim, helpers) { + cm.openDialog = helpers.fakeOpenDialog('match'); + helpers.doKeys('?', 'n'); + helpers.assertCursorAt(0, 11); + + helpers.doKeys('c', 'gn', 'changed', ''); + + // change the current match. + eq('match nope changed \n nope Match', cm.getValue()); + + // change the next match. + helpers.doKeys('.'); + eq('changed nope changed \n nope Match', cm.getValue()); + + // change the final match. + helpers.doKeys('.'); + eq('changed nope changed \n nope changed', cm.getValue()); +}, { value: 'match nope match \n nope Match' }); +testVim('? and gN with an associated operator', function(cm, vim, helpers) { + cm.openDialog = helpers.fakeOpenDialog('match'); + helpers.doKeys('?', 'n'); + helpers.assertCursorAt(0, 11); + + helpers.doKeys('c', 'gN', 'changed', ''); + + // change the current match. + eq('match nope changed \n nope Match', cm.getValue()); + + // change the next match. + helpers.doKeys('.'); + eq('match nope changed \n nope changed', cm.getValue()); + + // change the final match. + helpers.doKeys('.'); + eq('changed nope changed \n nope changed', cm.getValue()); +}, { value: 'match nope match \n nope Match' }); testVim('*', function(cm, vim, helpers) { cm.setCursor(0, 9); helpers.doKeys('*'); From db719a2e37f802e79d5e0abeed58721ed95fbaa9 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Tue, 15 Sep 2020 09:09:24 +0200 Subject: [PATCH 2010/2444] Fix drawing of marked text with only attributes Closes #6414 --- src/line/line_data.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/line/line_data.js b/src/line/line_data.js index 20dd432831..e650b3e306 100644 --- a/src/line/line_data.js +++ b/src/line/line_data.js @@ -178,7 +178,7 @@ function buildToken(builder, text, style, startStyle, endStyle, css, attributes) } } builder.trailingSpace = displayText.charCodeAt(text.length - 1) == 32 - if (style || startStyle || endStyle || mustWrap || css) { + if (style || startStyle || endStyle || mustWrap || css || attributes) { let fullStyle = style || "" if (startStyle) fullStyle += startStyle if (endStyle) fullStyle += endStyle From 18aa69e17cc7703f106fbe03992456b8e59e8cdc Mon Sep 17 00:00:00 2001 From: Adrian Kunz Date: Thu, 17 Sep 2020 11:32:20 +0200 Subject: [PATCH 2011/2444] [lint addon] Use separate CSS classes for common lint styles This changes lint.css to be less reliant on the predefined severities (error and warning), in turn making it easier to define custom ones. Now all that needs to be done in order to define a new severity, e.g. `note`, is to add the following CSS: ```css /* underline */ .CodeMirror-lint-mark-note { background-image: ...; } /* icon */ .CodeMirror-lint-marker-note, .CodeMirror-lint-message-note { background-image: ...; } ``` Previously, it was necessary to copy many styles that were only available under the `CodeMirror-lint-*-error` and `CodeMirror-lint-*-warning` classes. --- addon/lint/lint.css | 6 +++--- addon/lint/lint.js | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/addon/lint/lint.css b/addon/lint/lint.css index f097cfe345..fef620a492 100644 --- a/addon/lint/lint.css +++ b/addon/lint/lint.css @@ -25,7 +25,7 @@ -ms-transition: opacity .4s; } -.CodeMirror-lint-mark-error, .CodeMirror-lint-mark-warning { +.CodeMirror-lint-mark { background-position: left bottom; background-repeat: repeat-x; } @@ -40,7 +40,7 @@ background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAADCAYAAAC09K7GAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sJFhQXEbhTg7YAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAMklEQVQI12NkgIIvJ3QXMjAwdDN+OaEbysDA4MPAwNDNwMCwiOHLCd1zX07o6kBVGQEAKBANtobskNMAAAAASUVORK5CYII="); } -.CodeMirror-lint-marker-error, .CodeMirror-lint-marker-warning { +.CodeMirror-lint-marker { background-position: center center; background-repeat: no-repeat; cursor: pointer; @@ -51,7 +51,7 @@ position: relative; } -.CodeMirror-lint-message-error, .CodeMirror-lint-message-warning { +.CodeMirror-lint-message { padding-left: 18px; background-position: top left; background-repeat: no-repeat; diff --git a/addon/lint/lint.js b/addon/lint/lint.js index 5bc1af18ae..963f2cf227 100644 --- a/addon/lint/lint.js +++ b/addon/lint/lint.js @@ -83,10 +83,10 @@ function makeMarker(cm, labels, severity, multiple, tooltips) { var marker = document.createElement("div"), inner = marker; - marker.className = "CodeMirror-lint-marker-" + severity; + marker.className = "CodeMirror-lint-marker CodeMirror-lint-marker-" + severity; if (multiple) { inner = marker.appendChild(document.createElement("div")); - inner.className = "CodeMirror-lint-marker-multiple"; + inner.className = "CodeMirror-lint-marker CodeMirror-lint-marker-multiple"; } if (tooltips != false) CodeMirror.on(inner, "mouseover", function(e) { @@ -114,7 +114,7 @@ var severity = ann.severity; if (!severity) severity = "error"; var tip = document.createElement("div"); - tip.className = "CodeMirror-lint-message-" + severity; + tip.className = "CodeMirror-lint-message CodeMirror-lint-message-" + severity; if (typeof ann.messageHTML != 'undefined') { tip.innerHTML = ann.messageHTML; } else { @@ -183,7 +183,7 @@ if (state.hasGutter) tipLabel.appendChild(annotationTooltip(ann)); if (ann.to) state.marked.push(cm.markText(ann.from, ann.to, { - className: "CodeMirror-lint-mark-" + severity, + className: "CodeMirror-lint-mark CodeMirror-lint-mark-" + severity, __annotation: ann })); } From 376c0d9a9e67f42fa2c77e3529b1740097ea68b3 Mon Sep 17 00:00:00 2001 From: Adrian Kunz Date: Sun, 20 Sep 2020 14:36:24 +0200 Subject: [PATCH 2012/2444] [lint addon] Put error CSS after warning By swapping the CSS rules, the error rules take priority in case there are markers with both severities on the same token. That token is now underlined red instead of yellow, making it consistent with how errors take priority in the gutter. --- addon/lint/lint.css | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/addon/lint/lint.css b/addon/lint/lint.css index fef620a492..0871865959 100644 --- a/addon/lint/lint.css +++ b/addon/lint/lint.css @@ -30,16 +30,14 @@ background-repeat: repeat-x; } -.CodeMirror-lint-mark-error { - background-image: - url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAADCAYAAAC09K7GAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sJDw4cOCW1/KIAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAHElEQVQI12NggIL/DAz/GdA5/xkY/qPKMDAwAADLZwf5rvm+LQAAAABJRU5ErkJggg==") - ; -} - .CodeMirror-lint-mark-warning { background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAADCAYAAAC09K7GAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sJFhQXEbhTg7YAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAMklEQVQI12NkgIIvJ3QXMjAwdDN+OaEbysDA4MPAwNDNwMCwiOHLCd1zX07o6kBVGQEAKBANtobskNMAAAAASUVORK5CYII="); } +.CodeMirror-lint-mark-error { + background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAADCAYAAAC09K7GAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sJDw4cOCW1/KIAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAHElEQVQI12NggIL/DAz/GdA5/xkY/qPKMDAwAADLZwf5rvm+LQAAAABJRU5ErkJggg=="); +} + .CodeMirror-lint-marker { background-position: center center; background-repeat: no-repeat; @@ -57,14 +55,14 @@ background-repeat: no-repeat; } -.CodeMirror-lint-marker-error, .CodeMirror-lint-message-error { - background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAAHlBMVEW7AAC7AACxAAC7AAC7AAAAAAC4AAC5AAD///+7AAAUdclpAAAABnRSTlMXnORSiwCK0ZKSAAAATUlEQVR42mWPOQ7AQAgDuQLx/z8csYRmPRIFIwRGnosRrpamvkKi0FTIiMASR3hhKW+hAN6/tIWhu9PDWiTGNEkTtIOucA5Oyr9ckPgAWm0GPBog6v4AAAAASUVORK5CYII="); -} - .CodeMirror-lint-marker-warning, .CodeMirror-lint-message-warning { background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAANlBMVEX/uwDvrwD/uwD/uwD/uwD/uwD/uwD/uwD/uwD6twD/uwAAAADurwD2tQD7uAD+ugAAAAD/uwDhmeTRAAAADHRSTlMJ8mN1EYcbmiixgACm7WbuAAAAVklEQVR42n3PUQqAIBBFUU1LLc3u/jdbOJoW1P08DA9Gba8+YWJ6gNJoNYIBzAA2chBth5kLmG9YUoG0NHAUwFXwO9LuBQL1giCQb8gC9Oro2vp5rncCIY8L8uEx5ZkAAAAASUVORK5CYII="); } +.CodeMirror-lint-marker-error, .CodeMirror-lint-message-error { + background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAAHlBMVEW7AAC7AACxAAC7AAC7AAAAAAC4AAC5AAD///+7AAAUdclpAAAABnRSTlMXnORSiwCK0ZKSAAAATUlEQVR42mWPOQ7AQAgDuQLx/z8csYRmPRIFIwRGnosRrpamvkKi0FTIiMASR3hhKW+hAN6/tIWhu9PDWiTGNEkTtIOucA5Oyr9ckPgAWm0GPBog6v4AAAAASUVORK5CYII="); +} + .CodeMirror-lint-marker-multiple { background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAcAAAAHCAMAAADzjKfhAAAACVBMVEUAAAAAAAC/v7914kyHAAAAAXRSTlMAQObYZgAAACNJREFUeNo1ioEJAAAIwmz/H90iFFSGJgFMe3gaLZ0od+9/AQZ0ADosbYraAAAAAElFTkSuQmCC"); background-repeat: no-repeat; From 66a96a567b7b1e3da6319bd933c94b284811f161 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Sun, 20 Sep 2020 19:37:00 +0200 Subject: [PATCH 2013/2444] Set the readonly attribute on the hidden textarea when the editor is read-only This prevents cut/paste from showing up in the context menu on Chrome (but doesn't help on Firefox). Closes #6418 --- src/input/TextareaInput.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/input/TextareaInput.js b/src/input/TextareaInput.js index 8fe14bb413..977eb22723 100644 --- a/src/input/TextareaInput.js +++ b/src/input/TextareaInput.js @@ -366,6 +366,7 @@ export default class TextareaInput { readOnlyChanged(val) { if (!val) this.reset() this.textarea.disabled = val == "nocursor" + this.textarea.readOnly = !!val } setUneditable() {} From 7b63084691b9c56baf02e5f2c2a9d5aebd435dc1 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Mon, 21 Sep 2020 09:46:57 +0200 Subject: [PATCH 2014/2444] Update placeholder visibility during composition Closes #6420: --- addon/display/placeholder.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/addon/display/placeholder.js b/addon/display/placeholder.js index 4eabe3d901..19e9a3418c 100644 --- a/addon/display/placeholder.js +++ b/addon/display/placeholder.js @@ -15,11 +15,13 @@ cm.on("blur", onBlur); cm.on("change", onChange); cm.on("swapDoc", onChange); + CodeMirror.on(cm.getInputField(), "compositionupdate", cm.state.placeholderCompose = () => onComposition(cm)) onChange(cm); } else if (!val && prev) { cm.off("blur", onBlur); cm.off("change", onChange); cm.off("swapDoc", onChange); + CodeMirror.off(cm.getInputField(), "compositionupdate", cm.state.placeholderCompose) clearPlaceholder(cm); var wrapper = cm.getWrapperElement(); wrapper.className = wrapper.className.replace(" CodeMirror-empty", ""); @@ -46,6 +48,16 @@ cm.display.lineSpace.insertBefore(elt, cm.display.lineSpace.firstChild); } + function onComposition(cm) { + var empty = true, input = cm.getInputField() + if (input.nodeName == "TEXTAREA") + empty = !input.value + else if (cm.lineCount() == 1) + empty = !/[^\u200b]/.test(input.querySelector(".CodeMirror-line").textContent) + if (empty) clearPlaceholder(cm) + else setPlaceholder(cm) + } + function onBlur(cm) { if (isEmpty(cm)) setPlaceholder(cm); } From 76590dcb0683c0ef94c19133d64afe8bb43373ba Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Mon, 21 Sep 2020 09:52:29 +0200 Subject: [PATCH 2015/2444] Mark version 5.58.0 --- AUTHORS | 3 +++ CHANGELOG.md | 20 ++++++++++++++++++++ doc/manual.html | 2 +- doc/releases.html | 12 ++++++++++++ index.html | 2 +- package.json | 2 +- src/edit/main.js | 2 +- 7 files changed, 39 insertions(+), 4 deletions(-) diff --git a/AUTHORS b/AUTHORS index 3fa6199e41..bb017e9574 100644 --- a/AUTHORS +++ b/AUTHORS @@ -15,6 +15,7 @@ Adán Lobato Aditya Toshniwal Adrian Aichner Adrian Heine +Adrian Kunz Adrien Bertrand aeroson Ahmad Amireh @@ -332,6 +333,7 @@ Hiroyuki Makino hitsthings Hocdoc Howard +Howard Jing Hugues Malphettes Ian Beck Ian Davies @@ -348,6 +350,7 @@ ilvalle Ilya Kharlamov Ilya Zverev Ingo Richter +Intervue Irakli Gozalishvili Ivan Kurnosov Ivoah diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e651ec7ec..782f493af6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,23 @@ +## 5.58.0 (2020-09-21) + +### Bug fixes + +Make backspace delete by code point, not glyph. + +Suppress flickering focus outline when clicking on scrollbars in Chrome. + +Fix a bug that prevented attributes added via `markText` from showing up unless the span also had some other styling. + +Suppress cut and paste context menu entries in readonly editors in Chrome. + +[placeholder addon](https://codemirror.net/doc/manual.html#addon_placeholder): Update placeholder visibility during composition. + +### New features + +Make it less cumbersome to style new lint message types. + +[vim bindings](https://codemirror.net/demo/vim.html): Support black hole register, `gn` and `gN` + ## 5.57.0 (2020-08-20) ### Bug fixes diff --git a/doc/manual.html b/doc/manual.html index 8635a1e060..e193f9929b 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -70,7 +70,7 @@

    User manual and reference guide - version 5.57.0 + version 5.58.0

    CodeMirror is a code-editor component that can be embedded in diff --git a/doc/releases.html b/doc/releases.html index 334a0184c6..3e0adcda6e 100644 --- a/doc/releases.html +++ b/doc/releases.html @@ -30,6 +30,18 @@

    Release notes and version history

    Version 5.x

    +

    21-09-2020: Version 5.58.0:

    + +
      +
    • Make backspace delete by code point, not glyph.
    • +
    • Suppress flickering focus outline when clicking on scrollbars in Chrome.
    • +
    • Fix a bug that prevented attributes added via markText from showing up unless the span also had some other styling.
    • +
    • Suppress cut and paste context menu entries in readonly editors in Chrome.
    • +
    • placeholder addon: Update placeholder visibility during composition.
    • +
    • Make it less cumbersome to style new lint message types.
    • +
    • vim bindings: Support black hole register, gn and gN
    • +
    +

    20-08-2020: Version 5.57.0:

      diff --git a/index.html b/index.html index 21fe3ef0eb..b6b595b9c4 100644 --- a/index.html +++ b/index.html @@ -99,7 +99,7 @@

      This is CodeMirror

    - Get the current version: 5.57.0.
    + Get the current version: 5.58.0.
    You can see the code,
    read the release notes,
    or study the user manual. diff --git a/package.json b/package.json index faf0ca08b6..4472c6be3d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "codemirror", - "version": "5.57.0", + "version": "5.58.0", "main": "lib/codemirror.js", "style": "lib/codemirror.css", "author": { diff --git a/src/edit/main.js b/src/edit/main.js index 64e94929dd..00990e1601 100644 --- a/src/edit/main.js +++ b/src/edit/main.js @@ -66,4 +66,4 @@ import { addLegacyProps } from "./legacy.js" addLegacyProps(CodeMirror) -CodeMirror.version = "5.57.0" +CodeMirror.version = "5.58.0" From c74a1cafc01a7e34af1b19dd4c82ff821c2e1442 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Mon, 21 Sep 2020 09:55:45 +0200 Subject: [PATCH 2016/2444] Fix use of ES6 in addon --- addon/display/placeholder.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addon/display/placeholder.js b/addon/display/placeholder.js index 19e9a3418c..eb8332ac4b 100644 --- a/addon/display/placeholder.js +++ b/addon/display/placeholder.js @@ -15,7 +15,7 @@ cm.on("blur", onBlur); cm.on("change", onChange); cm.on("swapDoc", onChange); - CodeMirror.on(cm.getInputField(), "compositionupdate", cm.state.placeholderCompose = () => onComposition(cm)) + CodeMirror.on(cm.getInputField(), "compositionupdate", cm.state.placeholderCompose = function() { onComposition(cm) }) onChange(cm); } else if (!val && prev) { cm.off("blur", onBlur); From ca046d7d2fe737a0f09b90e2ae455093ca60faa5 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Tue, 22 Sep 2020 21:19:03 +0200 Subject: [PATCH 2017/2444] [placeholder addon] Fix composition handling Issue #6422 --- addon/display/placeholder.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/addon/display/placeholder.js b/addon/display/placeholder.js index eb8332ac4b..89bb93f378 100644 --- a/addon/display/placeholder.js +++ b/addon/display/placeholder.js @@ -49,13 +49,15 @@ } function onComposition(cm) { - var empty = true, input = cm.getInputField() - if (input.nodeName == "TEXTAREA") - empty = !input.value - else if (cm.lineCount() == 1) - empty = !/[^\u200b]/.test(input.querySelector(".CodeMirror-line").textContent) - if (empty) clearPlaceholder(cm) - else setPlaceholder(cm) + setTimeout(function() { + var empty = false, input = cm.getInputField() + if (input.nodeName == "TEXTAREA") + empty = !input.value + else if (cm.lineCount() == 1) + empty = !/[^\u200b]/.test(input.querySelector(".CodeMirror-line").textContent) + if (empty) setPlaceholder(cm) + else clearPlaceholder(cm) + }, 20) } function onBlur(cm) { From 1c60749b6882bd67b2a11a3f2e21cffa5eb4c5d3 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Wed, 23 Sep 2020 10:11:42 +0200 Subject: [PATCH 2018/2444] Mark version 5.58.1 --- CHANGELOG.md | 6 ++++++ doc/manual.html | 2 +- doc/releases.html | 8 ++++++++ index.html | 2 +- package.json | 2 +- src/edit/main.js | 2 +- 6 files changed, 18 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 782f493af6..d3e3fe4223 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## 5.58.1 (2020-09-23) + +### Bug fixes + +[placeholder addon](https://codemirror.net/doc/manual.html#addon_placeholder): Remove arrow function that ended up in the code. + ## 5.58.0 (2020-09-21) ### Bug fixes diff --git a/doc/manual.html b/doc/manual.html index e193f9929b..42ab5491ed 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -70,7 +70,7 @@

    User manual and reference guide - version 5.58.0 + version 5.58.1

    CodeMirror is a code-editor component that can be embedded in diff --git a/doc/releases.html b/doc/releases.html index 3e0adcda6e..3b4378f3f1 100644 --- a/doc/releases.html +++ b/doc/releases.html @@ -32,6 +32,14 @@

    Version 5.x

    21-09-2020: Version 5.58.0:

    + + +

    Version 5.x

    + +

    21-09-2020: Version 5.58.0:

    +
    • Make backspace delete by code point, not glyph.
    • Suppress flickering focus outline when clicking on scrollbars in Chrome.
    • diff --git a/index.html b/index.html index b6b595b9c4..ff27b925b7 100644 --- a/index.html +++ b/index.html @@ -99,7 +99,7 @@

      This is CodeMirror

    - Get the current version: 5.58.0.
    + Get the current version: 5.58.1.
    You can see the code,
    read the release notes,
    or study the user manual. diff --git a/package.json b/package.json index 4472c6be3d..ba8e7fc79d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "codemirror", - "version": "5.58.0", + "version": "5.58.1", "main": "lib/codemirror.js", "style": "lib/codemirror.css", "author": { diff --git a/src/edit/main.js b/src/edit/main.js index 00990e1601..4f9152d892 100644 --- a/src/edit/main.js +++ b/src/edit/main.js @@ -66,4 +66,4 @@ import { addLegacyProps } from "./legacy.js" addLegacyProps(CodeMirror) -CodeMirror.version = "5.58.0" +CodeMirror.version = "5.58.1" From f3dde7c60552daea3de7d4141ba9553197f20543 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Sat, 26 Sep 2020 21:56:10 +0200 Subject: [PATCH 2019/2444] [julia mode] Fix infinite recursion I couldn't figure out what the original code was intended to do, but I've tried to fix the problem without changing it more than necessary. Closes #6428 --- mode/julia/julia.js | 63 +++++++++++++++++++++++---------------------- 1 file changed, 32 insertions(+), 31 deletions(-) diff --git a/mode/julia/julia.js b/mode/julia/julia.js index f1d2cd5c4b..3942492042 100644 --- a/mode/julia/julia.js +++ b/mode/julia/julia.js @@ -255,41 +255,43 @@ CodeMirror.defineMode("julia", function(config, parserConf) { } function tokenCallOrDef(stream, state) { - var match = stream.match(/^(\(\s*)/); - if (match) { - if (state.firstParenPos < 0) - state.firstParenPos = state.scopes.length; - state.scopes.push('('); - state.charsAdvanced += match[1].length; - } - if (currentScope(state) == '(' && stream.match(/^\)/)) { - state.scopes.pop(); - state.charsAdvanced += 1; - if (state.scopes.length <= state.firstParenPos) { - var isDefinition = stream.match(/^(\s*where\s+[^\s=]+)*\s*?=(?!=)/, false); - stream.backUp(state.charsAdvanced); + for (;;) { + var match = stream.match(/^(\(\s*)/), charsAdvanced = 0; + if (match) { + if (state.firstParenPos < 0) + state.firstParenPos = state.scopes.length; + state.scopes.push('('); + charsAdvanced += match[1].length; + } + if (currentScope(state) == '(' && stream.match(/^\)/)) { + state.scopes.pop(); + charsAdvanced += 1; + if (state.scopes.length <= state.firstParenPos) { + var isDefinition = stream.match(/^(\s*where\s+[^\s=]+)*\s*?=(?!=)/, false); + stream.backUp(charsAdvanced); + state.firstParenPos = -1; + state.tokenize = tokenBase; + if (isDefinition) + return "def"; + return "builtin"; + } + } + // Unfortunately javascript does not support multiline strings, so we have + // to undo anything done upto here if a function call or definition splits + // over two or more lines. + if (stream.match(/^$/g, false)) { + stream.backUp(charsAdvanced); + while (state.scopes.length > state.firstParenPos) + state.scopes.pop(); state.firstParenPos = -1; - state.charsAdvanced = 0; state.tokenize = tokenBase; - if (isDefinition) - return "def"; return "builtin"; } + if (!stream.match(/^[^()]+/)) { + stream.next() + return null + } } - // Unfortunately javascript does not support multiline strings, so we have - // to undo anything done upto here if a function call or definition splits - // over two or more lines. - if (stream.match(/^$/g, false)) { - stream.backUp(state.charsAdvanced); - while (state.scopes.length > state.firstParenPos) - state.scopes.pop(); - state.firstParenPos = -1; - state.charsAdvanced = 0; - state.tokenize = tokenBase; - return "builtin"; - } - state.charsAdvanced += stream.match(/^([^()]*)/)[1].length; - return state.tokenize(stream, state); } function tokenAnnotation(stream, state) { @@ -383,7 +385,6 @@ CodeMirror.defineMode("julia", function(config, parserConf) { nestedComments: 0, nestedGenerators: 0, nestedParameters: 0, - charsAdvanced: 0, firstParenPos: -1 }; }, From 58c553470fe6d65d494d4dbaf471f6ec97f9ab9d Mon Sep 17 00:00:00 2001 From: Nina Pypchenko <22447785+nina-py@users.noreply.github.com> Date: Mon, 28 Sep 2020 12:11:52 +1000 Subject: [PATCH 2020/2444] Fixes #6331. Backticks are stripped from SQL query words before comparison --- addon/hint/sql-hint.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addon/hint/sql-hint.js b/addon/hint/sql-hint.js index de84707db3..5b65e29105 100644 --- a/addon/hint/sql-hint.js +++ b/addon/hint/sql-hint.js @@ -187,7 +187,7 @@ function eachWord(lineText, f) { var words = lineText.split(/\s+/) for (var i = 0; i < words.length; i++) - if (words[i]) f(words[i].replace(/[,;]/g, '')) + if (words[i]) f(words[i].replace(/[`,;]/g, '')) } function findTableByAlias(alias, editor) { From fdc2de3856f928d04fdac222294870edb9ce639b Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Mon, 28 Sep 2020 14:45:21 +0200 Subject: [PATCH 2021/2444] [tern demo] Use unpkg, now that the URL structure of ternjs.net changed --- demo/tern.html | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/demo/tern.html b/demo/tern.html index c6834e8899..e331fd5cf8 100644 --- a/demo/tern.html +++ b/demo/tern.html @@ -13,16 +13,16 @@ - - - + + + - - - - - - + + + + + + @@ -109,7 +109,7 @@

    Tern Demo

    } var server; - getURL("//ternjs.net/defs/ecmascript.json", function(err, code) { + getURL("https://unpkg.com/tern/defs/ecmascript.json", function(err, code) { if (err) throw new Error("Request for ecmascript.json: " + err); server = new CodeMirror.TernServer({defs: [JSON.parse(code)]}); editor.setOption("extraKeys", { From 8bc57f76383e62e1a03c7d97c9eac74493fdbedc Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Fri, 2 Oct 2020 23:40:06 +0200 Subject: [PATCH 2022/2444] Remove link to gitter room It never took off, and I very much prefer communicating through the forum and bug tracker. --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 2a7b1f5eba..92debf4488 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,6 @@ [![Build Status](https://travis-ci.org/codemirror/CodeMirror.svg)](https://travis-ci.org/codemirror/CodeMirror) [![NPM version](https://img.shields.io/npm/v/codemirror.svg)](https://www.npmjs.org/package/codemirror) -[![Join the chat at https://gitter.im/codemirror/CodeMirror](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/codemirror/CodeMirror) CodeMirror is a versatile text editor implemented in JavaScript for the browser. It is specialized for editing code, and comes with over From 719a91275352a5b551b7b450726b056f11d22685 Mon Sep 17 00:00:00 2001 From: Nina Pypchenko <22447785+nina-py@users.noreply.github.com> Date: Mon, 5 Oct 2020 19:15:49 +1100 Subject: [PATCH 2023/2444] Fixes #6402. Adds option to turn off highlighting of non-standard CSS properties --- mode/css/css.js | 7 ++++--- mode/css/index.html | 6 ++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/mode/css/css.js b/mode/css/css.js index 77ca0c10e2..240c270a90 100644 --- a/mode/css/css.js +++ b/mode/css/css.js @@ -29,7 +29,8 @@ CodeMirror.defineMode("css", function(config, parserConfig) { valueKeywords = parserConfig.valueKeywords || {}, allowNested = parserConfig.allowNested, lineComment = parserConfig.lineComment, - supportsAtComponent = parserConfig.supportsAtComponent === true; + supportsAtComponent = parserConfig.supportsAtComponent === true, + highlightNonStandardPropertyKeywords = config.highlightNonStandardPropertyKeywords !== false; var type, override; function ret(style, tp) { type = tp; return style; } @@ -197,7 +198,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) { override = "property"; return "maybeprop"; } else if (nonStandardPropertyKeywords.hasOwnProperty(word)) { - override = "string-2"; + override = highlightNonStandardPropertyKeywords ? "string-2" : "property"; return "maybeprop"; } else if (allowNested) { override = stream.match(/^\s*:(?:\s|$)/, false) ? "property" : "tag"; @@ -291,7 +292,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) { else if (propertyKeywords.hasOwnProperty(word)) override = "property"; else if (nonStandardPropertyKeywords.hasOwnProperty(word)) - override = "string-2"; + override = highlightNonStandardPropertyKeywords ? "string-2" : "property"; else if (valueKeywords.hasOwnProperty(word)) override = "atom"; else if (colorKeywords.hasOwnProperty(word)) diff --git a/mode/css/index.html b/mode/css/index.html index 6588c408ac..42b327ca66 100644 --- a/mode/css/index.html +++ b/mode/css/index.html @@ -68,6 +68,12 @@

    CSS mode

    }); +

    CSS mode supports this option:

    + +
    highlightNonStandardPropertyKeywords: boolean
    +
    Whether to highlight non-standard CSS property keywords such as margin-inline or zoom (default: true).
    +
    +

    MIME types defined: text/css, text/x-scss (demo), text/x-less (demo).

    Parsing/Highlighting Tests: normal, verbose.

    From 1cb6de23c7e2b965201972ac5c6dcd2317e9eacf Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Mon, 5 Oct 2020 14:05:36 +0200 Subject: [PATCH 2024/2444] Fix doc/releases.html copy-paste mistake --- doc/releases.html | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/doc/releases.html b/doc/releases.html index 3b4378f3f1..0b466970fc 100644 --- a/doc/releases.html +++ b/doc/releases.html @@ -30,14 +30,12 @@

    Release notes and version history

    Version 5.x

    -

    21-09-2020: Version 5.58.0:

    +

    21-09-2020: Version 5.58.1:

    -

    Version 5.x

    -

    21-09-2020: Version 5.58.0:

      From cdb228ac736369c685865b122b736cd0d397836c Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Fri, 9 Oct 2020 10:00:16 +0200 Subject: [PATCH 2025/2444] Fix horizontal scrolling-into-view with non-fixed gutters Closes #6436 --- src/display/scrolling.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/display/scrolling.js b/src/display/scrolling.js index 6d97247d92..75d6fc7ee4 100644 --- a/src/display/scrolling.js +++ b/src/display/scrolling.js @@ -91,14 +91,15 @@ function calculateScrollPos(cm, rect) { if (newTop != screentop) result.scrollTop = newTop } - let screenleft = cm.curOp && cm.curOp.scrollLeft != null ? cm.curOp.scrollLeft : display.scroller.scrollLeft - let screenw = displayWidth(cm) - (cm.options.fixedGutter ? display.gutters.offsetWidth : 0) + let gutterSpace = cm.options.fixedGutter ? 0 : display.gutters.offsetWidth + let screenleft = cm.curOp && cm.curOp.scrollLeft != null ? cm.curOp.scrollLeft : display.scroller.scrollLeft - gutterSpace + let screenw = displayWidth(cm) - display.gutters.offsetWidth let tooWide = rect.right - rect.left > screenw if (tooWide) rect.right = rect.left + screenw if (rect.left < 10) result.scrollLeft = 0 else if (rect.left < screenleft) - result.scrollLeft = Math.max(0, rect.left - (tooWide ? 0 : 10)) + result.scrollLeft = Math.max(0, rect.left + gutterSpace - (tooWide ? 0 : 10)) else if (rect.right > screenw + screenleft - 3) result.scrollLeft = rect.right + (tooWide ? 0 : 10) - screenw return result From 55d0333907117c9231ffdf555ae8824705993bbb Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Fri, 9 Oct 2020 15:38:39 +0200 Subject: [PATCH 2026/2444] [javascript mode] Fix potentially-exponential regexp --- mode/javascript/javascript.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mode/javascript/javascript.js b/mode/javascript/javascript.js index 66e5a308d4..3139fd00d2 100644 --- a/mode/javascript/javascript.js +++ b/mode/javascript/javascript.js @@ -126,7 +126,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { var kw = keywords[word] return ret(kw.type, kw.style, word) } - if (word == "async" && stream.match(/^(\s|\/\*.*?\*\/)*[\[\(\w]/, false)) + if (word == "async" && stream.match(/^(\s|\/\*([^*]|\*(?!\/))*?\*\/)*[\[\(\w]/, false)) return ret("async", "keyword", word) } return ret("variable", "variable", word) From 9caacec1900d71a971561147ba1e8acb2f08609c Mon Sep 17 00:00:00 2001 From: Mark Boyes Date: Thu, 15 Oct 2020 21:06:38 +0100 Subject: [PATCH 2027/2444] [sparql mode] Improve parsing of IRI atoms * Do not treat the opening '<' of an expanded IRI atom as an operator The existing code would not highlight the IRI atom "" in the following line as an atom. FILTER( ?x = "42"^^ ) for example everything after the # would be highlighted as a comment. This is because the sequence "^^<" while all "operator characters", are not all SPARQL operators in this case: the "<" introduces the IRI atom. I special-case the "^^". * Improve PN_LOCAL parsing to SPARQL 1.1 The following legal sequences of characters from SPARQL 1.1 are additionally parsed as being the right-hand-side of a prefixed IRI. 1) Colons 2) PERCENT escaping 3) PN_LOCAL_ESCAPE escaping --- mode/sparql/sparql.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/mode/sparql/sparql.js b/mode/sparql/sparql.js index bb79abff7f..73997c667f 100644 --- a/mode/sparql/sparql.js +++ b/mode/sparql/sparql.js @@ -60,12 +60,18 @@ CodeMirror.defineMode("sparql", function(config) { stream.skipToEnd(); return "comment"; } + else if (ch === "^") { + ch = stream.peek(); + if (ch === "^") stream.eat("^"); + else stream.eatWhile(operatorChars); + return "operator"; + } else if (operatorChars.test(ch)) { stream.eatWhile(operatorChars); return "operator"; } else if (ch == ":") { - stream.eatWhile(/[\w\d\._\-]/); + eatPnLocal(stream); return "atom"; } else if (ch == "@") { @@ -75,7 +81,7 @@ CodeMirror.defineMode("sparql", function(config) { else { stream.eatWhile(/[_\w\d]/); if (stream.eat(":")) { - stream.eatWhile(/[\w\d_\-]/); + eatPnLocal(stream); return "atom"; } var word = stream.current(); @@ -88,6 +94,10 @@ CodeMirror.defineMode("sparql", function(config) { } } + function eatPnLocal(stream) { + while (stream.match(/([:\w\d._-]|\\[-\\_~.!$&'()*+,;=/?#@%]|%[a-fA-F0-9][a-fA-F0-9])/)); + } + function tokenLiteral(quote) { return function(stream, state) { var escaped = false, ch; From 9885241fe9dee2415f988d3a3619421f45ce8c6b Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Fri, 16 Oct 2020 09:53:55 +0200 Subject: [PATCH 2028/2444] [javascript mode] Don't indent in template strings Closes #6442 --- mode/javascript/javascript.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mode/javascript/javascript.js b/mode/javascript/javascript.js index 3139fd00d2..63eaa241b7 100644 --- a/mode/javascript/javascript.js +++ b/mode/javascript/javascript.js @@ -868,7 +868,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { }, indent: function(state, textAfter) { - if (state.tokenize == tokenComment) return CodeMirror.Pass; + if (state.tokenize == tokenComment || state.tokenize == tokenQuasi) return CodeMirror.Pass; if (state.tokenize != tokenBase) return 0; var firstChar = textAfter && textAfter.charAt(0), lexical = state.lexical, top // Kludge to prevent 'maybelse' from blocking lexical scope pops From 212bafa8ab7837abebc1d326ed943540a9a47200 Mon Sep 17 00:00:00 2001 From: tophf Date: Thu, 22 Oct 2020 14:42:10 +0300 Subject: [PATCH 2029/2444] [stylus mode] Recognize "url-prefix" token properly --- mode/stylus/stylus.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mode/stylus/stylus.js b/mode/stylus/stylus.js index 653958e83b..281118efee 100644 --- a/mode/stylus/stylus.js +++ b/mode/stylus/stylus.js @@ -731,7 +731,8 @@ var tagKeywords_ = ["a","abbr","address","area","article","aside","audio", "b", "base","bdi", "bdo","bgsound","blockquote","body","br","button","canvas","caption","cite", "code","col","colgroup","data","datalist","dd","del","details","dfn","div", "dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1", "h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe", "img","input","ins","kbd","keygen","label","legend","li","link","main","map", "mark","marquee","menu","menuitem","meta","meter","nav","nobr","noframes", "noscript","object","ol","optgroup","option","output","p","param","pre", "progress","q","rp","rt","ruby","s","samp","script","section","select", "small","source","span","strong","style","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","track", "u","ul","var","video"]; // github.com/codemirror/CodeMirror/blob/master/mode/css/css.js - var documentTypes_ = ["domain", "regexp", "url", "url-prefix"]; + // Note, "url-prefix" should precede "url" in order to match correctly in documentTypesRegexp + var documentTypes_ = ["domain", "regexp", "url-prefix", "url"]; var mediaTypes_ = ["all","aural","braille","handheld","print","projection","screen","tty","tv","embossed"]; var mediaFeatures_ = ["width","min-width","max-width","height","min-height","max-height","device-width","min-device-width","max-device-width","device-height","min-device-height","max-device-height","aspect-ratio","min-aspect-ratio","max-aspect-ratio","device-aspect-ratio","min-device-aspect-ratio","max-device-aspect-ratio","color","min-color","max-color","color-index","min-color-index","max-color-index","monochrome","min-monochrome","max-monochrome","resolution","min-resolution","max-resolution","scan","grid"]; var propertyKeywords_ = ["align-content","align-items","align-self","alignment-adjust","alignment-baseline","anchor-point","animation","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-timing-function","appearance","azimuth","backface-visibility","background","background-attachment","background-clip","background-color","background-image","background-origin","background-position","background-repeat","background-size","baseline-shift","binding","bleed","bookmark-label","bookmark-level","bookmark-state","bookmark-target","border","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-decoration-break","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","clear","clip","color","color-profile","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","content","counter-increment","counter-reset","crop","cue","cue-after","cue-before","cursor","direction","display","dominant-baseline","drop-initial-after-adjust","drop-initial-after-align","drop-initial-before-adjust","drop-initial-before-align","drop-initial-size","drop-initial-value","elevation","empty-cells","fit","fit-position","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","float-offset","flow-from","flow-into","font","font-feature-settings","font-family","font-kerning","font-language-override","font-size","font-size-adjust","font-stretch","font-style","font-synthesis","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-ligatures","font-variant-numeric","font-variant-position","font-weight","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-position","grid-auto-rows","grid-column","grid-column-end","grid-column-start","grid-row","grid-row-end","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphens","icon","image-orientation","image-rendering","image-resolution","inline-box-align","justify-content","left","letter-spacing","line-break","line-height","line-stacking","line-stacking-ruby","line-stacking-shift","line-stacking-strategy","list-style","list-style-image","list-style-position","list-style-type","margin","margin-bottom","margin-left","margin-right","margin-top","marker-offset","marks","marquee-direction","marquee-loop","marquee-play-count","marquee-speed","marquee-style","max-height","max-width","min-height","min-width","move-to","nav-down","nav-index","nav-left","nav-right","nav-up","object-fit","object-position","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-style","overflow-wrap","overflow-x","overflow-y","padding","padding-bottom","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","page-policy","pause","pause-after","pause-before","perspective","perspective-origin","pitch","pitch-range","play-during","position","presentation-level","punctuation-trim","quotes","region-break-after","region-break-before","region-break-inside","region-fragment","rendering-intent","resize","rest","rest-after","rest-before","richness","right","rotation","rotation-point","ruby-align","ruby-overhang","ruby-position","ruby-span","shape-image-threshold","shape-inside","shape-margin","shape-outside","size","speak","speak-as","speak-header","speak-numeral","speak-punctuation","speech-rate","stress","string-set","tab-size","table-layout","target","target-name","target-new","target-position","text-align","text-align-last","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-style","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-height","text-indent","text-justify","text-outline","text-overflow","text-shadow","text-size-adjust","text-space-collapse","text-transform","text-underline-position","text-wrap","top","transform","transform-origin","transform-style","transition","transition-delay","transition-duration","transition-property","transition-timing-function","unicode-bidi","vertical-align","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","volume","white-space","widows","width","will-change","word-break","word-spacing","word-wrap","z-index","clip-path","clip-rule","mask","enable-background","filter","flood-color","flood-opacity","lighting-color","stop-color","stop-opacity","pointer-events","color-interpolation","color-interpolation-filters","color-rendering","fill","fill-opacity","fill-rule","image-rendering","marker","marker-end","marker-mid","marker-start","shape-rendering","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","text-rendering","baseline-shift","dominant-baseline","glyph-orientation-horizontal","glyph-orientation-vertical","text-anchor","writing-mode","font-smoothing","osx-font-smoothing"]; From 23b7a9924b5f9460a091e97392dd00d3834e8cc6 Mon Sep 17 00:00:00 2001 From: "David R. Myers" Date: Fri, 23 Oct 2020 15:12:03 -0400 Subject: [PATCH 2030/2444] Add WebAssembly to meta --- mode/meta.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mode/meta.js b/mode/meta.js index d3efdc172f..c7738a514c 100644 --- a/mode/meta.js +++ b/mode/meta.js @@ -169,7 +169,8 @@ {name: "Z80", mime: "text/x-z80", mode: "z80", ext: ["z80"]}, {name: "mscgen", mime: "text/x-mscgen", mode: "mscgen", ext: ["mscgen", "mscin", "msc"]}, {name: "xu", mime: "text/x-xu", mode: "mscgen", ext: ["xu"]}, - {name: "msgenny", mime: "text/x-msgenny", mode: "mscgen", ext: ["msgenny"]} + {name: "msgenny", mime: "text/x-msgenny", mode: "mscgen", ext: ["msgenny"]}, + {name: "WebAssembly", mime: "text/webassembly", mode: "wast", ext: ["wat", "wast"]}, ]; // Ensure all modes have a mime property for backwards compatibility for (var i = 0; i < CodeMirror.modeInfo.length; i++) { From 264022ee4af4abca1c158944dc299a8faf8696d6 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Mon, 26 Oct 2020 09:08:51 +0100 Subject: [PATCH 2031/2444] Mark version 5.58.2 --- AUTHORS | 3 +++ CHANGELOG.md | 8 ++++++++ doc/manual.html | 2 +- doc/releases.html | 7 +++++++ index.html | 2 +- package.json | 2 +- src/edit/main.js | 2 +- 7 files changed, 22 insertions(+), 4 deletions(-) diff --git a/AUTHORS b/AUTHORS index bb017e9574..b8087133a8 100644 --- a/AUTHORS +++ b/AUTHORS @@ -208,6 +208,7 @@ David Barnett David H. Bronke David Mignot David Pathakjee +David R. Myers David Rodrigues David Santana David Vázquez @@ -524,6 +525,7 @@ Marijn Haverbeke Mário Gonçalves Mario Pietsch Mark Anderson +Mark Boyes Mark Dalgleish Mark Hamstra Mark Lentczner @@ -634,6 +636,7 @@ Nikolaj Kappler Nikolay Kostov nilp0inter Nils Knappmeier +Nina Pypchenko Nisarg Jhaveri nlwillia noragrossman diff --git a/CHANGELOG.md b/CHANGELOG.md index d3e3fe4223..80200fc784 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +## 5.58.2 (2020-10-23) + +### Bug fixes + +Fix a bug where horizontally scrolling the cursor into view sometimes failed with a non-fixed gutter. + +[julia mode](https://codemirror.net/mode/julia/): Fix an infinite recursion bug. + ## 5.58.1 (2020-09-23) ### Bug fixes diff --git a/doc/manual.html b/doc/manual.html index 42ab5491ed..1da41d3ccb 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -70,7 +70,7 @@

      User manual and reference guide - version 5.58.1 + version 5.58.2

      CodeMirror is a code-editor component that can be embedded in diff --git a/doc/releases.html b/doc/releases.html index 0b466970fc..bdf24ed2f7 100644 --- a/doc/releases.html +++ b/doc/releases.html @@ -30,6 +30,13 @@

      Release notes and version history

      Version 5.x

      +

      23-10-2020: Version 5.58.2:

      + +
        +
      • Fix a bug where horizontally scrolling the cursor into view sometimes failed with a non-fixed gutter.
      • +
      • julia mode: Fix an infinite recursion bug.
      • +
      +

      21-09-2020: Version 5.58.1:

        diff --git a/index.html b/index.html index ff27b925b7..6d41dcc79e 100644 --- a/index.html +++ b/index.html @@ -99,7 +99,7 @@

        This is CodeMirror

    - Get the current version: 5.58.1.
    + Get the current version: 5.58.2.
    You can see the code,
    read the release notes,
    or study the user manual. diff --git a/package.json b/package.json index ba8e7fc79d..2103e1c325 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "codemirror", - "version": "5.58.1", + "version": "5.58.2", "main": "lib/codemirror.js", "style": "lib/codemirror.css", "author": { diff --git a/src/edit/main.js b/src/edit/main.js index 4f9152d892..800ee766f2 100644 --- a/src/edit/main.js +++ b/src/edit/main.js @@ -66,4 +66,4 @@ import { addLegacyProps } from "./legacy.js" addLegacyProps(CodeMirror) -CodeMirror.version = "5.58.1" +CodeMirror.version = "5.58.2" From 138d1b75791f8bb0b9a07fd19cbc2bb81e13dd8f Mon Sep 17 00:00:00 2001 From: tophf Date: Wed, 28 Oct 2020 21:30:38 +0300 Subject: [PATCH 2032/2444] [stylus mode] allow block comments --- mode/stylus/stylus.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mode/stylus/stylus.js b/mode/stylus/stylus.js index 281118efee..eecc554bc0 100644 --- a/mode/stylus/stylus.js +++ b/mode/stylus/stylus.js @@ -722,6 +722,9 @@ return indent; }, electricChars: "}", + blockCommentStart: "/*", + blockCommentEnd: "*/", + blockCommentContinue: " * ", lineComment: "//", fold: "indent" }; From 4fddb355dead97ca7fc3e096ea5eb0ade62b306d Mon Sep 17 00:00:00 2001 From: Phil DeJarnett Date: Thu, 29 Oct 2020 15:27:22 -0400 Subject: [PATCH 2033/2444] [xml-hint addon] Replace nested function with function expression --- addon/hint/xml-hint.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addon/hint/xml-hint.js b/addon/hint/xml-hint.js index 543d19b61c..2b3153124e 100644 --- a/addon/hint/xml-hint.js +++ b/addon/hint/xml-hint.js @@ -101,12 +101,12 @@ } replaceToken = true; } - function returnHintsFromAtValues(atValues) { + var returnHintsFromAtValues = function(atValues) { if (atValues) for (var i = 0; i < atValues.length; ++i) if (!prefix || matches(atValues[i], prefix, matchInMiddle)) result.push(quote + atValues[i] + quote); return returnHints(); - } + }; if (atValues && atValues.then) return atValues.then(returnHintsFromAtValues); return returnHintsFromAtValues(atValues); } else { // An attribute name From 230cc2e3f70d3e4fc55617437fd4f4995e6817a5 Mon Sep 17 00:00:00 2001 From: iteriani Date: Fri, 30 Oct 2020 00:39:51 -0700 Subject: [PATCH 2034/2444] [soy mode] Add support for Element Composition Add support for Soy Element Composition. It has the syntax in the form of <{foo()}> This adds support to pass through allowEmptyTag and to support this mode in closetag. --- mode/htmlmixed/htmlmixed.js | 3 ++- mode/soy/soy.js | 4 +++- mode/soy/test.js | 16 ++++++++++++++++ mode/xml/xml.js | 4 ++-- 4 files changed, 23 insertions(+), 4 deletions(-) diff --git a/mode/htmlmixed/htmlmixed.js b/mode/htmlmixed/htmlmixed.js index 8341ac8261..66a158274c 100644 --- a/mode/htmlmixed/htmlmixed.js +++ b/mode/htmlmixed/htmlmixed.js @@ -74,7 +74,8 @@ name: "xml", htmlMode: true, multilineTagIndentFactor: parserConfig.multilineTagIndentFactor, - multilineTagIndentPastTag: parserConfig.multilineTagIndentPastTag + multilineTagIndentPastTag: parserConfig.multilineTagIndentPastTag, + allowMissingTagName: parserConfig.allowMissingTagName, }); var tags = {}; diff --git a/mode/soy/soy.js b/mode/soy/soy.js index d31c947eed..bd3d947145 100644 --- a/mode/soy/soy.js +++ b/mode/soy/soy.js @@ -16,6 +16,8 @@ "alias": { noEndTag: true }, "delpackage": { noEndTag: true }, "namespace": { noEndTag: true, soyState: "namespace-def" }, + "@attribute": paramData, + "@attribute?": paramData, "@param": paramData, "@param?": paramData, "@inject": paramData, @@ -53,7 +55,7 @@ CodeMirror.defineMode("soy", function(config) { var textMode = CodeMirror.getMode(config, "text/plain"); var modes = { - html: CodeMirror.getMode(config, {name: "text/html", multilineTagIndentFactor: 2, multilineTagIndentPastTag: false}), + html: CodeMirror.getMode(config, {name: "text/html", multilineTagIndentFactor: 2, multilineTagIndentPastTag: false, allowMissingTagName: true}), attributes: textMode, text: textMode, uri: textMode, diff --git a/mode/soy/test.js b/mode/soy/test.js index 57cd4be477..78faddb9aa 100644 --- a/mode/soy/test.js +++ b/mode/soy/test.js @@ -26,6 +26,10 @@ '[keyword {] [callee&variable index]([variable-2&error $list])[keyword }]' + '[string "][tag&bracket />]'); + MT('soy-element-composition-test', + '[tag&bracket <][keyword {][callee&variable foo]()[keyword }]', + '[tag&bracket >]'); + MT('namespace-test', '[keyword {namespace] [variable namespace][keyword }]') @@ -176,6 +180,18 @@ '[keyword {/template}]', ''); + MT('attribute-type', + '[keyword {template] [def .foo][keyword }]', + ' [keyword {@attribute] [def bar]: [type string][keyword }]', + '[keyword {/template}]', + ''); + + MT('attribute-type-optional', + '[keyword {template] [def .foo][keyword }]', + ' [keyword {@attribute] [def bar]: [type string][keyword }]', + '[keyword {/template}]', + ''); + MT('state-variable-reference', '[keyword {template] [def .foo][keyword }]', ' [keyword {@param] [def bar]:= [atom true][keyword }]', diff --git a/mode/xml/xml.js b/mode/xml/xml.js index 73c6e0e0dd..46806ac425 100644 --- a/mode/xml/xml.js +++ b/mode/xml/xml.js @@ -189,7 +189,7 @@ CodeMirror.defineMode("xml", function(editorConf, config_) { function Context(state, tagName, startOfLine) { this.prev = state.context; - this.tagName = tagName; + this.tagName = tagName || ""; this.indent = state.indented; this.startOfLine = startOfLine; if (config.doNotIndent.hasOwnProperty(tagName) || (state.context && state.context.noIndent)) @@ -399,7 +399,7 @@ CodeMirror.defineMode("xml", function(editorConf, config_) { xmlCurrentContext: function(state) { var context = [] for (var cx = state.context; cx; cx = cx.prev) - if (cx.tagName) context.push(cx.tagName) + context.push(cx.tagName) return context.reverse() } }; From 8e7f6728bf1d36963fafdf997b12858f25d7711a Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Mon, 26 Oct 2020 09:08:36 +0100 Subject: [PATCH 2035/2444] Delay blur events during dragging and clicking Issue #6427 --- src/display/focus.js | 9 ++++++--- src/edit/mouse_events.js | 10 ++++++---- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/display/focus.js b/src/display/focus.js index aa731b4353..0337327e12 100644 --- a/src/display/focus.js +++ b/src/display/focus.js @@ -4,19 +4,22 @@ import { addClass, rmClass } from "../util/dom.js" import { signal } from "../util/event.js" export function ensureFocus(cm) { - if (!cm.state.focused) { cm.display.input.focus(); onFocus(cm) } + if (!cm.hasFocus()) { + cm.display.input.focus() + if (!cm.state.focused) onFocus(cm) + } } export function delayBlurEvent(cm) { cm.state.delayingBlurEvent = true setTimeout(() => { if (cm.state.delayingBlurEvent) { cm.state.delayingBlurEvent = false - onBlur(cm) + if (cm.state.focused) onBlur(cm) } }, 100) } export function onFocus(cm, e) { - if (cm.state.delayingBlurEvent) cm.state.delayingBlurEvent = false + if (cm.state.delayingBlurEvent && !cm.state.draggingText) cm.state.delayingBlurEvent = false if (cm.options.readOnly == "nocursor") return if (!cm.state.focused) { diff --git a/src/edit/mouse_events.js b/src/edit/mouse_events.js index 5fcc437021..1c820fdb6e 100644 --- a/src/edit/mouse_events.js +++ b/src/edit/mouse_events.js @@ -1,4 +1,4 @@ -import { delayBlurEvent, ensureFocus } from "../display/focus.js" +import { delayBlurEvent, ensureFocus, onBlur } from "../display/focus.js" import { operation } from "../display/operations.js" import { visibleLines } from "../display/update_lines.js" import { clipPos, cmp, maxPos, minPos, Pos } from "../line/pos.js" @@ -149,6 +149,7 @@ function leftButtonStartDrag(cm, event, pos, behavior) { let dragEnd = operation(cm, e => { if (webkit) display.scroller.draggable = false cm.state.draggingText = false + if (cm.state.delayingBlurEvent) delayBlurEvent(cm) off(display.wrapper.ownerDocument, "mouseup", dragEnd) off(display.wrapper.ownerDocument, "mousemove", mouseMove) off(display.scroller, "dragstart", dragStart) @@ -172,15 +173,15 @@ function leftButtonStartDrag(cm, event, pos, behavior) { if (webkit) display.scroller.draggable = true cm.state.draggingText = dragEnd dragEnd.copy = !behavior.moveOnDrag - // IE's approach to draggable - if (display.scroller.dragDrop) display.scroller.dragDrop() on(display.wrapper.ownerDocument, "mouseup", dragEnd) on(display.wrapper.ownerDocument, "mousemove", mouseMove) on(display.scroller, "dragstart", dragStart) on(display.scroller, "drop", dragEnd) - delayBlurEvent(cm) + cm.state.delayingBlurEvent = true setTimeout(() => display.input.focus(), 20) + // IE's approach to draggable + if (display.scroller.dragDrop) display.scroller.dragDrop() } function rangeForUnit(cm, pos, unit) { @@ -193,6 +194,7 @@ function rangeForUnit(cm, pos, unit) { // Normal selection, as opposed to text dragging. function leftButtonSelect(cm, event, start, behavior) { + if (ie) delayBlurEvent(cm) let display = cm.display, doc = cm.doc e_preventDefault(event) From f006f3d867c62813309a6f16f5fc242092a73b7b Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Wed, 4 Nov 2020 16:30:32 +0100 Subject: [PATCH 2036/2444] Remove unused import --- src/edit/mouse_events.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/edit/mouse_events.js b/src/edit/mouse_events.js index 1c820fdb6e..401eadf431 100644 --- a/src/edit/mouse_events.js +++ b/src/edit/mouse_events.js @@ -1,4 +1,4 @@ -import { delayBlurEvent, ensureFocus, onBlur } from "../display/focus.js" +import { delayBlurEvent, ensureFocus } from "../display/focus.js" import { operation } from "../display/operations.js" import { visibleLines } from "../display/update_lines.js" import { clipPos, cmp, maxPos, minPos, Pos } from "../line/pos.js" From 57ba96eb392401d209b63dd187f2f2c087f1885b Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Thu, 5 Nov 2020 09:03:33 +0100 Subject: [PATCH 2037/2444] Fix handling of insertAt option to addLineWidget Issue #6460 --- src/model/line_widget.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/model/line_widget.js b/src/model/line_widget.js index 5444d89df0..f94727e5f8 100644 --- a/src/model/line_widget.js +++ b/src/model/line_widget.js @@ -63,7 +63,7 @@ export function addLineWidget(doc, handle, node, options) { changeLine(doc, handle, "widget", line => { let widgets = line.widgets || (line.widgets = []) if (widget.insertAt == null) widgets.push(widget) - else widgets.splice(Math.min(widgets.length - 1, Math.max(0, widget.insertAt)), 0, widget) + else widgets.splice(Math.min(widgets.length, Math.max(0, widget.insertAt)), 0, widget) widget.line = line if (cm && !lineIsHidden(doc, line)) { let aboveVisible = heightAtLine(line) < doc.scrollTop From 6ba05b288eb2fb948653b597f6f7f11770bb9aef Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Thu, 12 Nov 2020 09:28:39 +0100 Subject: [PATCH 2038/2444] [shell mode] Add support for Bash-style heredoc quoting Closes #6468 --- mode/shell/shell.js | 15 +++++++++++++++ mode/shell/test.js | 15 +++++++++++---- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/mode/shell/shell.js b/mode/shell/shell.js index 5af12413b0..2bc1eaf948 100644 --- a/mode/shell/shell.js +++ b/mode/shell/shell.js @@ -70,6 +70,13 @@ CodeMirror.defineMode('shell', function() { stream.eatWhile(/\w/); return 'attribute'; } + if (ch == "<") { + let heredoc = stream.match(/^<-?\s+(.*)/) + if (heredoc) { + state.tokens.unshift(tokenHeredoc(heredoc[1])) + return 'string-2' + } + } if (/\d/.test(ch)) { stream.eatWhile(/\d/); if(stream.eol() || !/\w/.test(stream.peek())) { @@ -129,6 +136,14 @@ CodeMirror.defineMode('shell', function() { return 'def'; }; + function tokenHeredoc(delim) { + return function(stream, state) { + if (stream.sol() && stream.string == delim) state.tokens.shift() + stream.skipToEnd() + return "string-2" + } + } + function tokenize(stream, state) { return (state.tokens[0] || tokenBase) (stream, state); }; diff --git a/mode/shell/test.js b/mode/shell/test.js index 7571d907de..237375d451 100644 --- a/mode/shell/test.js +++ b/mode/shell/test.js @@ -65,9 +65,16 @@ MT("strings in parens", "[def FOO][operator =]([quote $(<][string \"][def $MYDIR][string \"][quote /myfile grep ][string 'hello$'][quote )])") - MT ("string ending in dollar", - '[def a][operator =][string "xyz$"]; [def b][operator =][string "y"]') + MT("string ending in dollar", + '[def a][operator =][string "xyz$"]; [def b][operator =][string "y"]') - MT ("quote ending in dollar", - "[quote $(echo a$)]") + MT("quote ending in dollar", + "[quote $(echo a$)]") + + MT("heredoc", + "[builtin cat] [string-2 <<- end]", + "[string-2 content one]", + "[string-2 content two end]", + "[string-2 end]", + "[builtin echo]") })(); From ffc17920ed39779f3a18b3f6333bbf6a2bc3a537 Mon Sep 17 00:00:00 2001 From: Christopher Wallis Date: Thu, 12 Nov 2020 01:43:36 -0700 Subject: [PATCH 2039/2444] [soy mode] Add support for {@attribute *} - forks the state at param-def to detect * as a type --- mode/soy/soy.js | 5 +++++ mode/soy/test.js | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/mode/soy/soy.js b/mode/soy/soy.js index bd3d947145..cac59bb3df 100644 --- a/mode/soy/soy.js +++ b/mode/soy/soy.js @@ -276,6 +276,11 @@ return null; case "param-def": + if (match = stream.match(/^\*/)) { + state.soyState.pop(); + state.soyState.push("param-type"); + return "type"; + } if (match = stream.match(/^\w+/)) { state.variables = prepend(state.variables, match[0]); state.soyState.pop(); diff --git a/mode/soy/test.js b/mode/soy/test.js index 78faddb9aa..8c764c7a2b 100644 --- a/mode/soy/test.js +++ b/mode/soy/test.js @@ -192,6 +192,12 @@ '[keyword {/template}]', ''); + MT('attribute-type-all', + '[keyword {template] [def .foo][keyword }]', + ' [keyword {@attribute] [type *][keyword }]', + '[keyword {/template}]', + ''); + MT('state-variable-reference', '[keyword {template] [def .foo][keyword }]', ' [keyword {@param] [def bar]:= [atom true][keyword }]', From eb345ef70e75805bf7d7d02b9d87c30ec1db2937 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Fri, 13 Nov 2020 10:06:33 +0100 Subject: [PATCH 2040/2444] Fix lint error --- mode/shell/shell.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mode/shell/shell.js b/mode/shell/shell.js index 2bc1eaf948..2b0d8a91bc 100644 --- a/mode/shell/shell.js +++ b/mode/shell/shell.js @@ -71,7 +71,7 @@ CodeMirror.defineMode('shell', function() { return 'attribute'; } if (ch == "<") { - let heredoc = stream.match(/^<-?\s+(.*)/) + var heredoc = stream.match(/^<-?\s+(.*)/) if (heredoc) { state.tokens.unshift(tokenHeredoc(heredoc[1])) return 'string-2' From dda3f9d6b8d2450b87b619ed5db761cb20b892b8 Mon Sep 17 00:00:00 2001 From: iteriani Date: Fri, 13 Nov 2020 01:08:19 -0800 Subject: [PATCH 2041/2444] [soy mode] Natively support Soy Element Composition * Add support for Soy Element Composition. Add support for Soy Element Composition. It has the syntax in the form of <{foo()}> This adds support to pass through allowEmptyTag and to support this mode in closetag. * Disable allowMissingTagName and handle Soy Element Composition directly. Disable allowMissingTagName and handle Soy Element Composition directly. This also adds a case in closetag.js to handle autocompletes for soy element composition. Right now, if you were to do something like <{foo()}> it would autocomplet with . This change makes it autocomplete with --- addon/edit/closetag.js | 5 +++-- mode/soy/soy.js | 20 ++++++++++++++++++++ mode/soy/test.js | 9 +++++++-- 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/addon/edit/closetag.js b/addon/edit/closetag.js index 8689765eec..7c22a50ecf 100644 --- a/addon/edit/closetag.js +++ b/addon/edit/closetag.js @@ -128,9 +128,10 @@ replacement = head + "style"; } else { var context = inner.mode.xmlCurrentContext && inner.mode.xmlCurrentContext(state) - if (!context || (context.length && closingTagExists(cm, context, context[context.length - 1], pos))) + var top = context.length ? context[context.length - 1] : "" + if (!context || (context.length && closingTagExists(cm, context, top, pos))) return CodeMirror.Pass; - replacement = head + context[context.length - 1] + replacement = head + top } if (cm.getLine(pos.line).charAt(tok.end) != ">") replacement += ">"; replacements[i] = replacement; diff --git a/mode/soy/soy.js b/mode/soy/soy.js index cac59bb3df..17bafcd932 100644 --- a/mode/soy/soy.js +++ b/mode/soy/soy.js @@ -498,6 +498,17 @@ } return expression(stream, state); + case "template-call-expression": + if (stream.match(/^([\w-?]+)(?==)/)) { + return "attribute"; + } else if (stream.eat('>')) { + state.soyState.pop(); + return "keyword"; + } else if (stream.eat('/>')) { + state.soyState.pop(); + return "keyword"; + } + return expression(stream, state); case "literal": if (stream.match(/^(?=\{\/literal})/)) { state.soyState.pop(); @@ -563,6 +574,15 @@ state.soyState.push("import"); state.indent += 2 * config.indentUnit; return "keyword"; + } else if (match = stream.match(/^<\{/)) { + state.soyState.push("template-call-expression"); + state.tag = "print"; + state.indent += 2 * config.indentUnit; + state.soyState.push("tag"); + return "keyword"; + } else if (match = stream.match(/^<\/>/)) { + state.indent -= 2 * config.indentUnit; + return "keyword"; } return tokenUntil(stream, state, /\{|\s+\/\/|\/\*/); diff --git a/mode/soy/test.js b/mode/soy/test.js index 8c764c7a2b..ae13158720 100644 --- a/mode/soy/test.js +++ b/mode/soy/test.js @@ -27,8 +27,13 @@ '[string "][tag&bracket />]'); MT('soy-element-composition-test', - '[tag&bracket <][keyword {][callee&variable foo]()[keyword }]', - '[tag&bracket >]'); + '[keyword <{][callee&variable foo]()[keyword }]', + '[keyword >]'); + + MT('soy-element-composition-attribute-test', + '[keyword <{][callee&variable foo]()[keyword }]', + '[attribute class]=[string "Foo"]', + '[keyword >]'); MT('namespace-test', '[keyword {namespace] [variable namespace][keyword }]') From 37f7d7b00b674c4ebf380855d77f822829a8b76b Mon Sep 17 00:00:00 2001 From: Hendrik Erz Date: Sat, 14 Nov 2020 20:23:25 +0100 Subject: [PATCH 2042/2444] [show-hint addon] Document all options --- doc/manual.html | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/doc/manual.html b/doc/manual.html index 1da41d3ccb..2ba7c732f2 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -2700,8 +2700,8 @@

    Addons

    Defines editor.showHint, which takes an optional options object, and pops up a widget that allows the user to select a completion. Finding hints is done with a hinting - functions (the hint option), which is a function - that take an editor instance and options object, and return + function (the hint option). This function + takes an editor instance and an options object, and returns a {list, from, to} object, where list is an array of strings or objects (the completions), and from and to give the start and end @@ -2771,9 +2771,22 @@

    Addons

    alignWithWord: boolean
    Whether the pop-up should be horizontally aligned with the start of the word (true, default), or with the cursor (false).
    +
    closeCharacters: RegExp
    +
    A regular expression object used to match characters which + cause the pop up to be closed (default: /[\s()\[\]{};:>,]/). + If the user types one of these characters, the pop up will close, and + the endCompletion event is fired on the editor instance.
    closeOnUnfocus: boolean
    When enabled (which is the default), the pop-up will close when the editor is unfocused.
    +
    completeOnSingleClick: boolean
    +
    Whether a single click on a list item suffices to trigger the + completion (which is the default), or if the user has to use a + doubleclick.
    +
    container: Element|null
    +
    Can be used to define a custom container for the widget. The default + is null, in which case the body-element will + be used.
    customKeys: keymap
    Allows you to provide a custom key map of keys to be active when the pop-up is active. The handlers will be called with an @@ -2809,6 +2822,14 @@

    Addons

    "close" ()
    Fired when the completion is finished.
    + The following events will be fired on the editor instance during + completion: +
    +
    "endCompletion" ()
    +
    Fired when the pop-up is being closed programmatically, e.g., when + the user types a character which matches the + closeCharacters option.
    +
    This addon depends on styles from addon/hint/show-hint.css. Check out the demo for an From 097d7c957c7d4988a942d11c0ac681f004ba0e8a Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Mon, 16 Nov 2020 21:58:04 +0100 Subject: [PATCH 2043/2444] [html-hint addon] Add dialog tag Closes #6474 --- addon/hint/html-hint.js | 1 + 1 file changed, 1 insertion(+) diff --git a/addon/hint/html-hint.js b/addon/hint/html-hint.js index d0cca4f6a2..9878eca6ef 100644 --- a/addon/hint/html-hint.js +++ b/addon/hint/html-hint.js @@ -98,6 +98,7 @@ dfn: s, dir: s, div: s, + dialog: { attrs: { open: null } }, dl: s, dt: s, em: s, From 12512d3ed0014696a64fe5d6bee2e0e5259a4861 Mon Sep 17 00:00:00 2001 From: erosman Date: Tue, 17 Nov 2020 14:23:54 +0330 Subject: [PATCH 2044/2444] [javascript-lint addon] Add comment noting dependency Added note on dependency on jshint.js --- addon/lint/javascript-lint.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/addon/lint/javascript-lint.js b/addon/lint/javascript-lint.js index cc132d7f82..e5bc752308 100644 --- a/addon/lint/javascript-lint.js +++ b/addon/lint/javascript-lint.js @@ -1,6 +1,8 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE +// Depends on jshint.js from https://github.com/jshint/jshint + (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror")); From 0e6548686356d58504638c2bea95d403a9e53cde Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Wed, 18 Nov 2020 07:55:38 +0100 Subject: [PATCH 2045/2444] Fix focus state confusion in drag handler Issue #6480 --- mode/clike/clike.js | 8 ++++---- src/edit/mouse_events.js | 5 ++++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/mode/clike/clike.js b/mode/clike/clike.js index 37da2ec964..2154f1d2df 100644 --- a/mode/clike/clike.js +++ b/mode/clike/clike.js @@ -82,15 +82,15 @@ CodeMirror.defineMode("clike", function(config, parserConfig) { state.tokenize = tokenString(ch); return state.tokenize(stream, state); } - if (isPunctuationChar.test(ch)) { - curPunc = ch; - return null; - } if (numberStart.test(ch)) { stream.backUp(1) if (stream.match(number)) return "number" stream.next() } + if (isPunctuationChar.test(ch)) { + curPunc = ch; + return null; + } if (ch == "/") { if (stream.eat("*")) { state.tokenize = tokenComment; diff --git a/src/edit/mouse_events.js b/src/edit/mouse_events.js index 401eadf431..b5d0b5a64e 100644 --- a/src/edit/mouse_events.js +++ b/src/edit/mouse_events.js @@ -149,7 +149,10 @@ function leftButtonStartDrag(cm, event, pos, behavior) { let dragEnd = operation(cm, e => { if (webkit) display.scroller.draggable = false cm.state.draggingText = false - if (cm.state.delayingBlurEvent) delayBlurEvent(cm) + if (cm.state.delayingBlurEvent) { + if (cm.hasFocus()) cm.state.delayingBlurEvent = false + else delayBlurEvent(cm) + } off(display.wrapper.ownerDocument, "mouseup", dragEnd) off(display.wrapper.ownerDocument, "mousemove", mouseMove) off(display.scroller, "dragstart", dragStart) From 5d2feacfc89aab7e9b973ec59627b9def1f63d77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Esp=C3=ADn?= Date: Wed, 18 Nov 2020 13:27:20 +0100 Subject: [PATCH 2046/2444] [real-world uses] Add Graviton Editor --- doc/realworld.html | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/realworld.html b/doc/realworld.html index da6182515e..5da12e2c48 100644 --- a/doc/realworld.html +++ b/doc/realworld.html @@ -96,6 +96,7 @@

    CodeMirror real-world uses

  • Go language tour
  • Google Apps Script
  • Graphit (function graphing)
  • +
  • Graviton Editor (Cross-platform and modern-looking code editor)
  • HackMD (Realtime collaborative markdown notes on all platforms)
  • Handcraft (HTML prototyping)
  • Hawkee
  • From 0630b63d94ba1b1f79ae89577ec1985f5e277025 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Thu, 19 Nov 2020 09:29:46 +0100 Subject: [PATCH 2047/2444] [placeholder addon] Further fix composition handling Closes #6479 --- addon/display/placeholder.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/addon/display/placeholder.js b/addon/display/placeholder.js index 89bb93f378..cfb8341db2 100644 --- a/addon/display/placeholder.js +++ b/addon/display/placeholder.js @@ -50,11 +50,12 @@ function onComposition(cm) { setTimeout(function() { - var empty = false, input = cm.getInputField() - if (input.nodeName == "TEXTAREA") - empty = !input.value - else if (cm.lineCount() == 1) - empty = !/[^\u200b]/.test(input.querySelector(".CodeMirror-line").textContent) + var empty = false + if (cm.lineCount() == 1) { + var input = cm.getInputField() + empty = input.nodeName == "TEXTAREA" ? !cm.getLine(0).length + : !/[^\u200b]/.test(input.querySelector(".CodeMirror-line").textContent) + } if (empty) setPlaceholder(cm) else clearPlaceholder(cm) }, 20) From a53e86069bc06410ff477a8a5849a5abd26f983a Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Thu, 19 Nov 2020 09:38:15 +0100 Subject: [PATCH 2048/2444] Mark version 5.58.3 --- AUTHORS | 5 +++++ CHANGELOG.md | 12 ++++++++++++ doc/manual.html | 2 +- doc/releases.html | 9 +++++++++ index.html | 2 +- package.json | 2 +- src/edit/main.js | 2 +- 7 files changed, 30 insertions(+), 4 deletions(-) diff --git a/AUTHORS b/AUTHORS index b8087133a8..33d819ed24 100644 --- a/AUTHORS +++ b/AUTHORS @@ -251,6 +251,7 @@ Eric Allam Eric Bogard Erik Demaine Erik Welander +erosman eustas Evan Minsk Fabien Dubosson @@ -326,6 +327,7 @@ Heanes Hector Oswaldo Caballero Hein Htat Hélio +Hendrik Erz Hendrik Wallbaum Henrik Haugbølle Herculano Campos @@ -353,6 +355,7 @@ Ilya Zverev Ingo Richter Intervue Irakli Gozalishvili +iteriani Ivan Kurnosov Ivoah Jack Douglas @@ -517,6 +520,7 @@ Manuel Rego Casasnovas Marat Dreizin Marcel Gerber Marcelo Camargo +Marc Espín Marco Aurélio Marco Munizaga Marcus Bointon @@ -681,6 +685,7 @@ Peter Flynn peterkroon Peter Kroon Peter László +Phil DeJarnett Philipp A Philipp Markovics Philip Stadermann diff --git a/CHANGELOG.md b/CHANGELOG.md index 80200fc784..2b00dbd80e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,15 @@ +## 5.58.3 (2020-11-19) + +### Bug fixes + +Suppress quick-firing of blur-focus events when dragging and clicking on Internet Explorer. + +Fix the `insertAt` option to `addLineWidget` to actually allow the widget to be placed after all widgets for the line. + +[soy mode](https://codemirror.net/mode/soy/): Support `@Attribute` and element composition. + +[shell mode](https://codemirror.net/mode/shell/): Support heredoc quoting. + ## 5.58.2 (2020-10-23) ### Bug fixes diff --git a/doc/manual.html b/doc/manual.html index 2ba7c732f2..89a6328e6d 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -70,7 +70,7 @@

    User manual and reference guide - version 5.58.2 + version 5.58.3

    CodeMirror is a code-editor component that can be embedded in diff --git a/doc/releases.html b/doc/releases.html index bdf24ed2f7..1b4f9a7976 100644 --- a/doc/releases.html +++ b/doc/releases.html @@ -30,6 +30,15 @@

    Release notes and version history

    Version 5.x

    +

    19-11-2020: Version 5.58.3:

    + +
      +
    • Suppress quick-firing of blur-focus events when dragging and clicking on Internet Explorer.
    • +
    • Fix the insertAt option to addLineWidget to actually allow the widget to be placed after all widgets for the line.
    • +
    • soy mode: Support @Attribute and element composition.
    • +
    • shell mode: Support heredoc quoting.
    • +
    +

    23-10-2020: Version 5.58.2:

      diff --git a/index.html b/index.html index 6d41dcc79e..7ea8c48961 100644 --- a/index.html +++ b/index.html @@ -99,7 +99,7 @@

      This is CodeMirror

    - Get the current version: 5.58.2.
    + Get the current version: 5.58.3.
    You can see the code,
    read the release notes,
    or study the user manual. diff --git a/package.json b/package.json index 2103e1c325..a768858ec8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "codemirror", - "version": "5.58.2", + "version": "5.58.3", "main": "lib/codemirror.js", "style": "lib/codemirror.css", "author": { diff --git a/src/edit/main.js b/src/edit/main.js index 800ee766f2..d51192c6e5 100644 --- a/src/edit/main.js +++ b/src/edit/main.js @@ -66,4 +66,4 @@ import { addLegacyProps } from "./legacy.js" addLegacyProps(CodeMirror) -CodeMirror.version = "5.58.2" +CodeMirror.version = "5.58.3" From 5bef47a743e8569af3f11fac628501bb3bc10108 Mon Sep 17 00:00:00 2001 From: erosman Date: Thu, 19 Nov 2020 16:19:58 +0330 Subject: [PATCH 2049/2444] Fix white CodeMirror-scrollbar-filler on dark themes background-color: white; remains white on dark themes which doesn't suit dark background pages. Changing it to transparent to match the theme. --- lib/codemirror.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/codemirror.css b/lib/codemirror.css index a64f97c777..5ea2d2be2a 100644 --- a/lib/codemirror.css +++ b/lib/codemirror.css @@ -19,7 +19,7 @@ } .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler { - background-color: white; /* The little square between H and V scrollbars */ + background-color: transparent; /* The little square between H and V scrollbars */ } /* GUTTER */ From a82516d0fab6ce877f2aa699fd0a435e2274c7fd Mon Sep 17 00:00:00 2001 From: Lonnie Abelbeck Date: Fri, 20 Nov 2020 02:23:52 -0600 Subject: [PATCH 2050/2444] [shell mode] Fix Heredoc to allow quotes and not require a space (a space is not required and the DELIMITER may be quoted for special meaning) cat < Date: Sat, 21 Nov 2020 01:34:52 +0330 Subject: [PATCH 2051/2444] [lint addon] Filter out duplicate messages on a single line --- addon/lint/lint.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/addon/lint/lint.js b/addon/lint/lint.js index 963f2cf227..e970a25ade 100644 --- a/addon/lint/lint.js +++ b/addon/lint/lint.js @@ -170,6 +170,10 @@ var anns = annotations[line]; if (!anns) continue; + // filter out duplicate messages + var message = []; + anns = anns.filter(item => message.indexOf(item.message) > -1 ? false : message.push(item.message)); + var maxSeverity = null; var tipLabel = state.hasGutter && document.createDocumentFragment(); @@ -187,9 +191,9 @@ __annotation: ann })); } - + // use original annotations[line] to show multiple messages if (state.hasGutter) - cm.setGutterMarker(line, GUTTER_ID, makeMarker(cm, tipLabel, maxSeverity, anns.length > 1, + cm.setGutterMarker(line, GUTTER_ID, makeMarker(cm, tipLabel, maxSeverity, annotations[line].length > 1, state.options.tooltips)); } if (options.onUpdateLinting) options.onUpdateLinting(annotationsNotSorted, annotations, cm); From 4f37b1e9ca592461473a64bf3ba43543eecdf550 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Sat, 21 Nov 2020 11:34:06 +0100 Subject: [PATCH 2052/2444] [lint addon] Remove arrow function Issue #6492 --- addon/lint/lint.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addon/lint/lint.js b/addon/lint/lint.js index e970a25ade..395f0d9314 100644 --- a/addon/lint/lint.js +++ b/addon/lint/lint.js @@ -172,7 +172,7 @@ // filter out duplicate messages var message = []; - anns = anns.filter(item => message.indexOf(item.message) > -1 ? false : message.push(item.message)); + anns = anns.filter(function(item) { return message.indexOf(item.message) > -1 ? false : message.push(item.message) }); var maxSeverity = null; var tipLabel = state.hasGutter && document.createDocumentFragment(); From f65b46d154af2ba7e83fb78b449bea41e1c23c43 Mon Sep 17 00:00:00 2001 From: erosman Date: Sun, 22 Nov 2020 19:42:08 +0330 Subject: [PATCH 2053/2444] [seach addon] Add option to configure search, bottom option to put dialog at bottom Closes #6489 --- addon/search/jump-to-line.js | 5 ++++- addon/search/search.js | 8 ++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/addon/search/jump-to-line.js b/addon/search/jump-to-line.js index 1f3526d247..990c235ef1 100644 --- a/addon/search/jump-to-line.js +++ b/addon/search/jump-to-line.js @@ -13,8 +13,11 @@ })(function(CodeMirror) { "use strict"; + // default search panel location + CodeMirror.defineOption("search", {bottom: false}); + function dialog(cm, text, shortText, deflt, f) { - if (cm.openDialog) cm.openDialog(text, f, {value: deflt, selectValueOnOpen: true}); + if (cm.openDialog) cm.openDialog(text, f, {value: deflt, selectValueOnOpen: true, bottom: cm.options.search.bottom}); else f(prompt(shortText, deflt)); } diff --git a/addon/search/search.js b/addon/search/search.js index cecdd52ea1..118f1112f1 100644 --- a/addon/search/search.js +++ b/addon/search/search.js @@ -19,6 +19,9 @@ })(function(CodeMirror) { "use strict"; + // default search panel location + CodeMirror.defineOption("search", {bottom: false}); + function searchOverlay(query, caseInsensitive) { if (typeof query == "string") query = new RegExp(query.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"), caseInsensitive ? "gi" : "g"); @@ -63,12 +66,13 @@ selectValueOnOpen: true, closeOnEnter: false, onClose: function() { clearSearch(cm); }, - onKeyDown: onKeyDown + onKeyDown: onKeyDown, + bottom: cm.options.search.bottom }); } function dialog(cm, text, shortText, deflt, f) { - if (cm.openDialog) cm.openDialog(text, f, {value: deflt, selectValueOnOpen: true}); + if (cm.openDialog) cm.openDialog(text, f, {value: deflt, selectValueOnOpen: true, bottom: cm.options.search.bottom}); else f(prompt(shortText, deflt)); } From 464a66067b8d984c81b8e61ce048b34d7a1054bb Mon Sep 17 00:00:00 2001 From: quiddity-wp Date: Sun, 22 Nov 2020 13:02:36 -0800 Subject: [PATCH 2054/2444] [real-world uses] Add MediaWiki --- doc/realworld.html | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/realworld.html b/doc/realworld.html index 5da12e2c48..c6e6c80323 100644 --- a/doc/realworld.html +++ b/doc/realworld.html @@ -129,6 +129,7 @@

    CodeMirror real-world uses

  • LiveUML (PlantUML online editor)
  • Markdown Delight Editor (extensible markdown editor polymer component)
  • Marklight editor (lightweight markup editor)
  • +
  • MediaWiki extension (wiki engine)
  • Mergely (interactive diffing)
  • MIHTool (iOS web-app debugging tool)
  • mscgen_js (online sequence chart editor)
  • From f4b04da36d5c88762382db44651b0b5389077bac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20=C5=9Alepowro=C5=84ski?= <45392875+slepowronski@users.noreply.github.com> Date: Wed, 25 Nov 2020 09:23:24 +0100 Subject: [PATCH 2055/2444] [show-hint addon] Add additional customizing options Introduces four new options for the show-hint addon: - closeOnCursorActivity - closeOnPick - paddingForScrollbar - moveOnOverlap --- addon/hint/show-hint.js | 50 ++++++++++++++++++++++++++++++++--------- 1 file changed, 39 insertions(+), 11 deletions(-) diff --git a/addon/hint/show-hint.js b/addon/hint/show-hint.js index cd0d6a7bd5..5ef1bba645 100644 --- a/addon/hint/show-hint.js +++ b/addon/hint/show-hint.js @@ -1,6 +1,8 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE +// declare global: DOMRect + (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror")); @@ -94,8 +96,10 @@ completion.to || data.to, "complete"); CodeMirror.signal(data, "pick", completion); self.cm.scrollIntoView(); - }) - this.close(); + }); + if (this.options.closeOnPick) { + this.close(); + } }, cursorActivity: function() { @@ -113,7 +117,9 @@ if (pos.line != this.startPos.line || line.length - pos.ch != this.startLen - this.startPos.ch || pos.ch < identStart.ch || this.cm.somethingSelected() || (!pos.ch || this.options.closeCharacters.test(line.charAt(pos.ch - 1)))) { - this.close(); + if (this.options.closeOnCursorActivity) { + this.close(); + } } else { var self = this; this.debounce = requestAnimationFrame(function() {self.update();}); @@ -259,10 +265,15 @@ var winW = parentWindow.innerWidth || Math.max(ownerDocument.body.offsetWidth, ownerDocument.documentElement.offsetWidth); var winH = parentWindow.innerHeight || Math.max(ownerDocument.body.offsetHeight, ownerDocument.documentElement.offsetHeight); container.appendChild(hints); - var box = hints.getBoundingClientRect(), overlapY = box.bottom - winH; - var scrolls = hints.scrollHeight > hints.clientHeight + 1 - var startScroll = cm.getScrollInfo(); + var box = completion.options.moveOnOverlap ? hints.getBoundingClientRect() : new DOMRect(); + var scrolls = completion.options.paddingForScrollbar ? hints.scrollHeight > hints.clientHeight + 1 : false; + + // Compute in the timeout to avoid reflow on init + var startScroll; + setTimeout(function() { startScroll = cm.getScrollInfo(); }); + + var overlapY = box.bottom - winH; if (overlapY > 0) { var height = box.bottom - box.top, curTop = pos.top - (pos.bottom - box.top); if (curTop - height > 0) { // Fits above cursor @@ -332,7 +343,12 @@ CodeMirror.on(hints, "mousedown", function() { setTimeout(function(){cm.focus();}, 20); }); - this.scrollToActive() + + // The first hint doesn't need to be scrolled to on init + var selectedHintRange = this.getSelectedHintRange(); + if (selectedHintRange.from !== 0 || selectedHintRange.to !== 0) { + this.scrollToActive(); + } CodeMirror.signal(data, "select", completions[this.selectedHint], hints.childNodes[this.selectedHint]); return true; @@ -379,9 +395,9 @@ }, scrollToActive: function() { - var margin = this.completion.options.scrollMargin || 0; - var node1 = this.hints.childNodes[Math.max(0, this.selectedHint - margin)]; - var node2 = this.hints.childNodes[Math.min(this.data.list.length - 1, this.selectedHint + margin)]; + var selectedHintRange = this.getSelectedHintRange(); + var node1 = this.hints.childNodes[selectedHintRange.from]; + var node2 = this.hints.childNodes[selectedHintRange.to]; var firstNode = this.hints.firstChild; if (node1.offsetTop < this.hints.scrollTop) this.hints.scrollTop = node1.offsetTop - firstNode.offsetTop; @@ -391,6 +407,14 @@ screenAmount: function() { return Math.floor(this.hints.clientHeight / this.hints.firstChild.offsetHeight) || 1; + }, + + getSelectedHintRange: function() { + var margin = this.completion.options.scrollMargin || 0; + return { + from: Math.max(0, this.selectedHint - margin), + to: Math.min(this.data.list.length - 1, this.selectedHint + margin), + }; } }; @@ -468,11 +492,15 @@ completeSingle: true, alignWithWord: true, closeCharacters: /[\s()\[\]{};:>,]/, + closeOnCursorActivity: true, + closeOnPick: true, closeOnUnfocus: true, completeOnSingleClick: true, container: null, customKeys: null, - extraKeys: null + extraKeys: null, + paddingForScrollbar: true, + moveOnOverlap: true, }; CodeMirror.defineOption("hintOptions", null); From 5e11705588c69925dcd8531bc605854bb379150b Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Tue, 1 Dec 2020 08:48:39 +0100 Subject: [PATCH 2056/2444] [clojure mode] Fix exponential-complexity regexp --- mode/clojure/clojure.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mode/clojure/clojure.js b/mode/clojure/clojure.js index 25d308ab4c..0b9d6acc3e 100644 --- a/mode/clojure/clojure.js +++ b/mode/clojure/clojure.js @@ -160,10 +160,10 @@ CodeMirror.defineMode("clojure", function (options) { var numberLiteral = /^(?:[+\-]?\d+(?:(?:N|(?:[eE][+\-]?\d+))|(?:\.?\d*(?:M|(?:[eE][+\-]?\d+))?)|\/\d+|[xX][0-9a-fA-F]+|r[0-9a-zA-Z]+)?(?=[\\\[\]\s"#'(),;@^`{}~]|$))/; var characterLiteral = /^(?:\\(?:backspace|formfeed|newline|return|space|tab|o[0-7]{3}|u[0-9A-Fa-f]{4}|x[0-9A-Fa-f]{4}|.)?(?=[\\\[\]\s"(),;@^`{}~]|$))/; - // simple-namespace := /^[^\\\/\[\]\d\s"#'(),;@^`{}~][^\\\[\]\s"(),;@^`{}~]*/ + // simple-namespace := /^[^\\\/\[\]\d\s"#'(),;@^`{}~.][^\\\[\]\s"(),;@^`{}~.\/]*/ // simple-symbol := /^(?:\/|[^\\\/\[\]\d\s"#'(),;@^`{}~][^\\\[\]\s"(),;@^`{}~]*)/ // qualified-symbol := ((<.>)*)? - var qualifiedSymbol = /^(?:(?:[^\\\/\[\]\d\s"#'(),;@^`{}~][^\\\[\]\s"(),;@^`{}~]*(?:\.[^\\\/\[\]\d\s"#'(),;@^`{}~][^\\\[\]\s"(),;@^`{}~]*)*\/)?(?:\/|[^\\\/\[\]\d\s"#'(),;@^`{}~][^\\\[\]\s"(),;@^`{}~]*)*(?=[\\\[\]\s"(),;@^`{}~]|$))/; + var qualifiedSymbol = /^(?:(?:[^\\\/\[\]\d\s"#'(),;@^`{}~.][^\\\[\]\s"(),;@^`{}~.\/]*(?:\.[^\\\/\[\]\d\s"#'(),;@^`{}~.][^\\\[\]\s"(),;@^`{}~.\/]*)*\/)?(?:\/|[^\\\/\[\]\d\s"#'(),;@^`{}~][^\\\[\]\s"(),;@^`{}~]*)*(?=[\\\[\]\s"(),;@^`{}~]|$))/; function base(stream, state) { if (stream.eatSpace() || stream.eat(",")) return ["space", null]; From 1cec2af7be8a2158ff5bf71ab76c8c62fe669791 Mon Sep 17 00:00:00 2001 From: Ben Hormann Date: Wed, 2 Dec 2020 10:14:35 +0000 Subject: [PATCH 2057/2444] [wast mode] Add link --- mode/index.html | 1 + 1 file changed, 1 insertion(+) diff --git a/mode/index.html b/mode/index.html index 858ba127f2..51205ddce9 100644 --- a/mode/index.html +++ b/mode/index.html @@ -153,6 +153,7 @@

    Language modes

  • VHDL
  • Vue.js app
  • Web IDL
  • +
  • WebAssembly Text Format
  • XML/HTML
  • XQuery
  • Yacas
  • From f4fd159353930680dbe617d440e5a4867d8b13a9 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Wed, 2 Dec 2020 17:20:39 +0100 Subject: [PATCH 2058/2444] [hardwrap addon] Improve start-of-line condition for overlong words Issue #6494 --- addon/wrap/hardwrap.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addon/wrap/hardwrap.js b/addon/wrap/hardwrap.js index f194946c5d..bccdc8d14c 100644 --- a/addon/wrap/hardwrap.js +++ b/addon/wrap/hardwrap.js @@ -35,7 +35,7 @@ for (; at > 0; --at) if (wrapOn.test(text.slice(at - 1, at + 1))) break; - if (at == 0 && !forceBreak) { + if (!forceBreak && at <= text.match(/^[ \t]*/)[0].length) { // didn't find a break point before column, in non-forceBreak mode try to // find one after 'column'. for (at = column + 1; at < text.length - 1; ++at) { From c04867c786c5625f5f221c4162cb54d798dc9a8e Mon Sep 17 00:00:00 2001 From: "Jakub T. Jankiewicz" Date: Thu, 3 Dec 2020 19:15:50 +0100 Subject: [PATCH 2059/2444] [scheme mode] Add more special indentation words and keywords --- mode/scheme/scheme.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mode/scheme/scheme.js b/mode/scheme/scheme.js index 56e4e332e9..0bbb8c8a41 100644 --- a/mode/scheme/scheme.js +++ b/mode/scheme/scheme.js @@ -26,8 +26,8 @@ CodeMirror.defineMode("scheme", function () { return obj; } - var keywords = makeKeywords("λ case-lambda call/cc class define-class exit-handler field import inherit init-field interface let*-values let-values let/ec mixin opt-lambda override protect provide public rename require require-for-syntax syntax syntax-case syntax-error unit/sig unless when with-syntax and begin call-with-current-continuation call-with-input-file call-with-output-file case cond define define-syntax delay do dynamic-wind else for-each if lambda let let* let-syntax letrec letrec-syntax map or syntax-rules abs acos angle append apply asin assoc assq assv atan boolean? caar cadr call-with-input-file call-with-output-file call-with-values car cdddar cddddr cdr ceiling char->integer char-alphabetic? char-ci<=? char-ci=? char-ci>? char-downcase char-lower-case? char-numeric? char-ready? char-upcase char-upper-case? char-whitespace? char<=? char=? char>? char? close-input-port close-output-port complex? cons cos current-input-port current-output-port denominator display eof-object? eq? equal? eqv? eval even? exact->inexact exact? exp expt #f floor force gcd imag-part inexact->exact inexact? input-port? integer->char integer? interaction-environment lcm length list list->string list->vector list-ref list-tail list? load log magnitude make-polar make-rectangular make-string make-vector max member memq memv min modulo negative? newline not null-environment null? number->string number? numerator odd? open-input-file open-output-file output-port? pair? peek-char port? positive? procedure? quasiquote quote quotient rational? rationalize read read-char real-part real? remainder reverse round scheme-report-environment set! set-car! set-cdr! sin sqrt string string->list string->number string->symbol string-append string-ci<=? string-ci=? string-ci>? string-copy string-fill! string-length string-ref string-set! string<=? string=? string>? string? substring symbol->string symbol? #t tan transcript-off transcript-on truncate values vector vector->list vector-fill! vector-length vector-ref vector-set! with-input-from-file with-output-to-file write write-char zero?"); - var indentKeys = makeKeywords("define let letrec let* lambda"); + var keywords = makeKeywords("λ case-lambda call/cc class define-class exit-handler field import inherit init-field interface let*-values let-values let/ec mixin opt-lambda override protect provide public rename require require-for-syntax syntax syntax-case syntax-error unit/sig unless when with-syntax and begin call-with-current-continuation call-with-input-file call-with-output-file case cond define define-syntax define-macro defmacro delay do dynamic-wind else for-each if lambda let let* let-syntax letrec letrec-syntax map or syntax-rules abs acos angle append apply asin assoc assq assv atan boolean? caar cadr call-with-input-file call-with-output-file call-with-values car cdddar cddddr cdr ceiling char->integer char-alphabetic? char-ci<=? char-ci=? char-ci>? char-downcase char-lower-case? char-numeric? char-ready? char-upcase char-upper-case? char-whitespace? char<=? char=? char>? char? close-input-port close-output-port complex? cons cos current-input-port current-output-port denominator display eof-object? eq? equal? eqv? eval even? exact->inexact exact? exp expt #f floor force gcd imag-part inexact->exact inexact? input-port? integer->char integer? interaction-environment lcm length list list->string list->vector list-ref list-tail list? load log magnitude make-polar make-rectangular make-string make-vector max member memq memv min modulo negative? newline not null-environment null? number->string number? numerator odd? open-input-file open-output-file output-port? pair? peek-char port? positive? procedure? quasiquote quote quotient rational? rationalize read read-char real-part real? remainder reverse round scheme-report-environment set! set-car! set-cdr! sin sqrt string string->list string->number string->symbol string-append string-ci<=? string-ci=? string-ci>? string-copy string-fill! string-length string-ref string-set! string<=? string=? string>? string? substring symbol->string symbol? #t tan transcript-off transcript-on truncate values vector vector->list vector-fill! vector-length vector-ref vector-set! with-input-from-file with-output-to-file write write-char zero?"); + var indentKeys = makeKeywords("define let letrec let* lambda define-macro defmacro let-syntax letrec-syntax define-syntax syntax-rules"); function stateStack(indent, type, prev) { // represents a state stack object this.indent = indent; From e410e5c17866308e1aba41f56383a6a2d31f02a9 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Thu, 3 Dec 2020 19:30:28 +0100 Subject: [PATCH 2060/2444] Add a funding.yml file --- .github/FUNDING.yml | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .github/FUNDING.yml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000000..d87b38eee6 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,2 @@ +patreon: marijn +custom: ['https://www.paypal.com/paypalme/marijnhaverbeke', 'https://marijnhaverbeke.nl/fund/'] From a966b5d115af09983d37f7c9aa034b78ac954ca4 Mon Sep 17 00:00:00 2001 From: Piyush Date: Fri, 4 Dec 2020 09:50:24 +0530 Subject: [PATCH 2061/2444] fix memory leak with matchbrackets --- addon/edit/matchbrackets.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/addon/edit/matchbrackets.js b/addon/edit/matchbrackets.js index 2c47e07033..0377408802 100644 --- a/addon/edit/matchbrackets.js +++ b/addon/edit/matchbrackets.js @@ -117,25 +117,25 @@ }); } - CodeMirror.defineOption("matchBrackets", false, function(cm, val, old) { - function clear(cm) { - if (cm.state.matchBrackets && cm.state.matchBrackets.currentlyHighlighted) { - cm.state.matchBrackets.currentlyHighlighted(); - cm.state.matchBrackets.currentlyHighlighted = null; - } + function clearHighlighted(cm) { + if (cm.state.matchBrackets && cm.state.matchBrackets.currentlyHighlighted) { + cm.state.matchBrackets.currentlyHighlighted(); + cm.state.matchBrackets.currentlyHighlighted = null; } + } + CodeMirror.defineOption("matchBrackets", false, function(cm, val, old) { if (old && old != CodeMirror.Init) { cm.off("cursorActivity", doMatchBrackets); cm.off("focus", doMatchBrackets) - cm.off("blur", clear) - clear(cm); + cm.off("blur", clearHighlighted) + clearHighlighted(cm); } if (val) { cm.state.matchBrackets = typeof val == "object" ? val : {}; cm.on("cursorActivity", doMatchBrackets); cm.on("focus", doMatchBrackets) - cm.on("blur", clear) + cm.on("blur", clearHighlighted) } }); From e3fc417882517edaffda6f445c62f8697a0cd495 Mon Sep 17 00:00:00 2001 From: Simon Huber Date: Mon, 7 Dec 2020 10:16:23 +0100 Subject: [PATCH 2062/2444] [solaized theme] Fix typos --- theme/solarized.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/theme/solarized.css b/theme/solarized.css index fcd1d70de6..9c6b1265c1 100644 --- a/theme/solarized.css +++ b/theme/solarized.css @@ -99,7 +99,7 @@ http://ethanschoonover.com/solarized/img/solarized-palette.png .cm-s-solarized.cm-s-light div.CodeMirror-selected { background: #eee8d5; } .cm-s-solarized.cm-s-light .CodeMirror-line::selection, .cm-s-light .CodeMirror-line > span::selection, .cm-s-light .CodeMirror-line > span > span::selection { background: #eee8d5; } -.cm-s-solarized.cm-s-light .CodeMirror-line::-moz-selection, .cm-s-ligh .CodeMirror-line > span::-moz-selection, .cm-s-ligh .CodeMirror-line > span > span::-moz-selection { background: #eee8d5; } +.cm-s-solarized.cm-s-light .CodeMirror-line::-moz-selection, .cm-s-light .CodeMirror-line > span::-moz-selection, .cm-s-light .CodeMirror-line > span > span::-moz-selection { background: #eee8d5; } /* Editor styling */ From 622fcb9b8740ceade71c1f579eaa76c8b82a0c0b Mon Sep 17 00:00:00 2001 From: "Jakub T. Jankiewicz" Date: Mon, 7 Dec 2020 10:19:14 +0100 Subject: [PATCH 2063/2444] [scheme mode] More indent fixes --- mode/scheme/scheme.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mode/scheme/scheme.js b/mode/scheme/scheme.js index 0bbb8c8a41..efac89078b 100644 --- a/mode/scheme/scheme.js +++ b/mode/scheme/scheme.js @@ -26,8 +26,8 @@ CodeMirror.defineMode("scheme", function () { return obj; } - var keywords = makeKeywords("λ case-lambda call/cc class define-class exit-handler field import inherit init-field interface let*-values let-values let/ec mixin opt-lambda override protect provide public rename require require-for-syntax syntax syntax-case syntax-error unit/sig unless when with-syntax and begin call-with-current-continuation call-with-input-file call-with-output-file case cond define define-syntax define-macro defmacro delay do dynamic-wind else for-each if lambda let let* let-syntax letrec letrec-syntax map or syntax-rules abs acos angle append apply asin assoc assq assv atan boolean? caar cadr call-with-input-file call-with-output-file call-with-values car cdddar cddddr cdr ceiling char->integer char-alphabetic? char-ci<=? char-ci=? char-ci>? char-downcase char-lower-case? char-numeric? char-ready? char-upcase char-upper-case? char-whitespace? char<=? char=? char>? char? close-input-port close-output-port complex? cons cos current-input-port current-output-port denominator display eof-object? eq? equal? eqv? eval even? exact->inexact exact? exp expt #f floor force gcd imag-part inexact->exact inexact? input-port? integer->char integer? interaction-environment lcm length list list->string list->vector list-ref list-tail list? load log magnitude make-polar make-rectangular make-string make-vector max member memq memv min modulo negative? newline not null-environment null? number->string number? numerator odd? open-input-file open-output-file output-port? pair? peek-char port? positive? procedure? quasiquote quote quotient rational? rationalize read read-char real-part real? remainder reverse round scheme-report-environment set! set-car! set-cdr! sin sqrt string string->list string->number string->symbol string-append string-ci<=? string-ci=? string-ci>? string-copy string-fill! string-length string-ref string-set! string<=? string=? string>? string? substring symbol->string symbol? #t tan transcript-off transcript-on truncate values vector vector->list vector-fill! vector-length vector-ref vector-set! with-input-from-file with-output-to-file write write-char zero?"); - var indentKeys = makeKeywords("define let letrec let* lambda define-macro defmacro let-syntax letrec-syntax define-syntax syntax-rules"); + var keywords = makeKeywords("λ case-lambda call/cc class cond-expand define-class define-values exit-handler field import inherit init-field interface let*-values let-values let/ec mixin opt-lambda override protect provide public rename require require-for-syntax syntax syntax-case syntax-error unit/sig unless when with-syntax and begin call-with-current-continuation call-with-input-file call-with-output-file case cond define define-syntax define-macro defmacro delay do dynamic-wind else for-each if lambda let let* let-syntax letrec letrec-syntax map or syntax-rules abs acos angle append apply asin assoc assq assv atan boolean? caar cadr call-with-input-file call-with-output-file call-with-values car cdddar cddddr cdr ceiling char->integer char-alphabetic? char-ci<=? char-ci=? char-ci>? char-downcase char-lower-case? char-numeric? char-ready? char-upcase char-upper-case? char-whitespace? char<=? char=? char>? char? close-input-port close-output-port complex? cons cos current-input-port current-output-port denominator display eof-object? eq? equal? eqv? eval even? exact->inexact exact? exp expt #f floor force gcd imag-part inexact->exact inexact? input-port? integer->char integer? interaction-environment lcm length list list->string list->vector list-ref list-tail list? load log magnitude make-polar make-rectangular make-string make-vector max member memq memv min modulo negative? newline not null-environment null? number->string number? numerator odd? open-input-file open-output-file output-port? pair? peek-char port? positive? procedure? quasiquote quote quotient rational? rationalize read read-char real-part real? remainder reverse round scheme-report-environment set! set-car! set-cdr! sin sqrt string string->list string->number string->symbol string-append string-ci<=? string-ci=? string-ci>? string-copy string-fill! string-length string-ref string-set! string<=? string=? string>? string? substring symbol->string symbol? #t tan transcript-off transcript-on truncate values vector vector->list vector-fill! vector-length vector-ref vector-set! with-input-from-file with-output-to-file write write-char zero?"); + var indentKeys = makeKeywords("define let letrec let* lambda define-macro defmacro let-syntax letrec-syntax let-values let*-values define-syntax syntax-rules define-values when unless"); function stateStack(indent, type, prev) { // represents a state stack object this.indent = indent; From ae4e671eb2d931ce88cf91d6d1f39cdaf7f0654e Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Mon, 7 Dec 2020 21:45:51 +0100 Subject: [PATCH 2064/2444] [shell mode] Treat <<< as here string operator Issue #6512 --- mode/shell/shell.js | 1 + 1 file changed, 1 insertion(+) diff --git a/mode/shell/shell.js b/mode/shell/shell.js index 2219e62e19..8271485f5f 100644 --- a/mode/shell/shell.js +++ b/mode/shell/shell.js @@ -71,6 +71,7 @@ CodeMirror.defineMode('shell', function() { return 'attribute'; } if (ch == "<") { + if (stream.match("<<")) return "operator" var heredoc = stream.match(/^<-?\s*['"]?([^'"]*)['"]?/) if (heredoc) { state.tokens.unshift(tokenHeredoc(heredoc[1])) From fb4ec129858dc916de86e8dd802e9668ae0049a0 Mon Sep 17 00:00:00 2001 From: mlsad3 Date: Tue, 8 Dec 2020 01:35:04 -0700 Subject: [PATCH 2065/2444] [verilog mode] Improve * Handle `uvm_*_begin/end macros as well as macros in case/switch. * Prevent extern functions and typedef classes from indenting. * Indent lines after assignments, handle corner-case inside parenthesis. * Handle 'disable fork' and 'wait fork'. * Add '<' and '>' to operators. * Add tests for mode/verilog changes. * Verilog mode handles compiler directives and differentiates assignment vs comparison. * Cleanup lint errors. * Add verilog mode support for '@'. Co-authored-by: Matt Diehl --- mode/verilog/test.js | 170 ++++++++++++++++++++++++++++++++++++++++ mode/verilog/verilog.js | 138 ++++++++++++++++++++++++++++---- 2 files changed, 292 insertions(+), 16 deletions(-) diff --git a/mode/verilog/test.js b/mode/verilog/test.js index bafe726db3..38c1cbe457 100644 --- a/mode/verilog/test.js +++ b/mode/verilog/test.js @@ -139,6 +139,32 @@ "" ); + MT("align_assignments", + /** + * always @(posedge clk) begin + * if (rst) + * data_out <= 8'b0 + + * 8'b1; + * else + * data_out = 8'b0 + + * 8'b1; + * data_out = + * 8'b0 + 8'b1; + * end + */ + "[keyword always] [def @][bracket (][keyword posedge] [variable clk][bracket )] [keyword begin]", + " [keyword if] [bracket (][variable rst][bracket )]", + " [variable data_out] [meta <=] [number 8'b0] [meta +]", + " [number 8'b1];", + " [keyword else]", + " [variable data_out] [meta =] [number 8'b0] [meta +]", + " [number 8'b1];", + " [variable data_out] [meta =] [number 8'b0] [meta +]", + " [number 8'b1];", + "[keyword end]", + "" + ); + // Indentation tests MT("indent_single_statement_if", "[keyword if] [bracket (][variable foo][bracket )]", @@ -270,4 +296,148 @@ "" ); + MT("indent_uvm_macros", + /** + * `uvm_object_utils_begin(foo) + * `uvm_field_event(foo, UVM_ALL_ON) + * `uvm_object_utils_end + */ + "[def `uvm_object_utils_begin][bracket (][variable foo][bracket )]", + " [def `uvm_field_event][bracket (][variable foo], [variable UVM_ALL_ON][bracket )]", + "[def `uvm_object_utils_end]", + "" + ); + + MT("indent_uvm_macros2", + /** + * `uvm_do_with(mem_read,{ + * bar_nb == 0; + * }) + */ + "[def `uvm_do_with][bracket (][variable mem_read],[bracket {]", + " [variable bar_nb] [meta ==] [number 0];", + "[bracket })]", + "" + ); + + MT("indent_wait_disable_fork", + /** + * virtual task body(); + * repeat (20) begin + * fork + * `uvm_create_on(t,p_seq) + * join_none + * end + * wait fork; + * disable fork; + * endtask : body + */ + "[keyword virtual] [keyword task] [variable body][bracket ()];", + " [keyword repeat] [bracket (][number 20][bracket )] [keyword begin]", + " [keyword fork]", + " [def `uvm_create_on][bracket (][variable t],[variable p_seq][bracket )]", + " [keyword join_none]", + " [keyword end]", + " [keyword wait] [keyword fork];", + " [keyword disable] [keyword fork];", + "[keyword endtask] : [variable body]", + "" + ); + + MT("indent_typedef_class", + /** + * typedef class asdf; + * typedef p p_t[]; + * typedef enum { + * ASDF + * } t; + */ + "[keyword typedef] [keyword class] [variable asdf];", + "[keyword typedef] [variable p] [variable p_t][bracket [[]]];", + "[keyword typedef] [keyword enum] [bracket {]", + " [variable ASDF]", + "[bracket }] [variable t];", + "" + ); + + MT("indent_case_with_macro", + /** + * // It should be assumed that Macros can have ';' inside, or 'begin'/'end' blocks. + * // As such, 'case' statement should indent correctly with macros inside. + * case(foo) + * ASDF : this.foo = seqNum; + * ABCD : `update(f) + * EFGH : `update(g) + * endcase + */ + "[keyword case][bracket (][variable foo][bracket )]", + " [variable ASDF] : [keyword this].[variable foo] [meta =] [variable seqNum];", + " [variable ABCD] : [def `update][bracket (][variable f][bracket )]", + " [variable EFGH] : [def `update][bracket (][variable g][bracket )]", + "[keyword endcase]", + "" + ); + + MT("indent_extern_function", + /** + * extern virtual function void do(ref packet trans); + * extern virtual function void do2(ref packet trans); + */ + "[keyword extern] [keyword virtual] [keyword function] [keyword void] [variable do1][bracket (][keyword ref] [variable packet] [variable trans][bracket )];", + "[keyword extern] [keyword virtual] [keyword function] [keyword void] [variable do2][bracket (][keyword ref] [variable packet] [variable trans][bracket )];", + "" + ); + + MT("indent_assignment", + /** + * for (int i=1;i < fun;i++) begin + * foo = 2 << asdf || 11'h35 >> abcd + * && 8'h6 | 1'b1; + * end + */ + "[keyword for] [bracket (][keyword int] [variable i][meta =][number 1];[variable i] [meta <] [variable fun];[variable i][meta ++][bracket )] [keyword begin]", + " [variable foo] [meta =] [number 2] [meta <<] [variable asdf] [meta ||] [number 11'h35] [meta >>] [variable abcd]", + " [meta &&] [number 8'h6] [meta |] [number 1'b1];", + "[keyword end]", + "" + ); + + MT("indent_foreach_constraint", + /** + * `uvm_rand_send_with(wrTlp, { + * length ==1; + * foreach (Data[i]) { + * payload[i] == Data[i]; + * } + * }) + */ + "[def `uvm_rand_send_with][bracket (][variable wrTlp], [bracket {]", + " [variable length] [meta ==][number 1];", + " [keyword foreach] [bracket (][variable Data][bracket [[][variable i][bracket ]])] [bracket {]", + " [variable payload][bracket [[][variable i][bracket ]]] [meta ==] [variable Data][bracket [[][variable i][bracket ]]];", + " [bracket }]", + "[bracket })]", + "" + ); + + MT("indent_compiler_directives", + /** + * `ifdef DUT + * `else + * `ifndef FOO + * `define FOO + * `endif + * `endif + * `timescale 1ns/1ns + */ + "[def `ifdef] [variable DUT]", + "[def `else]", + " [def `ifndef] [variable FOO]", + " [def `define] [variable FOO]", + " [def `endif]", + "[def `endif]", + "[def `timescale] [number 1][variable ns][meta /][number 1][variable ns]", + "" + ); + })(); diff --git a/mode/verilog/verilog.js b/mode/verilog/verilog.js index 43990452d3..544045b867 100644 --- a/mode/verilog/verilog.js +++ b/mode/verilog/verilog.js @@ -16,6 +16,12 @@ CodeMirror.defineMode("verilog", function(config, parserConfig) { var indentUnit = config.indentUnit, statementIndentUnit = parserConfig.statementIndentUnit || indentUnit, dontAlignCalls = parserConfig.dontAlignCalls, + // compilerDirectivesUseRegularIndentation - If set, Compiler directive + // indentation follows the same rules as everything else. Otherwise if + // false, compiler directives will track their own indentation. + // For example, `ifdef nested inside another `ifndef will be indented, + // but a `ifdef inside a function block may not be indented. + compilerDirectivesUseRegularIndentation = parserConfig.compilerDirectivesUseRegularIndentation, noIndentKeywords = parserConfig.noIndentKeywords || [], multiLineStrings = parserConfig.multiLineStrings, hooks = parserConfig.hooks || {}; @@ -62,7 +68,7 @@ CodeMirror.defineMode("verilog", function(config, parserConfig) { binary_module_path_operator ::= == | != | && | || | & | | | ^ | ^~ | ~^ */ - var isOperatorChar = /[\+\-\*\/!~&|^%=?:]/; + var isOperatorChar = /[\+\-\*\/!~&|^%=?:<>]/; var isBracketChar = /[\[\]{}()]/; var unsignedNumber = /\d[0-9_]*/; @@ -72,8 +78,13 @@ CodeMirror.defineMode("verilog", function(config, parserConfig) { var hexLiteral = /\d*\s*'s?h\s*[0-9a-fxz?][0-9a-fxz?_]*/i; var realLiteral = /(\d[\d_]*(\.\d[\d_]*)?E-?[\d_]+)|(\d[\d_]*\.\d[\d_]*)/i; - var closingBracketOrWord = /^((\w+)|[)}\]])/; + var closingBracketOrWord = /^((`?\w+)|[)}\]])/; var closingBracket = /[)}\]]/; + var compilerDirectiveRegex = new RegExp( + "^(`(?:ifdef|ifndef|elsif|else|endif|undef|undefineall|define|include|begin_keywords|celldefine|default|" + + "nettype|end_keywords|endcelldefine|line|nounconnected_drive|pragma|resetall|timescale|unconnected_drive))\\b"); + var compilerDirectiveBeginRegex = /^(`(?:ifdef|ifndef|elsif|else))\b/; + var compilerDirectiveEndRegex = /^(`(?:elsif|else|endif))\b/; var curPunc; var curKeyword; @@ -96,6 +107,7 @@ CodeMirror.defineMode("verilog", function(config, parserConfig) { openClose["do" ] = "while"; openClose["fork" ] = "join;join_any;join_none"; openClose["covergroup"] = "endgroup"; + openClose["macro_begin"] = "macro_end"; for (var i in noIndentKeywords) { var keyword = noIndentKeywords[i]; @@ -105,7 +117,7 @@ CodeMirror.defineMode("verilog", function(config, parserConfig) { } // Keywords which open statements that are ended with a semi-colon - var statementKeywords = words("always always_comb always_ff always_latch assert assign assume else export for foreach forever if import initial repeat while"); + var statementKeywords = words("always always_comb always_ff always_latch assert assign assume else export for foreach forever if import initial repeat while extern typedef"); function tokenBase(stream, state) { var ch = stream.peek(), style; @@ -125,6 +137,24 @@ CodeMirror.defineMode("verilog", function(config, parserConfig) { if (ch == '`') { stream.next(); if (stream.eatWhile(/[\w\$_]/)) { + var cur = stream.current(); + curKeyword = cur; + // Macros that end in _begin, are start of block and end with _end + if (cur.startsWith("`uvm_") && cur.endsWith("_begin")) { + var keywordClose = curKeyword.substr(0,curKeyword.length - 5) + "end"; + openClose[cur] = keywordClose; + curPunc = "newblock"; + } else if (cur.startsWith("`uvm_") && cur.endsWith("_end")) { + } else { + stream.eatSpace(); + if (stream.peek() == '(') { + // Check if this is a block + curPunc = "newmacro"; + } + var withSpace = stream.current(); + // Move the stream back before the spaces + stream.backUp(withSpace.length - cur.length); + } return "def"; } else { return null; @@ -145,6 +175,12 @@ CodeMirror.defineMode("verilog", function(config, parserConfig) { stream.eatWhile(/[\d_.]/); return "def"; } + // Event + if (ch == '@') { + stream.next(); + stream.eatWhile(/[@]/); + return "def"; + } // Strings if (ch == '"') { stream.next(); @@ -178,6 +214,7 @@ CodeMirror.defineMode("verilog", function(config, parserConfig) { // Operators if (stream.eatWhile(isOperatorChar)) { + curPunc = stream.current(); return "meta"; } @@ -187,6 +224,15 @@ CodeMirror.defineMode("verilog", function(config, parserConfig) { if (keywords[cur]) { if (openClose[cur]) { curPunc = "newblock"; + if (cur === "fork") { + // Fork can be a statement instead of block in cases of: + // "disable fork;" and "wait fork;" (trailing semicolon) + stream.eatSpace() + if (stream.peek() == ';') { + curPunc = "newstatement"; + } + stream.backUp(stream.current().length - cur.length); + } } if (statementKeywords[cur]) { curPunc = "newstatement"; @@ -226,16 +272,17 @@ CodeMirror.defineMode("verilog", function(config, parserConfig) { return "comment"; } - function Context(indented, column, type, align, prev) { + function Context(indented, column, type, scopekind, align, prev) { this.indented = indented; this.column = column; this.type = type; + this.scopekind = scopekind; this.align = align; this.prev = prev; } - function pushContext(state, col, type) { + function pushContext(state, col, type, scopekind) { var indent = state.indented; - var c = new Context(indent, col, type, null, state.context); + var c = new Context(indent, col, type, scopekind ? scopekind : "", null, state.context); return state.context = c; } function popContext(state) { @@ -261,6 +308,16 @@ CodeMirror.defineMode("verilog", function(config, parserConfig) { } } + function isInsideScopeKind(ctx, scopekind) { + if (ctx == null) { + return false; + } + if (ctx.scopekind === scopekind) { + return true; + } + return isInsideScopeKind(ctx.prev, scopekind); + } + function buildElectricInputRegEx() { // Reindentation should occur on any bracket char: {}()[] // or on a match of any of the block closing keywords, at @@ -287,8 +344,9 @@ CodeMirror.defineMode("verilog", function(config, parserConfig) { startState: function(basecolumn) { var state = { tokenize: null, - context: new Context((basecolumn || 0) - indentUnit, 0, "top", false), + context: new Context((basecolumn || 0) - indentUnit, 0, "top", "top", false), indented: 0, + compilerDirectiveIndented: 0, startOfLine: true }; if (hooks.startState) hooks.startState(state); @@ -313,15 +371,42 @@ CodeMirror.defineMode("verilog", function(config, parserConfig) { curPunc = null; curKeyword = null; var style = (state.tokenize || tokenBase)(stream, state); - if (style == "comment" || style == "meta" || style == "variable") return style; + if (style == "comment" || style == "meta" || style == "variable") { + if (((curPunc === "=") || (curPunc === "<=")) && !isInsideScopeKind(ctx, "assignment")) { + // '<=' could be nonblocking assignment or lessthan-equals (which shouldn't cause indent) + // Search through the context to see if we are already in an assignment. + // '=' could be inside port declaration with comma or ')' afterward, or inside for(;;) block. + pushContext(state, stream.column() + curPunc.length, "assignment", "assignment"); + if (ctx.align == null) ctx.align = true; + } + return style; + } if (ctx.align == null) ctx.align = true; - if (curPunc == ctx.type) { - popContext(state); - } else if ((curPunc == ";" && ctx.type == "statement") || + var isClosingAssignment = ctx.type == "assignment" && + closingBracket.test(curPunc) && ctx.prev && ctx.prev.type === curPunc; + if (curPunc == ctx.type || isClosingAssignment) { + if (isClosingAssignment) { + ctx = popContext(state); + } + ctx = popContext(state); + if (curPunc == ")") { + // Handle closing macros, assuming they could have a semicolon or begin/end block inside. + if (ctx && (ctx.type === "macro")) { + ctx = popContext(state); + while (ctx && (ctx.type == "statement" || ctx.type == "assignment")) ctx = popContext(state); + } + } else if (curPunc == "}") { + // Handle closing statements like constraint block: "foreach () {}" which + // do not have semicolon at end. + if (ctx && (ctx.type === "statement")) { + while (ctx && (ctx.type == "statement")) ctx = popContext(state); + } + } + } else if (((curPunc == ";" || curPunc == ",") && (ctx.type == "statement" || ctx.type == "assignment")) || (ctx.type && isClosing(curKeyword, ctx.type))) { ctx = popContext(state); - while (ctx && ctx.type == "statement") ctx = popContext(state); + while (ctx && (ctx.type == "statement" || ctx.type == "assignment")) ctx = popContext(state); } else if (curPunc == "{") { pushContext(state, stream.column(), "}"); } else if (curPunc == "[") { @@ -329,9 +414,9 @@ CodeMirror.defineMode("verilog", function(config, parserConfig) { } else if (curPunc == "(") { pushContext(state, stream.column(), ")"); } else if (ctx && ctx.type == "endcase" && curPunc == ":") { - pushContext(state, stream.column(), "statement"); + pushContext(state, stream.column(), "statement", "case"); } else if (curPunc == "newstatement") { - pushContext(state, stream.column(), "statement"); + pushContext(state, stream.column(), "statement", curKeyword); } else if (curPunc == "newblock") { if (curKeyword == "function" && ctx && (ctx.type == "statement" || ctx.type == "endgroup")) { // The 'function' keyword can appear in some other contexts where it actually does not @@ -339,9 +424,23 @@ CodeMirror.defineMode("verilog", function(config, parserConfig) { // Do nothing in this case } else if (curKeyword == "task" && ctx && ctx.type == "statement") { // Same thing for task + } else if (curKeyword == "class" && ctx && ctx.type == "statement") { + // Same thing for class (e.g. typedef) } else { var close = openClose[curKeyword]; - pushContext(state, stream.column(), close); + pushContext(state, stream.column(), close, curKeyword); + } + } else if (curPunc == "newmacro" || (curKeyword && curKeyword.match(compilerDirectiveRegex))) { + if (curPunc == "newmacro") { + // Macros (especially if they have parenthesis) potentially have a semicolon + // or complete statement/block inside, and should be treated as such. + pushContext(state, stream.column(), "macro", "macro"); + } + if (curKeyword.match(compilerDirectiveEndRegex)) { + state.compilerDirectiveIndented -= statementIndentUnit; + } + if (curKeyword.match(compilerDirectiveBeginRegex)) { + state.compilerDirectiveIndented += statementIndentUnit; } } @@ -361,8 +460,15 @@ CodeMirror.defineMode("verilog", function(config, parserConfig) { var possibleClosing = textAfter.match(closingBracketOrWord); if (possibleClosing) closing = isClosing(possibleClosing[0], ctx.type); + if (!compilerDirectivesUseRegularIndentation && textAfter.match(compilerDirectiveRegex)) { + if (textAfter.match(compilerDirectiveEndRegex)) { + return state.compilerDirectiveIndented - statementIndentUnit; + } + return state.compilerDirectiveIndented; + } if (ctx.type == "statement") return ctx.indented + (firstChar == "{" ? 0 : statementIndentUnit); - else if (closingBracket.test(ctx.type) && ctx.align && !dontAlignCalls) return ctx.column + (closing ? 0 : 1); + else if ((closingBracket.test(ctx.type) || ctx.type == "assignment") + && ctx.align && !dontAlignCalls) return ctx.column + (closing ? 0 : 1); else if (ctx.type == ")" && !closing) return ctx.indented + statementIndentUnit; else return ctx.indented + (closing ? 0 : indentUnit); }, From 348ab5603405d1e396f32a9acfdf81055c91a16f Mon Sep 17 00:00:00 2001 From: iteriani Date: Tue, 8 Dec 2020 00:41:03 -0800 Subject: [PATCH 2066/2444] [soy mode] Update indentation rules for Element Composition * Add support for Soy Element Composition. Add support for Soy Element Composition. It has the syntax in the form of <{foo()}> This adds support to pass through allowEmptyTag and to support this mode in closetag. * Disable allowMissingTagName and handle Soy Element Composition directly. Disable allowMissingTagName and handle Soy Element Composition directly. This also adds a case in closetag.js to handle autocompletes for soy element composition. Right now, if you were to do something like <{foo()}> it would autocomplet with . This change makes it autocomplete with * Update indentation rules for Soy Element Composition Update indentation rules for Soy Element Composition * Update soy.js * Update soy.js --- mode/soy/soy.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/mode/soy/soy.js b/mode/soy/soy.js index 17bafcd932..e3427ebe3c 100644 --- a/mode/soy/soy.js +++ b/mode/soy/soy.js @@ -463,8 +463,15 @@ return null; case "tag": - var endTag = state.tag[0] == "/"; - var tagName = endTag ? state.tag.substring(1) : state.tag; + var endTag; + var tagName; + if (state.tag === undefined) { + endTag = true; + tagName = ''; + } else { + endTag = state.tag[0] == "/"; + tagName = endTag ? state.tag.substring(1) : state.tag; + } var tag = tags[tagName]; if (stream.match(/^\/?}/)) { var selfClosed = stream.current() == "/}"; @@ -576,12 +583,11 @@ return "keyword"; } else if (match = stream.match(/^<\{/)) { state.soyState.push("template-call-expression"); - state.tag = "print"; state.indent += 2 * config.indentUnit; state.soyState.push("tag"); return "keyword"; } else if (match = stream.match(/^<\/>/)) { - state.indent -= 2 * config.indentUnit; + state.indent -= 1 * config.indentUnit; return "keyword"; } From e20f9118534ebbb1249a2316639de5ce675523a8 Mon Sep 17 00:00:00 2001 From: Matt Diehl Date: Tue, 8 Dec 2020 09:50:20 -0700 Subject: [PATCH 2067/2444] Remove unnecessary line. --- mode/verilog/verilog.js | 1 - 1 file changed, 1 deletion(-) diff --git a/mode/verilog/verilog.js b/mode/verilog/verilog.js index 544045b867..89fe9c1ac8 100644 --- a/mode/verilog/verilog.js +++ b/mode/verilog/verilog.js @@ -144,7 +144,6 @@ CodeMirror.defineMode("verilog", function(config, parserConfig) { var keywordClose = curKeyword.substr(0,curKeyword.length - 5) + "end"; openClose[cur] = keywordClose; curPunc = "newblock"; - } else if (cur.startsWith("`uvm_") && cur.endsWith("_end")) { } else { stream.eatSpace(); if (stream.peek() == '(') { From d096a604db350e678c53bce0b2081e0817b84056 Mon Sep 17 00:00:00 2001 From: Elmar Peise Date: Thu, 10 Dec 2020 13:44:26 +0100 Subject: [PATCH 2068/2444] [hardwrap addon] Break an inifite loop This breaks an infinite loop triggered by wrapping a text containing a word longer than the targed width (e.g., a long URL). --- addon/wrap/hardwrap.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addon/wrap/hardwrap.js b/addon/wrap/hardwrap.js index bccdc8d14c..516368c80d 100644 --- a/addon/wrap/hardwrap.js +++ b/addon/wrap/hardwrap.js @@ -91,7 +91,8 @@ } while (curLine.length > column) { var bp = findBreakPoint(curLine, column, wrapOn, killTrailing, forceBreak); - if (bp.from != bp.to || forceBreak) { + if (bp.from != bp.to || + forceBreak && leadingSpace !== curLine.slice(0, bp.to)) { changes.push({text: ["", leadingSpace], from: Pos(curNo, bp.from), to: Pos(curNo, bp.to)}); From 7f3c36619f964d20e20c0ff5bec9cee99dae1549 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Fri, 11 Dec 2020 07:48:40 +0100 Subject: [PATCH 2069/2444] Fix platform detection for iPadOS Safari See https://github.com/ProseMirror/prosemirror/issues/1111 --- src/util/browser.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/browser.js b/src/util/browser.js index 9fc4602c68..6e3022e765 100644 --- a/src/util/browser.js +++ b/src/util/browser.js @@ -17,7 +17,7 @@ export let safari = /Apple Computer/.test(navigator.vendor) export let mac_geMountainLion = /Mac OS X 1\d\D([8-9]|\d\d)\D/.test(userAgent) export let phantom = /PhantomJS/.test(userAgent) -export let ios = !edge && /AppleWebKit/.test(userAgent) && /Mobile\/\w+/.test(userAgent) +export let ios = !edge && /AppleWebKit/.test(userAgent) && (/Mobile\/\w+/.test(userAgent) || navigator.maxTouchPoints > 2) export let android = /Android/.test(userAgent) // This is woefully incomplete. Suggestions for alternative methods welcome. export let mobile = ios || android || /webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(userAgent) From e4784f6e9c34f4642791ecf622640c81b91f37fa Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Tue, 15 Dec 2020 08:28:52 +0100 Subject: [PATCH 2070/2444] [javascript mode] Allow separator-less object types Issue #6520 --- mode/javascript/javascript.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/mode/javascript/javascript.js b/mode/javascript/javascript.js index 63eaa241b7..188dbf217c 100644 --- a/mode/javascript/javascript.js +++ b/mode/javascript/javascript.js @@ -616,13 +616,18 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { if (value == "|" || value == "&") return cont(typeexpr) if (type == "string" || type == "number" || type == "atom") return cont(afterType); if (type == "[") return cont(pushlex("]"), commasep(typeexpr, "]", ","), poplex, afterType) - if (type == "{") return cont(pushlex("}"), commasep(typeprop, "}", ",;"), poplex, afterType) + if (type == "{") return cont(pushlex("}"), typeprops, poplex, afterType) if (type == "(") return cont(commasep(typearg, ")"), maybeReturnType, afterType) if (type == "<") return cont(commasep(typeexpr, ">"), typeexpr) } function maybeReturnType(type) { if (type == "=>") return cont(typeexpr) } + function typeprops(type) { + if (type == "}") return cont() + if (type == "," || type == ";") return cont(typeprops) + return pass(typeprop, typeprops) + } function typeprop(type, value) { if (type == "variable" || cx.style == "keyword") { cx.marked = "property" From 7faab336a4b644eb4d8ff34d2eb1d96d912f7fa7 Mon Sep 17 00:00:00 2001 From: Kim-Anh Tran Date: Fri, 18 Dec 2020 05:27:35 +0100 Subject: [PATCH 2071/2444] [wast mode] Update to reflect latest reference-types spec --- mode/wast/test.js | 25 ++++++++++++++++++++++--- mode/wast/wast.js | 4 ++-- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/mode/wast/test.js b/mode/wast/test.js index 9998cfd965..3e5137c072 100644 --- a/mode/wast/test.js +++ b/mode/wast/test.js @@ -21,7 +21,8 @@ '[string "foo #\\"# bar"]'); MT('atom-test', - '[atom anyfunc]', + '[atom funcref]', + '[atom externref]', '[atom i32]', '[atom i64]', '[atom f32]', @@ -42,9 +43,11 @@ '[keyword br_table] [variable-2 $label0] [variable-2 $label1] [variable-2 $label3]', '[keyword return]', '[keyword call] [variable-2 $func0]', - '[keyword call_indirect] ([keyword param] [atom f32] [atom f64]) ([keyword result] [atom i32] [atom i64])', + '[keyword call_indirect] [variable-2 $table] ([keyword param] [atom f32] [atom f64]) ([keyword result] [atom i32] [atom i64])', '[keyword return_call] [variable-2 $func0]', - '[keyword return_call_indirect] ([keyword param] [atom f32] [atom f64]) ([keyword result] [atom i32] [atom i64])'); + '[keyword return_call_indirect] ([keyword param] [atom f32] [atom f64]) ([keyword result] [atom i32] [atom i64])', + '[keyword select] ([keyword local.get] [number 1]) ([keyword local.get] [number 2]) ([keyword local.get] [number 3])'); + MT('memory-instructions', '[keyword i32.load] [keyword offset]=[number 4] [keyword align]=[number 4]', @@ -318,4 +321,20 @@ '[keyword i32x4.trunc_sat_f32x4_u]', '[keyword f32x4.convert_i32x4_s]', '[keyword f32x4.convert_i32x4_u]'); + + MT('reference-type-instructions', + '[keyword ref.null] [keyword extern]', + '[keyword ref.null] [keyword func]', + '[keyword ref.is_null] ([keyword ref.func] [variable-2 $f])', + '[keyword ref.func] [variable-2 $f]'); + + MT('table-instructions', + '[keyword table.get] [variable-2 $t] ([keyword i32.const] [number 5])', + '[keyword table.set] [variable-2 $t] ([keyword i32.const] [number 5]) ([keyword ref.func] [variable-2 $f])', + '[keyword table.size] [variable-2 $t]', + '[keyword table.grow] [variable-2 $t] ([keyword ref.null] [keyword extern]) ([keyword i32.const] [number 5])', + '[keyword table.fill] [variable-2 $t] ([keyword i32.const] [number 5]) ([keyword param] [variable-2 $r] [atom externref]) ([keyword i32.const] [number 5])', + '[keyword table.init] [variable-2 $t] [number 1] ([keyword i32.const] [number 5]) ([keyword i32.const] [number 10]) ([keyword i32.const] [number 15])', + '[keyword table.copy] [variable-2 $t] [variable-2 $t2] ([keyword i32.const] [number 5]) ([keyword i32.const] [number 10]) ([keyword i32.const] [number 15])' + ); })(); diff --git a/mode/wast/wast.js b/mode/wast/wast.js index 9348ad3e0a..a730d39efc 100644 --- a/mode/wast/wast.js +++ b/mode/wast/wast.js @@ -14,8 +14,8 @@ CodeMirror.defineSimpleMode('wast', { start: [ {regex: /[+\-]?(?:nan(?::0x[0-9a-fA-F]+)?|infinity|inf|0x[0-9a-fA-F]+\.?[0-9a-fA-F]*p[+\/-]?\d+|\d+(?:\.\d*)?[eE][+\-]?\d*|\d+\.\d*|0x[0-9a-fA-F]+|\d+)/, token: "number"}, - {regex: /mut|nop|block|if|then|else|loop|br_if|br_table|br|call(_indirect)?|drop|end|return(_call(_indirect)?)?|local\.(get|set|tee)|global\.(get|set)|i(32|64)\.(store(8|16)|(load(8|16)_[su]))|i64\.(load32_[su]|store32)|[fi](32|64)\.(const|load|store)|f(32|64)\.(abs|add|ceil|copysign|div|eq|floor|[gl][et]|max|min|mul|nearest|neg?|sqrt|sub|trunc)|i(32|64)\.(a[dn]d|c[lt]z|(div|rem)_[su]|eqz?|[gl][te]_[su]|mul|ne|popcnt|rot[lr]|sh(l|r_[su])|sub|x?or)|i64\.extend_[su]_i32|i32\.wrap_i64|i(32|64)\.trunc_f(32|64)_[su]|f(32|64)\.convert_i(32|64)_[su]|f64\.promote_f32|f32\.demote_f64|f32\.reinterpret_i32|i32\.reinterpret_f32|f64\.reinterpret_i64|i64\.reinterpret_f64|select|unreachable|current_memory|memory(\.((atomic\.(notify|wait(32|64)))|grow|size))?|type|func|param|result|local|global|module|table|start|elem|data|align|offset|import|export|i64\.atomic\.(load32_u|store32|rmw32\.(a[dn]d|sub|x?or|(cmp)?xchg)_u)|i(32|64)\.atomic\.(load((8|16)_u)?|store(8|16)?|rmw(\.(a[dn]d|sub|x?or|(cmp)?xchg)|(8|16)\.(a[dn]d|sub|x?or|(cmp)?xchg)_u))|v128\.(load|store|const|not|andnot|and|or|xor|bitselect)|i(8x16|16x8|32x4|64x2)\.(shl|shr_[su])|i(8x16|16x8)\.(extract_lane_[su]|((add|sub)_saturate_[su])|avgr_u)|(i(8x16|16x8|32x4|64x2)|f(32x4|64x2))\.(splat|replace_lane|neg|add|sub)|i(8x16|16x8|32x4)\.(eq|ne|([lg][te]_[su])|abs|any_true|all_true|bitmask|((min|max)_[su]))|f(32x4|64x2)\.(eq|ne|[lg][te]|abs|sqrt|mul|div|min|max)|[fi](32x4|64x2)\.extract_lane|v8x16\.(shuffle|swizzle)|i16x8\.(load8x8_[su]|narrow_i32x4_[su]|widen_(low|high)_i8x16_[su]|mul)|i32x4\.(load16x4_[su]|widen_(low|high)_i16x8_[su]|mul|trunc_sat_f32x4_[su])|i64x2\.(load32x2_[su]|mul)|(v(8x16|16x8|32x4|64x2)\.load_splat)|i8x16\.narrow_i16x8_[su]|f32x4\.convert_i32x4_[su]/, token: "keyword"}, - {regex: /\b(anyfunc|[fi](32|64))\b/, token: "atom"}, + {regex: /mut|nop|block|if|then|else|loop|br_if|br_table|br|call(_indirect)?|drop|end|return(_call(_indirect)?)?|local\.(get|set|tee)|global\.(get|set)|i(32|64)\.(store(8|16)|(load(8|16)_[su]))|i64\.(load32_[su]|store32)|[fi](32|64)\.(const|load|store)|f(32|64)\.(abs|add|ceil|copysign|div|eq|floor|[gl][et]|max|min|mul|nearest|neg?|sqrt|sub|trunc)|i(32|64)\.(a[dn]d|c[lt]z|(div|rem)_[su]|eqz?|[gl][te]_[su]|mul|ne|popcnt|rot[lr]|sh(l|r_[su])|sub|x?or)|i64\.extend_[su]_i32|i32\.wrap_i64|i(32|64)\.trunc_f(32|64)_[su]|f(32|64)\.convert_i(32|64)_[su]|f64\.promote_f32|f32\.demote_f64|f32\.reinterpret_i32|i32\.reinterpret_f32|f64\.reinterpret_i64|i64\.reinterpret_f64|select|unreachable|current_memory|memory(\.((atomic\.(notify|wait(32|64)))|grow|size))?|type|\bfunc\b|param|result|local|global|module|start|elem|data|align|offset|import|export|i64\.atomic\.(load32_u|store32|rmw32\.(a[dn]d|sub|x?or|(cmp)?xchg)_u)|i(32|64)\.atomic\.(load((8|16)_u)?|store(8|16)?|rmw(\.(a[dn]d|sub|x?or|(cmp)?xchg)|(8|16)\.(a[dn]d|sub|x?or|(cmp)?xchg)_u))|v128\.(load|store|const|not|andnot|and|or|xor|bitselect)|i(8x16|16x8|32x4|64x2)\.(shl|shr_[su])|i(8x16|16x8)\.(extract_lane_[su]|((add|sub)_saturate_[su])|avgr_u)|(i(8x16|16x8|32x4|64x2)|f(32x4|64x2))\.(splat|replace_lane|neg|add|sub)|i(8x16|16x8|32x4)\.(eq|ne|([lg][te]_[su])|abs|any_true|all_true|bitmask|((min|max)_[su]))|f(32x4|64x2)\.(eq|ne|[lg][te]|abs|sqrt|mul|div|min|max)|[fi](32x4|64x2)\.extract_lane|v8x16\.(shuffle|swizzle)|i16x8\.(load8x8_[su]|narrow_i32x4_[su]|widen_(low|high)_i8x16_[su]|mul)|i32x4\.(load16x4_[su]|widen_(low|high)_i16x8_[su]|mul|trunc_sat_f32x4_[su])|i64x2\.(load32x2_[su]|mul)|(v(8x16|16x8|32x4|64x2)\.load_splat)|i8x16\.narrow_i16x8_[su]|f32x4\.convert_i32x4_[su]|ref\.(func|(is_)?null)|\bextern\b|table(\.(size|get|set|size|grow|fill|init|copy))?/, token: "keyword"}, + {regex: /\b(funcref|externref|[fi](32|64))\b/, token: "atom"}, {regex: /\$([a-zA-Z0-9_`\+\-\*\/\\\^~=<>!\?@#$%&|:\.]+)/, token: "variable-2"}, {regex: /"(?:[^"\\\x00-\x1f\x7f]|\\[nt\\'"]|\\[0-9a-fA-F][0-9a-fA-F])*"/, token: "string"}, {regex: /\(;.*?/, token: "comment", next: "comment"}, From abc65fe746384652c36c027ff73b95f17d262378 Mon Sep 17 00:00:00 2001 From: nathanlesage Date: Thu, 17 Dec 2020 09:15:10 +0100 Subject: [PATCH 2072/2444] Document singleCursorHeightPerLine option --- doc/manual.html | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/doc/manual.html b/doc/manual.html index 89a6328e6d..ad5c275d50 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -512,6 +512,15 @@

    Configuration

    which causes the cursor to not reach all the way to the bottom of the line, looks better +
    singleCursorHeightPerLine: boolean
    +
    Determines if CodeMirror can expect all lines to be of the + same height (true, the default) and the cursor-size + can therefore be lazily evaluated. In case your editor contains + multiple line-sizes, for instance, if addLineClass + sets classes which contain line-height-rules, you + should consider setting this to false to prevent + visual artefacts. +
    resetSelectionOnContextMenu: boolean
    Controls whether, when the context menu is opened with a click outside of the current selection, the cursor is moved to From ee414661b9099e9c122f40b8408b841801f37ed9 Mon Sep 17 00:00:00 2001 From: Hendrik Erz Date: Sat, 19 Dec 2020 21:05:56 +0100 Subject: [PATCH 2073/2444] Update description of singleCursorHeightPerLine --- doc/manual.html | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/doc/manual.html b/doc/manual.html index ad5c275d50..06ee3dbf18 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -513,13 +513,13 @@

    Configuration

    of the line, looks better
    singleCursorHeightPerLine: boolean
    -
    Determines if CodeMirror can expect all lines to be of the - same height (true, the default) and the cursor-size - can therefore be lazily evaluated. In case your editor contains - multiple line-sizes, for instance, if addLineClass - sets classes which contain line-height-rules, you - should consider setting this to false to prevent - visual artefacts. +
    If set to true (the default), CodeMirror will + calculate the cursor height from the adjacent characters or + text markers. If set to false, the cursor height + will be calculated based off the height of all bounding boxes + on the current (wrapped) line, keeping the height consistent. + This is visible especially if you use text markers that are + bigger than the font-size of the characters on the line.
    resetSelectionOnContextMenu: boolean
    Controls whether, when the context menu is opened with a From a90d0f8e992b6fa9232c8982a970305096a28164 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Sun, 20 Dec 2020 11:17:22 +0100 Subject: [PATCH 2074/2444] [manual] Correct documentation for singleCursorHeightPerLine Issue #6524 --- doc/manual.html | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/doc/manual.html b/doc/manual.html index 06ee3dbf18..1086507a91 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -513,13 +513,10 @@

    Configuration

    of the line, looks better
    singleCursorHeightPerLine: boolean
    -
    If set to true (the default), CodeMirror will - calculate the cursor height from the adjacent characters or - text markers. If set to false, the cursor height - will be calculated based off the height of all bounding boxes - on the current (wrapped) line, keeping the height consistent. - This is visible especially if you use text markers that are - bigger than the font-size of the characters on the line. +
    If set to true (the default), will keep the + cursor height constant for an entire line (or wrapped part of a + line). When false, the cursor's height is based on + the height of the adjacent reference character.
    resetSelectionOnContextMenu: boolean
    Controls whether, when the context menu is opened with a From e49f2950e9ca59f437db26a2b43e3cc478fc4761 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Sun, 20 Dec 2020 11:48:25 +0100 Subject: [PATCH 2075/2444] Mark release 5.59.0 --- AUTHORS | 10 ++++++++++ CHANGELOG.md | 18 ++++++++++++++++++ doc/manual.html | 2 +- doc/releases.html | 11 +++++++++++ index.html | 2 +- package.json | 2 +- src/edit/main.js | 2 +- 7 files changed, 43 insertions(+), 4 deletions(-) diff --git a/AUTHORS b/AUTHORS index 33d819ed24..95134fa2d5 100644 --- a/AUTHORS +++ b/AUTHORS @@ -244,6 +244,7 @@ edoroshenko edsharp ekhaled Elisée +Elmar Peise elpnt Emmanuel Schanzer Enam Mijbah Noor @@ -363,6 +364,7 @@ Jacob Lee Jaimin Jake Peyser Jakob Miland +Jakub T. Jankiewicz Jakub Vrana Jakub Vrána James Campos @@ -466,6 +468,7 @@ Kevin Muret Kevin Sawicki Kevin Ushey Kier Darby +Kim-Anh Tran Klaus Silveira Koh Zi Han, Cliff komakino @@ -547,6 +550,7 @@ Mason Malone Mateusz Paprocki Mathias Bynens mats cronqvist +Matt Diehl Matt Gaide Matthew Bauer Matthew Beale @@ -604,6 +608,7 @@ Miraculix87 misfo mkaminsky11 mloginov +mlsad3 Moritz Schubotz (physikerwelt) Moritz Schwörer Moshe Wajnberg @@ -614,6 +619,7 @@ Mu-An ✌️ Chiou Mu-An Chiou mzabuawala Narciso Jaramillo +nathanlesage Nathan Williams ndr Neil Anderson @@ -692,6 +698,7 @@ Philip Stadermann Pi Delport Pierre Gerold Pieter Ouwerkerk +Piyush Pontus Melke prasanthj Prasanth J @@ -699,6 +706,7 @@ Prayag Verma prendota Prendota Qiang Li +quiddity-wp Radek Piórkowski Rahul Rahul Anand @@ -759,6 +767,7 @@ Scott Aikin Scott Feeney Scott Goodhew Seb35 +Sebastian Ślepowroński Sebastian Wilzbach Sebastian Zaha Seren D @@ -779,6 +788,7 @@ Siamak Mokhtari Siddhartha Gunti silverwind Simon Edwards +Simon Huber sinkuu snasa soliton4 diff --git a/CHANGELOG.md b/CHANGELOG.md index 2b00dbd80e..9276146f78 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,21 @@ +## 5.59.0 (2020-12-20) + +### Bug fixes + +Fix platform detection on recent iPadOS. + +[lint addon](https://codemirror.net/doc/manual.html#addon_lint): Don't show duplicate messages for a given line. + +[clojure mode](https://codemirror.net/mode/clojure/index.html): Fix regexp that matched in exponential time for some inputs. + +[hardwrap addon](https://codemirror.net/doc/manual.html#addon_hardwrap): Improve handling of words that are longer than the line length. + +[matchbrackets addon](https://codemirror.net/doc/manual.html#addon_matchbrackets): Fix leaked event handler on disabling the addon. + +### New features + +[search addon](https://codemirror.net/demo/search/): Make it possible to configure the search addon to show the dialog at the bottom of the editor. + ## 5.58.3 (2020-11-19) ### Bug fixes diff --git a/doc/manual.html b/doc/manual.html index 1086507a91..b7ca9a6972 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -70,7 +70,7 @@

    User manual and reference guide - version 5.58.3 + version 5.59.0

    CodeMirror is a code-editor component that can be embedded in diff --git a/doc/releases.html b/doc/releases.html index 1b4f9a7976..18987f5ea2 100644 --- a/doc/releases.html +++ b/doc/releases.html @@ -30,6 +30,17 @@

    Release notes and version history

    Version 5.x

    +

    20-12-2020: Version 5.59.0:

    + +
      +
    • Fix platform detection on recent iPadOS.
    • +
    • lint addon: Don't show duplicate messages for a given line.
    • +
    • clojure mode: Fix regexp that matched in exponential time for some inputs.
    • +
    • hardwrap addon: Improve handling of words that are longer than the line length.
    • +
    • matchbrackets addon: Fix leaked event handler on disabling the addon.
    • +
    • search addon: Make it possible to configure the search addon to show the dialog at the bottom of the editor.
    • +
    +

    19-11-2020: Version 5.58.3:

      diff --git a/index.html b/index.html index 7ea8c48961..849447a578 100644 --- a/index.html +++ b/index.html @@ -99,7 +99,7 @@

      This is CodeMirror

    - Get the current version: 5.58.3.
    + Get the current version: 5.59.0.
    You can see the code,
    read the release notes,
    or study the user manual. diff --git a/package.json b/package.json index a768858ec8..321a46c1d6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "codemirror", - "version": "5.58.3", + "version": "5.59.0", "main": "lib/codemirror.js", "style": "lib/codemirror.css", "author": { diff --git a/src/edit/main.js b/src/edit/main.js index d51192c6e5..6550214906 100644 --- a/src/edit/main.js +++ b/src/edit/main.js @@ -66,4 +66,4 @@ import { addLegacyProps } from "./legacy.js" addLegacyProps(CodeMirror) -CodeMirror.version = "5.58.3" +CodeMirror.version = "5.59.0" From ffa872e4d5a7b01cc148099322ef376bd6ada5a3 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Mon, 21 Dec 2020 08:57:43 +0100 Subject: [PATCH 2076/2444] [closebrackets addon] Fix left-to-right assumption Closes #6527 --- addon/edit/closebrackets.js | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/addon/edit/closebrackets.js b/addon/edit/closebrackets.js index 4415c39381..f2239fdd12 100644 --- a/addon/edit/closebrackets.js +++ b/addon/edit/closebrackets.js @@ -87,7 +87,7 @@ cm.operation(function() { var linesep = cm.lineSeparator() || "\n"; cm.replaceSelection(linesep + linesep, null); - cm.execCommand("goCharLeft"); + moveSel(cm, -1) ranges = cm.listSelections(); for (var i = 0; i < ranges.length; i++) { var line = ranges[i].head.line; @@ -97,6 +97,17 @@ }); } + function moveSel(cm, dir) { + let newRanges = [], ranges = cm.listSelections(), primary = 0 + for (let i = 0; i < ranges.length; i++) { + let range = ranges[i] + if (range.head == cm.getCursor()) primary = i + let pos = {line: range.head.line, ch: range.head.ch + dir} + newRanges.push({anchor: pos, head: pos}) + } + cm.setSelections(newRanges, primary) + } + function contractSelection(sel) { var inverted = CodeMirror.cmpPos(sel.anchor, sel.head) > 0; return {anchor: new Pos(sel.anchor.line, sel.anchor.ch + (inverted ? -1 : 1)), @@ -153,10 +164,9 @@ var right = pos % 2 ? ch : pairs.charAt(pos + 1); cm.operation(function() { if (type == "skip") { - cm.execCommand("goCharRight"); + moveSel(cm, 1) } else if (type == "skipThree") { - for (var i = 0; i < 3; i++) - cm.execCommand("goCharRight"); + moveSel(cm, 3) } else if (type == "surround") { var sels = cm.getSelections(); for (var i = 0; i < sels.length; i++) @@ -169,10 +179,10 @@ } else if (type == "both") { cm.replaceSelection(left + right, null); cm.triggerElectric(left + right); - cm.execCommand("goCharLeft"); + moveSel(cm, -1) } else if (type == "addFour") { cm.replaceSelection(left + left + left + left, "before"); - cm.execCommand("goCharRight"); + moveSel(cm, 1) } }); } From ff70b4e2d1139b052064ec73e4d1ad86cf56d36c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20dBruxelles?= <18559798+jdbruxelles@users.noreply.github.com> Date: Mon, 21 Dec 2020 08:58:32 +0100 Subject: [PATCH 2077/2444] [release notes] Fix the search addon page link Simply add the .html extension to the link. --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9276146f78..c1ffa87816 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,7 +14,7 @@ Fix platform detection on recent iPadOS. ### New features -[search addon](https://codemirror.net/demo/search/): Make it possible to configure the search addon to show the dialog at the bottom of the editor. +[search addon](https://codemirror.net/demo/search.html): Make it possible to configure the search addon to show the dialog at the bottom of the editor. ## 5.58.3 (2020-11-19) From 885daa14aad5dd35a537cdadea7e01300374aeea Mon Sep 17 00:00:00 2001 From: Yash Singh Date: Mon, 21 Dec 2020 00:04:40 -0800 Subject: [PATCH 2078/2444] Defined the webmanifest MIME (#6529) --- mode/javascript/javascript.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mode/javascript/javascript.js b/mode/javascript/javascript.js index 188dbf217c..cfcd6cb6ed 100644 --- a/mode/javascript/javascript.js +++ b/mode/javascript/javascript.js @@ -930,9 +930,10 @@ CodeMirror.defineMIME("text/ecmascript", "javascript"); CodeMirror.defineMIME("application/javascript", "javascript"); CodeMirror.defineMIME("application/x-javascript", "javascript"); CodeMirror.defineMIME("application/ecmascript", "javascript"); -CodeMirror.defineMIME("application/json", {name: "javascript", json: true}); -CodeMirror.defineMIME("application/x-json", {name: "javascript", json: true}); -CodeMirror.defineMIME("application/ld+json", {name: "javascript", jsonld: true}); +CodeMirror.defineMIME("application/json", { name: "javascript", json: true }); +CodeMirror.defineMIME("application/x-json", { name: "javascript", json: true }); +CodeMirror.defineMIME("application/manifest+json", { name: "javascript", json: true }) +CodeMirror.defineMIME("application/ld+json", { name: "javascript", jsonld: true }); CodeMirror.defineMIME("text/typescript", { name: "javascript", typescript: true }); CodeMirror.defineMIME("application/typescript", { name: "javascript", typescript: true }); From c58ccada2ddfb064149237cb7f59ce73176b376a Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Mon, 21 Dec 2020 09:07:47 +0100 Subject: [PATCH 2079/2444] Fix ES6 use in addon --- addon/edit/closebrackets.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addon/edit/closebrackets.js b/addon/edit/closebrackets.js index f2239fdd12..19a3c53c1f 100644 --- a/addon/edit/closebrackets.js +++ b/addon/edit/closebrackets.js @@ -98,11 +98,11 @@ } function moveSel(cm, dir) { - let newRanges = [], ranges = cm.listSelections(), primary = 0 + var newRanges = [], ranges = cm.listSelections(), primary = 0 for (let i = 0; i < ranges.length; i++) { - let range = ranges[i] + var range = ranges[i] if (range.head == cm.getCursor()) primary = i - let pos = {line: range.head.line, ch: range.head.ch + dir} + var pos = {line: range.head.line, ch: range.head.ch + dir} newRanges.push({anchor: pos, head: pos}) } cm.setSelections(newRanges, primary) From f18854ef817b831419b5b3353197b403b7a9b8b8 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Mon, 21 Dec 2020 12:44:06 +0100 Subject: [PATCH 2080/2444] Remove another let in an addon --- addon/edit/closebrackets.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addon/edit/closebrackets.js b/addon/edit/closebrackets.js index 19a3c53c1f..5c1aeab3c5 100644 --- a/addon/edit/closebrackets.js +++ b/addon/edit/closebrackets.js @@ -99,7 +99,7 @@ function moveSel(cm, dir) { var newRanges = [], ranges = cm.listSelections(), primary = 0 - for (let i = 0; i < ranges.length; i++) { + for (var i = 0; i < ranges.length; i++) { var range = ranges[i] if (range.head == cm.getCursor()) primary = i var pos = {line: range.head.line, ch: range.head.ch + dir} From c88d09d0ca8b6c2f88b4432094d72e4be757b4a3 Mon Sep 17 00:00:00 2001 From: Masahiro MATAYOSHI Date: Tue, 22 Dec 2020 16:52:16 +0900 Subject: [PATCH 2081/2444] [perl mode] Don't treat <<1 as here document start --- mode/perl/perl.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mode/perl/perl.js b/mode/perl/perl.js index a3101a7c5b..f620b41e27 100644 --- a/mode/perl/perl.js +++ b/mode/perl/perl.js @@ -516,7 +516,7 @@ CodeMirror.defineMode("perl",function(){ if(stream.match(/^\-?[\d\.]/,false)) if(stream.match(/^(\-?(\d*\.\d+(e[+-]?\d+)?|\d+\.\d*)|0x[\da-fA-F]+|0b[01]+|\d+(e[+-]?\d+)?)/)) return 'number'; - if(stream.match(/^<<(?=\w)/)){ // NOTE: < Date: Wed, 23 Dec 2020 08:22:14 +0100 Subject: [PATCH 2082/2444] Try to refine iPadOS/iOS detection Issue #6532 --- src/util/browser.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/browser.js b/src/util/browser.js index 6e3022e765..ae9d6af706 100644 --- a/src/util/browser.js +++ b/src/util/browser.js @@ -17,7 +17,7 @@ export let safari = /Apple Computer/.test(navigator.vendor) export let mac_geMountainLion = /Mac OS X 1\d\D([8-9]|\d\d)\D/.test(userAgent) export let phantom = /PhantomJS/.test(userAgent) -export let ios = !edge && /AppleWebKit/.test(userAgent) && (/Mobile\/\w+/.test(userAgent) || navigator.maxTouchPoints > 2) +export let ios = safari && (/Mobile\/\w+/.test(userAgent) || navigator.maxTouchPoints > 2) export let android = /Android/.test(userAgent) // This is woefully incomplete. Suggestions for alternative methods welcome. export let mobile = ios || android || /webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(userAgent) From d8d78f5e7aa07e682bf51ad94a75ba6bb2484794 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Wed, 23 Dec 2020 08:29:43 +0100 Subject: [PATCH 2083/2444] [panel addon] Preserve scroll post when initializing/removing panel wrapper Closes #6533 --- addon/display/panel.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/addon/display/panel.js b/addon/display/panel.js index 4c9f2c0fca..29f7e0bebb 100644 --- a/addon/display/panel.js +++ b/addon/display/panel.js @@ -76,7 +76,7 @@ }; function initPanels(cm) { - var wrap = cm.getWrapperElement(); + var wrap = cm.getWrapperElement() var style = window.getComputedStyle ? window.getComputedStyle(wrap) : wrap.currentStyle; var height = parseInt(style.height); var info = cm.state.panels = { @@ -84,9 +84,10 @@ panels: [], wrapper: document.createElement("div") }; + var hasFocus = cm.hasFocus(), scrollPos = cm.getScrollInfo() wrap.parentNode.insertBefore(info.wrapper, wrap); - var hasFocus = cm.hasFocus(); info.wrapper.appendChild(wrap); + cm.scrollTo(scrollPos.left, scrollPos.top) if (hasFocus) cm.focus(); cm._setSize = cm.setSize; @@ -114,8 +115,11 @@ var info = cm.state.panels; cm.state.panels = null; - var wrap = cm.getWrapperElement(); + var wrap = cm.getWrapperElement() + var hasFocus = cm.hasFocus(), scrollPos = cm.getScrollInfo() info.wrapper.parentNode.replaceChild(wrap, info.wrapper); + cm.scrollTo(scrollPos.left, scrollPos.top) + if (hasFocus) cm.focus(); wrap.style.height = info.setHeight; cm.setSize = cm._setSize; cm.setSize(); From 3ce2ef56989085002e6ac4078b0f580ab5fcc4ad Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Wed, 23 Dec 2020 16:46:53 +0100 Subject: [PATCH 2084/2444] [perl mode] Don't include brackets in variable names Closes #6534 --- mode/perl/perl.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mode/perl/perl.js b/mode/perl/perl.js index f620b41e27..220b0a6994 100644 --- a/mode/perl/perl.js +++ b/mode/perl/perl.js @@ -697,7 +697,7 @@ CodeMirror.defineMode("perl",function(){ return "variable-2";} stream.pos=p;} if(/[$@%&]/.test(ch)){ - if(stream.eatWhile(/[\w$\[\]]/)||stream.eat("{")&&stream.eatWhile(/[\w$\[\]]/)&&stream.eat("}")){ + if(stream.eatWhile(/[\w$]/)||stream.eat("{")&&stream.eatWhile(/[\w$]/)&&stream.eat("}")){ var c=stream.current(); if(PERL[c]) return "variable-2"; From d4a1a1a5d8648508c314ffb20fc700333f9ab5de Mon Sep 17 00:00:00 2001 From: "Dinindu D. Wanniarachchi" Date: Sat, 26 Dec 2020 19:15:17 +0530 Subject: [PATCH 2085/2444] [real-world uses] Changed SASS2CSS url --- doc/realworld.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/realworld.html b/doc/realworld.html index c6e6c80323..487208b286 100644 --- a/doc/realworld.html +++ b/doc/realworld.html @@ -157,7 +157,7 @@

    CodeMirror real-world uses

  • RealTime.io (Internet-of-Things infrastructure)
  • Refork (animation demo gallery and sharing)
  • SageMathCell (interactive mathematical software)
  • -
  • SASS2CSS (SASS, SCSS or LESS to CSS converter and CSS beautifier)
  • +
  • SASS2CSS (SASS, SCSS or LESS to CSS converter and CSS beautifier)
  • SageMathCloud (interactive mathematical software environment)
  • salvare (real-time collaborative code editor)
  • ServePHP (PHP code testing in Chrome dev tools)
  • From 90e1c26104b2b98aa803b2b98d917b19a32c8720 Mon Sep 17 00:00:00 2001 From: Yash Singh Date: Tue, 29 Dec 2020 00:05:24 -0800 Subject: [PATCH 2086/2444] [javascript mode] Mention more MIME types in demo page --- mode/javascript/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mode/javascript/index.html b/mode/javascript/index.html index d1f7f68e8a..3023835727 100644 --- a/mode/javascript/index.html +++ b/mode/javascript/index.html @@ -110,5 +110,5 @@

    JavaScript mode

    -

    MIME types defined: text/javascript, application/json, application/ld+json, text/typescript, application/typescript.

    +

    MIME types defined: text/javascript, application/javascript, application/x-javascript, text/ecmascript, application/ecmascript, application/json, application/x-json, application/manifest+json, application/ld+json, text/typescript, application/typescript.

    From d2728850abe64849ddd2730dc22536ef1361a90a Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Tue, 29 Dec 2020 09:04:32 +0100 Subject: [PATCH 2087/2444] [javascript mode] Fix infinite loop on some invalid syntax Closes #6542 --- mode/javascript/javascript.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mode/javascript/javascript.js b/mode/javascript/javascript.js index cfcd6cb6ed..8191c4d925 100644 --- a/mode/javascript/javascript.js +++ b/mode/javascript/javascript.js @@ -640,6 +640,8 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { return cont(expect("variable"), maybetypeOrIn, expect("]"), typeprop) } else if (type == "(") { return pass(functiondecl, typeprop) + } else { + return cont() } } function typearg(type, value) { From 4d5da83c1493cf5dec219ecb637adc69e468ea5d Mon Sep 17 00:00:00 2001 From: Yash-Singh1 Date: Mon, 28 Dec 2020 11:28:36 -0800 Subject: [PATCH 2088/2444] Prefer dot syntax in test --- test/test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test.js b/test/test.js index 2a5101f4e1..07fa67858f 100644 --- a/test/test.js +++ b/test/test.js @@ -1807,8 +1807,8 @@ testCM("atomicMarker", function(cm) { inclusiveRight: ri }; - if (ls === true || ls === false) options["selectLeft"] = ls; - if (rs === true || rs === false) options["selectRight"] = rs; + if (ls === true || ls === false) options.selectLeft = ls; + if (rs === true || rs === false) options.selectRight = rs; return cm.markText(Pos(ll, cl), Pos(lr, cr), options); } From 863c18904febf364876494ee650ced49c3b08bd9 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Tue, 29 Dec 2020 09:27:13 +0100 Subject: [PATCH 2089/2444] [javascript mode] Make sure type props don't consume closing braces --- mode/javascript/javascript.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mode/javascript/javascript.js b/mode/javascript/javascript.js index 8191c4d925..966ffef063 100644 --- a/mode/javascript/javascript.js +++ b/mode/javascript/javascript.js @@ -640,7 +640,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { return cont(expect("variable"), maybetypeOrIn, expect("]"), typeprop) } else if (type == "(") { return pass(functiondecl, typeprop) - } else { + } else if (!type.match(/[;\}\)\],]/)) { return cont() } } From 37d7b2efceb192c94811a13b2b7b3eec4b786608 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Tue, 29 Dec 2020 18:10:02 +0100 Subject: [PATCH 2090/2444] Fix moving backwards across astral chars Closes #6544 --- src/edit/methods.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/edit/methods.js b/src/edit/methods.js index a5e2afc39f..eb8f8d28dc 100644 --- a/src/edit/methods.js +++ b/src/edit/methods.js @@ -480,9 +480,12 @@ function findPosH(doc, pos, dir, unit, visually) { let next if (unit == "codepoint") { let ch = lineObj.text.charCodeAt(pos.ch + (unit > 0 ? 0 : -1)) - if (isNaN(ch)) next = null - else next = new Pos(pos.line, Math.max(0, Math.min(lineObj.text.length, pos.ch + dir * (ch >= 0xD800 && ch < 0xDC00 ? 2 : 1))), - -dir) + if (isNaN(ch)) { + next = null + } else { + let astral = dir > 0 ? ch >= 0xD800 && ch < 0xDC00 : ch >= 0xDC00 && ch < 0xDFFF + next = new Pos(pos.line, Math.max(0, Math.min(lineObj.text.length, pos.ch + dir * (astral ? 2 : 1))), -dir) + } } else if (visually) { next = moveVisually(doc.cm, lineObj, pos, dir) } else { From 5e25c3ce3026d7be3e98b8653f1aa171333d43ca Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Wed, 30 Dec 2020 09:21:06 +0100 Subject: [PATCH 2091/2444] [sponsors] Add Execute Program logo --- index.html | 1 + 1 file changed, 1 insertion(+) diff --git a/index.html b/index.html index 849447a578..9631b88366 100644 --- a/index.html +++ b/index.html @@ -203,6 +203,7 @@

    Sponsors

  • CodePen
  • JetBrains
  • desmos
  • +
  • Execute Program
  • From 1698f003a5cfabfbabad106c69cd214ec4ed996a Mon Sep 17 00:00:00 2001 From: Yash Singh Date: Thu, 31 Dec 2020 02:09:33 -0800 Subject: [PATCH 2092/2444] [manual] Add link to demo for jump-to-line Closes #6539 --- doc/manual.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/manual.html b/doc/manual.html index b7ca9a6972..00472c5236 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -2405,7 +2405,7 @@

    Addons

    Accepts linenumber, +/-linenumber, line:char, scroll% and :linenumber formats. This will make use of openDialog - when available to make prompting for line number neater. + when available to make prompting for line number neater. Demo avaliable here.
    search/matchesonscrollbar.js
    Adds a showMatchesOnScrollbar method to editor From bd37a96d362b8d92895d3960d569168ec39e4165 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Thu, 31 Dec 2020 13:02:29 +0100 Subject: [PATCH 2093/2444] Mark version 5.59.1 --- AUTHORS | 4 ++++ CHANGELOG.md | 6 ++++++ doc/manual.html | 2 +- doc/releases.html | 6 ++++++ index.html | 2 +- package.json | 2 +- src/edit/main.js | 2 +- 7 files changed, 20 insertions(+), 4 deletions(-) diff --git a/AUTHORS b/AUTHORS index 95134fa2d5..4ea87576d3 100644 --- a/AUTHORS +++ b/AUTHORS @@ -432,6 +432,7 @@ Jon Malmaud Jon Sangster Joo Joost-Wim Boekesteijn +José dBruxelles Joseph Pecoraro Josh Barnes Josh Cohen @@ -546,6 +547,7 @@ Martin Hasoň Martin Hunt Martin Laine Martin Zagora +Masahiro MATAYOSHI Mason Malone Mateusz Paprocki Mathias Bynens @@ -894,6 +896,8 @@ wonderboyjon Wu Cheng-Han Xavier Mendez Yang Guo +Yash Singh +Yash-Singh1 Yassin N. Hassan YNH Webdev yoongu diff --git a/CHANGELOG.md b/CHANGELOG.md index c1ffa87816..5a9baf4df1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## 5.59.1 (2020-12-31) + +### Bug fixes + +Fix an issue where some Chrome browsers were detected as iOS. + ## 5.59.0 (2020-12-20) ### Bug fixes diff --git a/doc/manual.html b/doc/manual.html index 00472c5236..285d420d9a 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -70,7 +70,7 @@

    User manual and reference guide - version 5.59.0 + version 5.59.1

    CodeMirror is a code-editor component that can be embedded in diff --git a/doc/releases.html b/doc/releases.html index 18987f5ea2..f6628b6548 100644 --- a/doc/releases.html +++ b/doc/releases.html @@ -30,6 +30,12 @@

    Release notes and version history

    Version 5.x

    +

    31-12-2020: Version 5.59.1:

    + +
      +
    • Fix an issue where some Chrome browsers were detected as iOS.
    • +
    +

    20-12-2020: Version 5.59.0:

      diff --git a/index.html b/index.html index 9631b88366..a89b1de5d3 100644 --- a/index.html +++ b/index.html @@ -99,7 +99,7 @@

      This is CodeMirror

      - Get the current version: 5.59.0.
      + Get the current version: 5.59.1.
      You can see the code,
      read the release notes,
      or study the user manual. diff --git a/package.json b/package.json index 321a46c1d6..7ab19be203 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "codemirror", - "version": "5.59.0", + "version": "5.59.1", "main": "lib/codemirror.js", "style": "lib/codemirror.css", "author": { diff --git a/src/edit/main.js b/src/edit/main.js index 6550214906..cb8c8cac5b 100644 --- a/src/edit/main.js +++ b/src/edit/main.js @@ -66,4 +66,4 @@ import { addLegacyProps } from "./legacy.js" addLegacyProps(CodeMirror) -CodeMirror.version = "5.59.0" +CodeMirror.version = "5.59.1" From 9749ba3ce08154510e631217e21532987415d9b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Wielgus?= <61328879+encap@users.noreply.github.com> Date: Sun, 3 Jan 2021 19:58:51 +0100 Subject: [PATCH 2094/2444] [real world uses] Add coderush.xyz (typing speed test) Uses CodeMirror with dynamic mode switching --- doc/realworld.html | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/realworld.html b/doc/realworld.html index 487208b286..698b0c3a80 100644 --- a/doc/realworld.html +++ b/doc/realworld.html @@ -58,6 +58,7 @@

      CodeMirror real-world uses

    • Codepen (gallery of animations)
    • Coderba Google Web Toolkit (GWT) wrapper
    • Coderpad (interviewing tool)
    • +
    • CodeRush typing speed test for programmers
    • Code School (online tech learning environment)
    • Code Snippets (WordPress snippet management plugin)
    • Code together (collaborative editing)
    • From c8059735fc9ef79a1b8176d776cb81a03771a28c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Wielgus?= <61328879+encap@users.noreply.github.com> Date: Sun, 3 Jan 2021 20:11:00 +0100 Subject: [PATCH 2095/2444] [real world uses] Update "clone-it" url Previous url (clone-it.github.io) returns 404 because I changed github account. --- doc/realworld.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/realworld.html b/doc/realworld.html index 698b0c3a80..a7402551f7 100644 --- a/doc/realworld.html +++ b/doc/realworld.html @@ -41,7 +41,7 @@

      CodeMirror real-world uses

    • Cargo Collective (creative publishing platform)
    • Chrome DevTools
    • ClickHelp (technical writing tool)
    • -
    • Clone-It (HTML & CSS learning game)
    • +
    • Clone-It (HTML & CSS learning game)
    • Colon (A flexible text editor or IDE)
    • CodeWorld (Haskell playground)
    • Complete.ly playground
    • From a46e33049de2c6f4550b77cad743d293039f2e93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20=C5=9Alepowro=C5=84ski?= <45392875+slepowronski@users.noreply.github.com> Date: Mon, 4 Jan 2021 13:28:25 +0100 Subject: [PATCH 2096/2444] [show-hint addon] Changed closeOnCursorActivity to updateOnCursorActivity --- addon/hint/show-hint.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/addon/hint/show-hint.js b/addon/hint/show-hint.js index 5ef1bba645..a9f2ded18c 100644 --- a/addon/hint/show-hint.js +++ b/addon/hint/show-hint.js @@ -61,8 +61,10 @@ this.startPos = this.cm.getCursor("start"); this.startLen = this.cm.getLine(this.startPos.line).length - this.cm.getSelection().length; - var self = this; - cm.on("cursorActivity", this.activityFunc = function() { self.cursorActivity(); }); + if (this.options.updateOnCursorActivity) { + var self = this; + cm.on("cursorActivity", this.activityFunc = function() { self.cursorActivity(); }); + } } var requestAnimationFrame = window.requestAnimationFrame || function(fn) { @@ -75,7 +77,9 @@ if (!this.active()) return; this.cm.state.completionActive = null; this.tick = null; - this.cm.off("cursorActivity", this.activityFunc); + if (this.options.updateOnCursorActivity) { + this.cm.off("cursorActivity", this.activityFunc); + } if (this.widget && this.data) CodeMirror.signal(this.data, "close"); if (this.widget) this.widget.close(); @@ -117,9 +121,7 @@ if (pos.line != this.startPos.line || line.length - pos.ch != this.startLen - this.startPos.ch || pos.ch < identStart.ch || this.cm.somethingSelected() || (!pos.ch || this.options.closeCharacters.test(line.charAt(pos.ch - 1)))) { - if (this.options.closeOnCursorActivity) { - this.close(); - } + this.close(); } else { var self = this; this.debounce = requestAnimationFrame(function() {self.update();}); @@ -492,9 +494,9 @@ completeSingle: true, alignWithWord: true, closeCharacters: /[\s()\[\]{};:>,]/, - closeOnCursorActivity: true, closeOnPick: true, closeOnUnfocus: true, + updateOnCursorActivity: true, completeOnSingleClick: true, container: null, customKeys: null, From 36c786bcca35c0650e78ab65ac8afb9d71abb89c Mon Sep 17 00:00:00 2001 From: Yash Singh Date: Tue, 5 Jan 2021 02:42:31 -0800 Subject: [PATCH 2097/2444] [closetag demo] Add description --- demo/closetag.html | 1 + 1 file changed, 1 insertion(+) diff --git a/demo/closetag.html b/demo/closetag.html index 4f857fa4bb..1f86114a9f 100644 --- a/demo/closetag.html +++ b/demo/closetag.html @@ -38,4 +38,5 @@

      Close-Tag Demo

      autoCloseTags: true }); +

      Uses the closetag addon to auto-close tags.

      From d19a746e51e041dd9aa1c9b79386b29cb1bcb3f1 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Wed, 6 Jan 2021 18:23:19 +0100 Subject: [PATCH 2098/2444] Fix bug in findPosH Closes #6554 --- src/edit/methods.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/edit/methods.js b/src/edit/methods.js index eb8f8d28dc..c33a859865 100644 --- a/src/edit/methods.js +++ b/src/edit/methods.js @@ -479,7 +479,7 @@ function findPosH(doc, pos, dir, unit, visually) { function moveOnce(boundToLine) { let next if (unit == "codepoint") { - let ch = lineObj.text.charCodeAt(pos.ch + (unit > 0 ? 0 : -1)) + let ch = lineObj.text.charCodeAt(pos.ch + (dir > 0 ? 0 : -1)) if (isNaN(ch)) { next = null } else { From 498e7c0c0a762c2ad5b8bc8b455ef1f12db1e5bd Mon Sep 17 00:00:00 2001 From: Josh Soref Date: Fri, 8 Jan 2021 08:32:22 -0500 Subject: [PATCH 2099/2444] Fix various spelling mistakes * spelling: across Signed-off-by: Josh Soref * spelling: advise Signed-off-by: Josh Soref * spelling: aframework Signed-off-by: Josh Soref * spelling: after Signed-off-by: Josh Soref * spelling: alphanumeric Signed-off-by: Josh Soref * spelling: anyway Signed-off-by: Josh Soref * spelling: async Signed-off-by: Josh Soref * spelling: available Signed-off-by: Josh Soref * spelling: backticks Signed-off-by: Josh Soref * spelling: behavior Signed-off-by: Josh Soref * spelling: bracket Signed-off-by: Josh Soref * spelling: cacheable Signed-off-by: Josh Soref * spelling: characters Signed-off-by: Josh Soref * spelling: completeable Signed-off-by: Josh Soref * spelling: data Signed-off-by: Josh Soref * spelling: definition Signed-off-by: Josh Soref * spelling: different Signed-off-by: Josh Soref * spelling: do not Signed-off-by: Josh Soref * spelling: duplicate Signed-off-by: Josh Soref * spelling: e.g. Signed-off-by: Josh Soref * spelling: entities Signed-off-by: Josh Soref * spelling: expression-in Signed-off-by: Josh Soref * spelling: extract Signed-off-by: Josh Soref * spelling: feedback Signed-off-by: Josh Soref * spelling: filesystem Signed-off-by: Josh Soref * spelling: function Signed-off-by: Josh Soref * spelling: github Signed-off-by: Josh Soref * spelling: height Signed-off-by: Josh Soref * spelling: highlighted Signed-off-by: Josh Soref * spelling: i'm Signed-off-by: Josh Soref * spelling: identifier Signed-off-by: Josh Soref * spelling: immediately Signed-off-by: Josh Soref * spelling: in case Signed-off-by: Josh Soref * spelling: indentation Signed-off-by: Josh Soref * spelling: independent Signed-off-by: Josh Soref * spelling: initial Signed-off-by: Josh Soref * spelling: interchangeable Signed-off-by: Josh Soref * spelling: interruptible Signed-off-by: Josh Soref * spelling: interviews Signed-off-by: Josh Soref * spelling: intrinsic Signed-off-by: Josh Soref * spelling: javascript Signed-off-by: Josh Soref * spelling: label Signed-off-by: Josh Soref * spelling: matching Signed-off-by: Josh Soref * spelling: misbehavior Signed-off-by: Josh Soref * spelling: number Signed-off-by: Josh Soref * spelling: numbered Signed-off-by: Josh Soref * spelling: occurrences Signed-off-by: Josh Soref * spelling: repeatedly Signed-off-by: Josh Soref * spelling: separator Signed-off-by: Josh Soref * spelling: string Signed-off-by: Josh Soref * spelling: styleable Signed-off-by: Josh Soref * spelling: textarea Signed-off-by: Josh Soref * spelling: texture Signed-off-by: Josh Soref * spelling: useful Signed-off-by: Josh Soref * spelling: whenever Signed-off-by: Josh Soref * spelling: wikipedia Signed-off-by: Josh Soref --- CHANGELOG.md | 14 +++++++------- addon/edit/continuelist.js | 2 +- addon/edit/matchbrackets.js | 2 +- addon/hint/javascript-hint.js | 2 +- addon/hint/sql-hint.js | 4 ++-- addon/search/match-highlighter.js | 2 +- demo/complete.html | 4 ++-- demo/matchhighlighter.html | 2 +- demo/simplemode.html | 2 +- doc/internals.html | 2 +- doc/manual.html | 8 ++++---- doc/realworld.html | 4 ++-- doc/releases.html | 14 +++++++------- doc/upgrade_v2.2.html | 2 +- index.html | 2 +- keymap/vim.js | 6 +++--- mode/asn.1/asn.1.js | 2 +- mode/clike/clike.js | 2 +- mode/clike/index.html | 2 +- mode/dtd/dtd.js | 2 +- mode/factor/factor.js | 2 +- mode/factor/index.html | 2 +- mode/fcl/index.html | 10 +++++----- mode/forth/index.html | 2 +- mode/gas/gas.js | 4 ++-- mode/gfm/test.js | 2 +- mode/haml/haml.js | 2 +- mode/htmlembedded/index.html | 2 +- mode/idl/idl.js | 2 +- mode/javascript/test.js | 2 +- mode/markdown/index.html | 10 +++++----- mode/markdown/markdown.js | 2 +- mode/markdown/test.js | 4 ++-- mode/meta.js | 2 +- mode/modelica/modelica.js | 6 +++--- mode/mumps/mumps.js | 2 +- mode/nginx/index.html | 4 ++-- mode/ntriples/index.html | 2 +- mode/oz/oz.js | 2 +- mode/perl/perl.js | 4 ++-- mode/python/index.html | 2 +- mode/python/test.js | 2 +- mode/rpm/rpm.js | 4 ++-- mode/ruby/index.html | 2 +- mode/scheme/scheme.js | 2 +- mode/sieve/sieve.js | 2 +- mode/sql/sql.js | 4 ++-- mode/vbscript/vbscript.js | 4 ++-- mode/velocity/velocity.js | 2 +- mode/verilog/verilog.js | 4 ++-- mode/vue/index.html | 2 +- mode/yaml/yaml.js | 4 ++-- 52 files changed, 91 insertions(+), 91 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5a9baf4df1..3a3ee68cef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -234,7 +234,7 @@ Make Shift-Delete to cut work on Firefox. [handlebars mode](https://codemirror.net/mode/handlebars/): Fix triple-brace support. -[searchcursor addon](https://codemirror.net/doc/manual.html#addon_searchcursor): Support mathing `$` in reverse regexp search. +[searchcursor addon](https://codemirror.net/doc/manual.html#addon_searchcursor): Support matching `$` in reverse regexp search. [panel addon](https://codemirror.net/doc/manual.html#addon_panel): Don't get confused by changing panel sizes. @@ -490,7 +490,7 @@ Add `hintWords` (basic completion) helper to [clojure](https://codemirror.net/mo [panel addon](https://codemirror.net/doc/manual.html#addon_panel): Fix problem where replacing the last remaining panel dropped the newly added panel. -[hardwrap addon](https://codemirror.net/doc/manual.html#addon_hardwrap): Fix an infinite loop when the indention is greater than the target column. +[hardwrap addon](https://codemirror.net/doc/manual.html#addon_hardwrap): Fix an infinite loop when the indentation is greater than the target column. [jinja2](https://codemirror.net/mode/jinja2/) and [markdown](https://codemirror.net/mode/markdown/) modes: Add comment metadata. @@ -878,7 +878,7 @@ Add `role=presentation` to more DOM elements to improve screen reader support. [merge addon](https://codemirror.net/doc/manual.html#addon_merge): Make aligning of unchanged chunks more robust. -[comment addon](https://codemirror.net/doc/manual.html#addon_comment): Fix comment-toggling on a block of text that starts and ends in a (differnet) block comment. +[comment addon](https://codemirror.net/doc/manual.html#addon_comment): Fix comment-toggling on a block of text that starts and ends in a (different) block comment. [javascript mode](https://codemirror.net/mode/javascript/): Improve support for TypeScript syntax. @@ -996,7 +996,7 @@ New event: [`optionChange`](https://codemirror.net/doc/manual.html#event_optionC Tapping/clicking the editor in [contentEditable mode](https://codemirror.net/doc/manual.html#option_inputStyle) on Chrome now puts the cursor at the tapped position. -Fix various crashes and misbehaviors when reading composition events in [contentEditable mode](https://codemirror.net/doc/manual.html#option_inputStyle). +Fix various crashes and misbehavior when reading composition events in [contentEditable mode](https://codemirror.net/doc/manual.html#option_inputStyle). Catches and ignores an IE 'Unspecified Error' when creating an editor in an iframe before there is a ``. @@ -1331,7 +1331,7 @@ Fix a [bug](https://github.com/codemirror/CodeMirror/issues/3834) that caused ph * New modes: [Vue](https://codemirror.net/mode/vue/index.html), [Oz](https://codemirror.net/mode/oz/index.html), [MscGen](https://codemirror.net/mode/mscgen/index.html) (and dialects), [Closure Stylesheets](https://codemirror.net/mode/css/gss.html) * Implement [CommonMark](http://commonmark.org)-style flexible list indent and cross-line code spans in [Markdown](https://codemirror.net/mode/markdown/index.html) mode * Add a replace-all button to the [search addon](https://codemirror.net/doc/manual.html#addon_search), and make the persistent search dialog transparent when it obscures the match -* Handle `acync`/`await` and ocal and binary numbers in [JavaScript mode](https://codemirror.net/mode/javascript/index.html) +* Handle `async`/`await` and ocal and binary numbers in [JavaScript mode](https://codemirror.net/mode/javascript/index.html) * Fix various issues with the [Haxe mode](https://codemirror.net/mode/haxe/index.html) * Make the [closebrackets addon](https://codemirror.net/doc/manual.html#addon_closebrackets) select only the wrapped text when wrapping selection in brackets * Tokenize properties as properties in the [CoffeeScript mode](https://codemirror.net/mode/coffeescript/index.html) @@ -1818,7 +1818,7 @@ Emergency fix for a bug where an editor with line wrapping on IE will break when * Slightly incompatible API changes. Read [this](https://codemirror.net/doc/upgrade_v2.2.html). * New approach to [binding](https://codemirror.net/doc/manual.html#option_extraKeys) keys, support for [custom bindings](https://codemirror.net/doc/manual.html#option_keyMap). * Support for overwrite (insert). -* [Custom-width](https://codemirror.net/doc/manual.html#option_tabSize) and [stylable](https://codemirror.net/demo/visibletabs.html) tabs. +* [Custom-width](https://codemirror.net/doc/manual.html#option_tabSize) and [styleable](https://codemirror.net/demo/visibletabs.html) tabs. * Moved more code into [add-on scripts](https://codemirror.net/doc/manual.html#addons). * Support for sane vertical cursor movement in wrapped lines. * More reliable handling of editing [marked text](https://codemirror.net/doc/manual.html#markText). @@ -1832,7 +1832,7 @@ Fixes `TextMarker.clear`, which is broken in 2.17. ## 2.17.0 (2011-11-21) * Add support for [line wrapping](https://codemirror.net/doc/manual.html#option_lineWrapping) and [code folding](https://codemirror.net/doc/manual.html#hideLine). -* Add [Github-style Markdown](https://codemirror.net/mode/gfm/index.html) mode. +* Add [GitHub-style Markdown](https://codemirror.net/mode/gfm/index.html) mode. * Add [Monokai](https://codemirror.net/theme/monokai.css) and [Rubyblue](https://codemirror.net/theme/rubyblue.css) themes. * Add [`setBookmark`](https://codemirror.net/doc/manual.html#setBookmark) method. * Move some of the demo code into reusable components under [`lib/util`](https://codemirror.net/addon/). diff --git a/addon/edit/continuelist.js b/addon/edit/continuelist.js index 2e5625adc4..6ec65010d2 100644 --- a/addon/edit/continuelist.js +++ b/addon/edit/continuelist.js @@ -90,7 +90,7 @@ }); } else { if (startIndent.length > nextIndent.length) return; - // This doesn't run if the next line immediatley indents, as it is + // This doesn't run if the next line immediately indents, as it is // not clear of the users intention (new indented item or same level) if ((startIndent.length < nextIndent.length) && (lookAhead === 1)) return; skipCount += 1; diff --git a/addon/edit/matchbrackets.js b/addon/edit/matchbrackets.js index 0377408802..692e09e0cc 100644 --- a/addon/edit/matchbrackets.js +++ b/addon/edit/matchbrackets.js @@ -94,7 +94,7 @@ if (marks.length) { // Kludge to work around the IE bug from issue #1193, where text - // input stops going to the textare whever this fires. + // input stops going to the textarea whenever this fires. if (ie_lt8 && cm.state.focused) cm.focus(); var clear = function() { diff --git a/addon/hint/javascript-hint.js b/addon/hint/javascript-hint.js index 6d09e6b44e..9f06b1b546 100644 --- a/addon/hint/javascript-hint.js +++ b/addon/hint/javascript-hint.js @@ -69,7 +69,7 @@ function getCoffeeScriptToken(editor, cur) { // This getToken, it is for coffeescript, imitates the behavior of // getTokenAt method in javascript.js, that is, returning "property" - // type and treat "." as indepenent token. + // type and treat "." as independent token. var token = editor.getTokenAt(cur); if (cur.ch == token.start + 1 && token.string.charAt(0) == '.') { token.end = token.start; diff --git a/addon/hint/sql-hint.js b/addon/hint/sql-hint.js index 5b65e29105..efdce813cf 100644 --- a/addon/hint/sql-hint.js +++ b/addon/hint/sql-hint.js @@ -97,7 +97,7 @@ if (name.charAt(0) == ".") { name = name.substr(1); } - // replace doublicated identifierQuotes with single identifierQuotes + // replace duplicated identifierQuotes with single identifierQuotes // and remove single identifierQuotes var nameParts = name.split(identifierQuote+identifierQuote); for (var i = 0; i < nameParts.length; i++) @@ -109,7 +109,7 @@ var nameParts = getText(name).split("."); for (var i = 0; i < nameParts.length; i++) nameParts[i] = identifierQuote + - // doublicate identifierQuotes + // duplicate identifierQuotes nameParts[i].replace(new RegExp(identifierQuote,"g"), identifierQuote+identifierQuote) + identifierQuote; var escaped = nameParts.join("."); diff --git a/addon/search/match-highlighter.js b/addon/search/match-highlighter.js index 3a4a7dedc1..9b181ebc01 100644 --- a/addon/search/match-highlighter.js +++ b/addon/search/match-highlighter.js @@ -16,7 +16,7 @@ // highlighted only if the selected text is a word. showToken, when enabled, // will cause the current token to be highlighted when nothing is selected. // delay is used to specify how much time to wait, in milliseconds, before -// highlighting the matches. If annotateScrollbar is enabled, the occurences +// highlighting the matches. If annotateScrollbar is enabled, the occurrences // will be highlighted on the scrollbar via the matchesonscrollbar addon. (function(mod) { diff --git a/demo/complete.html b/demo/complete.html index 2fef796401..3e7bd5ff56 100644 --- a/demo/complete.html +++ b/demo/complete.html @@ -71,7 +71,7 @@

      Autocomplete Demo

      addons.

      @@ -88,7 +88,7 @@

      Autocomplete Demo

      ["here", "hither"], ["asynchronous", "nonsynchronous"], ["completion", "achievement", "conclusion", "culmination", "expirations"], - ["hinting", "advive", "broach", "imply"], + ["hinting", "advise", "broach", "imply"], ["function","action"], ["provide", "add", "bring", "give"], ["synonyms", "equivalents"], diff --git a/demo/matchhighlighter.html b/demo/matchhighlighter.html index 6aa937782d..8e0ff25b89 100644 --- a/demo/matchhighlighter.html +++ b/demo/matchhighlighter.html @@ -98,6 +98,6 @@

      Match Highlighter Demo

      }); -

      Search and highlight occurences of the selected text.

      +

      Search and highlight occurrences of the selected text.

      diff --git a/demo/simplemode.html b/demo/simplemode.html index d7b0cface4..b03335fb87 100644 --- a/demo/simplemode.html +++ b/demo/simplemode.html @@ -129,7 +129,7 @@

      Simple Mode Demo

      */ CodeMirror.defineSimpleMode("simplemode", { - // The start state contains the rules that are intially used + // The start state contains the rules that are initially used start: [ // The regex matches the token, the token property contains the type {regex: /"(?:[^\\]|\\.)*?(?:"|$)/, token: "string"}, diff --git a/doc/internals.html b/doc/internals.html index 2137c937f2..893604e936 100644 --- a/doc/internals.html +++ b/doc/internals.html @@ -293,7 +293,7 @@

      Intelligent Updating

      Parsers can be Simple

      When I wrote CodeMirror 1, I -thought interruptable +thought interruptible parsers were a hugely scary and complicated thing, and I used a bunch of heavyweight abstractions to keep this supposed complexity under control: parsers diff --git a/doc/manual.html b/doc/manual.html index 285d420d9a..7aade3df15 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -2405,7 +2405,7 @@

      Addons

      Accepts linenumber, +/-linenumber, line:char, scroll% and :linenumber formats. This will make use of openDialog - when available to make prompting for line number neater.
    Demo avaliable here. + when available to make prompting for line number neater. Demo available here.
    search/matchesonscrollbar.js
    Adds a showMatchesOnScrollbar method to editor @@ -2721,7 +2721,7 @@

    Addons

    the "hint" type to find applicable hinting functions, and tries them one by one. If that fails, it looks for a "hintWords" helper to fetch a list of - completable words for the mode, and + completeable words for the mode, and uses CodeMirror.hint.fromList to complete from those.
    When completions aren't simple strings, they should be @@ -3683,13 +3683,13 @@

    Extending VIM

    getRegisterController()
    Returns the RegisterController that manages the state of registers used by vim mode. For the RegisterController api see its - defintion here. + definition here.
    buildKeyMap()
    Not currently implemented. If you would like to contribute this please open - a pull request on Github. + a pull request on GitHub.
    defineRegister()
    diff --git a/doc/realworld.html b/doc/realworld.html index a7402551f7..e5f8aef6f9 100644 --- a/doc/realworld.html +++ b/doc/realworld.html @@ -81,7 +81,7 @@

    CodeMirror real-world uses

  • Eloquent JavaScript (book)
  • Emmet (fast XML editing)
  • Espruino Web IDE (Chrome App for writing code on Espruino devices)
  • -
  • EXLskills Live Interivews
  • +
  • EXLskills Live Interviews
  • Fastfig (online computation/math tool)
  • Farabi (modern Perl IDE)
  • FathomJS integration (slides with editors, again)
  • @@ -92,7 +92,7 @@

    CodeMirror real-world uses

  • Gerrit's diff view and inline editor
  • Git Crx (Chrome App for browsing local git repos)
  • GitHub's Android app
  • -
  • Github's in-browser edit feature
  • +
  • GitHub's in-browser edit feature
  • Glitch (community-driven app building)
  • Go language tour
  • Google Apps Script
  • diff --git a/doc/releases.html b/doc/releases.html index f6628b6548..feeb8088d5 100644 --- a/doc/releases.html +++ b/doc/releases.html @@ -193,7 +193,7 @@

    Version 5.x

  • Make Shift-Delete to cut work on Firefox.
  • closetag addon: Properly handle self-closing tags.
  • handlebars mode: Fix triple-brace support.
  • -
  • searchcursor addon: Support mathing $ in reverse regexp search.
  • +
  • searchcursor addon: Support matching $ in reverse regexp search.
  • panel addon: Don’t get confused by changing panel sizes.
  • javascript-hint addon: Complete variables defined in outer scopes.
  • sublime bindings: Make by-subword motion more consistent with Sublime Text.
  • @@ -354,7 +354,7 @@

    Version 5.x

  • New method phrase and option phrases to make translating UI text in addons easier.
  • closebrackets addon: Fix issue where bracket-closing wouldn't work before punctuation.
  • panel addon: Fix problem where replacing the last remaining panel dropped the newly added panel.
  • -
  • hardwrap addon: Fix an infinite loop when the indention is greater than the target column.
  • +
  • hardwrap addon: Fix an infinite loop when the indentation is greater than the target column.
  • jinja2 and markdown modes: Add comment metadata.
  • @@ -588,7 +588,7 @@

    Version 5.x

  • Fix handling of shadow DOM roots when finding the active element.
  • Add role=presentation to more DOM elements to improve screen reader support.
  • merge addon: Make aligning of unchanged chunks more robust.
  • -
  • comment addon: Fix comment-toggling on a block of text that starts and ends in a (differnet) block comment.
  • +
  • comment addon: Fix comment-toggling on a block of text that starts and ends in a (different) block comment.
  • javascript mode: Improve support for TypeScript syntax.
  • r mode: Fix indentation after semicolon-less statements.
  • shell mode: Properly handle escaped parentheses in parenthesized expressions.
  • @@ -653,7 +653,7 @@

    Version 5.x

    • Tapping/clicking the editor in contentEditable mode on Chrome now puts the cursor at the tapped position.
    • -
    • Fix various crashes and misbehaviors when reading composition events in contentEditable mode.
    • +
    • Fix various crashes and misbehavior when reading composition events in contentEditable mode.
    • Catches and ignores an IE 'Unspecified Error' when creating an editor in an iframe before there is a <body>.
    • merge addon: Fix several issues in the chunk-aligning feature.
    • verilog mode: Rewritten to address various issues.
    • @@ -876,7 +876,7 @@

      Version 5.x

    • New modes: Vue, Oz, MscGen (and dialects), Closure Stylesheets
    • Implement CommonMark-style flexible list indent and cross-line code spans in Markdown mode
    • Add a replace-all button to the search addon, and make the persistent search dialog transparent when it obscures the match
    • -
    • Handle acync/await and ocal and binary numbers in JavaScript mode
    • +
    • Handle async/await and ocal and binary numbers in JavaScript mode
    • Fix various issues with the Haxe mode
    • Make the closebrackets addon select only the wrapped text when wrapping selection in brackets
    • Tokenize properties as properties in the CoffeeScript mode
    • @@ -1683,7 +1683,7 @@

      Version 2.x

      bindings.
    • Support for overwrite (insert).
    • Custom-width - and stylable tabs.
    • + and styleable tabs.
    • Moved more code into add-on scripts.
    • Support for sane vertical cursor movement in wrapped lines.
    • More reliable handling of @@ -1704,7 +1704,7 @@

      Version 2.x

    • Add support for line wrapping and code folding.
    • -
    • Add Github-style Markdown mode.
    • +
    • Add GitHub-style Markdown mode.
    • Add Monokai and Rubyblue themes.
    • Add setBookmark method.
    • diff --git a/doc/upgrade_v2.2.html b/doc/upgrade_v2.2.html index 5709e652bf..dabe974cfa 100644 --- a/doc/upgrade_v2.2.html +++ b/doc/upgrade_v2.2.html @@ -79,7 +79,7 @@

      Different key customization

      and indent it less when shift is held ("indentLess"). There are also "indentAuto" (smart indent) and "insertTab" commands provided for alternate -behaviors. Or you can write your own handler function to do something +behavior. Or you can write your own handler function to do something different altogether.

      Tabs

      diff --git a/index.html b/index.html index a89b1de5d3..3934c309d9 100644 --- a/index.html +++ b/index.html @@ -100,7 +100,7 @@

      This is CodeMirror

      Get the current version: 5.59.1.
      - You can see the code,
      + You can see the code,
      read the release notes,
      or study the user manual.
      diff --git a/keymap/vim.js b/keymap/vim.js index 789e1e55b3..dba9d7c1e0 100644 --- a/keymap/vim.js +++ b/keymap/vim.js @@ -737,7 +737,7 @@ // TODO: Convert keymap into dictionary format for fast lookup. }, // Testing hook, though it might be useful to expose the register - // controller anyways. + // controller anyway. getRegisterController: function() { return vimGlobalState.registerController; }, @@ -4322,7 +4322,7 @@ raw += ' ' + desc + ''; return raw; } - var searchPromptDesc = '(Javascript regexp)'; + var searchPromptDesc = '(JavaScript regexp)'; function showPrompt(cm, options) { var shortText = (options.prefix || '') + ' ' + (options.desc || ''); var prompt = makePrompt(options.prefix, options.desc); @@ -5234,7 +5234,7 @@ * @param {Cursor} lineEnd Line to stop replacing at. * @param {RegExp} query Query for performing matches with. * @param {string} replaceWith Text to replace matches with. May contain $1, - * $2, etc for replacing captured groups using Javascript replace. + * $2, etc for replacing captured groups using JavaScript replace. * @param {function()} callback A callback for when the replace is done. */ function doReplace(cm, confirm, global, lineStart, lineEnd, searchCursor, query, diff --git a/mode/asn.1/asn.1.js b/mode/asn.1/asn.1.js index d3ecb08781..df1330b686 100644 --- a/mode/asn.1/asn.1.js +++ b/mode/asn.1/asn.1.js @@ -190,7 +190,7 @@ " NetworkAddress BITS BMPString TimeStamp TimeTicks" + " TruthValue RowStatus DisplayString GeneralString" + " GraphicString IA5String NumericString" + - " PrintableString SnmpAdminAtring TeletexString" + + " PrintableString SnmpAdminString TeletexString" + " UTF8String VideotexString VisibleString StringStore" + " ISO646String T61String UniversalString Unsigned32" + " Integer32 Gauge Gauge32 Counter Counter32 Counter64"), diff --git a/mode/clike/clike.js b/mode/clike/clike.js index 2154f1d2df..5d01e1cd4c 100644 --- a/mode/clike/clike.js +++ b/mode/clike/clike.js @@ -749,7 +749,7 @@ CodeMirror.defineMode("clike", function(config, parserConfig) { "gl_ModelViewMatrix gl_ProjectionMatrix gl_ModelViewProjectionMatrix " + "gl_TextureMatrix gl_NormalMatrix gl_ModelViewMatrixInverse " + "gl_ProjectionMatrixInverse gl_ModelViewProjectionMatrixInverse " + - "gl_TexureMatrixTranspose gl_ModelViewMatrixInverseTranspose " + + "gl_TextureMatrixTranspose gl_ModelViewMatrixInverseTranspose " + "gl_ProjectionMatrixInverseTranspose " + "gl_ModelViewProjectionMatrixInverseTranspose " + "gl_TextureMatrixInverseTranspose " + diff --git a/mode/clike/index.html b/mode/clike/index.html index 0cfae2149e..b1c881904f 100644 --- a/mode/clike/index.html +++ b/mode/clike/index.html @@ -148,7 +148,7 @@

      Objective-C example

      */ #import "MyClass.h" -#import +#import @import BFrameworkModule; NS_ENUM(SomeValues) { diff --git a/mode/dtd/dtd.js b/mode/dtd/dtd.js index 74b8c6bded..40370a393d 100644 --- a/mode/dtd/dtd.js +++ b/mode/dtd/dtd.js @@ -34,7 +34,7 @@ CodeMirror.defineMode("dtd", function(config) { state.tokenize = inBlock("meta", "?>"); return ret("meta", ch); } else if (ch == "#" && stream.eatWhile(/[\w]/)) return ret("atom", "tag"); - else if (ch == "|") return ret("keyword", "seperator"); + else if (ch == "|") return ret("keyword", "separator"); else if (ch.match(/[\(\)\[\]\-\.,\+\?>]/)) return ret(null, ch);//if(ch === ">") return ret(null, "endtag"); else else if (ch.match(/[\[\]]/)) return ret("rule", ch); else if (ch == "\"" || ch == "'") { diff --git a/mode/factor/factor.js b/mode/factor/factor.js index 7108278cca..4c876d4d29 100644 --- a/mode/factor/factor.js +++ b/mode/factor/factor.js @@ -16,7 +16,7 @@ "use strict"; CodeMirror.defineSimpleMode("factor", { - // The start state contains the rules that are intially used + // The start state contains the rules that are initially used start: [ // comments {regex: /#?!.*/, token: "comment"}, diff --git a/mode/factor/index.html b/mode/factor/index.html index 574d402dda..6a77230d40 100644 --- a/mode/factor/index.html +++ b/mode/factor/index.html @@ -70,7 +70,7 @@

      Factor mode

      });

      -

      Simple mode that handles Factor Syntax (Factor on WikiPedia).

      +

      Simple mode that handles Factor Syntax (Factor on Wikipedia).

      MIME types defined: text/x-factor.

      diff --git a/mode/fcl/index.html b/mode/fcl/index.html index e51fa166b9..9194dfddaf 100644 --- a/mode/fcl/index.html +++ b/mode/fcl/index.html @@ -61,7 +61,7 @@

      FCL mode

      END_FUZZIFY DEFUZZIFY ProbabilityAccess - TERM hight := 1; + TERM height := 1; TERM medium := 0.5; TERM low := 0; ACCU: MAX; @@ -70,7 +70,7 @@

      FCL mode

      END_DEFUZZIFY DEFUZZIFY ProbabilityDistribution - TERM hight := 1; + TERM height := 1; TERM medium := 0.5; TERM low := 0; ACCU: MAX; @@ -80,14 +80,14 @@

      FCL mode

      RULEBLOCK No1 AND : MIN; - RULE 1 : IF TimeDay IS outside AND ApplicateHost IS few THEN ProbabilityAccess IS hight; - RULE 2 : IF ApplicateHost IS many THEN ProbabilityAccess IS hight; + RULE 1 : IF TimeDay IS outside AND ApplicateHost IS few THEN ProbabilityAccess IS height; + RULE 2 : IF ApplicateHost IS many THEN ProbabilityAccess IS height; RULE 3 : IF TimeDay IS inside AND ApplicateHost IS few THEN ProbabilityAccess IS low; END_RULEBLOCK RULEBLOCK No2 AND : MIN; - RULE 1 : IF ApplicateHost IS many THEN ProbabilityDistribution IS hight; + RULE 1 : IF ApplicateHost IS many THEN ProbabilityDistribution IS height; END_RULEBLOCK END_FUNCTION_BLOCK diff --git a/mode/forth/index.html b/mode/forth/index.html index c6f0b5c5c8..6b6477cae7 100644 --- a/mode/forth/index.html +++ b/mode/forth/index.html @@ -68,7 +68,7 @@

      Forth mode

      }); -

      Simple mode that handle Forth-Syntax (Forth on WikiPedia).

      +

      Simple mode that handle Forth-Syntax (Forth on Wikipedia).

      MIME types defined: text/x-forth.

      diff --git a/mode/gas/gas.js b/mode/gas/gas.js index e34d7a7b61..b3515abe77 100644 --- a/mode/gas/gas.js +++ b/mode/gas/gas.js @@ -302,11 +302,11 @@ CodeMirror.defineMode("gas", function(_config, parserConfig) { } if (ch === '{') { - return "braket"; + return "bracket"; } if (ch === '}') { - return "braket"; + return "bracket"; } if (/\d/.test(ch)) { diff --git a/mode/gfm/test.js b/mode/gfm/test.js index d933896aa5..e2002879cb 100644 --- a/mode/gfm/test.js +++ b/mode/gfm/test.js @@ -92,7 +92,7 @@ "[em *foo ][em&link bar/hello@be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2][em *]"); MT("wordSHA", - "ask for feedbac") + "ask for feedback") MT("num", "foo [link #1] bar"); diff --git a/mode/haml/haml.js b/mode/haml/haml.js index 3c8f505eb5..d941d97433 100644 --- a/mode/haml/haml.js +++ b/mode/haml/haml.js @@ -72,7 +72,7 @@ } } - // donot handle --> as valid ruby, make it HTML close comment instead + // do not handle --> as valid ruby, make it HTML close comment instead if (state.startOfLine && !stream.match("-->", false) && (ch == "=" || ch == "-" )) { state.tokenize = ruby; return state.tokenize(stream, state); diff --git a/mode/htmlembedded/index.html b/mode/htmlembedded/index.html index b1cafde973..d17afec8b1 100644 --- a/mode/htmlembedded/index.html +++ b/mode/htmlembedded/index.html @@ -55,6 +55,6 @@

      Html Embedded Scripts mode

      JavaScript, CSS and XML.
      Other dependencies include those of the scripting language chosen.

      MIME types defined: application/x-aspx (ASP.NET), - application/x-ejs (Embedded Javascript), application/x-jsp (JavaServer Pages) + application/x-ejs (Embedded JavaScript), application/x-jsp (JavaServer Pages) and application/x-erb

      diff --git a/mode/idl/idl.js b/mode/idl/idl.js index 168761cd88..37302bb90f 100644 --- a/mode/idl/idl.js +++ b/mode/idl/idl.js @@ -62,7 +62,7 @@ 'empty', 'enable_sysrtn', 'eof', 'eos', 'erase', 'erf', 'erfc', 'erfcx', 'erode', 'errorplot', 'errplot', 'estimator_filter', 'execute', 'exit', 'exp', - 'expand', 'expand_path', 'expint', 'extrac', 'extract_slice', + 'expand', 'expand_path', 'expint', 'extract', 'extract_slice', 'f_cvf', 'f_pdf', 'factorial', 'fft', 'file_basename', 'file_chmod', 'file_copy', 'file_delete', 'file_dirname', 'file_expand_path', 'file_gunzip', 'file_gzip', 'file_info', diff --git a/mode/javascript/test.js b/mode/javascript/test.js index ffff05f513..26a81ffc8d 100644 --- a/mode/javascript/test.js +++ b/mode/javascript/test.js @@ -252,7 +252,7 @@ MT("async_object", "[keyword let] [def obj] [operator =] { [property async]: [atom false] };"); - // async be highlighet as keyword and foo as def, but it requires potentially expensive look-ahead. See #4173 + // async be highlighted as keyword and foo as def, but it requires potentially expensive look-ahead. See #4173 MT("async_object_function", "[keyword let] [def obj] [operator =] { [property async] [property foo]([def args]) { [keyword return] [atom true]; } };"); diff --git a/mode/markdown/index.html b/mode/markdown/index.html index da3fe61b98..4984c04b2c 100644 --- a/mode/markdown/index.html +++ b/mode/markdown/index.html @@ -159,7 +159,7 @@

      Markdown mode

      Unordered (bulleted) lists use asterisks, pluses, and hyphens (`*`, `+`, and `-`) as list markers. These three markers are -interchangable; this: +interchangeable; this: * Candy. * Gum. @@ -306,7 +306,7 @@

      Markdown mode

      I strongly recommend against using any `<blink>` tags. I wish SmartyPants used named entities like `&mdash;` - instead of decimal-encoded entites like `&#8212;`. + instead of decimal-encoded entities like `&#8212;`. Output: @@ -315,7 +315,7 @@

      Markdown mode

      <p>I wish SmartyPants used named entities like <code>&amp;mdash;</code> instead of decimal-encoded - entites like <code>&amp;#8212;</code>.</p> + entities like <code>&amp;#8212;</code>.</p> To specify an entire block of pre-formatted code, indent every line of @@ -360,7 +360,7 @@

      Markdown mode

      }); -

      If you also want support strikethrough, emoji and few other goodies, check out Github-Flavored Markdown mode.

      +

      If you also want support strikethrough, emoji and few other goodies, check out GitHub-Flavored Markdown mode.

      Optionally depends on other modes for properly highlighted code blocks, and XML mode for properly highlighted inline XML blocks.

      @@ -370,7 +370,7 @@

      Markdown mode

    • highlightFormatting: boolean
      -
      Whether to separately highlight markdown meta characterts (*[]()etc.) (default: false).
      +
      Whether to separately highlight markdown meta characters (*[]()etc.) (default: false).
    • diff --git a/mode/markdown/markdown.js b/mode/markdown/markdown.js index 287f39b55d..aee76c43ac 100644 --- a/mode/markdown/markdown.js +++ b/mode/markdown/markdown.js @@ -223,7 +223,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) { // Add this list item's content's indentation to the stack state.listStack.push(state.indentation); - // Reset inline styles which shouldn't propagate aross list items + // Reset inline styles which shouldn't propagate across list items state.em = false; state.strong = false; state.code = false; diff --git a/mode/markdown/test.js b/mode/markdown/test.js index 929e7bba19..fd5a1fb4d5 100644 --- a/mode/markdown/test.js +++ b/mode/markdown/test.js @@ -315,7 +315,7 @@ "[header&header-2 bar]", "[header&header-2 ---]"); - MT("setextAferATX", + MT("setextAfterATX", "[header&header-1 # foo]", "[header&header-2 bar]", "[header&header-2 ---]"); @@ -659,7 +659,7 @@ " [variable-2 text after fenced code]"); // should correctly parse numbered list content indentation - MT("listCommonMark_NumeberedListIndent", + MT("listCommonMark_NumberedListIndent", "[variable-2 1000. list with base indent of 6]", "", " [variable-2 text must be indented 6 spaces at minimum]", diff --git a/mode/meta.js b/mode/meta.js index c7738a514c..92b68074ca 100644 --- a/mode/meta.js +++ b/mode/meta.js @@ -44,7 +44,7 @@ {name: "edn", mime: "application/edn", mode: "clojure", ext: ["edn"]}, {name: "Eiffel", mime: "text/x-eiffel", mode: "eiffel", ext: ["e"]}, {name: "Elm", mime: "text/x-elm", mode: "elm", ext: ["elm"]}, - {name: "Embedded Javascript", mime: "application/x-ejs", mode: "htmlembedded", ext: ["ejs"]}, + {name: "Embedded JavaScript", mime: "application/x-ejs", mode: "htmlembedded", ext: ["ejs"]}, {name: "Embedded Ruby", mime: "application/x-erb", mode: "htmlembedded", ext: ["erb"]}, {name: "Erlang", mime: "text/x-erlang", mode: "erlang", ext: ["erl"]}, {name: "Esper", mime: "text/x-esper", mode: "sql"}, diff --git a/mode/modelica/modelica.js b/mode/modelica/modelica.js index a83a4135d0..2e9622f03f 100644 --- a/mode/modelica/modelica.js +++ b/mode/modelica/modelica.js @@ -90,7 +90,7 @@ return "error"; } - function tokenUnsignedNuber(stream, state) { + function tokenUnsignedNumber(stream, state) { stream.eatWhile(isDigit); if (stream.eat('.')) { stream.eatWhile(isDigit); @@ -164,9 +164,9 @@ else if(ch == '"') { state.tokenize = tokenString; } - // UNSIGNED_NUBER + // UNSIGNED_NUMBER else if(isDigit.test(ch)) { - state.tokenize = tokenUnsignedNuber; + state.tokenize = tokenUnsignedNumber; } // ERROR else { diff --git a/mode/mumps/mumps.js b/mode/mumps/mumps.js index 3671c9cb36..c53b4bf3a2 100644 --- a/mode/mumps/mumps.js +++ b/mode/mumps/mumps.js @@ -26,7 +26,7 @@ var brackets = new RegExp("[()]"); var identifiers = new RegExp("^[%A-Za-z][A-Za-z0-9]*"); var commandKeywords = ["break","close","do","else","for","goto", "halt", "hang", "if", "job","kill","lock","merge","new","open", "quit", "read", "set", "tcommit", "trollback", "tstart", "use", "view", "write", "xecute", "b","c","d","e","f","g", "h", "i", "j","k","l","m","n","o", "q", "r", "s", "tc", "tro", "ts", "u", "v", "w", "x"]; - // The following list includes instrinsic functions _and_ special variables + // The following list includes intrinsic functions _and_ special variables var intrinsicFuncsWords = ["\\$ascii", "\\$char", "\\$data", "\\$ecode", "\\$estack", "\\$etrap", "\\$extract", "\\$find", "\\$fnumber", "\\$get", "\\$horolog", "\\$io", "\\$increment", "\\$job", "\\$justify", "\\$length", "\\$name", "\\$next", "\\$order", "\\$piece", "\\$qlength", "\\$qsubscript", "\\$query", "\\$quit", "\\$random", "\\$reverse", "\\$select", "\\$stack", "\\$test", "\\$text", "\\$translate", "\\$view", "\\$x", "\\$y", "\\$a", "\\$c", "\\$d", "\\$e", "\\$ec", "\\$es", "\\$et", "\\$f", "\\$fn", "\\$g", "\\$h", "\\$i", "\\$j", "\\$l", "\\$n", "\\$na", "\\$o", "\\$p", "\\$q", "\\$ql", "\\$qs", "\\$r", "\\$re", "\\$s", "\\$st", "\\$t", "\\$tr", "\\$v", "\\$z"]; var intrinsicFuncs = wordRegexp(intrinsicFuncsWords); var command = wordRegexp(commandKeywords); diff --git a/mode/nginx/index.html b/mode/nginx/index.html index 5c2bc6e2cf..1aa690a6d4 100644 --- a/mode/nginx/index.html +++ b/mode/nginx/index.html @@ -62,7 +62,7 @@

      NGINX mode

      location / { index index.html index.php; ## Allow a static html file to be shown first try_files $uri $uri/ @handler; ## If missing pass the URI to Magento's front handler - expires 30d; ## Assume all files are cachable + expires 30d; ## Assume all files are cacheable } ## These locations would be hidden by .htaccess normally @@ -128,7 +128,7 @@

      NGINX mode

      location / { index index.html index.php; ## Allow a static html file to be shown first try_files $uri $uri/ @handler; ## If missing pass the URI to Magento's front handler - expires 30d; ## Assume all files are cachable + expires 30d; ## Assume all files are cacheable } ## These locations would be hidden by .htaccess normally diff --git a/mode/ntriples/index.html b/mode/ntriples/index.html index 5473dbffc0..275cf08b49 100644 --- a/mode/ntriples/index.html +++ b/mode/ntriples/index.html @@ -58,7 +58,7 @@

      N-Triples mode

      "literal 1" . _:bnode3 . _:bnode4 "literal 2"@lang . - # if a graph labe + # if a graph label _:bnode5 "literal 3"^^ . diff --git a/mode/oz/oz.js b/mode/oz/oz.js index a9738495b6..63ad806abc 100644 --- a/mode/oz/oz.js +++ b/mode/oz/oz.js @@ -130,7 +130,7 @@ CodeMirror.defineMode("oz", function (conf) { return "operator"; } - // If nothing match, we skip the entire alphanumerical block + // If nothing match, we skip the entire alphanumeric block stream.eatWhile(/\w/); return "variable"; diff --git a/mode/perl/perl.js b/mode/perl/perl.js index 220b0a6994..ffe7877af1 100644 --- a/mode/perl/perl.js +++ b/mode/perl/perl.js @@ -347,7 +347,7 @@ CodeMirror.defineMode("perl",function(){ lc :1, // - return lower-case version of a string lcfirst :1, // - return a string with just the next letter in lower case length :1, // - return the number of bytes in a string - 'link' :1, // - create a hard link in the filesytem + 'link' :1, // - create a hard link in the filesystem listen :1, // - register your socket as a server local : 2, // - create a temporary value for a global variable (dynamic scoping) localtime :1, // - convert UNIX time into record or string using local time @@ -441,7 +441,7 @@ CodeMirror.defineMode("perl",function(){ state :1, // - declare and assign a state variable (persistent lexical scoping) study :1, // - optimize input data for repeated searches 'sub' :1, // - declare a subroutine, possibly anonymously - 'substr' :1, // - get or alter a portion of a stirng + 'substr' :1, // - get or alter a portion of a string symlink :1, // - create a symbolic link to a file syscall :1, // - execute an arbitrary system call sysopen :1, // - open a file, pipe, or descriptor diff --git a/mode/python/index.html b/mode/python/index.html index bdfc8f574c..78a3a14641 100644 --- a/mode/python/index.html +++ b/mode/python/index.html @@ -190,7 +190,7 @@

      Configuration Options for Python mode:

    • hangingIndent - int - If you want to write long arguments to a function starting on a new line, how much that line should be indented. Defaults to one normal indentation unit.

    Advanced Configuration Options:

    -

    Usefull for superset of python syntax like Enthought enaml, IPython magics and questionmark help

    +

    Useful for superset of python syntax like Enthought enaml, IPython magics and questionmark help

    • singleOperators - RegEx - Regular Expression for single operator matching, default :
      ^[\\+\\-\\*/%&|\\^~<>!]
      including
      @
      on Python 3
    • singleDelimiters - RegEx - Regular Expression for single delimiter matching, default :
      ^[\\(\\)\\[\\]\\{\\}@,:`=;\\.]
    • diff --git a/mode/python/test.js b/mode/python/test.js index 2b605b8e62..39b80cf70a 100644 --- a/mode/python/test.js +++ b/mode/python/test.js @@ -31,7 +31,7 @@ } MT("fValidStringPrefix", "[string f'this is a]{[variable formatted]}[string string']"); - MT("fValidExpressioninFString", "[string f'expression ]{[number 100][operator *][number 5]}[string string']"); + MT("fValidExpressionInFString", "[string f'expression ]{[number 100][operator *][number 5]}[string string']"); MT("fInvalidFString", "[error f'this is wrong}]"); MT("fNestedFString", "[string f'expression ]{[number 100] [operator +] [string f'inner]{[number 5]}[string ']}[string string']"); MT("uValidStringPrefix", "[string u'this is an unicode string']"); diff --git a/mode/rpm/rpm.js b/mode/rpm/rpm.js index 2dece2eabd..88a7e889ed 100644 --- a/mode/rpm/rpm.js +++ b/mode/rpm/rpm.js @@ -12,14 +12,14 @@ "use strict"; CodeMirror.defineMode("rpm-changes", function() { - var headerSeperator = /^-+$/; + var headerSeparator = /^-+$/; var headerLine = /^(Mon|Tue|Wed|Thu|Fri|Sat|Sun) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) ?\d{1,2} \d{2}:\d{2}(:\d{2})? [A-Z]{3,4} \d{4} - /; var simpleEmail = /^[\w+.-]+@[\w.-]+/; return { token: function(stream) { if (stream.sol()) { - if (stream.match(headerSeperator)) { return 'tag'; } + if (stream.match(headerSeparator)) { return 'tag'; } if (stream.match(headerLine)) { return 'tag'; } } if (stream.match(simpleEmail)) { return 'string'; } diff --git a/mode/ruby/index.html b/mode/ruby/index.html index 55fe6c5892..daebdca291 100644 --- a/mode/ruby/index.html +++ b/mode/ruby/index.html @@ -34,7 +34,7 @@

      Ruby mode

      # This program evaluates polynomials. It first asks for the coefficients # of a polynomial, which must be entered on one line, highest-order first. # It then requests values of x and will compute the value of the poly for -# each x. It will repeatly ask for x values, unless you the user enters +# each x. It will repeatedly ask for x values, unless you the user enters # a blank line. It that case, it will ask for another polynomial. If the # user types quit for either input, the program immediately exits. # diff --git a/mode/scheme/scheme.js b/mode/scheme/scheme.js index efac89078b..370250d856 100644 --- a/mode/scheme/scheme.js +++ b/mode/scheme/scheme.js @@ -170,7 +170,7 @@ CodeMirror.defineMode("scheme", function () { } else if (stream.match(/^[-+0-9.]/, false)) { hasRadix = false; numTest = isDecimalNumber; - // re-consume the intial # if all matches failed + // re-consume the initial # if all matches failed } else if (!hasExactness) { stream.eat('#'); } diff --git a/mode/sieve/sieve.js b/mode/sieve/sieve.js index f02a867e7a..b7236401a7 100644 --- a/mode/sieve/sieve.js +++ b/mode/sieve/sieve.js @@ -43,7 +43,7 @@ CodeMirror.defineMode("sieve", function(config) { if (ch == "(") { state._indent.push("("); // add virtual angel wings so that editor behaves... - // ...more sane incase of broken brackets + // ...more sane in case of broken brackets state._indent.push("{"); return null; } diff --git a/mode/sql/sql.js b/mode/sql/sql.js index 4127cd9a05..dcde1a771c 100644 --- a/mode/sql/sql.js +++ b/mode/sql/sql.js @@ -370,7 +370,7 @@ CodeMirror.defineMode("sql", function(config, parserConfig) { "$": hookVar, // The preferred way to escape Identifiers is using double quotes, ref: http://sqlite.org/lang_keywords.html "\"": hookIdentifierDoublequote, - // there is also support for backtics, ref: http://sqlite.org/lang_keywords.html + // there is also support for backticks, ref: http://sqlite.org/lang_keywords.html "`": hookIdentifier } }); @@ -451,7 +451,7 @@ CodeMirror.defineMode("sql", function(config, parserConfig) { // Spark SQL CodeMirror.defineMIME("text/x-sparksql", { name: "sql", - keywords: set("add after all alter analyze and anti archive array as asc at between bucket buckets by cache cascade case cast change clear cluster clustered codegen collection column columns comment commit compact compactions compute concatenate cost create cross cube current current_date current_timestamp database databases datata dbproperties defined delete delimited deny desc describe dfs directories distinct distribute drop else end escaped except exchange exists explain export extended external false fields fileformat first following for format formatted from full function functions global grant group grouping having if ignore import in index indexes inner inpath inputformat insert intersect interval into is items join keys last lateral lazy left like limit lines list load local location lock locks logical macro map minus msck natural no not null nulls of on optimize option options or order out outer outputformat over overwrite partition partitioned partitions percent preceding principals purge range recordreader recordwriter recover reduce refresh regexp rename repair replace reset restrict revoke right rlike role roles rollback rollup row rows schema schemas select semi separated serde serdeproperties set sets show skewed sort sorted start statistics stored stratify struct table tables tablesample tblproperties temp temporary terminated then to touch transaction transactions transform true truncate unarchive unbounded uncache union unlock unset use using values view when where window with"), + keywords: set("add after all alter analyze and anti archive array as asc at between bucket buckets by cache cascade case cast change clear cluster clustered codegen collection column columns comment commit compact compactions compute concatenate cost create cross cube current current_date current_timestamp database databases data dbproperties defined delete delimited deny desc describe dfs directories distinct distribute drop else end escaped except exchange exists explain export extended external false fields fileformat first following for format formatted from full function functions global grant group grouping having if ignore import in index indexes inner inpath inputformat insert intersect interval into is items join keys last lateral lazy left like limit lines list load local location lock locks logical macro map minus msck natural no not null nulls of on optimize option options or order out outer outputformat over overwrite partition partitioned partitions percent preceding principals purge range recordreader recordwriter recover reduce refresh regexp rename repair replace reset restrict revoke right rlike role roles rollback rollup row rows schema schemas select semi separated serde serdeproperties set sets show skewed sort sorted start statistics stored stratify struct table tables tablesample tblproperties temp temporary terminated then to touch transaction transactions transform true truncate unarchive unbounded uncache union unlock unset use using values view when where window with"), builtin: set("tinyint smallint int bigint boolean float double string binary timestamp decimal array map struct uniontype delimited serde sequencefile textfile rcfile inputformat outputformat"), atoms: set("false true null"), operatorChars: /^[*\/+\-%<>!=~&|^]/, diff --git a/mode/vbscript/vbscript.js b/mode/vbscript/vbscript.js index 0670c0ceef..4033948133 100644 --- a/mode/vbscript/vbscript.js +++ b/mode/vbscript/vbscript.js @@ -32,7 +32,7 @@ CodeMirror.defineMode("vbscript", function(conf, parserConf) { var singleOperators = new RegExp("^[\\+\\-\\*/&\\\\\\^<>=]"); var doubleOperators = new RegExp("^((<>)|(<=)|(>=))"); var singleDelimiters = new RegExp('^[\\.,]'); - var brakets = new RegExp('^[\\(\\)]'); + var brackets = new RegExp('^[\\(\\)]'); var identifiers = new RegExp("^[A-Za-z][_A-Za-z0-9]*"); var openingKeywords = ['class','sub','select','while','if','function', 'property', 'with', 'for']; @@ -183,7 +183,7 @@ CodeMirror.defineMode("vbscript", function(conf, parserConf) { return null; } - if (stream.match(brakets)) { + if (stream.match(brackets)) { return "bracket"; } diff --git a/mode/velocity/velocity.js b/mode/velocity/velocity.js index 56caa671b3..1d17c84ebe 100644 --- a/mode/velocity/velocity.js +++ b/mode/velocity/velocity.js @@ -48,7 +48,7 @@ CodeMirror.defineMode("velocity", function() { else if (state.inParams) return chain(stream, state, tokenString(ch)); } - // is it one of the special signs []{}().,;? Seperator? + // is it one of the special signs []{}().,;? Separator? else if (/[\[\]{}\(\),;\.]/.test(ch)) { if (ch == "(" && beforeParams) state.inParams = true; diff --git a/mode/verilog/verilog.js b/mode/verilog/verilog.js index 89fe9c1ac8..6c799f298b 100644 --- a/mode/verilog/verilog.js +++ b/mode/verilog/verilog.js @@ -542,7 +542,7 @@ CodeMirror.defineMode("verilog", function(config, parserConfig) { }; var tlvIndentUnit = 3; var tlvTrackStatements = false; - var tlvIdentMatch = /^([~!@#\$%\^&\*-\+=\?\/\\\|'"<>]+)([\d\w_]*)/; // Matches an identifiere. + var tlvIdentMatch = /^([~!@#\$%\^&\*-\+=\?\/\\\|'"<>]+)([\d\w_]*)/; // Matches an identifier. // Note that ':' is excluded, because of it's use in [:]. var tlvFirstLevelIndentMatch = /^[! ] /; var tlvLineIndentationMatch = /^[! ] */; @@ -719,7 +719,7 @@ CodeMirror.defineMode("verilog", function(config, parserConfig) { } else { // Just swallow one character and try again. // This enables subsequent identifier match with preceding symbol character, which - // is legal within a statement. (Eg, !$reset). It also enables detection of + // is legal within a statement. (E.g., !$reset). It also enables detection of // comment start with preceding symbols. stream.backUp(stream.current().length - 1); style = "tlv-default"; diff --git a/mode/vue/index.html b/mode/vue/index.html index df519a5cb7..78b4784840 100644 --- a/mode/vue/index.html +++ b/mode/vue/index.html @@ -38,7 +38,7 @@

      Vue.js mode

      - Get the current version: 5.65.8.
      + Get the current version: 5.65.9.
      You can see the code,
      read the release notes,
      or study the user manual. diff --git a/package.json b/package.json index e1388a4b0c..4647fb121f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "codemirror", - "version": "5.65.8", + "version": "5.65.9", "main": "lib/codemirror.js", "style": "lib/codemirror.css", "author": { diff --git a/src/edit/main.js b/src/edit/main.js index 5b222fe15e..85841e7279 100644 --- a/src/edit/main.js +++ b/src/edit/main.js @@ -66,4 +66,4 @@ import { addLegacyProps } from "./legacy.js" addLegacyProps(CodeMirror) -CodeMirror.version = "5.65.8" +CodeMirror.version = "5.65.9" From e1fe2100d0fdc7c34d47993f6514bdd2213c0015 Mon Sep 17 00:00:00 2001 From: Mark Boyes Date: Thu, 6 Oct 2022 12:52:06 +0100 Subject: [PATCH 2376/2444] [sparql mode] Identify all characters in prefixes --- mode/sparql/sparql.js | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/mode/sparql/sparql.js b/mode/sparql/sparql.js index 5e68f5670d..6d928b5cde 100644 --- a/mode/sparql/sparql.js +++ b/mode/sparql/sparql.js @@ -33,6 +33,9 @@ CodeMirror.defineMode("sparql", function(config) { "true", "false", "with", "data", "copy", "to", "move", "add", "create", "drop", "clear", "load", "into"]); var operatorChars = /[*+\-<>=&|\^\/!\?]/; + var PN_CHARS = "[A-Za-z_\\-0-9]"; + var PREFIX_START = new RegExp("[A-Za-z]"); + var PREFIX_REMAINDER = new RegExp("((" + PN_CHARS + "|\\.)*(" + PN_CHARS + "))?:"); function tokenBase(stream, state) { var ch = stream.next(); @@ -71,20 +74,18 @@ CodeMirror.defineMode("sparql", function(config) { stream.eatWhile(/[a-z\d\-]/i); return "meta"; } - else { - stream.eatWhile(/[_\w\d]/); - if (stream.eat(":")) { + else if (PREFIX_START.test(ch) && stream.match(PREFIX_REMAINDER)) { eatPnLocal(stream); return "atom"; - } - var word = stream.current(); - if (ops.test(word)) - return "builtin"; - else if (keywords.test(word)) - return "keyword"; - else - return "variable"; } + stream.eatWhile(/[_\w\d]/); + var word = stream.current(); + if (ops.test(word)) + return "builtin"; + else if (keywords.test(word)) + return "keyword"; + else + return "variable"; } function eatPnLocal(stream) { From 9296326b0a9e37489e00d4d7bfabd4725f6bfb7b Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Wed, 26 Oct 2022 14:23:29 +0200 Subject: [PATCH 2377/2444] [javascript mode] Fix recognition of class property keywords before private names Closes https://github.com/codemirror/codemirror5/issues/6996 --- mode/javascript/javascript.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mode/javascript/javascript.js b/mode/javascript/javascript.js index 48a46d65d0..bb735ebc96 100644 --- a/mode/javascript/javascript.js +++ b/mode/javascript/javascript.js @@ -779,7 +779,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { if (type == "async" || (type == "variable" && (value == "static" || value == "get" || value == "set" || (isTS && isModifier(value))) && - cx.stream.match(/^\s+[\w$\xa1-\uffff]/, false))) { + cx.stream.match(/^\s+#?[\w$\xa1-\uffff]/, false))) { cx.marked = "keyword"; return cont(classBody); } From 2e3df70d4cfa5db5a9218893f2366fba7e59b928 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Tue, 15 Nov 2022 01:32:23 +0100 Subject: [PATCH 2378/2444] [pegjs mode] Remove useless lines --- mode/pegjs/pegjs.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/mode/pegjs/pegjs.js b/mode/pegjs/pegjs.js index c0ed2fcc06..c0012c5cf2 100644 --- a/mode/pegjs/pegjs.js +++ b/mode/pegjs/pegjs.js @@ -31,8 +31,6 @@ CodeMirror.defineMode("pegjs", function (config) { }; }, token: function (stream, state) { - if (stream) - //check for state changes if (!state.inString && !state.inComment && ((stream.peek() == '"') || (stream.peek() == "'"))) { state.stringType = stream.peek(); @@ -43,7 +41,6 @@ CodeMirror.defineMode("pegjs", function (config) { state.inComment = true; } - //return state if (state.inString) { while (state.inString && !stream.eol()) { if (stream.peek() === state.stringType) { From 407d1f1c896dd507095559466fedb3335b8e182f Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Tue, 15 Nov 2022 01:33:47 +0100 Subject: [PATCH 2379/2444] [sql-hint addon] Make completion work when SQL isn't the outermost mode Closes https://github.com/codemirror/codemirror5/issues/5249 --- addon/hint/sql-hint.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/addon/hint/sql-hint.js b/addon/hint/sql-hint.js index 57c3b64f26..e01f502635 100644 --- a/addon/hint/sql-hint.js +++ b/addon/hint/sql-hint.js @@ -24,15 +24,13 @@ function isArray(val) { return Object.prototype.toString.call(val) == "[object Array]" } function getKeywords(editor) { - var mode = editor.doc.modeOption; - if (mode === "sql") mode = "text/x-sql"; - return CodeMirror.resolveMode(mode).keywords; + return editor.getModeAt(editor.getCursor()).keywords || CodeMirror.resolveMode("text/x-sql").keywords; } function getIdentifierQuote(editor) { - var mode = editor.doc.modeOption; - if (mode === "sql") mode = "text/x-sql"; - return CodeMirror.resolveMode(mode).identifierQuote || "`"; + return editor.getModeAt(editor.getCursor()).identifierQuote || + CodeMirror.resolveMode("text/x-sql").identifierQuote || + "`"; } function getText(item) { From 742627abcab8314dcabed2ce8ae6d347eaaf5512 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Tue, 15 Nov 2022 09:36:27 +0100 Subject: [PATCH 2380/2444] [sql-hint addon] Fix retrieving of parser config --- addon/hint/sql-hint.js | 10 ++++++---- mode/sql/sql.js | 3 ++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/addon/hint/sql-hint.js b/addon/hint/sql-hint.js index e01f502635..61faec0bc0 100644 --- a/addon/hint/sql-hint.js +++ b/addon/hint/sql-hint.js @@ -23,14 +23,16 @@ function isArray(val) { return Object.prototype.toString.call(val) == "[object Array]" } + function getModeConf(editor) { + return editor.getModeAt(editor.getCursor()).config || CodeMirror.resolveMode("text/x-sql") + } + function getKeywords(editor) { - return editor.getModeAt(editor.getCursor()).keywords || CodeMirror.resolveMode("text/x-sql").keywords; + return getModeConf(editor).keywords || [] } function getIdentifierQuote(editor) { - return editor.getModeAt(editor.getCursor()).identifierQuote || - CodeMirror.resolveMode("text/x-sql").identifierQuote || - "`"; + return getModeConf(editor).identifierQuote || "`"; } function getText(item) { diff --git a/mode/sql/sql.js b/mode/sql/sql.js index 105b22ffb9..fedf6cd77c 100644 --- a/mode/sql/sql.js +++ b/mode/sql/sql.js @@ -207,7 +207,8 @@ CodeMirror.defineMode("sql", function(config, parserConfig) { blockCommentStart: "/*", blockCommentEnd: "*/", lineComment: support.commentSlashSlash ? "//" : support.commentHash ? "#" : "--", - closeBrackets: "()[]{}''\"\"``" + closeBrackets: "()[]{}''\"\"``", + config: parserConfig }; }); From fe0bc6d5d5967ad4073805022b4e01e96a21bc1f Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Sun, 20 Nov 2022 16:35:33 +0100 Subject: [PATCH 2381/2444] Mark version 5.65.10 --- CHANGELOG.md | 8 ++++++++ doc/manual.html | 2 +- doc/releases.html | 7 +++++++ index.html | 2 +- package.json | 2 +- src/edit/main.js | 2 +- 6 files changed, 19 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b8e118d258..41d7f0815d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +## 5.65.10 (2022-11-20) + +### Bug fixes + +[sql-hint addon](https://codemirror.net/5/doc/manual.html#addon_sql-hint): Fix completion when the SQL mode is wrapped by some outer mode. + +[javascript mode](https://codemirror.net/5/mode/javascript/index.html): Fix parsing of property keywords before private property names. + ## 5.65.9 (2022-09-20) ### Bug fixes diff --git a/doc/manual.html b/doc/manual.html index 9be3471a1c..19b21d8c1c 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -70,7 +70,7 @@

      User manual and reference guide - version 5.65.9 + version 5.65.10

      CodeMirror is a code-editor component that can be embedded in diff --git a/doc/releases.html b/doc/releases.html index 9a8f368bc6..a20dfa0312 100644 --- a/doc/releases.html +++ b/doc/releases.html @@ -34,6 +34,13 @@

      Version 6.x

      Version 5.x

      +

      20-11-2022: Version 5.65.10:

      + +
        +
      • sql mode: Fix completion when the SQL mode is wrapped by some outer mode.
      • +
      • javascript mode: Fix parsing of property keywords before private property names.
      • +
      +

      20-09-2022: Version 5.65.9:

        diff --git a/index.html b/index.html index 33dd81f12d..75c53a2de0 100644 --- a/index.html +++ b/index.html @@ -92,7 +92,7 @@

        This is CodeMirror

        - Get the current version: 5.65.9.
        + Get the current version: 5.65.10.
        You can see the code,
        read the release notes,
        or study the user manual. diff --git a/package.json b/package.json index 4647fb121f..b6cde62684 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "codemirror", - "version": "5.65.9", + "version": "5.65.10", "main": "lib/codemirror.js", "style": "lib/codemirror.css", "author": { diff --git a/src/edit/main.js b/src/edit/main.js index 85841e7279..6d436dfbeb 100644 --- a/src/edit/main.js +++ b/src/edit/main.js @@ -66,4 +66,4 @@ import { addLegacyProps } from "./legacy.js" addLegacyProps(CodeMirror) -CodeMirror.version = "5.65.9" +CodeMirror.version = "5.65.10" From 349c8a6c7adbb1a0d31b205260807f4f5847b1a6 Mon Sep 17 00:00:00 2001 From: DoctorKrolic <70431552+DoctorKrolic@users.noreply.github.com> Date: Tue, 29 Nov 2022 18:58:47 +0300 Subject: [PATCH 2382/2444] [clike mode] Add new C# keywords --- mode/clike/clike.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mode/clike/clike.js b/mode/clike/clike.js index 748909efeb..8075edb8a1 100644 --- a/mode/clike/clike.js +++ b/mode/clike/clike.js @@ -512,8 +512,8 @@ CodeMirror.defineMode("clike", function(config, parserConfig) { name: "clike", keywords: words("abstract as async await base break case catch checked class const continue" + " default delegate do else enum event explicit extern finally fixed for" + - " foreach goto if implicit in interface internal is lock namespace new" + - " operator out override params private protected public readonly ref return sealed" + + " foreach goto if implicit in init interface internal is lock namespace new" + + " operator out override params private protected public readonly record ref required return sealed" + " sizeof stackalloc static struct switch this throw try typeof unchecked" + " unsafe using virtual void volatile while add alias ascending descending dynamic from get" + " global group into join let orderby partial remove select set value var yield"), @@ -522,7 +522,7 @@ CodeMirror.defineMode("clike", function(config, parserConfig) { " UInt64 bool byte char decimal double short int long object" + " sbyte float string ushort uint ulong"), blockKeywords: words("catch class do else finally for foreach if struct switch try while"), - defKeywords: words("class interface namespace struct var"), + defKeywords: words("class interface namespace record struct var"), typeFirstDefinitions: true, atoms: words("true false null"), hooks: { From 7814ddf4011a9ec479d378fe7f3623bea0b17faf Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Thu, 8 Dec 2022 08:21:15 +0100 Subject: [PATCH 2383/2444] [sql-hint addon] Reindent --- addon/hint/sql-hint.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/addon/hint/sql-hint.js b/addon/hint/sql-hint.js index 61faec0bc0..b4a919518e 100644 --- a/addon/hint/sql-hint.js +++ b/addon/hint/sql-hint.js @@ -109,9 +109,9 @@ var nameParts = getText(name).split("."); for (var i = 0; i < nameParts.length; i++) nameParts[i] = identifierQuote + - // duplicate identifierQuotes - nameParts[i].replace(new RegExp(identifierQuote,"g"), identifierQuote+identifierQuote) + - identifierQuote; + // duplicate identifierQuotes + nameParts[i].replace(new RegExp(identifierQuote,"g"), identifierQuote+identifierQuote) + + identifierQuote; var escaped = nameParts.join("."); if (typeof name == "string") return escaped; name = shallowClone(name); @@ -283,21 +283,21 @@ } return w; }; - addMatches(result, search, defaultTable, function(w) { + addMatches(result, search, defaultTable, function(w) { return objectOrClass(w, "CodeMirror-hint-table CodeMirror-hint-default-table"); - }); - addMatches( + }); + addMatches( result, search, tables, function(w) { return objectOrClass(w, "CodeMirror-hint-table"); } - ); - if (!disableKeywords) - addMatches(result, search, keywords, function(w) { + ); + if (!disableKeywords) + addMatches(result, search, keywords, function(w) { return objectOrClass(w.toUpperCase(), "CodeMirror-hint-keyword"); - }); - } + }); + } return {list: result, from: Pos(cur.line, start), to: Pos(cur.line, end)}; }); From fbe612a66ab2a8063b6309c24d5cc613d8b80a50 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Thu, 8 Dec 2022 08:27:56 +0100 Subject: [PATCH 2384/2444] [sql-hint addon] Fix getting keywords from plain sql mode --- addon/hint/sql-hint.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/addon/hint/sql-hint.js b/addon/hint/sql-hint.js index b4a919518e..5c9810537a 100644 --- a/addon/hint/sql-hint.js +++ b/addon/hint/sql-hint.js @@ -23,16 +23,16 @@ function isArray(val) { return Object.prototype.toString.call(val) == "[object Array]" } - function getModeConf(editor) { - return editor.getModeAt(editor.getCursor()).config || CodeMirror.resolveMode("text/x-sql") + function getModeConf(editor, field) { + return editor.getModeAt(editor.getCursor()).config[field] || CodeMirror.resolveMode("text/x-sql")[field] } function getKeywords(editor) { - return getModeConf(editor).keywords || [] + return getModeConf(editor, "keywords") || [] } function getIdentifierQuote(editor) { - return getModeConf(editor).identifierQuote || "`"; + return getModeConf(editor, "identifierQuote") || "`"; } function getText(item) { From d122e55c4818ef72e45939c4c06301bc36cb4a53 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Thu, 8 Dec 2022 08:35:20 +0100 Subject: [PATCH 2385/2444] [sql mode] Always enable tokenizing of dot-prefixed names --- mode/sql/sql.js | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/mode/sql/sql.js b/mode/sql/sql.js index fedf6cd77c..7b9dec7de1 100644 --- a/mode/sql/sql.js +++ b/mode/sql/sql.js @@ -94,9 +94,7 @@ CodeMirror.defineMode("sql", function(config, parserConfig) { return "number"; if (stream.match(/^\.+/)) return null - // .table_name (ODBC) - // // ref: https://dev.mysql.com/doc/refman/8.0/en/identifier-qualifiers.html - if (support.ODBCdotTable && stream.match(/^[\w\d_$#]+/)) + if (stream.match(/^[\w\d_$#]+/)) return "variable-2"; } else if (operatorChars.test(ch)) { // operators @@ -295,7 +293,7 @@ CodeMirror.defineMode("sql", function(config, parserConfig) { builtin: set(defaultBuiltin), atoms: set("false true null unknown"), dateSQL: set("date time timestamp"), - support: set("ODBCdotTable doubleQuote binaryNumber hexNumber") + support: set("doubleQuote binaryNumber hexNumber") }); CodeMirror.defineMIME("text/x-mssql", { @@ -322,7 +320,7 @@ CodeMirror.defineMode("sql", function(config, parserConfig) { atoms: set("false true null unknown"), operatorChars: /^[*+\-%<>!=&|^]/, dateSQL: set("date time timestamp"), - support: set("ODBCdotTable decimallessFloat zerolessFloat binaryNumber hexNumber doubleQuote nCharCast charsetCast commentHash commentSpaceRequired"), + support: set("decimallessFloat zerolessFloat binaryNumber hexNumber doubleQuote nCharCast charsetCast commentHash commentSpaceRequired"), hooks: { "@": hookVar, "`": hookIdentifier, @@ -338,7 +336,7 @@ CodeMirror.defineMode("sql", function(config, parserConfig) { atoms: set("false true null unknown"), operatorChars: /^[*+\-%<>!=&|^]/, dateSQL: set("date time timestamp"), - support: set("ODBCdotTable decimallessFloat zerolessFloat binaryNumber hexNumber doubleQuote nCharCast charsetCast commentHash commentSpaceRequired"), + support: set("decimallessFloat zerolessFloat binaryNumber hexNumber doubleQuote nCharCast charsetCast commentHash commentSpaceRequired"), hooks: { "@": hookVar, "`": hookIdentifier, @@ -409,7 +407,7 @@ CodeMirror.defineMode("sql", function(config, parserConfig) { atoms: set("false true null unknown"), operatorChars: /^[*+\-%<>!=]/, dateSQL: set("date timestamp"), - support: set("ODBCdotTable doubleQuote binaryNumber hexNumber") + support: set("doubleQuote binaryNumber hexNumber") }); CodeMirror.defineMIME("text/x-pgsql", { @@ -424,7 +422,7 @@ CodeMirror.defineMode("sql", function(config, parserConfig) { operatorChars: /^[*\/+\-%<>!=&|^\/#@?~]/, backslashStringEscapes: false, dateSQL: set("date time timestamp"), - support: set("ODBCdotTable decimallessFloat zerolessFloat binaryNumber hexNumber nCharCast charsetCast escapeConstant") + support: set("decimallessFloat zerolessFloat binaryNumber hexNumber nCharCast charsetCast escapeConstant") }); // Google's SQL-like query language, GQL @@ -446,7 +444,7 @@ CodeMirror.defineMode("sql", function(config, parserConfig) { atoms: set("false true null unknown"), operatorChars: /^[*+\-%<>!=&|^\/#@?~]/, dateSQL: set("date time timestamp"), - support: set("ODBCdotTable decimallessFloat zerolessFloat binaryNumber hexNumber nCharCast charsetCast") + support: set("decimallessFloat zerolessFloat binaryNumber hexNumber nCharCast charsetCast") }); // Spark SQL @@ -457,7 +455,7 @@ CodeMirror.defineMode("sql", function(config, parserConfig) { atoms: set("false true null"), operatorChars: /^[*\/+\-%<>!=~&|^]/, dateSQL: set("date time timestamp"), - support: set("ODBCdotTable doubleQuote zerolessFloat") + support: set("doubleQuote zerolessFloat") }); // Esper @@ -490,7 +488,7 @@ CodeMirror.defineMode("sql", function(config, parserConfig) { dateSQL: set("date time timestamp zone"), // hexNumber is necessary for VARBINARY literals, e.g. X'65683F' // but it also enables 0xFF hex numbers, which Trino doesn't support. - support: set("ODBCdotTable decimallessFloat zerolessFloat hexNumber") + support: set("decimallessFloat zerolessFloat hexNumber") }); }); @@ -508,7 +506,6 @@ CodeMirror.defineMode("sql", function(config, parserConfig) { Commands parsed and executed by the client (not the server). support: A list of supported syntaxes which are not common, but are supported by more than 1 DBMS. - * ODBCdotTable: .tableName * zerolessFloat: .1 * decimallessFloat: 1. * hexNumber: X'01AF' X'01af' x'01AF' x'01af' 0x01AF 0x01af From dd931d8f896de393b959f7519ff401071c09135b Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Fri, 9 Dec 2022 10:47:14 +0100 Subject: [PATCH 2386/2444] Respect spellcheck/autocorrect/autocapitalize options in textarea input style Issue https://github.com/codemirror/codemirror5/issues/7009 --- src/input/ContentEditableInput.js | 1 + src/input/TextareaInput.js | 4 +++- src/input/input.js | 1 - 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/input/ContentEditableInput.js b/src/input/ContentEditableInput.js index ef2e41f51e..f789af74ee 100644 --- a/src/input/ContentEditableInput.js +++ b/src/input/ContentEditableInput.js @@ -94,6 +94,7 @@ export default class ContentEditableInput { } // Old-fashioned briefly-focus-a-textarea hack let kludge = hiddenTextarea(), te = kludge.firstChild + disableBrowserMagic(te) cm.display.lineSpace.insertBefore(kludge, cm.display.lineSpace.firstChild) te.value = lastCopied.text.join("\n") let hadFocus = activeElt(div.ownerDocument) diff --git a/src/input/TextareaInput.js b/src/input/TextareaInput.js index 3db3f5f0f3..0aac125b11 100644 --- a/src/input/TextareaInput.js +++ b/src/input/TextareaInput.js @@ -1,6 +1,6 @@ import { operation, runInOp } from "../display/operations.js" import { prepareSelection } from "../display/selection.js" -import { applyTextInput, copyableRanges, handlePaste, hiddenTextarea, setLastCopied } from "./input.js" +import { applyTextInput, copyableRanges, handlePaste, hiddenTextarea, disableBrowserMagic, setLastCopied } from "./input.js" import { cursorCoords, posFromMouse } from "../measurement/position_measurement.js" import { eventInWidget } from "../measurement/widgets.js" import { simpleSelection } from "../model/selection.js" @@ -117,6 +117,8 @@ export default class TextareaInput { // The semihidden textarea that is focused when the editor is // focused, and receives input. this.textarea = this.wrapper.firstChild + let opts = this.cm.options + disableBrowserMagic(this.textarea, opts.spellcheck, opts.autocorrect, opts.autocapitalize) } screenReaderLabelChanged(label) { diff --git a/src/input/input.js b/src/input/input.js index e740106298..8b15639cfd 100644 --- a/src/input/input.js +++ b/src/input/input.js @@ -130,6 +130,5 @@ export function hiddenTextarea() { else te.setAttribute("wrap", "off") // If border: 0; -- iOS fails to open keyboard (issue #1287) if (ios) te.style.border = "1px solid black" - disableBrowserMagic(te) return div } From d4d7d3c4e18cc6bfff7136abc4cbd31bad194b6e Mon Sep 17 00:00:00 2001 From: "Joseph D. Purcell" Date: Wed, 7 Dec 2022 18:20:31 -0500 Subject: [PATCH 2387/2444] Use autocorrect and autocapitalize value of on instead of empty string --- src/input/input.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/input/input.js b/src/input/input.js index 8b15639cfd..b766d415db 100644 --- a/src/input/input.js +++ b/src/input/input.js @@ -114,8 +114,8 @@ export function copyableRanges(cm) { } export function disableBrowserMagic(field, spellcheck, autocorrect, autocapitalize) { - field.setAttribute("autocorrect", autocorrect ? "" : "off") - field.setAttribute("autocapitalize", autocapitalize ? "" : "off") + field.setAttribute("autocorrect", autocorrect ? "on" : "off") + field.setAttribute("autocapitalize", autocapitalize ? "on" : "off") field.setAttribute("spellcheck", !!spellcheck) } From f006b571d20b3b3e932b1d9013d73d0ada2c22bd Mon Sep 17 00:00:00 2001 From: "sahil.mahna" Date: Tue, 13 Dec 2022 17:46:27 +0530 Subject: [PATCH 2388/2444] Add keyboard spacebar interactive for merge editor buttons --- addon/merge/merge.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addon/merge/merge.js b/addon/merge/merge.js index d61051cf32..14362fa6e9 100644 --- a/addon/merge/merge.js +++ b/addon/merge/merge.js @@ -610,7 +610,7 @@ lock.setAttribute("tabindex", "0"); var lockWrap = elt("div", [lock], "CodeMirror-merge-scrolllock-wrap"); CodeMirror.on(lock, "click", function() { setScrollLock(dv, !dv.lockScroll); }); - CodeMirror.on(lock, "keyup", function(e) { e.key === "Enter" && setScrollLock(dv, !dv.lockScroll); }); + CodeMirror.on(lock, "keyup", function(e) { (e.key === "Enter" || e.code === "Space") && setScrollLock(dv, !dv.lockScroll); }); var gapElts = [lockWrap]; if (dv.mv.options.revertButtons !== false) { dv.copyButtons = elt("div", null, "CodeMirror-merge-copybuttons-" + dv.type); @@ -624,7 +624,7 @@ copyChunk(dv, dv.edit, dv.orig, node.chunk); } CodeMirror.on(dv.copyButtons, "click", copyButtons); - CodeMirror.on(dv.copyButtons, "keyup", function(e) { e.key === "Enter" && copyButtons(e); }); + CodeMirror.on(dv.copyButtons, "keyup", function(e) { (e.key === "Enter" || e.code === "Space") && copyButtons(e); }); gapElts.unshift(dv.copyButtons); } if (dv.mv.options.connect != "align") { From f124e299238f2b622a96761886d0d930b11d55d9 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Tue, 20 Dec 2022 11:11:01 +0100 Subject: [PATCH 2389/2444] Mark version 5.65.11 --- AUTHORS | 2 ++ CHANGELOG.md | 8 ++++++++ doc/manual.html | 2 +- doc/releases.html | 7 +++++++ index.html | 2 +- package.json | 2 +- src/edit/main.js | 2 +- 7 files changed, 21 insertions(+), 4 deletions(-) diff --git a/AUTHORS b/AUTHORS index 3d19b21470..72c1eaa757 100644 --- a/AUTHORS +++ b/AUTHORS @@ -238,6 +238,7 @@ Dimitri Mitropoulos Dinindu D. Wanniarachchi dmaclach Dmitry Kiselyov +DoctorKrolic domagoj412 Dominator008 Domizio Demichelis @@ -460,6 +461,7 @@ Jon Sangster Joo Joost-Wim Boekesteijn José dBruxelles +Joseph D. Purcell Joseph Pecoraro Josh Barnes Josh Cohen diff --git a/CHANGELOG.md b/CHANGELOG.md index 41d7f0815d..a4f6c93166 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +## 5.65.11 (2022-12-20) + +### Bug fixes + +Also respect autocapitalize/autocorrect/spellcheck options in textarea mode. + +[sql-hint addon](https://codemirror.net/5/doc/manual.html#addon_sql-hint): Fix keyword completion in generic SQL mode. + ## 5.65.10 (2022-11-20) ### Bug fixes diff --git a/doc/manual.html b/doc/manual.html index 19b21d8c1c..6598c9f52d 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -70,7 +70,7 @@

        User manual and reference guide - version 5.65.10 + version 5.65.11

        CodeMirror is a code-editor component that can be embedded in diff --git a/doc/releases.html b/doc/releases.html index a20dfa0312..20948676a4 100644 --- a/doc/releases.html +++ b/doc/releases.html @@ -34,6 +34,13 @@

        Version 6.x

        Version 5.x

        +

        20-12-2022: Version 5.65.11:

        + +
          +
        • Also respect autocapitalize/autocorrect/spellcheck options in textarea mode.
        • +
        • sql-hint addon: Fix keyword completion in generic SQL mode.
        • +
        +

        20-11-2022: Version 5.65.10:

          diff --git a/index.html b/index.html index 75c53a2de0..022d6d39c3 100644 --- a/index.html +++ b/index.html @@ -92,7 +92,7 @@

          This is CodeMirror

          - Get the current version: 5.65.10.
          + Get the current version: 5.65.11.
          You can see the code,
          read the release notes,
          or study the user manual. diff --git a/package.json b/package.json index b6cde62684..c845e8fbca 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "codemirror", - "version": "5.65.10", + "version": "5.65.11", "main": "lib/codemirror.js", "style": "lib/codemirror.css", "author": { diff --git a/src/edit/main.js b/src/edit/main.js index 6d436dfbeb..7cbb5330b4 100644 --- a/src/edit/main.js +++ b/src/edit/main.js @@ -66,4 +66,4 @@ import { addLegacyProps } from "./legacy.js" addLegacyProps(CodeMirror) -CodeMirror.version = "5.65.10" +CodeMirror.version = "5.65.11" From d4a6699187bb34ebf82321c227c0118f4c28f564 Mon Sep 17 00:00:00 2001 From: yoyoyodog123 <104166150+CommanderQuack@users.noreply.github.com> Date: Fri, 23 Dec 2022 03:07:17 -0600 Subject: [PATCH 2390/2444] [python mode] Add match/case to py3 keywords --- mode/python/python.js | 6 +++--- mode/python/test.js | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/mode/python/python.js b/mode/python/python.js index d75b021e2c..cbf12ad4b1 100644 --- a/mode/python/python.js +++ b/mode/python/python.js @@ -20,7 +20,7 @@ "def", "del", "elif", "else", "except", "finally", "for", "from", "global", "if", "import", "lambda", "pass", "raise", "return", - "try", "while", "with", "yield", "in"]; + "try", "while", "with", "yield", "in", "False", "True"]; var commonBuiltins = ["abs", "all", "any", "bin", "bool", "bytearray", "callable", "chr", "classmethod", "compile", "complex", "delattr", "dict", "dir", "divmod", "enumerate", "eval", "filter", "float", "format", "frozenset", @@ -60,7 +60,7 @@ if (py3) { // since http://legacy.python.org/dev/peps/pep-0465/ @ is also an operator var identifiers = parserConf.identifiers|| /^[_A-Za-z\u00A1-\uFFFF][_A-Za-z0-9\u00A1-\uFFFF]*/; - myKeywords = myKeywords.concat(["nonlocal", "False", "True", "None", "async", "await"]); + myKeywords = myKeywords.concat(["nonlocal", "None", "async", "await", "match", "case"]); myBuiltins = myBuiltins.concat(["ascii", "bytes", "exec", "print"]); var stringPrefixes = new RegExp("^(([rbuf]|(br)|(rb)|(fr)|(rf))?('{3}|\"{3}|['\"]))", "i"); } else { @@ -68,7 +68,7 @@ myKeywords = myKeywords.concat(["exec", "print"]); myBuiltins = myBuiltins.concat(["apply", "basestring", "buffer", "cmp", "coerce", "execfile", "file", "intern", "long", "raw_input", "reduce", "reload", - "unichr", "unicode", "xrange", "False", "True", "None"]); + "unichr", "unicode", "xrange", "None"]); var stringPrefixes = new RegExp("^(([rubf]|(ur)|(br))?('{3}|\"{3}|['\"]))", "i"); } var keywords = wordRegexp(myKeywords); diff --git a/mode/python/test.js b/mode/python/test.js index ca5da153dd..9fe1439f3f 100644 --- a/mode/python/test.js +++ b/mode/python/test.js @@ -71,4 +71,19 @@ " [keyword pass]", " [keyword else]:", " [variable baz]()") + + MT("dedentCase", + "[keyword match] [variable x]:", + " [keyword case] [variable y]:", + " [variable foo]()") + MT("dedentCasePass", + "[keyword match] [variable x]:", + " [keyword case] [variable y]:", + " [keyword pass]") + + MT("dedentCaseInFunction", + "[keyword def] [def foo]():", + " [keyword match] [variable x]:", + " [keyword case] [variable y]:", + " [variable foo]()") })(); From 9e864a1bb7c4c452f462d7f8d8be111c8bb8ad6f Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Fri, 23 Dec 2022 10:17:29 +0100 Subject: [PATCH 2391/2444] Remove trailing whitespace --- mode/python/test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mode/python/test.js b/mode/python/test.js index 9fe1439f3f..ade5498166 100644 --- a/mode/python/test.js +++ b/mode/python/test.js @@ -71,7 +71,7 @@ " [keyword pass]", " [keyword else]:", " [variable baz]()") - + MT("dedentCase", "[keyword match] [variable x]:", " [keyword case] [variable y]:", From 34b84359c4ce289086c82c203f66ef74614d8a0d Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Tue, 24 Jan 2023 08:25:56 +0100 Subject: [PATCH 2392/2444] Update maintainer email --- LICENSE | 2 +- index.html | 2 +- package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/LICENSE b/LICENSE index ff7db4b99f..9018d33e8f 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (C) 2017 by Marijn Haverbeke and others +Copyright (C) 2017 by Marijn Haverbeke and others Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/index.html b/index.html index 022d6d39c3..bd697e9c72 100644 --- a/index.html +++ b/index.html @@ -152,7 +152,7 @@

          Community

          posted in the forum's "announce" category. If needed, you can - contact the maintainer + contact the maintainer directly. We aim to be an inclusive, welcoming community. To make that explicit, we have a code of diff --git a/package.json b/package.json index c845e8fbca..b2082c799d 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "style": "lib/codemirror.css", "author": { "name": "Marijn Haverbeke", - "email": "marijnh@gmail.com", + "email": "marijn@haverbeke.berlin", "url": "http://marijnhaverbeke.nl" }, "description": "Full-featured in-browser code editor", From 58f592582f114919e980a8035a46327471c01527 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Thu, 2 Feb 2023 09:57:06 +0100 Subject: [PATCH 2393/2444] [bespin theme] Increase selection contrast Closes https://github.com/codemirror/codemirror5/issues/7018 --- theme/bespin.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/theme/bespin.css b/theme/bespin.css index 60913ba938..3fd3d93a5a 100644 --- a/theme/bespin.css +++ b/theme/bespin.css @@ -9,7 +9,7 @@ */ .cm-s-bespin.CodeMirror {background: #28211c; color: #9d9b97;} -.cm-s-bespin div.CodeMirror-selected {background: #36312e !important;} +.cm-s-bespin div.CodeMirror-selected {background: #59554f !important;} .cm-s-bespin .CodeMirror-gutters {background: #28211c; border-right: 0px;} .cm-s-bespin .CodeMirror-linenumber {color: #666666;} .cm-s-bespin .CodeMirror-cursor {border-left: 1px solid #797977 !important;} From 659df46b1f53cd94952058e23687f9e58e1b997e Mon Sep 17 00:00:00 2001 From: yoyoyodog123 <104166150+Captain-Quack@users.noreply.github.com> Date: Tue, 14 Feb 2023 11:44:36 -0600 Subject: [PATCH 2394/2444] [python mode] Add new built-in functions - Aiter (added in 3.10) - Anext (added in 3.10) - Breakpoint (added in 3.7) --- mode/python/python.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mode/python/python.js b/mode/python/python.js index cbf12ad4b1..3946ceeeb0 100644 --- a/mode/python/python.js +++ b/mode/python/python.js @@ -60,7 +60,7 @@ if (py3) { // since http://legacy.python.org/dev/peps/pep-0465/ @ is also an operator var identifiers = parserConf.identifiers|| /^[_A-Za-z\u00A1-\uFFFF][_A-Za-z0-9\u00A1-\uFFFF]*/; - myKeywords = myKeywords.concat(["nonlocal", "None", "async", "await", "match", "case"]); + myKeywords = myKeywords.concat(["nonlocal", "None", "aiter", "anext", "async", "await", "breakpoint", "match", "case"]); myBuiltins = myBuiltins.concat(["ascii", "bytes", "exec", "print"]); var stringPrefixes = new RegExp("^(([rbuf]|(br)|(rb)|(fr)|(rf))?('{3}|\"{3}|['\"]))", "i"); } else { From 6fc81b126fabd791a31d9c9d146f2aff32953d5b Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Mon, 20 Feb 2023 11:55:39 +0100 Subject: [PATCH 2395/2444] Mark version 5.65.12 --- AUTHORS | 2 ++ CHANGELOG.md | 6 ++++++ doc/manual.html | 2 +- doc/releases.html | 6 ++++++ index.html | 2 +- package.json | 2 +- src/edit/main.js | 2 +- 7 files changed, 18 insertions(+), 4 deletions(-) diff --git a/AUTHORS b/AUTHORS index 72c1eaa757..13e0c7f48a 100644 --- a/AUTHORS +++ b/AUTHORS @@ -799,6 +799,7 @@ ryu-sato sabaca sach.gupta Sachin Gupta +sahil.mahna Sam Lee Sam Rawlins Samuel Ainsworth @@ -964,6 +965,7 @@ Yash-Singh1 Yassin N. Hassan YNH Webdev yoongu +yoyoyodog123 Yunchi Luo Yuvi Panda Yvonnick Esnault diff --git a/CHANGELOG.md b/CHANGELOG.md index a4f6c93166..ab3ca34ee5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## 5.65.12 (2023-02-20) + +### Bug fixes + +[python mode](https://codemirror.net/5/mode/python/): Add new built-ins and keywords. + ## 5.65.11 (2022-12-20) ### Bug fixes diff --git a/doc/manual.html b/doc/manual.html index 6598c9f52d..20ff731d01 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -70,7 +70,7 @@

          User manual and reference guide - version 5.65.11 + version 5.65.12

          CodeMirror is a code-editor component that can be embedded in diff --git a/doc/releases.html b/doc/releases.html index 20948676a4..3e86d6e9eb 100644 --- a/doc/releases.html +++ b/doc/releases.html @@ -34,6 +34,12 @@

          Version 6.x

          Version 5.x

          +

          20-12-2022: Version 5.65.12:

          + + +

          20-12-2022: Version 5.65.11:

            diff --git a/index.html b/index.html index bd697e9c72..ea7dc4ffb8 100644 --- a/index.html +++ b/index.html @@ -92,7 +92,7 @@

            This is CodeMirror

            - Get the current version: 5.65.11.
            + Get the current version: 5.65.12.
            You can see the code,
            read the release notes,
            or study the user manual. diff --git a/package.json b/package.json index b2082c799d..6bdd100884 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "codemirror", - "version": "5.65.11", + "version": "5.65.12", "main": "lib/codemirror.js", "style": "lib/codemirror.css", "author": { diff --git a/src/edit/main.js b/src/edit/main.js index 7cbb5330b4..2becd5c766 100644 --- a/src/edit/main.js +++ b/src/edit/main.js @@ -66,4 +66,4 @@ import { addLegacyProps } from "./legacy.js" addLegacyProps(CodeMirror) -CodeMirror.version = "5.65.11" +CodeMirror.version = "5.65.12" From 658bff7c56b7829aeabb8a914be5ca728d8aba0b Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Fri, 24 Feb 2023 08:40:47 +0100 Subject: [PATCH 2396/2444] [sql mode] Make sure 'with' is highlighted as a keyword for PostgreSQL Closes https://github.com/codemirror/codemirror5/issues/7022 --- mode/sql/sql.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mode/sql/sql.js b/mode/sql/sql.js index 7b9dec7de1..d3983889f7 100644 --- a/mode/sql/sql.js +++ b/mode/sql/sql.js @@ -417,7 +417,7 @@ CodeMirror.defineMode("sql", function(config, parserConfig) { // For pl/pgsql lang - https://github.com/postgres/postgres/blob/REL_11_2/src/pl/plpgsql/src/pl_scanner.c keywords: set(sqlKeywords + "a abort abs absent absolute access according action ada add admin after aggregate alias all allocate also alter always analyse analyze and any are array array_agg array_max_cardinality as asc asensitive assert assertion assignment asymmetric at atomic attach attribute attributes authorization avg backward base64 before begin begin_frame begin_partition bernoulli between bigint binary bit bit_length blob blocked bom boolean both breadth by c cache call called cardinality cascade cascaded case cast catalog catalog_name ceil ceiling chain char char_length character character_length character_set_catalog character_set_name character_set_schema characteristics characters check checkpoint class class_origin clob close cluster coalesce cobol collate collation collation_catalog collation_name collation_schema collect column column_name columns command_function command_function_code comment comments commit committed concurrently condition condition_number configuration conflict connect connection connection_name constant constraint constraint_catalog constraint_name constraint_schema constraints constructor contains content continue control conversion convert copy corr corresponding cost count covar_pop covar_samp create cross csv cube cume_dist current current_catalog current_date current_default_transform_group current_path current_role current_row current_schema current_time current_timestamp current_transform_group_for_type current_user cursor cursor_name cycle data database datalink datatype date datetime_interval_code datetime_interval_precision day db deallocate debug dec decimal declare default defaults deferrable deferred defined definer degree delete delimiter delimiters dense_rank depends depth deref derived desc describe descriptor detach detail deterministic diagnostics dictionary disable discard disconnect dispatch distinct dlnewcopy dlpreviouscopy dlurlcomplete dlurlcompleteonly dlurlcompletewrite dlurlpath dlurlpathonly dlurlpathwrite dlurlscheme dlurlserver dlvalue do document domain double drop dump dynamic dynamic_function dynamic_function_code each element else elseif elsif empty enable encoding encrypted end end_frame end_partition endexec enforced enum equals errcode error escape event every except exception exclude excluding exclusive exec execute exists exit exp explain expression extension external extract false family fetch file filter final first first_value flag float floor following for force foreach foreign fortran forward found frame_row free freeze from fs full function functions fusion g general generated get global go goto grant granted greatest group grouping groups handler having header hex hierarchy hint hold hour id identity if ignore ilike immediate immediately immutable implementation implicit import in include including increment indent index indexes indicator info inherit inherits initially inline inner inout input insensitive insert instance instantiable instead int integer integrity intersect intersection interval into invoker is isnull isolation join k key key_member key_type label lag language large last last_value lateral lead leading leakproof least left length level library like like_regex limit link listen ln load local localtime localtimestamp location locator lock locked log logged loop lower m map mapping match matched materialized max max_cardinality maxvalue member merge message message_length message_octet_length message_text method min minute minvalue mod mode modifies module month more move multiset mumps name names namespace national natural nchar nclob nesting new next nfc nfd nfkc nfkd nil no none normalize normalized not nothing notice notify notnull nowait nth_value ntile null nullable nullif nulls number numeric object occurrences_regex octet_length octets of off offset oids old on only open operator option options or order ordering ordinality others out outer output over overlaps overlay overriding owned owner p pad parallel parameter parameter_mode parameter_name parameter_ordinal_position parameter_specific_catalog parameter_specific_name parameter_specific_schema parser partial partition pascal passing passthrough password path percent percent_rank percentile_cont percentile_disc perform period permission pg_context pg_datatype_name pg_exception_context pg_exception_detail pg_exception_hint placing plans pli policy portion position position_regex power precedes preceding precision prepare prepared preserve primary print_strict_params prior privileges procedural procedure procedures program public publication query quote raise range rank read reads real reassign recheck recovery recursive ref references referencing refresh regr_avgx regr_avgy regr_count regr_intercept regr_r2 regr_slope regr_sxx regr_sxy regr_syy reindex relative release rename repeatable replace replica requiring reset respect restart restore restrict result result_oid return returned_cardinality returned_length returned_octet_length returned_sqlstate returning returns reverse revoke right role rollback rollup routine routine_catalog routine_name routine_schema routines row row_count row_number rows rowtype rule savepoint scale schema schema_name schemas scope scope_catalog scope_name scope_schema scroll search second section security select selective self sensitive sequence sequences serializable server server_name session session_user set setof sets share show similar simple size skip slice smallint snapshot some source space specific specific_name specifictype sql sqlcode sqlerror sqlexception sqlstate sqlwarning sqrt stable stacked standalone start state statement static statistics stddev_pop stddev_samp stdin stdout storage strict strip structure style subclass_origin submultiset subscription substring substring_regex succeeds sum symmetric sysid system system_time system_user t table table_name tables tablesample tablespace temp template temporary text then ties time timestamp timezone_hour timezone_minute to token top_level_count trailing transaction transaction_active transactions_committed transactions_rolled_back transform transforms translate translate_regex translation treat trigger trigger_catalog trigger_name trigger_schema trim trim_array true truncate trusted type types uescape unbounded uncommitted under unencrypted union unique unknown unlink unlisten unlogged unnamed unnest until untyped update upper uri usage use_column use_variable user user_defined_type_catalog user_defined_type_code user_defined_type_name user_defined_type_schema using vacuum valid validate validator value value_of values var_pop var_samp varbinary varchar variable_conflict variadic varying verbose version versioning view views volatile warning when whenever where while whitespace width_bucket window with within without work wrapper write xml xmlagg xmlattributes xmlbinary xmlcast xmlcomment xmlconcat xmldeclaration xmldocument xmlelement xmlexists xmlforest xmliterate xmlnamespaces xmlparse xmlpi xmlquery xmlroot xmlschema xmlserialize xmltable xmltext xmlvalidate year yes zone"), // https://www.postgresql.org/docs/11/datatype.html - builtin: set("bigint int8 bigserial serial8 bit varying varbit boolean bool box bytea character char varchar cidr circle date double precision float8 inet integer int int4 interval json jsonb line lseg macaddr macaddr8 money numeric decimal path pg_lsn point polygon real float4 smallint int2 smallserial serial2 serial serial4 text time without zone with timetz timestamp timestamptz tsquery tsvector txid_snapshot uuid xml"), + builtin: set("bigint int8 bigserial serial8 bit varying varbit boolean bool box bytea character char varchar cidr circle date double precision float8 inet integer int int4 interval json jsonb line lseg macaddr macaddr8 money numeric decimal path pg_lsn point polygon real float4 smallint int2 smallserial serial2 serial serial4 text time zone timetz timestamp timestamptz tsquery tsvector txid_snapshot uuid xml"), atoms: set("false true null unknown"), operatorChars: /^[*\/+\-%<>!=&|^\/#@?~]/, backslashStringEscapes: false, From 6a705898e74e223b74e02fe59f60af83074205a0 Mon Sep 17 00:00:00 2001 From: Brett Morgan Date: Fri, 3 Mar 2023 10:10:22 +1100 Subject: [PATCH 2397/2444] [dart mode] Add keywords --- mode/dart/dart.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mode/dart/dart.js b/mode/dart/dart.js index 340076712c..54aedf3297 100644 --- a/mode/dart/dart.js +++ b/mode/dart/dart.js @@ -15,7 +15,7 @@ "implements mixin get native set typedef with enum throw rethrow " + "assert break case continue default in return new deferred async await covariant " + "try catch finally do else for if switch while import library export " + - "part of show hide is as extension on yield late required").split(" "); + "part of show hide is as extension on yield late required sealed base interface when").split(" "); var blockKeywords = "try catch finally do else for if switch while".split(" "); var atoms = "true false null".split(" "); var builtins = "void bool num int double dynamic var String Null Never".split(" "); From c17c5f0abe0147151d834e8eec9c400ec327120a Mon Sep 17 00:00:00 2001 From: Brett Morgan Date: Wed, 8 Mar 2023 21:26:18 +1100 Subject: [PATCH 2398/2444] [dart mode] Add `inline` keyword for inline classes Context: https://github.com/dart-lang/language/blob/master/accepted/future-releases/inline-classes/feature-specification.md Related: https://github.com/dart-lang/sdk/issues/49734 --- mode/dart/dart.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mode/dart/dart.js b/mode/dart/dart.js index 54aedf3297..f81e4f91a4 100644 --- a/mode/dart/dart.js +++ b/mode/dart/dart.js @@ -12,10 +12,10 @@ "use strict"; var keywords = ("this super static final const abstract class extends external factory " + - "implements mixin get native set typedef with enum throw rethrow " + - "assert break case continue default in return new deferred async await covariant " + - "try catch finally do else for if switch while import library export " + - "part of show hide is as extension on yield late required sealed base interface when").split(" "); + "implements mixin get native set typedef with enum throw rethrow assert break case " + + "continue default in return new deferred async await covariant try catch finally " + + "do else for if switch while import library export part of show hide is as extension " + + "on yield late required sealed base interface when inline").split(" "); var blockKeywords = "try catch finally do else for if switch while".split(" "); var atoms = "true false null".split(" "); var builtins = "void bool num int double dynamic var String Null Never".split(" "); From 9974ded36bf01746eb2a00926916fef834d3d0d0 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Thu, 16 Mar 2023 17:45:22 +0100 Subject: [PATCH 2399/2444] [clike mode] Properly match character literals in Scala mode --- mode/clike/clike.js | 1 + 1 file changed, 1 insertion(+) diff --git a/mode/clike/clike.js b/mode/clike/clike.js index 8075edb8a1..fcfc7c45cc 100644 --- a/mode/clike/clike.js +++ b/mode/clike/clike.js @@ -613,6 +613,7 @@ CodeMirror.defineMode("clike", function(config, parserConfig) { return state.tokenize(stream, state); }, "'": function(stream) { + if (stream.match(/^(\\[^'\s]+|[^\\'])'/)) return "string-2" stream.eatWhile(/[\w\$_\xa1-\uffff]/); return "atom"; }, From 330a06dd6ece17833f0127093d44ae18a1a5c451 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Thu, 27 Apr 2023 10:23:26 +0200 Subject: [PATCH 2400/2444] Mark version 5.65.13 --- AUTHORS | 1 + CHANGELOG.md | 8 ++++++++ doc/manual.html | 2 +- doc/releases.html | 7 +++++++ index.html | 2 +- package.json | 2 +- src/edit/main.js | 2 +- 7 files changed, 20 insertions(+), 4 deletions(-) diff --git a/AUTHORS b/AUTHORS index 13e0c7f48a..3dd26e0fbb 100644 --- a/AUTHORS +++ b/AUTHORS @@ -139,6 +139,7 @@ Brad Metcalf Brandon Frohs Brandon Wamboldt Bret Little +Brett Morgan Brett Zamir Brian Grinstead BrianHung diff --git a/CHANGELOG.md b/CHANGELOG.md index ab3ca34ee5..3daac7a9ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +## 5.65.13 (2023-04-27) + +### Bug fixes + +[dart mode](https://codemirror.net/5/mode/dart/index.html): Add some new keywords. + +[clike mode](https://codemirror.net/5/mode/clike/): Tokenize Scala character literals. + ## 5.65.12 (2023-02-20) ### Bug fixes diff --git a/doc/manual.html b/doc/manual.html index 20ff731d01..7d3667f90d 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -70,7 +70,7 @@

            User manual and reference guide - version 5.65.12 + version 5.65.13

            CodeMirror is a code-editor component that can be embedded in diff --git a/doc/releases.html b/doc/releases.html index 3e86d6e9eb..40f7e16031 100644 --- a/doc/releases.html +++ b/doc/releases.html @@ -34,6 +34,13 @@

            Version 6.x

            Version 5.x

            +

            20-12-2022: Version 5.65.13:

            + + +

            20-12-2022: Version 5.65.12:

              diff --git a/index.html b/index.html index ea7dc4ffb8..2adb14b3ed 100644 --- a/index.html +++ b/index.html @@ -92,7 +92,7 @@

              This is CodeMirror

              - Get the current version: 5.65.12.
              + Get the current version: 5.65.13.
              You can see the code,
              read the release notes,
              or study the user manual. diff --git a/package.json b/package.json index 6bdd100884..3af57c7282 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "codemirror", - "version": "5.65.12", + "version": "5.65.13", "main": "lib/codemirror.js", "style": "lib/codemirror.css", "author": { diff --git a/src/edit/main.js b/src/edit/main.js index 2becd5c766..d41a4e45c0 100644 --- a/src/edit/main.js +++ b/src/edit/main.js @@ -66,4 +66,4 @@ import { addLegacyProps } from "./legacy.js" addLegacyProps(CodeMirror) -CodeMirror.version = "5.65.12" +CodeMirror.version = "5.65.13" From 480a35d793745572de439a5aaa44fd4fe74a2bb3 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Thu, 27 Apr 2023 10:39:13 +0200 Subject: [PATCH 2401/2444] Fix error output in release upload script --- bin/upload-release.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/upload-release.js b/bin/upload-release.js index 59ed6f5a8f..336a37ecd0 100644 --- a/bin/upload-release.js +++ b/bin/upload-release.js @@ -24,7 +24,7 @@ function post(host, path, body) { } else if (res.statusCode >= 400) { console.error(res.statusCode, res.statusMessage) res.on("data", d => console.log(d.toString())) - res.on("end", process.exit(1)) + res.on("end", () => process.exit(1)) } }) req.write(body) From 1e58b28781af0d2a9fc426c744dcdc22c6216dd6 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Thu, 29 Jun 2023 17:15:39 +0200 Subject: [PATCH 2402/2444] [lint addon] Remove confused annotation filtering --- addon/lint/lint.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/addon/lint/lint.js b/addon/lint/lint.js index 7b40e10e91..052313dc5c 100644 --- a/addon/lint/lint.js +++ b/addon/lint/lint.js @@ -199,10 +199,6 @@ var anns = annotations[line]; if (!anns) continue; - // filter out duplicate messages - var message = []; - anns = anns.filter(function(item) { return message.indexOf(item.message) > -1 ? false : message.push(item.message) }); - var maxSeverity = null; var tipLabel = state.hasGutter && document.createDocumentFragment(); @@ -220,9 +216,8 @@ __annotation: ann })); } - // use original annotations[line] to show multiple messages if (state.hasGutter) - cm.setGutterMarker(line, GUTTER_ID, makeMarker(cm, tipLabel, maxSeverity, annotations[line].length > 1, + cm.setGutterMarker(line, GUTTER_ID, makeMarker(cm, tipLabel, maxSeverity, anns.length > 1, options.tooltips)); if (options.highlightLines) From a0854c752a76e4ba9512a9beedb9076f36e4f8f9 Mon Sep 17 00:00:00 2001 From: "Jan T. Sott" Date: Mon, 3 Jul 2023 09:54:01 +0200 Subject: [PATCH 2403/2444] [nsis mode] Add !assert command --- mode/nsis/nsis.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mode/nsis/nsis.js b/mode/nsis/nsis.js index 2173916bb2..de18871251 100644 --- a/mode/nsis/nsis.js +++ b/mode/nsis/nsis.js @@ -24,7 +24,7 @@ CodeMirror.defineSimpleMode("nsis",{ { regex: /`(?:[^\\`]|\\.)*`?/, token: "string" }, // Compile Time Commands - {regex: /^\s*(?:\!(addincludedir|addplugindir|appendfile|cd|define|delfile|echo|error|execute|finalize|getdllversion|gettlbversion|include|insertmacro|macro|macroend|makensis|packhdr|pragma|searchparse|searchreplace|system|tempfile|undef|uninstfinalize|verbose|warning))\b/i, token: "keyword"}, + {regex: /^\s*(?:\!(addincludedir|addplugindir|appendfile|assert|cd|define|delfile|echo|error|execute|finalize|getdllversion|gettlbversion|include|insertmacro|macro|macroend|makensis|packhdr|pragma|searchparse|searchreplace|system|tempfile|undef|uninstfinalize|verbose|warning))\b/i, token: "keyword"}, // Conditional Compilation {regex: /^\s*(?:\!(if(?:n?def)?|ifmacron?def|macro))\b/i, token: "keyword", indent: true}, From 69e38f574c03bc2d46c806ffc5f652d31d071c21 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Sat, 15 Jul 2023 08:59:15 +0200 Subject: [PATCH 2404/2444] [java mode] Fix indentation after class extends clause Closes https://github.com/codemirror/codemirror5/issues/7049 --- mode/clike/clike.js | 3 ++- mode/clike/test.js | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/mode/clike/clike.js b/mode/clike/clike.js index fcfc7c45cc..e9f441fc0a 100644 --- a/mode/clike/clike.js +++ b/mode/clike/clike.js @@ -218,7 +218,8 @@ CodeMirror.defineMode("clike", function(config, parserConfig) { }, indent: function(state, textAfter) { - if (state.tokenize != tokenBase && state.tokenize != null || state.typeAtEndOfLine) return CodeMirror.Pass; + if (state.tokenize != tokenBase && state.tokenize != null || state.typeAtEndOfLine && isTopScope(state.context)) + return CodeMirror.Pass; var ctx = state.context, firstChar = textAfter && textAfter.charAt(0); var closing = firstChar == ctx.type; if (ctx.type == "statement" && firstChar == "}") ctx = ctx.prev; diff --git a/mode/clike/test.js b/mode/clike/test.js index 80d8ea4548..2933a00277 100644 --- a/mode/clike/test.js +++ b/mode/clike/test.js @@ -162,4 +162,9 @@ "[type StringBuffer];", "[type StringBuilder];", "[type Void];"); + + MTJAVA("indent", + "[keyword public] [keyword class] [def A] [keyword extends] [variable B]", + "{", + " [variable c]()") })(); From 82ce3d2f64b18e86306a9d9da85beeba4e17834e Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Mon, 17 Jul 2023 09:35:44 +0200 Subject: [PATCH 2405/2444] Mark version 5.65.14 --- CHANGELOG.md | 10 ++++++++++ doc/manual.html | 2 +- doc/releases.html | 12 ++++++++++-- index.html | 2 +- package.json | 2 +- src/edit/main.js | 2 +- 6 files changed, 24 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3daac7a9ac..4ef2a2cc79 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ +## 5.65.14 (2023-07-17) + +### Bug fixes + +[clike mode](https://codemirror.net/5/mode/clike/): Fix poor indentation in some Java code. + +[nsis mode](https://codemirror.net/5/mode/nsis/index.html): Recognize `!assert` command. + +[lint addon](https://codemirror.net/5/doc/manual.html#addon_lint): Remove broken annotation deduplication. + ## 5.65.13 (2023-04-27) ### Bug fixes diff --git a/doc/manual.html b/doc/manual.html index 7d3667f90d..873bd4a6a9 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -70,7 +70,7 @@

              User manual and reference guide - version 5.65.13 + version 5.65.14

              CodeMirror is a code-editor component that can be embedded in diff --git a/doc/releases.html b/doc/releases.html index 40f7e16031..e8b6ccae7c 100644 --- a/doc/releases.html +++ b/doc/releases.html @@ -34,14 +34,22 @@

              Version 6.x

              Version 5.x

              -

              20-12-2022: Version 5.65.13:

              +

              17-07-2023: Version 5.65.14:

              + +
                +
              • clike mode: Fix poor indentation in some Java code.
              • +
              • nsis mode: Recognize !assert command.
              • +
              • lint addon: Remove broken annotation deduplication.
              • +
              + +

              27-04-2023: Version 5.65.13:

              -

              20-12-2022: Version 5.65.12:

              +

              20-02-2023: Version 5.65.12:

              • python mode: Add new built-ins and keywords.
              • diff --git a/index.html b/index.html index 2adb14b3ed..728b0bfb62 100644 --- a/index.html +++ b/index.html @@ -92,7 +92,7 @@

                This is CodeMirror

                - Get the current version: 5.65.13.
                + Get the current version: 5.65.14.
                You can see the code,
                read the release notes,
                or study the user manual. diff --git a/package.json b/package.json index 3af57c7282..a9c6f80eb6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "codemirror", - "version": "5.65.13", + "version": "5.65.14", "main": "lib/codemirror.js", "style": "lib/codemirror.css", "author": { diff --git a/src/edit/main.js b/src/edit/main.js index d41a4e45c0..834e27eb45 100644 --- a/src/edit/main.js +++ b/src/edit/main.js @@ -66,4 +66,4 @@ import { addLegacyProps } from "./legacy.js" addLegacyProps(CodeMirror) -CodeMirror.version = "5.65.13" +CodeMirror.version = "5.65.14" From 370f7c4a7222211987a826b0e9f43d8980229c64 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Fri, 21 Jul 2023 21:23:28 +0200 Subject: [PATCH 2406/2444] [lint addon] Make sure tooltips don't stick out of the window width Issue https://github.com/codemirror/codemirror5/pull/7044 --- addon/lint/lint.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/addon/lint/lint.js b/addon/lint/lint.js index 052313dc5c..21631b9d24 100644 --- a/addon/lint/lint.js +++ b/addon/lint/lint.js @@ -24,8 +24,10 @@ function position(e) { if (!tt.parentNode) return CodeMirror.off(document, "mousemove", position); - tt.style.top = Math.max(0, e.clientY - tt.offsetHeight - 5) + "px"; - tt.style.left = (e.clientX + 5) + "px"; + var top = Math.max(0, e.clientY - tt.offsetHeight - 5); + var left = Math.max(0, Math.min(e.clientX + 5, tt.ownerDocument.defaultView.innerWidth - tt.offsetWidth)); + tt.style.top = top + "px" + tt.style.left = left + "px"; } CodeMirror.on(document, "mousemove", position); position(e); From 817ea7be474c3452a78864c05aa7f38ec8f2ff85 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Mon, 31 Jul 2023 21:21:56 +0200 Subject: [PATCH 2407/2444] Fix install example in readme Closes https://github.com/codemirror/codemirror5/issues/7051 --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 578a5a9730..e021f2bf7a 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ # CodeMirror [![Build Status](https://github.com/codemirror/codemirror5/workflows/main/badge.svg)](https://github.com/codemirror/codemirror5/actions) -[![NPM version](https://img.shields.io/npm/v/codemirror.svg)](https://www.npmjs.org/package/codemirror) CodeMirror is a versatile text editor implemented in JavaScript for the browser. It is specialized for editing code, and comes with over @@ -33,7 +32,7 @@ Either get the [zip file](https://codemirror.net/5/codemirror.zip) with the latest version, or make sure you have [Node](https://nodejs.org/) installed and run: - npm install codemirror + npm install codemirror@5 **NOTE**: This is the source repository for the library, and not the distribution channel. Cloning it is not the recommended way to install From 4ea5f465587e1624b668ae98738ffafc1bef71de Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Wed, 9 Aug 2023 22:54:39 +0200 Subject: [PATCH 2408/2444] [yaml mode] Fix exponential regexp Closes https://github.com/codemirror/codemirror5/issues/7053 --- mode/yaml/yaml.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mode/yaml/yaml.js b/mode/yaml/yaml.js index 298db55f6f..895d1330a2 100644 --- a/mode/yaml/yaml.js +++ b/mode/yaml/yaml.js @@ -85,7 +85,7 @@ CodeMirror.defineMode("yaml", function() { } /* pairs (associative arrays) -> key */ - if (!state.pair && stream.match(/^\s*(?:[,\[\]{}&*!|>'"%@`][^\s'":]|[^,\[\]{}#&*!|>'"%@`])[^#]*?(?=\s*:($|\s))/)) { + if (!state.pair && stream.match(/^\s*(?:[,\[\]{}&*!|>'"%@`][^\s'":]|[^\s,\[\]{}#&*!|>'"%@`])[^#:]*(?=:($|\s))/)) { state.pair = true; state.keyCol = stream.indentation(); return "atom"; From 854ee51ef20434eae043d64f92e6f8548d569030 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Tue, 29 Aug 2023 08:59:28 +0200 Subject: [PATCH 2409/2444] Mark version 5.65.15 --- CHANGELOG.md | 8 ++++++++ doc/manual.html | 2 +- doc/releases.html | 7 +++++++ index.html | 2 +- package.json | 2 +- src/edit/main.js | 2 +- 6 files changed, 19 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4ef2a2cc79..31c9043708 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +## 5.65.15 (2023-08-29) + +### Bug fixes + +[lint addon](https://codemirror.net/5/doc/manual.html#addon_lint): Prevent tooltips from sticking out of the viewport. + +[yaml mode](https://codemirror.net/5/mode/yaml/): Fix an exponential-complexity regular expression. + ## 5.65.14 (2023-07-17) ### Bug fixes diff --git a/doc/manual.html b/doc/manual.html index 873bd4a6a9..7496ff277a 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -70,7 +70,7 @@

                User manual and reference guide - version 5.65.14 + version 5.65.15

                CodeMirror is a code-editor component that can be embedded in diff --git a/doc/releases.html b/doc/releases.html index e8b6ccae7c..5d94bad1fb 100644 --- a/doc/releases.html +++ b/doc/releases.html @@ -34,6 +34,13 @@

                Version 6.x

                Version 5.x

                +

                29-08-2023: Version 5.65.15:

                + +
                  +
                • lint addon: Prevent tooltips from sticking out of the viewport.
                • +
                • yaml mode: Fix an exponential-complexity regular expression.
                • +
                +

                17-07-2023: Version 5.65.14:

                  diff --git a/index.html b/index.html index 728b0bfb62..319adcbaa9 100644 --- a/index.html +++ b/index.html @@ -92,7 +92,7 @@

                  This is CodeMirror

                  - Get the current version: 5.65.14.
                  + Get the current version: 5.65.15.
                  You can see the code,
                  read the release notes,
                  or study the user manual. diff --git a/package.json b/package.json index a9c6f80eb6..eb0c44cf09 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "codemirror", - "version": "5.65.14", + "version": "5.65.15", "main": "lib/codemirror.js", "style": "lib/codemirror.css", "author": { diff --git a/src/edit/main.js b/src/edit/main.js index 834e27eb45..f69663b6fe 100644 --- a/src/edit/main.js +++ b/src/edit/main.js @@ -66,4 +66,4 @@ import { addLegacyProps } from "./legacy.js" addLegacyProps(CodeMirror) -CodeMirror.version = "5.65.14" +CodeMirror.version = "5.65.15" From 638abda97cf458d9243804b75de53714209e8632 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Fri, 1 Sep 2023 08:56:11 +0200 Subject: [PATCH 2410/2444] [go mode] Allow underscore separators in numbers Closes https://github.com/codemirror/codemirror5/issues/7059 --- mode/go/go.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mode/go/go.js b/mode/go/go.js index 8dbdc65d1c..bd54f1ab03 100644 --- a/mode/go/go.js +++ b/mode/go/go.js @@ -46,11 +46,11 @@ CodeMirror.defineMode("go", function(config) { } if (/[\d\.]/.test(ch)) { if (ch == ".") { - stream.match(/^[0-9]+([eE][\-+]?[0-9]+)?/); + stream.match(/^[0-9_]+([eE][\-+]?[0-9_]+)?/); } else if (ch == "0") { - stream.match(/^[xX][0-9a-fA-F]+/) || stream.match(/^0[0-7]+/); + stream.match(/^[xX][0-9a-fA-F_]+/) || stream.match(/^[0-7_]+/); } else { - stream.match(/^[0-9]*\.?[0-9]*([eE][\-+]?[0-9]+)?/); + stream.match(/^[0-9_]*\.?[0-9_]*([eE][\-+]?[0-9_]+)?/); } return "number"; } From ee6a1d201f748fa6b777513e4998eb652df896ed Mon Sep 17 00:00:00 2001 From: Parker Lougheed Date: Sun, 10 Sep 2023 10:35:37 -0500 Subject: [PATCH 2411/2444] [dart mode] Remove support for inline keyword --- mode/dart/dart.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mode/dart/dart.js b/mode/dart/dart.js index f81e4f91a4..ba9ff3dd2c 100644 --- a/mode/dart/dart.js +++ b/mode/dart/dart.js @@ -15,7 +15,7 @@ "implements mixin get native set typedef with enum throw rethrow assert break case " + "continue default in return new deferred async await covariant try catch finally " + "do else for if switch while import library export part of show hide is as extension " + - "on yield late required sealed base interface when inline").split(" "); + "on yield late required sealed base interface when").split(" "); var blockKeywords = "try catch finally do else for if switch while".split(" "); var atoms = "true false null".split(" "); var builtins = "void bool num int double dynamic var String Null Never".split(" "); From 53faa33ac69598b7495e160824b58ebb8d70fe97 Mon Sep 17 00:00:00 2001 From: Parker Lougheed Date: Sun, 10 Sep 2023 10:36:12 -0500 Subject: [PATCH 2412/2444] [dart mdoe] Fix code example to compile and run with modern Dart versions --- mode/dart/index.html | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/mode/dart/index.html b/mode/dart/index.html index 88b8936dec..ee6128c1f7 100644 --- a/mode/dart/index.html +++ b/mode/dart/index.html @@ -29,33 +29,33 @@

                  Dart mode

                  import 'dart:math' show Random; void main() { - print(new Die(n: 12).roll()); + print(Die(n: 12).roll()); } // Define a class. class Die { // Define a class variable. - static Random shaker = new Random(); + static final Random shaker = Random(); // Define instance variables. - int sides, value; - - // Define a method using shorthand syntax. - String toString() => '$value'; + final int sides; + int? lastRoll; // Define a constructor. - Die({int n: 6}) { - if (4 <= n && n <= 20) { - sides = n; - } else { + Die({int n = 6}) : sides = n { + if (4 > n || n > 20) { // Support for errors and exceptions. - throw new ArgumentError(/* */); + throw ArgumentError(/* */); } } + // Define a method using shorthand syntax. + @override + String toString() => '$lastRoll'; + // Define an instance method. int roll() { - return value = shaker.nextInt(sides) + 1; + return lastRoll = shaker.nextInt(sides) + 1; } } From 3bb9e7a38a9b95c66538676100fcced9cfe264ef Mon Sep 17 00:00:00 2001 From: Gabriela Gutierrez Date: Thu, 21 Sep 2023 11:27:55 -0300 Subject: [PATCH 2413/2444] Ref actions by commit SHA in ci.yml It's important to make sure the SHA's are from the original repositories and not forks. For reference: https://github.com/actions/checkout/releases/tag/v4.0.0 https://github.com/actions/checkout/commit/3df4ab11eba7bda6032a0b82a6bb43b11571feac https://github.com/actions/cache/releases/tag/v3.3.2 https://github.com/actions/cache/commit/704facf57e6136b1bc63b828d79edcd491f0ee84 Signed-off-by: Gabriela Gutierrez --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 82d6354155..d0a07b4e07 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,9 +5,9 @@ jobs: runs-on: ubuntu-latest name: Build and test steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac #v4.0.0 - - uses: actions/cache@v2 + - uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 #v3.3.2 with: path: '/home/runner/work/codemirror/codemirror5/node_modules' key: ${{ runner.os }}-modules From 2329ebb19b9846d1306c2379a5c85858df85e71f Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Wed, 18 Oct 2023 17:54:08 +0200 Subject: [PATCH 2414/2444] Link to CM6 in readme --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e021f2bf7a..6f42e99c50 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,6 @@ -# CodeMirror +# CodeMirror 5 + +**NOTE:** [CodeMirror 6](https://codemirror.net/) exists, and is more mobile-friendly, more accessible, better designed, and much more actively maintained. [![Build Status](https://github.com/codemirror/codemirror5/workflows/main/badge.svg)](https://github.com/codemirror/codemirror5/actions) From bcb86262e8a2a606bfa13ed47f8c6171b4d37ac9 Mon Sep 17 00:00:00 2001 From: Luke Haas Date: Wed, 25 Oct 2023 17:13:13 +0100 Subject: [PATCH 2415/2444] [jsx mode] Support trailing-comma generics syntax in JSX with TS Issue https://github.com/codemirror/codemirror5/pull/7073 --- mode/jsx/jsx.js | 2 +- mode/jsx/test.js | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/mode/jsx/jsx.js b/mode/jsx/jsx.js index 1406ef195d..83141c0567 100644 --- a/mode/jsx/jsx.js +++ b/mode/jsx/jsx.js @@ -103,7 +103,7 @@ } function jsToken(stream, state, cx) { - if (stream.peek() == "<" && jsMode.expressionAllowed(stream, cx.state)) { + if (stream.peek() == "<" && !/,\s*>/.test(stream.string) && jsMode.expressionAllowed(stream, cx.state)) { state.context = new Context(CodeMirror.startState(xmlMode, jsMode.indent(cx.state, "", "")), xmlMode, 0, state.context) jsMode.skipExpression(cx.state) diff --git a/mode/jsx/test.js b/mode/jsx/test.js index 08a0d47c3e..606557363a 100644 --- a/mode/jsx/test.js +++ b/mode/jsx/test.js @@ -95,4 +95,6 @@ "[bracket&tag <][tag MyComponent] [attribute foo]=[string \"bar\"] [bracket&tag />]; [comment //ok]", "[bracket&tag <][tag MyComponent] [attribute foo]={[number 0]} [bracket&tag />]; [comment //error]") + TS("tsx_react_generics", + "[variable x] [operator =] [operator <] [variable T],[operator >] ([def v]: [type T]) [operator =>] [variable-2 v];") })() From adc4282471ee15e2c91b7da7d5398cd1b8eee978 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Fri, 27 Oct 2023 10:34:12 +0200 Subject: [PATCH 2416/2444] [jsx mode] Narrow test for trailing-comma generic Issue https://github.com/codemirror/codemirror5/pull/7073 --- mode/jsx/jsx.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mode/jsx/jsx.js b/mode/jsx/jsx.js index 83141c0567..35ac608e16 100644 --- a/mode/jsx/jsx.js +++ b/mode/jsx/jsx.js @@ -103,7 +103,8 @@ } function jsToken(stream, state, cx) { - if (stream.peek() == "<" && !/,\s*>/.test(stream.string) && jsMode.expressionAllowed(stream, cx.state)) { + if (stream.peek() == "<" && !stream.match(/^<([^<>]|<[^>]*>)+,\s*>/, false) && + jsMode.expressionAllowed(stream, cx.state)) { state.context = new Context(CodeMirror.startState(xmlMode, jsMode.indent(cx.state, "", "")), xmlMode, 0, state.context) jsMode.skipExpression(cx.state) From 676fc52bf13e8788636af2cd4519e6b50c1f5adc Mon Sep 17 00:00:00 2001 From: Pavel Feldman Date: Fri, 10 Nov 2023 23:42:44 -0800 Subject: [PATCH 2417/2444] Make active element tracking work inside closed shadow roots --- src/display/operations.js | 4 ++-- src/display/update_display.js | 6 +++--- src/edit/fromTextArea.js | 4 ++-- src/edit/key_events.js | 4 ++-- src/edit/methods.js | 4 ++-- src/edit/mouse_events.js | 6 +++--- src/input/ContentEditableInput.js | 8 ++++---- src/input/TextareaInput.js | 4 ++-- src/util/dom.js | 14 ++++++++++++-- 9 files changed, 32 insertions(+), 22 deletions(-) diff --git a/src/display/operations.js b/src/display/operations.js index b004575bb9..a7e8039e89 100644 --- a/src/display/operations.js +++ b/src/display/operations.js @@ -2,7 +2,7 @@ import { clipPos } from "../line/pos.js" import { findMaxLine } from "../line/spans.js" import { displayWidth, measureChar, scrollGap } from "../measurement/position_measurement.js" import { signal } from "../util/event.js" -import { activeElt, doc } from "../util/dom.js" +import { activeElt, root } from "../util/dom.js" import { finishOperation, pushOperation } from "../util/operation_group.js" import { ensureFocus } from "./focus.js" @@ -116,7 +116,7 @@ function endOperation_W2(op) { cm.display.maxLineChanged = false } - let takeFocus = op.focus && op.focus == activeElt(doc(cm)) + let takeFocus = op.focus && op.focus == activeElt(root(cm)) if (op.preparedSelection) cm.display.input.showSelection(op.preparedSelection, takeFocus) if (op.updatedDisplay || op.startHeight != cm.doc.height) diff --git a/src/display/update_display.js b/src/display/update_display.js index 63529d5188..665dc8c91a 100644 --- a/src/display/update_display.js +++ b/src/display/update_display.js @@ -3,7 +3,7 @@ import { heightAtLine, visualLineEndNo, visualLineNo } from "../line/spans.js" import { getLine, lineNumberFor } from "../line/utils_line.js" import { displayHeight, displayWidth, getDimensions, paddingVert, scrollGap } from "../measurement/position_measurement.js" import { mac, webkit } from "../util/browser.js" -import { activeElt, removeChildren, contains, win, doc } from "../util/dom.js" +import { activeElt, removeChildren, contains, win, root, rootNode } from "../util/dom.js" import { hasHandler, signal } from "../util/event.js" import { signalLater } from "../util/operation_group.js" import { indexOf } from "../util/misc.js" @@ -57,7 +57,7 @@ export function maybeClipScrollbars(cm) { function selectionSnapshot(cm) { if (cm.hasFocus()) return null - let active = activeElt(doc(cm)) + let active = activeElt(root(cm)) if (!active || !contains(cm.display.lineDiv, active)) return null let result = {activeElt: active} if (window.getSelection) { @@ -73,7 +73,7 @@ function selectionSnapshot(cm) { } function restoreSelection(snapshot) { - if (!snapshot || !snapshot.activeElt || snapshot.activeElt == activeElt(snapshot.activeElt.ownerDocument)) return + if (!snapshot || !snapshot.activeElt || snapshot.activeElt == activeElt(rootNode(snapshot.activeElt))) return snapshot.activeElt.focus() if (!/^(INPUT|TEXTAREA)$/.test(snapshot.activeElt.nodeName) && snapshot.anchorNode && contains(document.body, snapshot.anchorNode) && contains(document.body, snapshot.focusNode)) { diff --git a/src/edit/fromTextArea.js b/src/edit/fromTextArea.js index cdd10d74a0..cbad7f6eb4 100644 --- a/src/edit/fromTextArea.js +++ b/src/edit/fromTextArea.js @@ -1,5 +1,5 @@ import { CodeMirror } from "./CodeMirror.js" -import { activeElt } from "../util/dom.js" +import { activeElt, rootNode } from "../util/dom.js" import { off, on } from "../util/event.js" import { copyObj } from "../util/misc.js" @@ -13,7 +13,7 @@ export function fromTextArea(textarea, options) { // Set autofocus to true if this textarea is focused, or if it has // autofocus and no other element is focused. if (options.autofocus == null) { - let hasFocus = activeElt(textarea.ownerDocument) + let hasFocus = activeElt(rootNode(textarea)) options.autofocus = hasFocus == textarea || textarea.getAttribute("autofocus") != null && hasFocus == document.body } diff --git a/src/edit/key_events.js b/src/edit/key_events.js index 1d3c9f908c..737d11d89b 100644 --- a/src/edit/key_events.js +++ b/src/edit/key_events.js @@ -3,7 +3,7 @@ import { restartBlink } from "../display/selection.js" import { isModifierKey, keyName, lookupKey } from "../input/keymap.js" import { eventInWidget } from "../measurement/widgets.js" import { ie, ie_version, mac, presto, gecko } from "../util/browser.js" -import { activeElt, addClass, rmClass, doc } from "../util/dom.js" +import { activeElt, addClass, rmClass, root } from "../util/dom.js" import { e_preventDefault, off, on, signalDOMEvent } from "../util/event.js" import { hasCopyEvent } from "../util/feature_detection.js" import { Delayed, Pass } from "../util/misc.js" @@ -107,7 +107,7 @@ let lastStoppedKey = null export function onKeyDown(e) { let cm = this if (e.target && e.target != cm.display.input.getField()) return - cm.curOp.focus = activeElt(doc(cm)) + cm.curOp.focus = activeElt(root(cm)) if (signalDOMEvent(cm, e)) return // IE does strange things with escape. if (ie && ie_version < 11 && e.keyCode == 27) e.returnValue = false diff --git a/src/edit/methods.js b/src/edit/methods.js index b1cbcc9e2e..9fb8787522 100644 --- a/src/edit/methods.js +++ b/src/edit/methods.js @@ -1,7 +1,7 @@ import { deleteNearSelection } from "./deleteNearSelection.js" import { commands } from "./commands.js" import { attachDoc } from "../model/document_data.js" -import { activeElt, addClass, rmClass, doc, win } from "../util/dom.js" +import { activeElt, addClass, rmClass, root, win } from "../util/dom.js" import { eventMixin, signal } from "../util/event.js" import { getLineStyles, getContextBefore, takeToken } from "../line/highlight.js" import { indentLine } from "../input/indent.js" @@ -358,7 +358,7 @@ export default function(CodeMirror) { signal(this, "overwriteToggle", this, this.state.overwrite) }, - hasFocus: function() { return this.display.input.getField() == activeElt(doc(this)) }, + hasFocus: function() { return this.display.input.getField() == activeElt(root(this)) }, isReadOnly: function() { return !!(this.options.readOnly || this.doc.cantEdit) }, scrollTo: methodOp(function (x, y) { scrollToCoords(this, x, y) }), diff --git a/src/edit/mouse_events.js b/src/edit/mouse_events.js index e854d64791..421e70b2a7 100644 --- a/src/edit/mouse_events.js +++ b/src/edit/mouse_events.js @@ -9,7 +9,7 @@ import { normalizeSelection, Range, Selection } from "../model/selection.js" import { extendRange, extendSelection, replaceOneSelection, setSelection } from "../model/selection_updates.js" import { captureRightClick, chromeOS, ie, ie_version, mac, webkit, safari } from "../util/browser.js" import { getOrder, getBidiPartAt } from "../util/bidi.js" -import { activeElt, doc as getDoc, win } from "../util/dom.js" +import { activeElt, root, win } from "../util/dom.js" import { e_button, e_defaultPrevented, e_preventDefault, e_target, hasHandler, off, on, signal, signalDOMEvent } from "../util/event.js" import { dragAndDrop } from "../util/feature_detection.js" import { bind, countColumn, findColumn, sel_mouse } from "../util/misc.js" @@ -128,7 +128,7 @@ function configureMouse(cm, repeat, event) { function leftButtonDown(cm, pos, repeat, event) { if (ie) setTimeout(bind(ensureFocus, cm), 0) - else cm.curOp.focus = activeElt(getDoc(cm)) + else cm.curOp.focus = activeElt(root(cm)) let behavior = configureMouse(cm, repeat, event) @@ -292,7 +292,7 @@ function leftButtonSelect(cm, event, start, behavior) { let cur = posFromMouse(cm, e, true, behavior.unit == "rectangle") if (!cur) return if (cmp(cur, lastPos) != 0) { - cm.curOp.focus = activeElt(getDoc(cm)) + cm.curOp.focus = activeElt(root(cm)) extendTo(cur) let visible = visibleLines(display, doc) if (cur.line >= visible.to || cur.line < visible.from) diff --git a/src/input/ContentEditableInput.js b/src/input/ContentEditableInput.js index f789af74ee..158ff24749 100644 --- a/src/input/ContentEditableInput.js +++ b/src/input/ContentEditableInput.js @@ -10,7 +10,7 @@ import { simpleSelection } from "../model/selection.js" import { setSelection } from "../model/selection_updates.js" import { getBidiPartAt, getOrder } from "../util/bidi.js" import { android, chrome, gecko, ie_version } from "../util/browser.js" -import { activeElt, contains, range, removeChildrenAndAdd, selectInput } from "../util/dom.js" +import { activeElt, contains, range, removeChildrenAndAdd, selectInput, rootNode } from "../util/dom.js" import { on, signalDOMEvent } from "../util/event.js" import { Delayed, lst, sel_dontScroll } from "../util/misc.js" @@ -97,7 +97,7 @@ export default class ContentEditableInput { disableBrowserMagic(te) cm.display.lineSpace.insertBefore(kludge, cm.display.lineSpace.firstChild) te.value = lastCopied.text.join("\n") - let hadFocus = activeElt(div.ownerDocument) + let hadFocus = activeElt(rootNode(div)) selectInput(te) setTimeout(() => { cm.display.lineSpace.removeChild(kludge) @@ -120,7 +120,7 @@ export default class ContentEditableInput { prepareSelection() { let result = prepareSelection(this.cm, false) - result.focus = activeElt(this.div.ownerDocument) == this.div + result.focus = activeElt(rootNode(this.div)) == this.div return result } @@ -214,7 +214,7 @@ export default class ContentEditableInput { focus() { if (this.cm.options.readOnly != "nocursor") { - if (!this.selectionInEditor() || activeElt(this.div.ownerDocument) != this.div) + if (!this.selectionInEditor() || activeElt(rootNode(this.div)) != this.div) this.showSelection(this.prepareSelection(), true) this.div.focus() } diff --git a/src/input/TextareaInput.js b/src/input/TextareaInput.js index 0aac125b11..26a17281c4 100644 --- a/src/input/TextareaInput.js +++ b/src/input/TextareaInput.js @@ -6,7 +6,7 @@ import { eventInWidget } from "../measurement/widgets.js" import { simpleSelection } from "../model/selection.js" import { selectAll, setSelection } from "../model/selection_updates.js" import { captureRightClick, ie, ie_version, ios, mac, mobile, presto, webkit } from "../util/browser.js" -import { activeElt, removeChildrenAndAdd, selectInput } from "../util/dom.js" +import { activeElt, removeChildrenAndAdd, selectInput, rootNode } from "../util/dom.js" import { e_preventDefault, e_stop, off, on, signalDOMEvent } from "../util/event.js" import { hasSelection } from "../util/feature_detection.js" import { Delayed, sel_dontScroll } from "../util/misc.js" @@ -182,7 +182,7 @@ export default class TextareaInput { supportsTouch() { return false } focus() { - if (this.cm.options.readOnly != "nocursor" && (!mobile || activeElt(this.textarea.ownerDocument) != this.textarea)) { + if (this.cm.options.readOnly != "nocursor" && (!mobile || activeElt(rootNode(this.textarea)) != this.textarea)) { try { this.textarea.focus() } catch (e) {} // IE8 will throw if the textarea is display: none or not in DOM } diff --git a/src/util/dom.js b/src/util/dom.js index 6672645a8d..52fc9495ce 100644 --- a/src/util/dom.js +++ b/src/util/dom.js @@ -64,13 +64,14 @@ export function contains(parent, child) { } while (child = child.parentNode) } -export function activeElt(doc) { +export function activeElt(rootNode) { // IE and Edge may throw an "Unspecified Error" when accessing document.activeElement. // IE < 10 will throw when accessed while the page is loading or in an iframe. // IE > 9 and Edge will throw when accessed in an iframe if document.body is unavailable. + let doc = rootNode.ownerDocument || rootNode let activeElement try { - activeElement = doc.activeElement + activeElement = rootNode.activeElement } catch(e) { activeElement = doc.body || null } @@ -98,4 +99,13 @@ else if (ie) // Suppress mysterious IE10 errors export function doc(cm) { return cm.display.wrapper.ownerDocument } +export function root(cm) { + return rootNode(cm.display.wrapper) +} + +export function rootNode(element) { + // Detect modern browsers (2017+). + return element.getRootNode ? element.getRootNode() : element.ownerDocument +} + export function win(cm) { return doc(cm).defaultView } From e84384b4210bc35300994de07c6333666f2a5c9e Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Mon, 20 Nov 2023 10:57:37 +0100 Subject: [PATCH 2418/2444] Mark version 5.65.16 --- AUTHORS | 2 ++ CHANGELOG.md | 10 ++++++++++ doc/manual.html | 2 +- doc/releases.html | 8 ++++++++ index.html | 2 +- package.json | 2 +- src/edit/main.js | 2 +- 7 files changed, 24 insertions(+), 4 deletions(-) diff --git a/AUTHORS b/AUTHORS index 3dd26e0fbb..c38f088f68 100644 --- a/AUTHORS +++ b/AUTHORS @@ -301,6 +301,7 @@ fraxx001 Fredrik Borg FUJI Goro (gfx) fzipp +Gabriela Gutierrez Gabriel Gheorghian Gabriel Horner Gabriel Nahmias @@ -718,6 +719,7 @@ Panupong Pasupat paris Paris Paris Kasidiaris +Parker Lougheed Patil Arpith Patrick Kettner Patrick Stoica diff --git a/CHANGELOG.md b/CHANGELOG.md index 31c9043708..6ba18d2cd7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ +## 5.65.16 (2023-11-20) + +### Bug fixes + +Fix focus tracking in shadow DOM. + +[go mode](https://codemirror.net/5/mode/go/): Allow underscores in numbers. + +[jsx mode](https://codemirror.net/5/mode/jsx/index.html): Support TS generics marked by trailing comma. + ## 5.65.15 (2023-08-29) ### Bug fixes diff --git a/doc/manual.html b/doc/manual.html index 7496ff277a..2a915729e3 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -70,7 +70,7 @@

                  User manual and reference guide - version 5.65.15 + version 5.65.16

                  CodeMirror is a code-editor component that can be embedded in diff --git a/doc/releases.html b/doc/releases.html index 5d94bad1fb..9777ec70ea 100644 --- a/doc/releases.html +++ b/doc/releases.html @@ -34,6 +34,14 @@

                  Version 6.x

                  Version 5.x

                  +

                  20-11-2023: Version 5.65.16:

                  + +
                    +
                  • Fix focus tracking in shadow DOM.
                  • +
                  • go mode: Allow underscores in numbers.
                  • +
                  • jsx mode: Support TS generics marked by trailing comma.
                  • +
                  +

                  29-08-2023: Version 5.65.15:

                    diff --git a/index.html b/index.html index 319adcbaa9..28c0918d63 100644 --- a/index.html +++ b/index.html @@ -92,7 +92,7 @@

                    This is CodeMirror

                    - Get the current version: 5.65.15.
                    + Get the current version: 5.65.16.
                    You can see the code,
                    read the release notes,
                    or study the user manual. diff --git a/package.json b/package.json index eb0c44cf09..2c618b4db0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "codemirror", - "version": "5.65.15", + "version": "5.65.16", "main": "lib/codemirror.js", "style": "lib/codemirror.css", "author": { diff --git a/src/edit/main.js b/src/edit/main.js index f69663b6fe..650d09bd95 100644 --- a/src/edit/main.js +++ b/src/edit/main.js @@ -66,4 +66,4 @@ import { addLegacyProps } from "./legacy.js" addLegacyProps(CodeMirror) -CodeMirror.version = "5.65.15" +CodeMirror.version = "5.65.16" From 0c8456c3bc92fb3085ac636f5ed117df24e22ca7 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Thu, 29 Feb 2024 07:17:45 +0100 Subject: [PATCH 2419/2444] [duotone theme] Improve contrast on comment tokens Closes https://github.com/codemirror/codemirror5/issues/7087 --- theme/duotone-dark.css | 2 +- theme/duotone-light.css | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/theme/duotone-dark.css b/theme/duotone-dark.css index 88fdc76c8e..5373178e8d 100644 --- a/theme/duotone-dark.css +++ b/theme/duotone-dark.css @@ -26,7 +26,7 @@ CodeMirror template by Jan T. Sott (https://github.com/idleberg), adapted by Bra .cm-s-duotone-dark span.cm-variable-2, .cm-s-duotone-dark span.cm-variable-3, .cm-s-duotone-dark span.cm-type, .cm-s-duotone-dark span.cm-string-2, .cm-s-duotone-dark span.cm-url { color: #7a63ee; } .cm-s-duotone-dark span.cm-def, .cm-s-duotone-dark span.cm-tag, .cm-s-duotone-dark span.cm-builtin, .cm-s-duotone-dark span.cm-qualifier, .cm-s-duotone-dark span.cm-header, .cm-s-duotone-dark span.cm-em { color: #eeebff; } -.cm-s-duotone-dark span.cm-bracket, .cm-s-duotone-dark span.cm-comment { color: #6c6783; } +.cm-s-duotone-dark span.cm-bracket, .cm-s-duotone-dark span.cm-comment { color: #a7a5b2; } /* using #f00 red for errors, don't think any of the colorscheme variables will stand out enough, ... maybe by giving it a background-color ... */ .cm-s-duotone-dark span.cm-error, .cm-s-duotone-dark span.cm-invalidchar { color: #f00; } diff --git a/theme/duotone-light.css b/theme/duotone-light.css index d99480f7c4..a0a0b8336e 100644 --- a/theme/duotone-light.css +++ b/theme/duotone-light.css @@ -25,7 +25,7 @@ CodeMirror template by Jan T. Sott (https://github.com/idleberg), adapted by Bra .cm-s-duotone-light span.cm-variable-2, .cm-s-duotone-light span.cm-variable-3, .cm-s-duotone-light span.cm-type, .cm-s-duotone-light span.cm-string-2, .cm-s-duotone-light span.cm-url { color: #896724; } .cm-s-duotone-light span.cm-def, .cm-s-duotone-light span.cm-tag, .cm-s-duotone-light span.cm-builtin, .cm-s-duotone-light span.cm-qualifier, .cm-s-duotone-light span.cm-header, .cm-s-duotone-light span.cm-em { color: #2d2006; } -.cm-s-duotone-light span.cm-bracket, .cm-s-duotone-light span.cm-comment { color: #b6ad9a; } +.cm-s-duotone-light span.cm-bracket, .cm-s-duotone-light span.cm-comment { color: #6f6e6a; } /* using #f00 red for errors, don't think any of the colorscheme variables will stand out enough, ... maybe by giving it a background-color ... */ /* .cm-s-duotone-light span.cm-error { background: #896724; color: #728fcb; } */ From b7b1bbcb9668032f6ab16766e19572745c6326b9 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Wed, 3 Apr 2024 14:56:27 +0200 Subject: [PATCH 2420/2444] [crystal mode] Fix an infinite loop in tokenizing of heredoc strings Closes https://github.com/codemirror/codemirror5/issues/7092 --- mode/crystal/crystal.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mode/crystal/crystal.js b/mode/crystal/crystal.js index 73b0dbe13c..b22c5dbe41 100644 --- a/mode/crystal/crystal.js +++ b/mode/crystal/crystal.js @@ -379,7 +379,7 @@ return "string"; } - escaped = embed && stream.next() == "\\"; + escaped = stream.next() == "\\" && embed; } else { stream.next(); escaped = false; From 5a966343ec7c7f740f0dc01e4a8e7d0bd288c1ef Mon Sep 17 00:00:00 2001 From: David Foster Date: Fri, 19 Apr 2024 09:48:36 -0700 Subject: [PATCH 2421/2444] Add regression test for issue #4641 --- test/comment_test.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/comment_test.js b/test/comment_test.js index 7deda79138..2210667163 100644 --- a/test/comment_test.js +++ b/test/comment_test.js @@ -115,4 +115,9 @@ namespace = "comment_"; cm.setCursor(1, 0) cm.execCommand("toggleComment") }, "", "") + + test("toggleWithMultipleInnerComments", "javascript", function(cm) { + cm.execCommand("selectAll") + cm.execCommand("toggleComment") + }, "/* foo */\na\n/* bar */\nb", "// /* foo */\n// a\n// /* bar */\n// b") })(); From fec380ddc125419ab2ba47765442ea557a88d611 Mon Sep 17 00:00:00 2001 From: David Foster Date: Mon, 22 Apr 2024 12:46:40 -0700 Subject: [PATCH 2422/2444] Add regression test for issue #1975 --- test/comment_test.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/comment_test.js b/test/comment_test.js index 2210667163..7612f47e37 100644 --- a/test/comment_test.js +++ b/test/comment_test.js @@ -120,4 +120,16 @@ namespace = "comment_"; cm.execCommand("selectAll") cm.execCommand("toggleComment") }, "/* foo */\na\n/* bar */\nb", "// /* foo */\n// a\n// /* bar */\n// b") + + var before = 'console.log("//string gets corrupted.");'; + var after = '// console.log("//string gets corrupted.");'; + test("toggleWithStringContainingComment1", "javascript", function(cm) { + cm.setCursor({line: 0, ch: 16 /* after // inside string */}); + cm.execCommand("toggleComment"); + }, before, after) + test("toggleWithStringContainingComment2", "javascript", function(cm) { + cm.setCursor({line: 0, ch: 16 /* after // inside string */}); + cm.execCommand("toggleComment"); + cm.execCommand("toggleComment"); + }, before, before) })(); From 064c9a880750a492c598433e6ddd155f836caaac Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Sat, 20 Jul 2024 16:24:23 +0200 Subject: [PATCH 2423/2444] Mark version 5.65.17 --- AUTHORS | 1 + CHANGELOG.md | 6 ++++++ doc/manual.html | 2 +- doc/releases.html | 6 ++++++ index.html | 2 +- package.json | 2 +- src/edit/main.js | 2 +- 7 files changed, 17 insertions(+), 4 deletions(-) diff --git a/AUTHORS b/AUTHORS index c38f088f68..5bc0ef4f48 100644 --- a/AUTHORS +++ b/AUTHORS @@ -218,6 +218,7 @@ Dave Brondsema Dave MacLachlan Dave Myers David Barnett +David Foster David H. Bronke David Mignot David Pathakjee diff --git a/CHANGELOG.md b/CHANGELOG.md index 6ba18d2cd7..81107b20dc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## 5.65.17 (2024-07-20) + +### Bug fixes + +[crystal mode](https://codemirror.net/5/mode/crystal/index.html): Fix an infinite loop bug when tokenizing heredoc strings. + ## 5.65.16 (2023-11-20) ### Bug fixes diff --git a/doc/manual.html b/doc/manual.html index 2a915729e3..9951e08cca 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -70,7 +70,7 @@

                    User manual and reference guide - version 5.65.16 + version 5.65.17

                    CodeMirror is a code-editor component that can be embedded in diff --git a/doc/releases.html b/doc/releases.html index 9777ec70ea..da9acb17aa 100644 --- a/doc/releases.html +++ b/doc/releases.html @@ -34,6 +34,12 @@

                    Version 6.x

                    Version 5.x

                    +

                    20-07-2024: Version 5.65.17:

                    + +
                      +
                    • crystal mode: Fix an infinite loop bug when tokenizing heredoc strings.
                    • +
                    +

                    20-11-2023: Version 5.65.16:

                      diff --git a/index.html b/index.html index 28c0918d63..0a61fa7693 100644 --- a/index.html +++ b/index.html @@ -92,7 +92,7 @@

                      This is CodeMirror

                      - Get the current version: 5.65.16.
                      + Get the current version: 5.65.17.
                      You can see the code,
                      read the release notes,
                      or study the user manual. diff --git a/package.json b/package.json index 2c618b4db0..37c4c86670 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "codemirror", - "version": "5.65.16", + "version": "5.65.17", "main": "lib/codemirror.js", "style": "lib/codemirror.css", "author": { diff --git a/src/edit/main.js b/src/edit/main.js index 650d09bd95..ad89b5a760 100644 --- a/src/edit/main.js +++ b/src/edit/main.js @@ -66,4 +66,4 @@ import { addLegacyProps } from "./legacy.js" addLegacyProps(CodeMirror) -CodeMirror.version = "5.65.16" +CodeMirror.version = "5.65.17" From 13eeec1ec2fe12571cd0b2feb57a1d575fc14355 Mon Sep 17 00:00:00 2001 From: "Allef Santana (garug)" Date: Thu, 1 Aug 2024 12:18:54 -0300 Subject: [PATCH 2424/2444] [clojure mode] Enable brace folding --- mode/clojure/clojure.js | 1 + 1 file changed, 1 insertion(+) diff --git a/mode/clojure/clojure.js b/mode/clojure/clojure.js index 3305165808..78bf286606 100644 --- a/mode/clojure/clojure.js +++ b/mode/clojure/clojure.js @@ -281,6 +281,7 @@ CodeMirror.defineMode("clojure", function (options) { }, closeBrackets: {pairs: "()[]{}\"\""}, + fold: "brace", lineComment: ";;" }; }); From 48d159a49b1db89523df7834cb18b46ac142764b Mon Sep 17 00:00:00 2001 From: pkucode Date: Thu, 15 Aug 2024 23:46:23 +0800 Subject: [PATCH 2425/2444] Remove repeated words in comments Signed-off-by: pkucode --- addon/edit/matchbrackets.js | 2 +- doc/manual.html | 2 +- src/display/update_lines.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/addon/edit/matchbrackets.js b/addon/edit/matchbrackets.js index c342910ed5..0d1bcb662e 100644 --- a/addon/edit/matchbrackets.js +++ b/addon/edit/matchbrackets.js @@ -27,7 +27,7 @@ afterCursor = /(^| )cm-fat-cursor($| )/.test(cm.getWrapperElement().className) var re = bracketRegex(config) - // A cursor is defined as between two characters, but in in vim command mode + // A cursor is defined as between two characters, but in vim command mode // (i.e. not insert mode), the cursor is visually represented as a // highlighted box on top of the 2nd character. Otherwise, we allow matches // from before or after the cursor. diff --git a/doc/manual.html b/doc/manual.html index 9951e08cca..553ac6c731 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -3733,7 +3733,7 @@

                      Extending VIM

                      been mapped to their Vim equivalents. Finds a command based on the key (and cached keys if there is a multi-key sequence). Returns undefined if no key is matched, a noop function if a partial match is found (multi-key), - and a function to execute the bound command if a a key is matched. The + and a function to execute the bound command if a key is matched. The function always returns true. diff --git a/src/display/update_lines.js b/src/display/update_lines.js index f09524b605..efb68f4479 100644 --- a/src/display/update_lines.js +++ b/src/display/update_lines.js @@ -58,7 +58,7 @@ function updateWidgetHeight(line) { } // Compute the lines that are visible in a given viewport (defaults -// the the current scroll position). viewport may contain top, +// the current scroll position). viewport may contain top, // height, and ensure (see op.scrollToPos) properties. export function visibleLines(display, doc, viewport) { let top = viewport && viewport.top != null ? Math.max(0, viewport.top) : display.scroller.scrollTop From dd44c943cc25109d73041abb9f859581c4dec07a Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Wed, 28 Aug 2024 10:21:47 +0200 Subject: [PATCH 2426/2444] [groovy mode] Stop parsing interpolated variable names when hitting whitespace Closes https://github.com/codemirror/codemirror5/issues/7103 --- mode/groovy/groovy.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/mode/groovy/groovy.js b/mode/groovy/groovy.js index 89d0fe0854..24d886ebb1 100644 --- a/mode/groovy/groovy.js +++ b/mode/groovy/groovy.js @@ -129,10 +129,8 @@ CodeMirror.defineMode("groovy", function(config) { function tokenVariableDeref(stream, state) { var next = stream.match(/^(\.|[\w\$_]+)/) - if (!next) { - state.tokenize.pop() - return state.tokenize[state.tokenize.length-1](stream, state) - } + if (!next || !stream.match(next[0] == "." ? /^[\w$_]/ : /^\./)) state.tokenize.pop() + if (!next) return state.tokenize[state.tokenize.length-1](stream, state) return next[0] == "." ? null : "variable" } From e1b414d88d515b895add96df9d689fc9d0098fa0 Mon Sep 17 00:00:00 2001 From: Sam Rawlins Date: Thu, 5 Sep 2024 07:45:25 -0700 Subject: [PATCH 2427/2444] [dart mode] Support digit separators --- mode/dart/dart.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mode/dart/dart.js b/mode/dart/dart.js index ba9ff3dd2c..cbbf391cc5 100644 --- a/mode/dart/dart.js +++ b/mode/dart/dart.js @@ -44,6 +44,8 @@ blockKeywords: set(blockKeywords), builtin: set(builtins), atoms: set(atoms), + // clike numbers without the suffixes, and with '_' separators. + number: /^(?:0x[a-f\d_]+|(?:[\d_]+\.?[\d_]*|\.[\d_]+)(?:e[-+]?[\d_]+)?)/i, hooks: { "@": function(stream) { stream.eatWhile(/[\w\$_\.]/); From 81d004923d399fdb3af447fee63c5255e255d6f3 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Wed, 18 Sep 2024 09:29:02 +0200 Subject: [PATCH 2428/2444] Drop realworld.html page --- doc/realworld.html | 209 --------------------------------------------- index.html | 9 +- 2 files changed, 1 insertion(+), 217 deletions(-) delete mode 100644 doc/realworld.html diff --git a/doc/realworld.html b/doc/realworld.html deleted file mode 100644 index 4d822b36ab..0000000000 --- a/doc/realworld.html +++ /dev/null @@ -1,209 +0,0 @@ - - -CodeMirror: Real-world Uses - - - - - -
                      - -

                      CodeMirror real-world uses

                      - -

                      Create a pull - request if you'd like your project to be added to this list.

                      - - - -
                      - diff --git a/index.html b/index.html index 0a61fa7693..2bc4b9c083 100644 --- a/index.html +++ b/index.html @@ -128,14 +128,7 @@

                      Features

                      Community

                      CodeMirror is an open-source project shared under - an MIT license. It is the editor used in the - dev tools for - Firefox, - Chrome, - and Safari, in Light - Table, Adobe - Brackets, Bitbucket, - and many other projects.

                      + an MIT license.

                      Development and bug tracking happens on github From 998f328b6b01217f6ef9e958ce3a128daddc592e Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Fri, 20 Sep 2024 13:18:09 +0200 Subject: [PATCH 2429/2444] Mark version 5.65.18 --- AUTHORS | 2 ++ CHANGELOG.md | 8 ++++++++ doc/manual.html | 2 +- doc/releases.html | 7 +++++++ index.html | 2 +- package.json | 2 +- src/edit/main.js | 2 +- 7 files changed, 21 insertions(+), 4 deletions(-) diff --git a/AUTHORS b/AUTHORS index 5bc0ef4f48..db9c367183 100644 --- a/AUTHORS +++ b/AUTHORS @@ -41,6 +41,7 @@ alexey-k Alex Piggott Alf Eaton Aliaksei Chapyzhenka +Allef Santana (garug) Allen Sarkisyan Ami Fischman Amin Shali @@ -748,6 +749,7 @@ Pi Delport Pierre Gerold Pieter Ouwerkerk Piyush +pkucode Pontus Granström Pontus Melke prasanthj diff --git a/CHANGELOG.md b/CHANGELOG.md index 81107b20dc..665ec14023 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +## 5.65.18 (2024-09-20) + +### Bug fixes + +[dart mode](https://codemirror.net/5/mode/dart/index.html): Handle numeric separators. + +[groovy mode](https://codemirror.net/5/mode/groovy/index.html): Fix a bug in highlighting interpolated variable names. + ## 5.65.17 (2024-07-20) ### Bug fixes diff --git a/doc/manual.html b/doc/manual.html index 553ac6c731..ae992b3e6d 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -70,7 +70,7 @@

                      User manual and reference guide - version 5.65.17 + version 5.65.18

                      CodeMirror is a code-editor component that can be embedded in diff --git a/doc/releases.html b/doc/releases.html index da9acb17aa..de5d6f0b82 100644 --- a/doc/releases.html +++ b/doc/releases.html @@ -34,6 +34,13 @@

                      Version 6.x

                      Version 5.x

                      +

                      20-09-2024: Version 5.65.18:

                      + +
                        +
                      • dart mode: Handle numeric separators.
                      • +
                      • groovy mode: Fix a bug in highlighting interpolated variable names.
                      • +
                      +

                      20-07-2024: Version 5.65.17:

                        diff --git a/index.html b/index.html index 2bc4b9c083..0d823ad2cb 100644 --- a/index.html +++ b/index.html @@ -92,7 +92,7 @@

                        This is CodeMirror

                        - Get the current version: 5.65.17.
                        + Get the current version: 5.65.18.
                        You can see the code,
                        read the release notes,
                        or study the user manual. diff --git a/package.json b/package.json index 37c4c86670..2b4a0f237a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "codemirror", - "version": "5.65.17", + "version": "5.65.18", "main": "lib/codemirror.js", "style": "lib/codemirror.css", "author": { diff --git a/src/edit/main.js b/src/edit/main.js index ad89b5a760..d136287d12 100644 --- a/src/edit/main.js +++ b/src/edit/main.js @@ -66,4 +66,4 @@ import { addLegacyProps } from "./legacy.js" addLegacyProps(CodeMirror) -CodeMirror.version = "5.65.17" +CodeMirror.version = "5.65.18" From deee5c01586a7630fb0c1b32d4635fd4bb5fa545 Mon Sep 17 00:00:00 2001 From: "noor.masarwa" <62531656+Noormasarwa@users.noreply.github.com> Date: Tue, 22 Oct 2024 14:21:57 +0300 Subject: [PATCH 2430/2444] [gherkin mode]: Add support for Rule Example keywords Co-authored-by: Noor-Masarwe --- mode/gherkin/gherkin.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/mode/gherkin/gherkin.js b/mode/gherkin/gherkin.js index 196543e505..b6464310c9 100644 --- a/mode/gherkin/gherkin.js +++ b/mode/gherkin/gherkin.js @@ -155,6 +155,22 @@ CodeMirror.defineMode("gherkin", function () { state.inKeywordLine = true; return "keyword"; + // RULE + } else if (state.allowScenario && stream.match(/(規則|ルール|قانون|قواعد|חוק|قاعدة|Правило|Правила|Reegel|Regel|Règle|Regola|Regla|Regulă|Regul|Regula|Regel|Regel|Regula|Правило|Правила|Regel|Regola|Regul|Reeglid|Rule):/)) { + state.allowPlaceholders = false; + state.allowSteps = true; + state.allowBackground = false; + state.allowMultilineArgument = true; + return "keyword"; + + // EXAMPLE + } else if (state.allowScenario && stream.match(/(例子|例|サンプル|예|דוגמה|مثال|Үрнәк|Пример|Παράδειγμα|Exemplo|Exemple|Beispiel|Ejemplo|Example|Esempio|Örnek|Példa|Pavyzdys|Paraugs|Voorbeeld|Příklad|Príklad|Exemplu|Esempi):/)) { + state.allowPlaceholders = false; + state.allowSteps = true; + state.allowBackground = false; + state.allowMultilineArgument = true; + return "keyword"; + // INLINE STRING } else if (stream.match(/"[^"]*"?/)) { return "string"; From b60e456801640147f47609c141105d5d58fcb1e8 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Thu, 5 Dec 2024 10:33:40 +0100 Subject: [PATCH 2431/2444] [pascal mode] Make keywords case-insensitive Closes https://github.com/codemirror/codemirror5/pull/7113 --- mode/pascal/pascal.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mode/pascal/pascal.js b/mode/pascal/pascal.js index 062ea1189e..502f2c886b 100644 --- a/mode/pascal/pascal.js +++ b/mode/pascal/pascal.js @@ -72,7 +72,7 @@ CodeMirror.defineMode("pascal", function() { return "operator"; } stream.eatWhile(/[\w\$_]/); - var cur = stream.current(); + var cur = stream.current().toLowerCase(); if (keywords.propertyIsEnumerable(cur)) return "keyword"; if (atoms.propertyIsEnumerable(cur)) return "atom"; return "variable"; From 064ea16b7d1c0724ed1f63b2d6187435c9497a1e Mon Sep 17 00:00:00 2001 From: Beni Cherniavsky-Paskin Date: Mon, 11 Mar 2019 20:02:26 +0200 Subject: [PATCH 2432/2444] [theme demo] Fix dropdown losing choice on solarized light / dark Choosing "solarized dark" correctly sets .cm-s-solarized .cm-s-dark (as documented https://codemirror.net/doc/manual.html#option_theme). It then sets URL fragment to #solarized%20dark, which was looking for `solarized%20dark` in dropdown and failing. This commit makes both setting and getting URL fragment reliable. --- demo/theme.html | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/demo/theme.html b/demo/theme.html index e394aa266b..5fe7a57547 100644 --- a/demo/theme.html +++ b/demo/theme.html @@ -183,9 +183,10 @@

                        Theme Demo

                        function selectTheme() { var theme = input.options[input.selectedIndex].textContent; editor.setOption("theme", theme); - location.hash = "#" + theme; + location.hash = "#" + encodeURIComponent(theme); } - var choice = (location.hash && location.hash.slice(1)) || + var choice = (location.hash && + decodeURIComponent(location.hash.slice(1))) || (document.location.search && decodeURIComponent(document.location.search.slice(1))); if (choice) { @@ -193,7 +194,7 @@

                        Theme Demo

                        editor.setOption("theme", choice); } CodeMirror.on(window, "hashchange", function() { - var theme = location.hash.slice(1); + var theme = decodeURIComponent(location.hash.slice(1)); if (theme) { input.value = theme; selectTheme(); } }); From 187450ac140094ae30630bc209c88c9f1b278e67 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Tue, 11 Mar 2025 15:39:10 +0100 Subject: [PATCH 2433/2444] Upgrade actions/cache to v4 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d0a07b4e07..723792ec31 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,7 +7,7 @@ jobs: steps: - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac #v4.0.0 - - uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 #v3.3.2 + - uses: actions/cache@v4 with: path: '/home/runner/work/codemirror/codemirror5/node_modules' key: ${{ runner.os }}-modules From eed51d071bce00302f209d66b8d2cf908b2cb733 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Vr=C3=A1na?= Date: Sun, 16 Mar 2025 20:27:59 +0100 Subject: [PATCH 2434/2444] [sql mode] Support quoted identifier for PostgreSQL --- mode/sql/sql.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mode/sql/sql.js b/mode/sql/sql.js index d3983889f7..a386f5c6c3 100644 --- a/mode/sql/sql.js +++ b/mode/sql/sql.js @@ -421,6 +421,10 @@ CodeMirror.defineMode("sql", function(config, parserConfig) { atoms: set("false true null unknown"), operatorChars: /^[*\/+\-%<>!=&|^\/#@?~]/, backslashStringEscapes: false, + identifierQuote: "\"", // https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS + hooks: { + "\"": hookIdentifierDoublequote + }, dateSQL: set("date time timestamp"), support: set("decimallessFloat zerolessFloat binaryNumber hexNumber nCharCast charsetCast escapeConstant") }); From 8a5dcbb838e06fa01cba4d0b74d988ab66821c33 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Thu, 20 Mar 2025 17:27:04 +0100 Subject: [PATCH 2435/2444] Mark version 5.65.19 --- AUTHORS | 1 + CHANGELOG.md | 10 ++++++++++ doc/manual.html | 2 +- doc/releases.html | 8 ++++++++ index.html | 2 +- package.json | 2 +- src/edit/main.js | 2 +- 7 files changed, 23 insertions(+), 4 deletions(-) diff --git a/AUTHORS b/AUTHORS index db9c367183..b263596758 100644 --- a/AUTHORS +++ b/AUTHORS @@ -697,6 +697,7 @@ Nils Knappmeier Nina Pypchenko Nisarg Jhaveri nlwillia +noor.masarwa noragrossman Norman Rzepka Nouzbe diff --git a/CHANGELOG.md b/CHANGELOG.md index 665ec14023..ee12d024db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ +## 5.65.19 (2025-03-20) + +### Bug fixes + +[gherkin mode](https://codemirror.net/5/mode/gherkin/index.html): Add support for Rule Example keywords + +[pascal mode](https://codemirror.net/5/mode/pascal/index.html) Make keywords case-insensitive + +[sql mode](https://codemirror.net/5/mode/sql/) Support quoted identifier for PostgreSQL + ## 5.65.18 (2024-09-20) ### Bug fixes diff --git a/doc/manual.html b/doc/manual.html index ae992b3e6d..957a8f2fd1 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -70,7 +70,7 @@

                        User manual and reference guide - version 5.65.18 + version 5.65.19

                        CodeMirror is a code-editor component that can be embedded in diff --git a/doc/releases.html b/doc/releases.html index de5d6f0b82..4229243846 100644 --- a/doc/releases.html +++ b/doc/releases.html @@ -34,6 +34,14 @@

                        Version 6.x

                        Version 5.x

                        +

                        20-03-2025: Version 5.65.19:

                        + + +

                        20-09-2024: Version 5.65.18:

                          diff --git a/index.html b/index.html index 0d823ad2cb..9190bf20f2 100644 --- a/index.html +++ b/index.html @@ -92,7 +92,7 @@

                          This is CodeMirror

                          - Get the current version: 5.65.18.
                          + Get the current version: 5.65.19.
                          You can see the code,
                          read the release notes,
                          or study the user manual. diff --git a/package.json b/package.json index 2b4a0f237a..6273631203 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "codemirror", - "version": "5.65.18", + "version": "5.65.19", "main": "lib/codemirror.js", "style": "lib/codemirror.css", "author": { diff --git a/src/edit/main.js b/src/edit/main.js index d136287d12..a27507456b 100644 --- a/src/edit/main.js +++ b/src/edit/main.js @@ -66,4 +66,4 @@ import { addLegacyProps } from "./legacy.js" addLegacyProps(CodeMirror) -CodeMirror.version = "5.65.18" +CodeMirror.version = "5.65.19" From 1df33b7ac759488da69d8d83a792636e7c08c2e2 Mon Sep 17 00:00:00 2001 From: Zaid Daba'een Date: Mon, 31 Mar 2025 13:50:52 +0300 Subject: [PATCH 2436/2444] clip-path issue fixed in Chrome 106 In Chrome 105, `clip-path` needed to be set as pointer events were ineffective outside CodeMirror editor instance but within paddings and margins of its elements. This has been resolved in Chrome 106 as seen [here](https://issues.chromium.org/issues/40863245#comment21). --- src/display/Display.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/display/Display.js b/src/display/Display.js index 28d8dbb013..201e81c1cc 100644 --- a/src/display/Display.js +++ b/src/display/Display.js @@ -49,7 +49,7 @@ export function Display(place, doc, input, options) { // The element in which the editor lives. d.wrapper = elt("div", [d.scrollbarFiller, d.gutterFiller, d.scroller], "CodeMirror") // See #6982. FIXME remove when this has been fixed for a while in Chrome - if (chrome && chrome_version >= 105) d.wrapper.style.clipPath = "inset(0px)" + if (chrome && chrome_version === 105) d.wrapper.style.clipPath = "inset(0px)" // This attribute is respected by automatic translation systems such as Google Translate, // and may also be respected by tools used by human translators. From 98e86d1ae3fc8b6353e511bf25cf7adac7b03482 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Fri, 18 Jul 2025 07:55:08 +0200 Subject: [PATCH 2437/2444] [gas mode] Define text/x-gas mime type Closes https://github.com/codemirror/codemirror5/issues/7134 --- mode/gas/gas.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mode/gas/gas.js b/mode/gas/gas.js index db09a8af08..cbf08586fc 100644 --- a/mode/gas/gas.js +++ b/mode/gas/gas.js @@ -350,4 +350,6 @@ CodeMirror.defineMode("gas", function(_config, parserConfig) { }; }); +CodeMirror.defineMIME("text/x-gas", "gas"); + }); From 9f1450da47dd6ce43bb54491415364782970fe98 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Sun, 10 Aug 2025 10:22:41 +0200 Subject: [PATCH 2438/2444] [show-hint addon] Fix incorrectly applied offset Closes https://github.com/codemirror/codemirror5/pull/7129 --- addon/hint/show-hint.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addon/hint/show-hint.js b/addon/hint/show-hint.js index aaf1f643f4..eb448db7af 100644 --- a/addon/hint/show-hint.js +++ b/addon/hint/show-hint.js @@ -290,7 +290,7 @@ var height = box.bottom - box.top, spaceAbove = box.top - (pos.bottom - pos.top) - 2 if (winH - box.top < spaceAbove) { // More room at the top if (height > spaceAbove) hints.style.height = (height = spaceAbove) + "px"; - hints.style.top = ((top = pos.top - height) + offsetTop) + "px"; + hints.style.top = ((top = pos.top - height) - offsetTop) + "px"; below = false; } else { hints.style.height = (winH - box.top - 2) + "px"; From b0c45cf0fbd3dc7cb2016a79fb81c723827f4e31 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Sun, 10 Aug 2025 10:30:49 +0200 Subject: [PATCH 2439/2444] Mark version 5.65.20 --- AUTHORS | 1 + CHANGELOG.md | 8 ++++++++ doc/manual.html | 2 +- doc/releases.html | 7 +++++++ index.html | 2 +- package.json | 2 +- src/edit/main.js | 2 +- 7 files changed, 20 insertions(+), 4 deletions(-) diff --git a/AUTHORS b/AUTHORS index b263596758..c800afe9d5 100644 --- a/AUTHORS +++ b/AUTHORS @@ -978,6 +978,7 @@ Yuvi Panda Yvonnick Esnault Zac Anger Zachary Dremann +Zaid Daba'een ZeeshanNoor Zeno Rocha Zhang Hao diff --git a/CHANGELOG.md b/CHANGELOG.md index ee12d024db..8a7064be6a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +## 5.65.20 (2025-08-10) + +### Bug fixes + +[show-hint addon](https://codemirror.net/5/doc/manual.html#addon_show-hint): Fix a positioning issue when the tooltip is at the bottom of the screen. + +[gas mode](https://codemirror.net/5/mode/gas/index.html): Properly define the MIME type the mode's demo page mentions. + ## 5.65.19 (2025-03-20) ### Bug fixes diff --git a/doc/manual.html b/doc/manual.html index 957a8f2fd1..3ea659e970 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -70,7 +70,7 @@

                          User manual and reference guide - version 5.65.19 + version 5.65.20

                          CodeMirror is a code-editor component that can be embedded in diff --git a/doc/releases.html b/doc/releases.html index 4229243846..42227c7316 100644 --- a/doc/releases.html +++ b/doc/releases.html @@ -34,6 +34,13 @@

                          Version 6.x

                          Version 5.x

                          +

                          10-08-2025: Version 5.65.20:

                          + +
                            +
                          • show-hint addon: Fix a positioning issue when the tooltip is at the bottom of the screen. +
                          • gas mode: Properly define the MIME type the mode's demo page mentions. +
                          +

                          20-03-2025: Version 5.65.19:

                            diff --git a/index.html b/index.html index 9190bf20f2..7cc603ccbc 100644 --- a/index.html +++ b/index.html @@ -92,7 +92,7 @@

                            This is CodeMirror

                            - Get the current version: 5.65.19.
                            + Get the current version: 5.65.20.
                            You can see the code,
                            read the release notes,
                            or study the user manual. diff --git a/package.json b/package.json index 6273631203..330bfeb30a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "codemirror", - "version": "5.65.19", + "version": "5.65.20", "main": "lib/codemirror.js", "style": "lib/codemirror.css", "author": { diff --git a/src/edit/main.js b/src/edit/main.js index a27507456b..949d9d4031 100644 --- a/src/edit/main.js +++ b/src/edit/main.js @@ -66,4 +66,4 @@ import { addLegacyProps } from "./legacy.js" addLegacyProps(CodeMirror) -CodeMirror.version = "5.65.19" +CodeMirror.version = "5.65.20" From 876911012efc844bcbc8e6e764399cf28916d7a7 Mon Sep 17 00:00:00 2001 From: flofriday Date: Thu, 21 Aug 2025 14:47:06 +0200 Subject: [PATCH 2440/2444] [kotlin mode]: Fix unsigned long literal token --- mode/clike/clike.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mode/clike/clike.js b/mode/clike/clike.js index e9f441fc0a..f783dfc8f2 100644 --- a/mode/clike/clike.js +++ b/mode/clike/clike.js @@ -680,7 +680,7 @@ CodeMirror.defineMode("clike", function(config, parserConfig) { intendSwitch: false, indentStatements: false, multiLineStrings: true, - number: /^(?:0x[a-f\d_]+|0b[01_]+|(?:[\d_]+(\.\d+)?|\.\d+)(?:e[-+]?[\d_]+)?)(u|ll?|l|f)?/i, + number: /^(?:0x[a-f\d_]+|0b[01_]+|(?:[\d_]+(\.\d+)?|\.\d+)(?:e[-+]?[\d_]+)?)(ul?|l|f)?/i, blockKeywords: words("catch class do else finally for if where try while enum"), defKeywords: words("class val var object interface fun"), atoms: words("true false null this"), From be271d3b04487edeece41c27f7a2e2ac98faccc9 Mon Sep 17 00:00:00 2001 From: Hicham Omari Date: Tue, 16 Sep 2025 16:09:16 +0200 Subject: [PATCH 2441/2444] [clike mode] Correct a typo --- mode/clike/clike.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mode/clike/clike.js b/mode/clike/clike.js index f783dfc8f2..30c8f6e3aa 100644 --- a/mode/clike/clike.js +++ b/mode/clike/clike.js @@ -677,7 +677,7 @@ CodeMirror.defineMode("clike", function(config, parserConfig) { "ByteArray Char CharArray DeprecationLevel DoubleArray Enum FloatArray Function Int IntArray Lazy " + "LazyThreadSafetyMode LongArray Nothing ShortArray Unit" ), - intendSwitch: false, + indentSwitch: false, indentStatements: false, multiLineStrings: true, number: /^(?:0x[a-f\d_]+|0b[01_]+|(?:[\d_]+(\.\d+)?|\.\d+)(?:e[-+]?[\d_]+)?)(ul?|l|f)?/i, From 78555dd4ac9bc691f081eec8266a01d3fbcc0d4e Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Wed, 31 Dec 2025 15:24:27 +0100 Subject: [PATCH 2442/2444] Note AI code policy in CONTRIBUTING.md --- CONTRIBUTING.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8a216d49c6..3f5ba3d1c0 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -51,6 +51,11 @@ Note that we are not accepting any new addons or modes into the main distribution. If you've written such a module, please distribute it as a separate NPM package. +Code written by "AI" language models (either partially or fully) is +**not welcome**. Both because you cannot guarantee it's not parroting +copyrighted content, and because it tends to be of low quality and a +waste of time to review. + - Make sure you have a [GitHub Account](https://github.com/signup/free) - Fork [CodeMirror](https://github.com/codemirror/CodeMirror/) ([how to fork a repo](https://help.github.com/articles/fork-a-repo)) From cc753ef5d757f6879461949d03c2569a21854528 Mon Sep 17 00:00:00 2001 From: Joseph Olstad Date: Thu, 5 Feb 2026 15:14:52 -0500 Subject: [PATCH 2443/2444] Use Object.prototype.hasOwnProperty in copyObj FIX: Fix an issue where the code assumes input objects have their own `hasOwnProperty` method. --- src/util/misc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/misc.js b/src/util/misc.js index 6dc8d8615c..b6f1c8c96f 100644 --- a/src/util/misc.js +++ b/src/util/misc.js @@ -6,7 +6,7 @@ export function bind(f) { export function copyObj(obj, target, overwrite) { if (!target) target = {} for (let prop in obj) - if (obj.hasOwnProperty(prop) && (overwrite !== false || !target.hasOwnProperty(prop))) + if (Object.prototype.hasOwnProperty.call(obj, prop) && (overwrite !== false || !Object.prototype.hasOwnProperty.call(target, prop))) target[prop] = obj[prop] return target } From 24ee74bbf433e8d484097a6ea421818a621ca13c Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Sat, 7 Feb 2026 08:44:03 +0100 Subject: [PATCH 2444/2444] Mark version 5.65.21 --- AUTHORS | 3 +++ CHANGELOG.md | 8 ++++++++ doc/manual.html | 2 +- doc/releases.html | 7 ++++++- index.html | 2 +- package.json | 2 +- src/edit/main.js | 2 +- 7 files changed, 21 insertions(+), 5 deletions(-) diff --git a/AUTHORS b/AUTHORS index c800afe9d5..ab566080de 100644 --- a/AUTHORS +++ b/AUTHORS @@ -290,6 +290,7 @@ Filip Stollár Filype Pereira finalfantasia flack +flofriday Florian Felten Fons van der Plas Forbes Lindesay @@ -356,6 +357,7 @@ Hendrik Erz Hendrik Wallbaum Henrik Haugbølle Herculano Campos +Hicham Omari hidaiy Hiroyuki Makino hitsthings @@ -466,6 +468,7 @@ Joo Joost-Wim Boekesteijn José dBruxelles Joseph D. Purcell +Joseph Olstad Joseph Pecoraro Josh Barnes Josh Cohen diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a7064be6a..02544da534 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +## 5.65.21 (2026-02-07) + +### Bug fixes + +Better handle configuration objects with a null prototype. + +[kotlin mode](https://codemirror.net/5/mode/clike/): Fix tokenizing of unsigned long literals. + ## 5.65.20 (2025-08-10) ### Bug fixes diff --git a/doc/manual.html b/doc/manual.html index 3ea659e970..84fe6e965c 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -70,7 +70,7 @@

                            User manual and reference guide - version 5.65.20 + version 5.65.21

                            CodeMirror is a code-editor component that can be embedded in diff --git a/doc/releases.html b/doc/releases.html index 42227c7316..422232edff 100644 --- a/doc/releases.html +++ b/doc/releases.html @@ -34,7 +34,12 @@

                            Version 6.x

                            Version 5.x

                            -

                            10-08-2025: Version 5.65.20:

                            +

                            07-02-2026: Version 5.65.21:

                            + +
                              +
                            • Better handle configuration objects with a null prototype. +
                            • kotlin mode: Fix tokenizing of unsigned long literals. +
                            • show-hint addon: Fix a positioning issue when the tooltip is at the bottom of the screen. diff --git a/index.html b/index.html index 7cc603ccbc..d8c1e983bb 100644 --- a/index.html +++ b/index.html @@ -92,7 +92,7 @@

                              This is CodeMirror

                              - Get the current version: 5.65.20.
                              + Get the current version: 5.65.21.
                              You can see the code,
                              read the release notes,
                              or study the user manual. diff --git a/package.json b/package.json index 330bfeb30a..76a5175be7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "codemirror", - "version": "5.65.20", + "version": "5.65.21", "main": "lib/codemirror.js", "style": "lib/codemirror.css", "author": { diff --git a/src/edit/main.js b/src/edit/main.js index 949d9d4031..610a205c3e 100644 --- a/src/edit/main.js +++ b/src/edit/main.js @@ -66,4 +66,4 @@ import { addLegacyProps } from "./legacy.js" addLegacyProps(CodeMirror) -CodeMirror.version = "5.65.20" +CodeMirror.version = "5.65.21"