From 5b538d53f683c1203a847a1fc434b97542014156 Mon Sep 17 00:00:00 2001 From: Patrick Kettner Date: Sun, 15 Mar 2020 01:13:25 -0400 Subject: [PATCH 001/557] add missing CSS properties --- mode/css/css.js | 181 ++++++++++++++++++++++++++++-------------------- 1 file changed, 105 insertions(+), 76 deletions(-) diff --git a/mode/css/css.js b/mode/css/css.js index 05742c5c45..441ba4abfd 100644 --- a/mode/css/css.js +++ b/mode/css/css.js @@ -455,81 +455,98 @@ CodeMirror.defineMode("css", function(config, parserConfig) { "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-blend-mode", "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", + "animation-timing-function", "appearance", "azimuth", "backdrop-filter", + "backface-visibility", "background", "background-attachment", + "background-blend-mode", "background-clip", "background-color", + "background-image", "background-origin", "background-position", + "background-position-x", "background-position-y", "background-repeat", + "background-size", "baseline-shift", "binding", "bleed", "block-size", + "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", "caret-color", "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-rows", "grid-column", "grid-column-end", "grid-column-gap", - "grid-column-start", "grid-gap", "grid-row", "grid-row-end", "grid-row-gap", - "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", "justify-items", "justify-self", "left", "letter-spacing", - "line-break", "line-height", "line-stacking", "line-stacking-ruby", + "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", "caret-color", + "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", "contain", + "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-family", "font-feature-settings", "font-kerning", + "font-language-override", "font-optical-sizing", "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-variation-settings", "font-weight", "gap", + "grid", "grid-area", "grid-auto-columns", "grid-auto-flow", "grid-auto-rows", + "grid-column", "grid-column-end", "grid-column-gap", "grid-column-start", + "grid-gap", "grid-row", "grid-row-end", "grid-row-gap", "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", + "inset", "inset-block", "inset-block-end", "inset-block-start", "inset-inline", + "inset-inline-end", "inset-inline-start", "isolation", "justify-content", + "justify-items", "justify-self", "left", "letter-spacing", "line-break", + "line-height", "line-height-step", "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", - "marks", "marquee-direction", "marquee-loop", - "marquee-play-count", "marquee-speed", "marquee-style", "max-height", - "max-width", "min-height", "min-width", "mix-blend-mode", "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", "place-content", "place-items", "place-self", "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", + "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", + "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", + "offset-distance", "offset-path", "offset-position", "offset-rotate", + "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", "place-content", "place-items", "place-self", "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", "rotate", "rotation", "rotation-point", + "row-gap", "ruby-align", "ruby-overhang", "ruby-position", "ruby-span", + "scale", "scroll-behavior", "scroll-margin", "scroll-margin-block", + "scroll-margin-block-end", "scroll-margin-block-start", "scroll-margin-bottom", + "scroll-margin-inline", "scroll-margin-inline-end", + "scroll-margin-inline-start", "scroll-margin-left", "scroll-margin-right", + "scroll-margin-top", "scroll-padding", "scroll-padding-block", + "scroll-padding-block-end", "scroll-padding-block-start", + "scroll-padding-bottom", "scroll-padding-inline", "scroll-padding-inline-end", + "scroll-padding-inline-start", "scroll-padding-left", "scroll-padding-right", + "scroll-padding-top", "scroll-snap-align", "scroll-snap-type", + "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-combine-upright", "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", - "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", "will-change", "word-break", - "word-spacing", "word-wrap", "z-index", + "text-decoration-skip-ink", "text-decoration-style", "text-emphasis", + "text-emphasis-color", "text-emphasis-position", "text-emphasis-style", + "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", + "transform-style", "transition", "transition-delay", "transition-duration", + "transition-property", "transition-timing-function", "translate", + "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", + "will-change", "word-break", "word-spacing", "word-wrap", "writing-mode", "z-index", // SVG-specific "clip-path", "clip-rule", "mask", "enable-background", "filter", "flood-color", "flood-opacity", "lighting-color", "stop-color", "stop-opacity", "pointer-events", @@ -543,16 +560,28 @@ CodeMirror.defineMode("css", function(config, parserConfig) { ], propertyKeywords = keySet(propertyKeywords_); var nonStandardPropertyKeywords_ = [ + "border-block", "border-block-color", "border-block-end", + "border-block-end-color", "border-block-end-style", "border-block-end-width", + "border-block-start", "border-block-start-color", "border-block-start-style", + "border-block-start-width", "border-block-style", "border-block-width", + "border-inline", "border-inline-color", "border-inline-end", + "border-inline-end-color", "border-inline-end-style", + "border-inline-end-width", "border-inline-start", "border-inline-start-color", + "border-inline-start-style", "border-inline-start-width", + "border-inline-style", "border-inline-width", "margin-block", + "margin-block-end", "margin-block-start", "margin-inline", "margin-inline-end", + "margin-inline-start", "padding-block", "padding-block-end", + "padding-block-start", "padding-inline", "padding-inline-end", + "padding-inline-start", "scroll-snap-stop", "scrollbar-3d-light-color", "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" + "scrollbar-track-color", "searchfield-cancel-button", "searchfield-decoration", + "searchfield-results-button", "searchfield-results-decoration", "shape-inside", "zoom" ], nonStandardPropertyKeywords = keySet(nonStandardPropertyKeywords_); var fontProperties_ = [ - "font-family", "src", "unicode-range", "font-variant", "font-feature-settings", - "font-stretch", "font-weight", "font-style" + "font-display", "font-family", "src", "unicode-range", "font-variant", + "font-feature-settings", "font-stretch", "font-weight", "font-style" ], fontProperties = keySet(fontProperties_); var counterDescriptors_ = [ From 519c520989c7a2cfc1e4e721bedee24e867ef6c2 Mon Sep 17 00:00:00 2001 From: Erik Welander Date: Wed, 18 Mar 2020 00:07:04 -0700 Subject: [PATCH 002/557] [vim bindings] Disable autocorrect for prompt --- keymap/vim.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/keymap/vim.js b/keymap/vim.js index ce5983d824..accc7d3c02 100644 --- a/keymap/vim.js +++ b/keymap/vim.js @@ -4186,7 +4186,8 @@ } function makePrompt(prefix, desc) { var raw = '' + - (prefix || "") + ''; + (prefix || "") + ''; if (desc) raw += ' ' + desc + ''; return raw; From e7b2c6466446e4ff1455a726b06e36fd1d7f5cca Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Wed, 18 Mar 2020 08:08:52 +0100 Subject: [PATCH 003/557] [zenburn theme] Improve specificity of background selector Closes #6180 --- theme/zenburn.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/theme/zenburn.css b/theme/zenburn.css index 781c40acac..4eb4247c92 100644 --- a/theme/zenburn.css +++ b/theme/zenburn.css @@ -11,7 +11,7 @@ .cm-s-zenburn .CodeMirror-gutters { background: #3f3f3f !important; } .cm-s-zenburn .CodeMirror-foldgutter-open, .CodeMirror-foldgutter-folded { color: #999; } .cm-s-zenburn .CodeMirror-cursor { border-left: 1px solid white; } -.cm-s-zenburn { background-color: #3f3f3f; color: #dcdccc; } +.cm-s-zenburn.CodeMirror { background-color: #3f3f3f; color: #dcdccc; } .cm-s-zenburn span.cm-builtin { color: #dcdccc; font-weight: bold; } .cm-s-zenburn span.cm-comment { color: #7f9f7f; } .cm-s-zenburn span.cm-keyword { color: #f0dfaf; font-weight: bold; } From 9a970e7895103660c1ad51f853c228858b74e2ca Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Wed, 18 Mar 2020 10:54:37 +0100 Subject: [PATCH 004/557] Fix bug in viewport updating for content-sized editors Closes #6181 --- src/display/update_display.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/display/update_display.js b/src/display/update_display.js index 20798f590b..50228d1779 100644 --- a/src/display/update_display.js +++ b/src/display/update_display.js @@ -172,6 +172,8 @@ export function postUpdateDisplay(cm, update) { update.visible = visibleLines(cm.display, cm.doc, viewport) if (update.visible.from >= cm.display.viewFrom && update.visible.to <= cm.display.viewTo) break + } else if (first) { + update.visible = visibleLines(cm.display, cm.doc, viewport) } if (!updateDisplayIfNeeded(cm, update)) break updateHeightsInViewport(cm) From ac9e655bc02f10c6af511f923895a27ffe1957b6 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Fri, 20 Mar 2020 09:05:17 +0100 Subject: [PATCH 005/557] Mark version 5.52.2 --- AUTHORS | 7 +++++++ CHANGELOG.md | 14 ++++++++++++++ doc/manual.html | 2 +- doc/releases.html | 10 ++++++++++ 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 3fdc7869c7..bf6d245134 100644 --- a/AUTHORS +++ b/AUTHORS @@ -160,6 +160,7 @@ Christopher Pfohl Christopher Wallis Chunliang Lyu ciaranj +clone-it clso CodeAnimal CodeBitt @@ -307,6 +308,7 @@ Hasan Delibaş Hasan Karahan Heanes Hector Oswaldo Caballero +Hein Htat Hélio Hendrik Wallbaum Henrik Haugbølle @@ -328,6 +330,7 @@ idleberg Igor Petruk ilvalle Ilya Kharlamov +Ilya Zverev Ingo Richter Irakli Gozalishvili Ivan Kurnosov @@ -362,6 +365,7 @@ Jason Johnston Jason San Jose Jason Siefken Jayaprabhakar +Jay Contonio Jaydeep Solanki Jean Boussier Jeff Blaisdell @@ -630,6 +634,7 @@ paris Paris Paris Kasidiaris Patil Arpith +Patrick Kettner Patrick Stoica Patrick Strawderman Paul Garvin @@ -690,6 +695,7 @@ Roman Janusz Rrandom Rrrandom Ruslan Osmanov +rvalavicius Ryan Pangrle Ryan Petrello Ryan Prior @@ -812,6 +818,7 @@ Tyler Makaro Vadim Dyachenko Vadzim Ramanenka Vaibhav Sagar +vamshi.revu VapidWorx Vestimir Markov vf diff --git a/CHANGELOG.md b/CHANGELOG.md index 33bca5cd27..f1be7b8aad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,17 @@ +## 5.52.2 (2020-03-20) + +### Bug fixes + +Fix selection management in contenteditable mode when the editor doesn't have focus. + +Fix a bug that would cause the editor to get confused about the visible viewport in some situations in line-wrapping mode. + +[markdown mode](https://codemirror.net/mode/markdown/): Don't treat single dashes as setext header markers. + +[zenburn theme](https://codemirror.net/demo/theme.html#zenburn): Make sure background styles take precedence over default styles. + +[css mode](https://codemirror.net/mode/css/): Recognize a number of new properties. + ## 5.52.0 (2020-02-20) ### Bug fixes diff --git a/doc/manual.html b/doc/manual.html index 7aab576141..49c9290b30 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -69,7 +69,7 @@

User manual and reference guide - version 5.52.0 + version 5.52.2

CodeMirror is a code-editor component that can be embedded in diff --git a/doc/releases.html b/doc/releases.html index 0768d49a9f..cde1015d39 100644 --- a/doc/releases.html +++ b/doc/releases.html @@ -30,6 +30,16 @@

Release notes and version history

Version 5.x

+

20-03-2020: Version 5.52.2:

+ +
    +
  • Fix selection management in contenteditable mode when the editor doesn’t have focus.
  • +
  • Fix a bug that would cause the editor to get confused about the visible viewport in some situations in line-wrapping mode.
  • +
  • markdown mode: Don’t treat single dashes as setext header markers.
  • +
  • zenburn theme: Make sure background styles take precedence over default styles.
  • +
  • css mode: Recognize a number of new properties.
  • +
+

20-02-2020: Version 5.52.0:

    diff --git a/index.html b/index.html index 49b637f2d9..454234e9ab 100644 --- a/index.html +++ b/index.html @@ -99,7 +99,7 @@

    This is CodeMirror

    - Get the current version: 5.52.0.
    + Get the current version: 5.52.2.
    You can see the code,
    read the release notes,
    or study the user manual. diff --git a/package.json b/package.json index 84ef216a90..1317b0272c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "codemirror", - "version": "5.52.0", + "version": "5.52.2", "main": "lib/codemirror.js", "style": "lib/codemirror.css", "author": { diff --git a/src/edit/main.js b/src/edit/main.js index 3f16593b9f..2f3eb97f94 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.52.0" +CodeMirror.version = "5.52.2" From 115ff0a36056201028e5520f8409aee114e1a274 Mon Sep 17 00:00:00 2001 From: Matthew Casperson Date: Tue, 24 Mar 2020 15:38:33 +1000 Subject: [PATCH 006/557] [powershell mode] Don't highlight backslashes as errors --- mode/powershell/index.html | 4 ++++ mode/powershell/powershell.js | 2 +- mode/powershell/test.js | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/mode/powershell/index.html b/mode/powershell/index.html index 6bb7babce2..fae029826f 100644 --- a/mode/powershell/index.html +++ b/mode/powershell/index.html @@ -28,6 +28,10 @@

    PowerShell mode

    + + + +

    MIME types defined: text/webassembly.

    + \ No newline at end of file diff --git a/mode/wast/test.js b/mode/wast/test.js new file mode 100644 index 0000000000..4de7e0b267 --- /dev/null +++ b/mode/wast/test.js @@ -0,0 +1,35 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: https://codemirror.net/LICENSE + +(function() { + var mode = CodeMirror.getMode({indentUnit: 4}, "wast"); + function MT(name) {test.mode(name, mode, Array.prototype.slice.call(arguments, 1));} + + MT('number-test', + '[number 0]', + '[number 123]', + '[number nan]', + '[number inf]', + '[number infinity]', + '[number 0.1]', + '[number 123.0]', + '[number 12E+99]'); + + MT('string-literals-test', + '[string "foo"]', + '[string "\\"foo\\""]', + '[string "foo #\\"# bar"]'); + + MT('atom-test', + '[atom i32]', + '[atom i64]', + '[atom f32]', + '[atom f64]'); + + MT('keyword-test', + '[keyword br]', + '[keyword if]', + '[keyword loop]', + '[keyword i32.add]', + '[keyword local.get]') +})(); diff --git a/mode/wast/wast.js b/mode/wast/wast.js new file mode 100644 index 0000000000..24ec27a6f7 --- /dev/null +++ b/mode/wast/wast.js @@ -0,0 +1,41 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: https://codemirror.net/LICENSE + +(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('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: /anyfunc|mut|nop|block|if|then|else|loop|br|br_if|br_table|call|call_indirect|drop|end|return|local\.get|local\.set|tee_local|global\.get|global\.set|i32\.load|i64\.load|f32\.load|f64\.load|i32\.store|i64\.store|f32\.store|f64\.store|i32\.load8_s|i64\.load8_s|i32\.load8_u|i64\.load8_u|i32\.load16_s|i64\.load16_s|i32\.load16_u|i64\.load16_u|i64\.load32_s|i64\.load32_u|i32\.store8|i64\.store8|i32\.store16|i64\.store16|i32\.const|i64\.const|f32\.const|f64\.const|i32\.eqz|i64\.eqz|i32\.clz|i64\.clz|i32\.ctz|i64\.ctz|i32\.popcnt|i64\.popcnt|f32\.neg|f64\.neg|f32\.abs|f64\.abs|f32\.sqrt|f64\.sqrt|f32\.ceil|f64\.ceil|f32\.floor|f64\.floor|f32\.trunc|f64\.trunc|f32\.nearest|f64\.nearest|i32\.add|i64\.add|i32\.sub|i64\.sub|i32\.mul|i64\.mul|i32\.div_s|i64\.div_s|i32\.div_u|i64\.div_u|i32\.rem_s|i64\.rem_s|i32\.rem_u|i64\.rem_u|i32\.and|i64\.and|i32\.or|i64\.or|i32\.xor|i64\.xor|i32\.shl|i64\.shl|i32\.shr_s|i64\.shr_s|i32\.shr_u|i64\.shr_u|i32\.rotl|i64\.rotl|i32\.rotr|i64\.rotr|f32\.add|f64\.add|f32\.sub|f64\.sub|f32\.mul|f64\.mul|f32\.div|f64\.div|f32\.min|f64\.min|f32\.max|f64\.max|f32\.copysign|f64\.copysign|i32\.eq|i64\.eq|i32\.ne|i64\.ne|i32\.lt_s|i64\.lt_s|i32\.lt_u|i64\.lt_u|i32\.le_s|i64\.le_s|i32\.le_u|i64\.le_u|i32\.gt_s|i64\.gt_s|i32\.gt_u|i64\.gt_u|i32\.ge_s|i64\.ge_s|i32\.ge_u|i64\.ge_u|f32\.eq|f64\.eq|f32\.ne|f64\.ne|f32\.lt|f64\.lt|f32\.le|f64\.le|f32\.gt|f64\.gt|f32\.ge|f64\.ge|i64\.extend_s\/i32|i64\.extend_u\/i32|i32\.wrap\/i64|i32\.trunc_s\/f32|i64\.trunc_s\/f32|i32\.trunc_s\/f64|i64\.trunc_s\/f64|i32\.trunc_u\/f32|i64\.trunc_u\/f32|i32\.trunc_u\/f64|i64\.trunc_u\/f64|f32\.convert_s\/i32|f64\.convert_s\/i32|f32\.convert_s\/i64|f64\.convert_s\/i64|f32\.convert_u\/i32|f64\.convert_u\/i32|f32\.convert_u\/i64|f64\.convert_u\/i64|f64\.promote\/f32|f32\.demote\/f64|f32\.reinterpret\/i32|i32\.reinterpret\/f32|f64\.reinterpret\/i64|i64\.reinterpret\/f64|select|unreachable|current_memory|memory.size|grow_memory|memory.grow|type|func|param|result|local|global|module|table|memory|start|elem|data|offset|import|export/, token: "keyword"}, + {regex: /\b(i32|i64|f32|f64)\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"}, + {regex: /;;.*$/, token: "comment"}, + {regex: /\(/, indent: true}, + {regex: /\)/, dedent: true}, + ], + + comment: [ + {regex: /.*?;\)/, token: "comment", next: "start"}, + {regex: /.*/, token: "comment"}, + ], + + meta: { + dontIndentStates: ['comment'], + }, +}); + +// https://github.com/WebAssembly/design/issues/981 mentions text/webassembly, +// which seems like a reasonable choice, although it's not standard right now. +CodeMirror.defineMIME("text/webassembly", "wast"); + +}); \ No newline at end of file diff --git a/test/index.html b/test/index.html index 13f2b6dc92..b68ce18964 100644 --- a/test/index.html +++ b/test/index.html @@ -57,6 +57,7 @@ + + +

    Sponsors

    +

    These companies support development of this project:

    + +
+ From 0de283c59c2e1295114e73bba25b04ce0a3eec31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20L=C3=A1szl=C3=B3?= Date: Sat, 9 May 2020 09:10:18 +0200 Subject: [PATCH 046/557] [tcl mode] Add # as a lineComment --- mode/tcl/tcl.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mode/tcl/tcl.js b/mode/tcl/tcl.js index a7ec89c9e8..dec0662a60 100644 --- a/mode/tcl/tcl.js +++ b/mode/tcl/tcl.js @@ -131,7 +131,8 @@ CodeMirror.defineMode("tcl", function() { token: function(stream, state) { if (stream.eatSpace()) return null; return state.tokenize(stream, state); - } + }, + lineComment: "#" }; }); CodeMirror.defineMIME("text/x-tcl", "tcl"); From 8e260c23bcf3f222430f9fae0d22bd0b9fe272e0 Mon Sep 17 00:00:00 2001 From: Sam Rawlins Date: Tue, 12 May 2020 15:17:46 -0700 Subject: [PATCH 047/557] [dart mode] Add `late` and `required` keywords, `Null` and `Never` types --- mode/dart/dart.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mode/dart/dart.js b/mode/dart/dart.js index 6c601ae9ae..fe64517a5e 100644 --- a/mode/dart/dart.js +++ b/mode/dart/dart.js @@ -15,10 +15,10 @@ "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").split(" "); + "part of show hide is as extension on yield late required").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".split(" "); + var builtins = "void bool num int double dynamic var String Null Never".split(" "); function set(words) { var obj = {}; From a810aee8fc68cf99731b6377a15d2914f7863429 Mon Sep 17 00:00:00 2001 From: Boris K Date: Wed, 13 May 2020 18:42:55 +0200 Subject: [PATCH 048/557] [mode/meta] Remove unwanted space in TiddlyWiki mode name --- mode/meta.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mode/meta.js b/mode/meta.js index d44590f61f..9f64f41048 100644 --- a/mode/meta.js +++ b/mode/meta.js @@ -144,7 +144,7 @@ {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"}, + {name: "TiddlyWiki", mime: "text/x-tiddlywiki", mode: "tiddlywiki"}, {name: "Tiki wiki", mime: "text/tiki", mode: "tiki"}, {name: "TOML", mime: "text/x-toml", mode: "toml", ext: ["toml"]}, {name: "Tornado", mime: "text/x-tornado", mode: "tornado"}, From 0884405eb7f0903af0b0b074a07343f8ed680ac7 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Thu, 14 May 2020 08:40:59 +0200 Subject: [PATCH 049/557] [runmode addon] Add support for lookahead Closes codemirror/google-modes#300 --- addon/runmode/runmode-standalone.js | 10 ++++++---- addon/runmode/runmode.js | 5 ++++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/addon/runmode/runmode-standalone.js b/addon/runmode/runmode-standalone.js index e2137df9c9..f47af3f2f1 100644 --- a/addon/runmode/runmode-standalone.js +++ b/addon/runmode/runmode-standalone.js @@ -9,9 +9,11 @@ root.CodeMirror = {}; function splitLines(string){ return string.split(/\r?\n|\r/); }; -function StringStream(string) { +function StringStream(strings, i) { this.pos = this.start = 0; - this.string = string; + this.string = strings[i]; + this.strings = strings + this.i = i this.lineStart = 0; } StringStream.prototype = { @@ -67,7 +69,7 @@ StringStream.prototype = { try { return inner(); } finally { this.lineStart -= n; } }, - lookAhead: function() { return null } + lookAhead: function(n) { return this.strings[this.i + n] } }; CodeMirror.StringStream = StringStream; @@ -151,7 +153,7 @@ CodeMirror.runMode = function (string, modespec, callback, options) { var lines = splitLines(string), state = (options && options.state) || CodeMirror.startState(mode); for (var i = 0, e = lines.length; i < e; ++i) { if (i) callback("\n"); - var stream = new CodeMirror.StringStream(lines[i]); + var stream = new CodeMirror.StringStream(lines, i); if (!stream.string && mode.blankLine) mode.blankLine(state); while (!stream.eol()) { var style = mode.token(stream, state); diff --git a/addon/runmode/runmode.js b/addon/runmode/runmode.js index eb4cadf5b4..ca8d9a9c79 100644 --- a/addon/runmode/runmode.js +++ b/addon/runmode/runmode.js @@ -59,7 +59,10 @@ CodeMirror.runMode = function(string, modespec, callback, options) { var lines = CodeMirror.splitLines(string), state = (options && options.state) || CodeMirror.startState(mode); for (var i = 0, e = lines.length; i < e; ++i) { if (i) callback("\n"); - var stream = new CodeMirror.StringStream(lines[i]); + var stream = new CodeMirror.StringStream(lines[i], null, { + lookAhead: function(n) { return lines[i + n] }, + baseToken: function() {} + }); if (!stream.string && mode.blankLine) mode.blankLine(state); while (!stream.eol()) { var style = mode.token(stream, state); From 890cb6bea3e73118d69f4e279da1dff57d7e4627 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Thu, 14 May 2020 14:43:50 +0200 Subject: [PATCH 050/557] [javascript mode] Fix a runaway regexp Issue #6273 --- 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 c724b23726..c6577630fd 100644 --- a/mode/javascript/javascript.js +++ b/mode/javascript/javascript.js @@ -458,7 +458,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 == "<" && cx.stream.match(/^([^>]|<.*?>)*>\s*\(/, false)) + 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); From b6ac63e3c361834d1470ac386e98d13f40fc07f6 Mon Sep 17 00:00:00 2001 From: Ajin Abraham Date: Fri, 15 May 2020 00:03:40 +0530 Subject: [PATCH 051/557] Proper escaping of \s See: https://lgtm.com/rules/1510624619946/ --- 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 9835d4626a..7b4ca0b391 100644 --- a/src/line/highlight.js +++ b/src/line/highlight.js @@ -198,7 +198,7 @@ function extractLineClasses(type, output) { let prop = lineClass[1] ? "bgClass" : "textClass" if (output[prop] == null) output[prop] = lineClass[2] - else if (!(new RegExp("(?:^|\s)" + lineClass[2] + "(?:$|\s)")).test(output[prop])) + else if (!(new RegExp("(?:^|\\s)" + lineClass[2] + "(?:$|\\s)")).test(output[prop])) output[prop] += " " + lineClass[2] } return type From 25e7a32daa108026736ddbb9a71c5ebb0e9c375a Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Fri, 15 May 2020 17:10:20 +0200 Subject: [PATCH 052/557] [match-highlighter] Fix issue in highlighting non-alphanumeric tokens Closes #6279 --- addon/search/match-highlighter.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addon/search/match-highlighter.js b/addon/search/match-highlighter.js index b344ac79e2..3a4a7dedc1 100644 --- a/addon/search/match-highlighter.js +++ b/addon/search/match-highlighter.js @@ -90,7 +90,9 @@ var state = cm.state.matchHighlighter; cm.addOverlay(state.overlay = makeOverlay(query, hasBoundary, style)); if (state.options.annotateScrollbar && cm.showMatchesOnScrollbar) { - var searchFor = hasBoundary ? new RegExp("\\b" + query.replace(/[\\\[.+*?(){|^$]/g, "\\$&") + "\\b") : query; + var searchFor = hasBoundary ? new RegExp((/\w/.test(query.charAt(0)) ? "\\b" : "") + + query.replace(/[\\\[.+*?(){|^$]/g, "\\$&") + + (/\w/.test(query.charAt(query.length - 1)) ? "\\b" : "")) : query; state.matchesonscroll = cm.showMatchesOnScrollbar(searchFor, false, {className: "CodeMirror-selection-highlight-scrollbar"}); } From 8facd9030bfa385eaad0d937ee4b8155aa91d76c Mon Sep 17 00:00:00 2001 From: Ben Hormann Date: Thu, 14 May 2020 19:03:06 +0100 Subject: [PATCH 053/557] [vim] Allow Ex-Commands with non-word names --- keymap/vim.js | 2 +- test/vim_test.js | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/keymap/vim.js b/keymap/vim.js index 213602b6df..b5be59cc4b 100644 --- a/keymap/vim.js +++ b/keymap/vim.js @@ -4456,7 +4456,7 @@ } // Parse command name. - var commandMatch = inputStream.match(/^(\w+)/); + var commandMatch = inputStream.match(/^(\w+|!!|@@|[!#&*<=>@~])/); if (commandMatch) { result.commandName = commandMatch[1]; } else { diff --git a/test/vim_test.js b/test/vim_test.js index 7e06434cfc..7adace8e45 100644 --- a/test/vim_test.js +++ b/test/vim_test.js @@ -4479,6 +4479,37 @@ testVim('ex_api_test', function(cm, vim, helpers) { is(res,'Mapping to key failed'); CodeMirror.Vim.mapclear(); }); +// Testing ex-commands with non-alpha names. +testVim('ex_special_names', function(cm, vim, helpers) { + var ran,val; + var cmds = ['!','!!','#','&','*','<','=','>','@','@@','~','regtest1','RT2']; + cmds.forEach(function(name){ + CodeMirror.Vim.defineEx(name,'',function(cm,params){ + ran=params.commandName; + val=params.argString; + }); + helpers.doEx(':'+name); + eq(ran,name,'Running ex-command failed'); + helpers.doEx(':'+name+' x'); + eq(val,' x','Running ex-command with param failed: '+name); + if(/^\W+$/.test(name)){ + helpers.doEx(':'+name+'y'); + eq(val,'y','Running ex-command with param failed: '+name); + } + else{ + helpers.doEx(':'+name+'-y'); + eq(val,'-y','Running ex-command with param failed: '+name); + } + if(name!=='!'){ + helpers.doEx(':'+name+'!'); + eq(ran,name,'Running ex-command with bang failed'); + eq(val,'!','Running ex-command with bang failed: '+name); + helpers.doEx(':'+name+'!z'); + eq(ran,name,'Running ex-command with bang & param failed'); + eq(val,'!z','Running ex-command with bang & param failed: '+name); + } + }); +}); // For now, this test needs to be last because it messes up : for future tests. testVim('ex_map_key2key_from_colon', function(cm, vim, helpers) { helpers.doEx('map : x'); From e56014c9caf63fec9173da7a8591057475883b32 Mon Sep 17 00:00:00 2001 From: Axel Lewenhaupt Date: Sun, 17 May 2020 22:05:19 +0200 Subject: [PATCH 054/557] [soy mode] Fix bug with "map" in type name Co-authored-by: Axel Lewenhaupt --- mode/soy/soy.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/mode/soy/soy.js b/mode/soy/soy.js index 4de0f37638..1b19923da5 100644 --- a/mode/soy/soy.js +++ b/mode/soy/soy.js @@ -300,10 +300,10 @@ } else if (peekChar == "[") { state.soyState.push('param-type-record'); return null; + } else if (peekChar == "<") { + state.soyState.push('param-type-parameter'); + return null; } else if (match = stream.match(/^([\w]+|[?])/)) { - if (match[0] == "map" || match[0] == "list") { - state.soyState.push('param-type-map-list'); - } return "type"; } stream.next(); @@ -322,8 +322,7 @@ stream.next(); return null; - case "param-type-map-list": - var peekChar = stream.peek(); + case "param-type-parameter": if (stream.match(/^[>]/)) { state.soyState.pop(); return null; From 4377c08dddb11faea627d2c27ef62ab4381e9493 Mon Sep 17 00:00:00 2001 From: Jack Douglas Date: Mon, 18 May 2020 14:34:00 +0100 Subject: [PATCH 055/557] [gfm mode] add fencedCodeBlockDefaultMode option --- mode/markdown/index.html | 10 ++++++++-- mode/markdown/markdown.js | 5 ++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/mode/markdown/index.html b/mode/markdown/index.html index f0a359d600..da3fe61b98 100644 --- a/mode/markdown/index.html +++ b/mode/markdown/index.html @@ -388,13 +388,19 @@

Markdown mode

  • fencedCodeBlockHighlighting: boolean
    -
    Whether to syntax-highlight fenced code blocks, if given mode is included (default: true).
    +
    Whether to syntax-highlight fenced code blocks, if given mode is included, or fencedCodeBlockDefaultMode is set (default: true).
    +
    +
  • +
  • + +
    fencedCodeBlockDefaultMode: string
    +
    Mode to use for fencedCodeBlockHighlighting, if given mode is not included.
  • tokenTypeOverrides: Object
    -
    When you want ot override default token type names (e.g. {code: "code"}).
    +
    When you want to override default token type names (e.g. {code: "code"}).
  • diff --git a/mode/markdown/markdown.js b/mode/markdown/markdown.js index 6d1468cdc0..dcb048c5e3 100644 --- a/mode/markdown/markdown.js +++ b/mode/markdown/markdown.js @@ -47,6 +47,9 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) { if (modeCfg.fencedCodeBlockHighlighting === undefined) modeCfg.fencedCodeBlockHighlighting = true; + + if (modeCfg.fencedCodeBlockDefaultMode === undefined) + modeCfg.fencedCodeBlockDefaultMode = ''; if (modeCfg.xml === undefined) modeCfg.xml = true; @@ -236,7 +239,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) { state.quote = 0; state.fencedEndRE = new RegExp(match[1] + "+ *$"); // try switching mode - state.localMode = modeCfg.fencedCodeBlockHighlighting && getMode(match[2]); + state.localMode = modeCfg.fencedCodeBlockHighlighting && getMode(match[2] || modeCfg.fencedCodeBlockDefaultMode ); if (state.localMode) state.localState = CodeMirror.startState(state.localMode); state.f = state.block = local; if (modeCfg.highlightFormatting) state.formatting = "code-block"; From a5497d1c13f5742b6df963319e9abf30d510387a Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Wed, 20 May 2020 10:19:11 +0200 Subject: [PATCH 056/557] Mark version 5.54.0 --- AUTHORS | 7 +++++++ 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, 46 insertions(+), 4 deletions(-) diff --git a/AUTHORS b/AUTHORS index 91d5b50e4c..f5b5d7a6b6 100644 --- a/AUTHORS +++ b/AUTHORS @@ -20,6 +20,7 @@ aeroson Ahmad Amireh Ahmad M. Zawawi ahoward +Ajin Abraham Akeksandr Motsjonov Alasdair Smith AlbertHilb @@ -100,6 +101,7 @@ Bem Jones-Bey benbro Benedikt Meurer benhormann +Ben Hormann Beni Cherniavsky-Paskin Benjamin DeCoste Benjamin Young @@ -120,6 +122,7 @@ Bo boomyjee Bo Peng borawjm +Boris K Brad Metcalf Brandon Frohs Brandon Wamboldt @@ -216,6 +219,7 @@ Dick Choi Diego Fernandez dignifiedquire Dimage Sapelkin +Dinindu D. Wanniarachchi dmaclach Dmitry Kiselyov domagoj412 @@ -394,6 +398,7 @@ joelpinheiro joewalsh Johan Ask Johannes +John Chen John Connor John-David Dalton John Engler @@ -660,6 +665,7 @@ peter Peter Flynn peterkroon Peter Kroon +Peter László Philipp A Philipp Markovics Philip Stadermann @@ -805,6 +811,7 @@ Tim Gates Timothy Farrell Timothy Gu Timothy Hatcher +Tim van der Lippe Tobias Bertelsen TobiasBg Todd Berman diff --git a/CHANGELOG.md b/CHANGELOG.md index f448c65cb1..a445dd913a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,25 @@ +## 5.54.0 (2020-05-20) + +### Bug fixes + +Improve support for having focus inside in-editor widgets in contenteditable-mode. + +Fix issue where the scroll position could jump when clicking on a selection in Chrome. + +[python mode](https://codemirror.net/mode/python/): Better format string support. + +[javascript mode](https://codemirror.net/mode/javascript/): Improve parsing of private properties and class fields. + +[matchbrackets addon](https://codemirror.net/doc/manual.html#addon_matchbrackets): Disable highlighting when the editor doesn't have focus. + +### New features + +[runmode addon](https://codemirror.net/doc/manual.html#addon_runmode): Properly support for cross-line lookahead. + +[vim bindings](https://codemirror.net/demo/vim.html): Allow Ex-Commands with non-word names. + +[gfm mode](https://codemirror.net/mode/gfm/): Add a `fencedCodeBlockDefaultMode` option. + ## 5.53.2 (2020-04-21) ### Bug fixes diff --git a/doc/manual.html b/doc/manual.html index acf9f4a393..e8acb01f92 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -69,7 +69,7 @@

    User manual and reference guide - version 5.53.2 + version 5.54.0

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

    Release notes and version history

    Version 5.x

    +

    20-05-2020: Version 5.54.0:

    + +
      +
    • runmode addon: Properly support for cross-line lookahead.
    • +
    • vim bindings: Allow Ex-Commands with non-word names.
    • +
    • gfm mode: Add a fencedCodeBlockDefaultMode option.
    • +
    • Improve support for having focus inside in-editor widgets in contenteditable-mode.
    • +
    • Fix issue where the scroll position could jump when clicking on a selection in Chrome.
    • +
    • python mode: Better format string support.
    • +
    • javascript mode: Improve parsing of private properties and class fields.
    • +
    • matchbrackets addon: Disable highlighting when the editor doesn’t have focus.
    • +
    +

    21-04-2020: Version 5.53.2:

      diff --git a/index.html b/index.html index cbbe9081a0..59cac746fd 100644 --- a/index.html +++ b/index.html @@ -99,7 +99,7 @@

      This is CodeMirror

      - Get the current version: 5.53.2.
      + Get the current version: 5.54.0.
      You can see the code,
      read the release notes,
      or study the user manual. diff --git a/package.json b/package.json index cf5a462507..7956d37b97 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "codemirror", - "version": "5.53.2", + "version": "5.54.0", "main": "lib/codemirror.js", "style": "lib/codemirror.css", "author": { diff --git a/src/edit/main.js b/src/edit/main.js index f8a7cf8db1..e15243a415 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.53.2" +CodeMirror.version = "5.54.0" From 2571b4ad08e007c246d73bdd973892bf5dd7b02e Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Tue, 26 May 2020 10:12:54 +0200 Subject: [PATCH 057/557] Don't render zero-width joiners as a special character Since it'll often mess up emoji rendering Issue #4488 --- 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 225f5499c5..400e000327 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-\u009f\u00ad\u061c\u200b-\u200f\u2028\u2029\ufeff\ufff9-\ufffc]/g, (cm, val, old) => { + option("specialChars", /[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u200b-\u200c\u200e\u200f\u2028\u2029\ufeff\ufff9-\ufffc]/g, (cm, val, old) => { cm.state.specialChars = new RegExp(val.source + (val.test("\t") ? "" : "|\t"), "g") if (old != Init) cm.refresh() }) From a66f466e33fd274785b043ce308e745a9c6d08dc Mon Sep 17 00:00:00 2001 From: Siddhartha Gunti Date: Wed, 27 May 2020 01:28:10 +0530 Subject: [PATCH 058/557] [real-world uses] Add Adaface PairPro Adding Adaface PairPro (remote pair programming tool with code editor, compiler and video conference) for interviews. Added in alphabetical order. --- doc/realworld.html | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/realworld.html b/doc/realworld.html index 152b557668..b308b39adf 100644 --- a/doc/realworld.html +++ b/doc/realworld.html @@ -25,6 +25,7 @@

      CodeMirror real-world uses

      request if you'd like your project to be added to this list.

        +
      • Adaface PairPro (Shared code editor with compiler and video conferencing)
      • Adobe Brackets (code editor)
      • Adnuntius (used for in-browser code editing and version history)
      • ALM Tools (TypeScript powered IDE)
      • From b42ee0965e7ab931c775af886286a3a34a34705d Mon Sep 17 00:00:00 2001 From: benhormann Date: Fri, 29 May 2020 08:07:16 +0100 Subject: [PATCH 059/557] [vim] Fix vim-mode-change event being signalled twice --- keymap/vim.js | 2 +- test/vim_test.js | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/keymap/vim.js b/keymap/vim.js index b5be59cc4b..bca6d46d72 100644 --- a/keymap/vim.js +++ b/keymap/vim.js @@ -3203,7 +3203,7 @@ vim.visualMode = false; vim.visualLine = false; vim.visualBlock = false; - CodeMirror.signal(cm, "vim-mode-change", {mode: "normal"}); + if (!vim.insertMode) CodeMirror.signal(cm, "vim-mode-change", {mode: "normal"}); clearFakeCursor(vim); } diff --git a/test/vim_test.js b/test/vim_test.js index 7adace8e45..71284bdf59 100644 --- a/test/vim_test.js +++ b/test/vim_test.js @@ -1153,6 +1153,41 @@ testVim('s_visual_block', function(cm, vim, helpers) { eq('1hello{\n world\n', cm.getValue()); }, {value: '1234\n5678\nabcdefg\n'}); +// Test mode change event. It should only fire once per mode transition. +testVim('on_mode_change', function(cm, vim, helpers) { + var modeHist = []; + function callback(arg) { + var subMode = arg.subMode ? ':' + arg.subMode : ''; + modeHist.push(arg.mode + subMode); + } + helpers.doKeys('', ''); + cm.on('vim-mode-change', callback); + function test(key, mode) { + modeHist.length = 0; + helpers.doKeys(key); + eq(modeHist.join(';'), mode); + } + test('v', 'visual'); + test('c', 'insert'); + test('', 'normal'); + test('', 'visual:blockwise'); + test('I', 'insert'); + test('', 'normal'); + test('R', 'replace'); + test('x', ''); + test('', 'normal'); + test('v', 'visual'); + test('V', 'visual:linewise'); + test('', 'visual:blockwise'); + test('v', 'visual'); + test('', 'normal'); + test('a', 'insert'); + test('', 'normal'); + test('v', 'visual'); + test(':', ''); // Event for Command-line mode not implemented. + test('y', 'normal'); +}); + // Swapcase commands edit in place and do not modify registers. testVim('g~w_repeat', function(cm, vim, helpers) { // Assert that dw does delete newline if it should go to the next line, and From cc92ea5fdb5d156bfefa745fe784ac0146f6353b Mon Sep 17 00:00:00 2001 From: Jack Douglas Date: Fri, 29 May 2020 15:40:22 +0100 Subject: [PATCH 060/557] [gfm mode] Allow forward slash in fenced code language --- 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 dcb048c5e3..508176e2b2 100644 --- a/mode/markdown/markdown.js +++ b/mode/markdown/markdown.js @@ -92,7 +92,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) { , atxHeaderRE = modeCfg.allowAtxHeaderWithoutSpace ? /^(#+)/ : /^(#+)(?: |$)/ , setextHeaderRE = /^ {0,3}(?:\={1,}|-{2,})\s*$/ , textRE = /^[^#!\[\]*_\\<>` "'(~:]+/ - , fencedCodeRE = /^(~~~+|```+)[ \t]*([\w+#-]*)[^\n`]*$/ + , fencedCodeRE = /^(~~~+|```+)[ \t]*([\w\/+#-]*)[^\n`]*$/ , linkDefRE = /^\s*\[[^\]]+?\]:.*$/ // naive link-definition , punctuation = /[!"#$%&'()*+,\-.\/:;<=>?@\[\\\]^_`{|}~\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u0AF0\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166D\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E42\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC9\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDF3C-\uDF3E]|\uD809[\uDC70-\uDC74]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]/ , expandedTab = " " // CommonMark specifies tab as 4 spaces From d331b896470d287a90df888b77e51671fc140bf5 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Wed, 3 Jun 2020 08:54:29 +0200 Subject: [PATCH 061/557] [loadmode addon] Support overriding script loading and filename computation Issue #6295 Issue #6294 --- addon/mode/loadmode.js | 22 ++++++++++++---------- doc/manual.html | 21 ++++++++++++++------- 2 files changed, 26 insertions(+), 17 deletions(-) diff --git a/addon/mode/loadmode.js b/addon/mode/loadmode.js index 4ce716a012..fc695d0c37 100644 --- a/addon/mode/loadmode.js +++ b/addon/mode/loadmode.js @@ -16,8 +16,8 @@ var countDown = n; return function() { if (--countDown == 0) cont(); }; } - function ensureDeps(mode, cont) { - var deps = CodeMirror.modes[mode].dependencies; + function ensureDeps(mode, cont, options) { + var modeObj = CodeMirror.modes[mode], deps = modeObj && modeObj.dependencies; if (!deps) return cont(); var missing = []; for (var i = 0; i < deps.length; ++i) { @@ -27,16 +27,18 @@ if (!missing.length) return cont(); var split = splitCallback(cont, missing.length); for (var i = 0; i < missing.length; ++i) - CodeMirror.requireMode(missing[i], split); + CodeMirror.requireMode(missing[i], split, options); } - CodeMirror.requireMode = function(mode, cont) { + CodeMirror.requireMode = function(mode, cont, options) { if (typeof mode != "string") mode = mode.name; - if (CodeMirror.modes.hasOwnProperty(mode)) return ensureDeps(mode, cont); + if (CodeMirror.modes.hasOwnProperty(mode)) return ensureDeps(mode, cont, options); if (loading.hasOwnProperty(mode)) return loading[mode].push(cont); - var file = CodeMirror.modeURL.replace(/%N/g, mode); - if (env == "plain") { + var file = options && options.path ? options.path(mode) : CodeMirror.modeURL.replace(/%N/g, mode); + if (options && options.loadMode) { + options.loadMode(file, function() { ensureDeps(mode, cont, options) }) + } else if (env == "plain") { var script = document.createElement("script"); script.src = file; var others = document.getElementsByTagName("script")[0]; @@ -44,7 +46,7 @@ CodeMirror.on(script, "load", function() { ensureDeps(mode, function() { for (var i = 0; i < list.length; ++i) list[i](); - }); + }, options); }); others.parentNode.insertBefore(script, others); } else if (env == "cjs") { @@ -55,10 +57,10 @@ } }; - CodeMirror.autoLoadMode = function(instance, mode) { + CodeMirror.autoLoadMode = function(instance, mode, options) { if (!CodeMirror.modes.hasOwnProperty(mode)) CodeMirror.requireMode(mode, function() { instance.setOption("mode", instance.getOption("mode")); - }); + }, options); }; }); diff --git a/doc/manual.html b/doc/manual.html index e8acb01f92..e85ec25b66 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -2950,13 +2950,20 @@

        Addons

        see a demo here.
        mode/loadmode.js
        -
        Defines a CodeMirror.requireMode(modename, - callback) function that will try to load a given mode and - call the callback when it succeeded. You'll have to - set CodeMirror.modeURL to a string that mode paths - can be constructed from, for - example "mode/%N/%N.js"—the %N's will - be replaced with the mode name. Also +
        Defines a CodeMirror.requireMode(modename, callback, + options) function that will try to load a given mode and + call the callback when it succeeded. options is an + optional object that may contain: +
        +
        path: fn(modeName: string) → string
        +
        Defines the way mode names are mapped to paths.
        +
        loadMode: fn(path: string, cont: fn())
        +
        Override the way the mode script is loaded. By default, + this will use the CommonJS or AMD module loader if one is + present, and fall back to creating + a <script> tag otherwise.
        +
        + This addon also defines CodeMirror.autoLoadMode(instance, mode), which will ensure the given mode is loaded and cause the given editor instance to refresh its mode when the loading From b9f846f20b21e8972192b7f3df2ed08ef7a4da03 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Wed, 3 Jun 2020 08:56:15 +0200 Subject: [PATCH 062/557] Remove trailing whitespace --- 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 508176e2b2..d416cfce6d 100644 --- a/mode/markdown/markdown.js +++ b/mode/markdown/markdown.js @@ -47,7 +47,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) { if (modeCfg.fencedCodeBlockHighlighting === undefined) modeCfg.fencedCodeBlockHighlighting = true; - + if (modeCfg.fencedCodeBlockDefaultMode === undefined) modeCfg.fencedCodeBlockDefaultMode = ''; From 91cb2943208f7fa34ba125ea2ef30582ea601f32 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Wed, 3 Jun 2020 22:38:35 +0200 Subject: [PATCH 063/557] [runmode-standalone addon] Fix interface mismatch in StringStream constructor Closes codemirror/google-modes#300 --- addon/runmode/runmode-standalone.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/addon/runmode/runmode-standalone.js b/addon/runmode/runmode-standalone.js index f47af3f2f1..c339aa2bd3 100644 --- a/addon/runmode/runmode-standalone.js +++ b/addon/runmode/runmode-standalone.js @@ -9,12 +9,10 @@ root.CodeMirror = {}; function splitLines(string){ return string.split(/\r?\n|\r/); }; -function StringStream(strings, i) { +function StringStream(string, _tabSize, oracle) { this.pos = this.start = 0; - this.string = strings[i]; - this.strings = strings - this.i = i - this.lineStart = 0; + this.string = string + this.oracle = oracle } StringStream.prototype = { eol: function() {return this.pos >= this.string.length;}, @@ -69,7 +67,7 @@ StringStream.prototype = { try { return inner(); } finally { this.lineStart -= n; } }, - lookAhead: function(n) { return this.strings[this.i + n] } + lookAhead: function(n) { return this.oracle && this.oracle.lookAhead(n) } }; CodeMirror.StringStream = StringStream; @@ -151,9 +149,10 @@ CodeMirror.runMode = function (string, modespec, callback, options) { } var lines = splitLines(string), state = (options && options.state) || CodeMirror.startState(mode); + var oracle = {lookAhead: function(n) { return lines[i + n] }} for (var i = 0, e = lines.length; i < e; ++i) { if (i) callback("\n"); - var stream = new CodeMirror.StringStream(lines, i); + var stream = new CodeMirror.StringStream(lines[i], tabSize, oracle); if (!stream.string && mode.blankLine) mode.blankLine(state); while (!stream.eol()) { var style = mode.token(stream, state); From b074875ead6013b4b2af8dc995f68b1602044918 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Fri, 5 Jun 2020 23:28:35 +0200 Subject: [PATCH 064/557] [javascript mode] Only allow HTML-style comments at the start of line Closes #6305 --- 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 c6577630fd..38468d83d5 100644 --- a/mode/javascript/javascript.js +++ b/mode/javascript/javascript.js @@ -103,7 +103,8 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { return ret("meta", "meta"); } else if (ch == "#" && stream.eatWhile(wordRE)) { return ret("variable", "property") - } else if (ch == "<" && stream.match("!--") || ch == "-" && stream.match("->")) { + } else if ((ch == "<" && stream.match("!--") || ch == "-" && stream.match("->")) && + !/\S/.test(stream.string.slice(0, stream.start))) { stream.skipToEnd() return ret("comment", "comment") } else if (isOperatorChar.test(ch)) { From 84a02bcec14a66f6ae6ca102078cb2dc6afd6349 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Fri, 5 Jun 2020 23:30:52 +0200 Subject: [PATCH 065/557] [javascript mode] Reduce start-of-line restriction to HTML close comment tokens Issue #6305 --- 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 38468d83d5..9c751d23f3 100644 --- a/mode/javascript/javascript.js +++ b/mode/javascript/javascript.js @@ -103,8 +103,8 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { return ret("meta", "meta"); } else if (ch == "#" && stream.eatWhile(wordRE)) { return ret("variable", "property") - } else if ((ch == "<" && stream.match("!--") || ch == "-" && stream.match("->")) && - !/\S/.test(stream.string.slice(0, stream.start))) { + } else if (ch == "<" && stream.match("!--") || + (ch == "-" && stream.match("->") && !/\S/.test(stream.string.slice(0, stream.start)))) { stream.skipToEnd() return ret("comment", "comment") } else if (isOperatorChar.test(ch)) { From 840464b337695d3c4fd2807bdd69e462e2f7d118 Mon Sep 17 00:00:00 2001 From: BrianHung Date: Sat, 6 Jun 2020 02:19:38 -0700 Subject: [PATCH 066/557] [pascal mode] Add highlighting for comments with curly brackets See #5523 --- mode/pascal/pascal.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/mode/pascal/pascal.js b/mode/pascal/pascal.js index dc3b1a3a3e..862ba5871c 100644 --- a/mode/pascal/pascal.js +++ b/mode/pascal/pascal.js @@ -50,7 +50,11 @@ CodeMirror.defineMode("pascal", function() { state.tokenize = tokenComment; return tokenComment(stream, state); } - if (/[\[\]{}\(\),;\:\.]/.test(ch)) { + if (ch == "{") { + state.tokenize = tokenCommentBraces; + return tokenCommentBraces(stream, state); + } + if (/[\[\]\(\),;\:\.]/.test(ch)) { return null; } if (/\d/.test(ch)) { @@ -98,6 +102,17 @@ CodeMirror.defineMode("pascal", function() { return "comment"; } + function tokenCommentBraces(stream, state) { + var ch; + while (ch = stream.next()) { + if (ch == "}") { + state.tokenize = null; + break; + } + } + return "comment"; + } + // Interface return { From bce03ed67520a999a07e3b2fcd33f911aa4883bc Mon Sep 17 00:00:00 2001 From: BrianHung Date: Tue, 9 Jun 2020 22:41:51 -0700 Subject: [PATCH 067/557] [markdown mode] Change fencedCodeBlockDefaultMode to 'text/plain' instead of '' --- 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 d416cfce6d..287f39b55d 100644 --- a/mode/markdown/markdown.js +++ b/mode/markdown/markdown.js @@ -49,7 +49,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) { modeCfg.fencedCodeBlockHighlighting = true; if (modeCfg.fencedCodeBlockDefaultMode === undefined) - modeCfg.fencedCodeBlockDefaultMode = ''; + modeCfg.fencedCodeBlockDefaultMode = 'text/plain'; if (modeCfg.xml === undefined) modeCfg.xml = true; From 01a9446d015638c03d0618d3fb7368c90a2350e4 Mon Sep 17 00:00:00 2001 From: Fons van der Plas Date: Wed, 10 Jun 2020 20:33:35 +0200 Subject: [PATCH 068/557] [julia mode] Tweak indent method --- mode/julia/julia.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mode/julia/julia.js b/mode/julia/julia.js index eaef97ebd3..2aadf36724 100644 --- a/mode/julia/julia.js +++ b/mode/julia/julia.js @@ -401,9 +401,9 @@ CodeMirror.defineMode("julia", function(config, parserConf) { indent: function(state, textAfter) { var delta = 0; - if ( textAfter === ']' || textAfter === ')' || textAfter === "end" || - textAfter === "else" || textAfter === "catch" || textAfter === "elseif" || - textAfter === "finally" ) { + if ( textAfter === ']' || textAfter === ')' || /^end/.test(textAfter) || + /^else/.test(textAfter) || /^catch/.test(textAfter) || /^elseif/.test(textAfter) || + /^finally/.test(textAfter) ) { delta = -1; } return (state.scopes.length + delta) * config.indentUnit; From 5be27709ecd36d834d4784a27194a53c8374749c Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Thu, 11 Jun 2020 11:36:39 +0200 Subject: [PATCH 069/557] Fix lint error --- 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 862ba5871c..c48698bd70 100644 --- a/mode/pascal/pascal.js +++ b/mode/pascal/pascal.js @@ -110,7 +110,7 @@ CodeMirror.defineMode("pascal", function() { break; } } - return "comment"; + return "comment"; } // Interface From 1191965ead00abbecfb6b79b60d0ad65926c472d Mon Sep 17 00:00:00 2001 From: Benedikt Meurer Date: Sat, 13 Jun 2020 18:38:11 +0200 Subject: [PATCH 070/557] [wast mode] update to match latest WebAssembly specification Also shorten the regex for the keyword tokens a bit. --- mode/wast/wast.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mode/wast/wast.js b/mode/wast/wast.js index 24ec27a6f7..cb64b26697 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: /anyfunc|mut|nop|block|if|then|else|loop|br|br_if|br_table|call|call_indirect|drop|end|return|local\.get|local\.set|tee_local|global\.get|global\.set|i32\.load|i64\.load|f32\.load|f64\.load|i32\.store|i64\.store|f32\.store|f64\.store|i32\.load8_s|i64\.load8_s|i32\.load8_u|i64\.load8_u|i32\.load16_s|i64\.load16_s|i32\.load16_u|i64\.load16_u|i64\.load32_s|i64\.load32_u|i32\.store8|i64\.store8|i32\.store16|i64\.store16|i32\.const|i64\.const|f32\.const|f64\.const|i32\.eqz|i64\.eqz|i32\.clz|i64\.clz|i32\.ctz|i64\.ctz|i32\.popcnt|i64\.popcnt|f32\.neg|f64\.neg|f32\.abs|f64\.abs|f32\.sqrt|f64\.sqrt|f32\.ceil|f64\.ceil|f32\.floor|f64\.floor|f32\.trunc|f64\.trunc|f32\.nearest|f64\.nearest|i32\.add|i64\.add|i32\.sub|i64\.sub|i32\.mul|i64\.mul|i32\.div_s|i64\.div_s|i32\.div_u|i64\.div_u|i32\.rem_s|i64\.rem_s|i32\.rem_u|i64\.rem_u|i32\.and|i64\.and|i32\.or|i64\.or|i32\.xor|i64\.xor|i32\.shl|i64\.shl|i32\.shr_s|i64\.shr_s|i32\.shr_u|i64\.shr_u|i32\.rotl|i64\.rotl|i32\.rotr|i64\.rotr|f32\.add|f64\.add|f32\.sub|f64\.sub|f32\.mul|f64\.mul|f32\.div|f64\.div|f32\.min|f64\.min|f32\.max|f64\.max|f32\.copysign|f64\.copysign|i32\.eq|i64\.eq|i32\.ne|i64\.ne|i32\.lt_s|i64\.lt_s|i32\.lt_u|i64\.lt_u|i32\.le_s|i64\.le_s|i32\.le_u|i64\.le_u|i32\.gt_s|i64\.gt_s|i32\.gt_u|i64\.gt_u|i32\.ge_s|i64\.ge_s|i32\.ge_u|i64\.ge_u|f32\.eq|f64\.eq|f32\.ne|f64\.ne|f32\.lt|f64\.lt|f32\.le|f64\.le|f32\.gt|f64\.gt|f32\.ge|f64\.ge|i64\.extend_s\/i32|i64\.extend_u\/i32|i32\.wrap\/i64|i32\.trunc_s\/f32|i64\.trunc_s\/f32|i32\.trunc_s\/f64|i64\.trunc_s\/f64|i32\.trunc_u\/f32|i64\.trunc_u\/f32|i32\.trunc_u\/f64|i64\.trunc_u\/f64|f32\.convert_s\/i32|f64\.convert_s\/i32|f32\.convert_s\/i64|f64\.convert_s\/i64|f32\.convert_u\/i32|f64\.convert_u\/i32|f32\.convert_u\/i64|f64\.convert_u\/i64|f64\.promote\/f32|f32\.demote\/f64|f32\.reinterpret\/i32|i32\.reinterpret\/f32|f64\.reinterpret\/i64|i64\.reinterpret\/f64|select|unreachable|current_memory|memory.size|grow_memory|memory.grow|type|func|param|result|local|global|module|table|memory|start|elem|data|offset|import|export/, token: "keyword"}, - {regex: /\b(i32|i64|f32|f64)\b/, token: "atom"}, + {regex: /mut|nop|block|if|then|else|loop|br_if|br_table|br|call_indirect|call|drop|end|return|local\.(get|set|tee)|global\.(get|set)|i(32|64)\.(store(8|16)|(load(8|16)_(s|u)))|i64\.(load32_(s|u)|store16)|(i32|i64|f32|f64)\.(load|store)|(i32|i64|f32|f64)\.const|f(32|64)\.(abs|add|ceil|copysign|div|eq|floor|(g|l)(t|e)|max|min|mul|nearest|neg?|sqrt|sub|trunc)|i(32|64)\.(add|and|clz|ctz|(div|rem)_(s|u)|eqz?|(g|l)(e|t)_(s|u)|mul|ne|popcnt|or|rot(l|r)|sh(l|r_(s|u))|sub|xor)|i64\.extend_(s|u)_i32|i32\.wrap_i64|i(32|64)\.trunc_f(32|64)_(s|u)|f(32|64)\.convert_i(32|64)_(s|u)|f64\.promote_f32|f32\.demote_f64|f32\.reinterpret_i32|i32\.reinterpret_f32|f64\.reinterpret_i64|i64\.reinterpret_f64|select|unreachable|current_memory|memory\.(size|grow)|type|func|param|result|local|global|module|table|memory|start|elem|data|align|offset|import|export/, token: "keyword"}, + {regex: /\b(anyfunc|i32|i64|f32|f64)\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"}, @@ -38,4 +38,4 @@ CodeMirror.defineSimpleMode('wast', { // which seems like a reasonable choice, although it's not standard right now. CodeMirror.defineMIME("text/webassembly", "wast"); -}); \ No newline at end of file +}); From a45f69980de5b33fcfe9b55a1f9772aad4af9f6c Mon Sep 17 00:00:00 2001 From: Benedikt Meurer Date: Sun, 14 Jun 2020 08:35:09 +0200 Subject: [PATCH 071/557] [wast mode] Support atomics from the Wasm Threads proposal This also adds more test coverage for not only the atomic memory instructions, but also the regular memory instructions. It also shortens the regex's for keyword and atom a bit. --- mode/wast/test.js | 96 ++++++++++++++++++++++++++++++++++++++++++++++- mode/wast/wast.js | 4 +- 2 files changed, 97 insertions(+), 3 deletions(-) diff --git a/mode/wast/test.js b/mode/wast/test.js index 4de7e0b267..435cf6670b 100644 --- a/mode/wast/test.js +++ b/mode/wast/test.js @@ -21,6 +21,7 @@ '[string "foo #\\"# bar"]'); MT('atom-test', + '[atom anyfunc]', '[atom i32]', '[atom i64]', '[atom f32]', @@ -31,5 +32,98 @@ '[keyword if]', '[keyword loop]', '[keyword i32.add]', - '[keyword local.get]') + '[keyword local.get]'); + + MT('memory-instructions', + '[keyword i32.load] [keyword offset]=[number 4] [keyword align]=[number 4]', + '[keyword i32.load8_s] [keyword offset]=[number 4] [keyword align]=[number 4]', + '[keyword i32.load8_u] [keyword offset]=[number 4] [keyword align]=[number 4]', + '[keyword i32.load16_s] [keyword offset]=[number 4] [keyword align]=[number 4]', + '[keyword i32.load16_u] [keyword offset]=[number 4] [keyword align]=[number 4]', + '[keyword i32.store] [keyword offset]=[number 4] [keyword align]=[number 4]', + '[keyword i32.store8] [keyword offset]=[number 4] [keyword align]=[number 4]', + '[keyword i32.store16] [keyword offset]=[number 4] [keyword align]=[number 4]', + '[keyword i64.store] [keyword offset]=[number 4] [keyword align]=[number 4]', + '[keyword i64.load] [keyword offset]=[number 4] [keyword align]=[number 4]', + '[keyword i64.load8_s] [keyword offset]=[number 4] [keyword align]=[number 4]', + '[keyword i64.load8_u] [keyword offset]=[number 4] [keyword align]=[number 4]', + '[keyword i64.load16_s] [keyword offset]=[number 4] [keyword align]=[number 4]', + '[keyword i64.load16_u] [keyword offset]=[number 4] [keyword align]=[number 4]', + '[keyword i64.load32_s] [keyword offset]=[number 4] [keyword align]=[number 4]', + '[keyword i64.load32_u] [keyword offset]=[number 4] [keyword align]=[number 4]', + '[keyword i64.store8] [keyword offset]=[number 4] [keyword align]=[number 4]', + '[keyword i64.store16] [keyword offset]=[number 4] [keyword align]=[number 4]', + '[keyword i64.store32] [keyword offset]=[number 4] [keyword align]=[number 4]', + '[keyword f32.load] [keyword offset]=[number 4] [keyword align]=[number 4]', + '[keyword f32.store] [keyword offset]=[number 4] [keyword align]=[number 4]', + '[keyword f64.load] [keyword offset]=[number 4] [keyword align]=[number 4]', + '[keyword f64.store] [keyword offset]=[number 4] [keyword align]=[number 4]'); + + MT('atomic-memory-instructions', + '[keyword atomic.notify] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i32.atomic.wait] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i64.atomic.wait] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i32.atomic.load] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i32.atomic.load8_u] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i32.atomic.load16_u] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i32.atomic.store] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i32.atomic.store8] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i32.atomic.store16] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i64.atomic.load] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i64.atomic.load8_u] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i64.atomic.load16_u] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i64.atomic.load32_u] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i64.atomic.store] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i64.atomic.store8] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i64.atomic.store16] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i64.atomic.store32] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i32.atomic.rmw.add] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i32.atomic.rmw8.add_u] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i32.atomic.rmw16.add_u] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i64.atomic.rmw.add] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i64.atomic.rmw8.add_u] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i64.atomic.rmw16.add_u] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i64.atomic.rmw32.add_u] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i32.atomic.rmw.sub] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i32.atomic.rmw8.sub_u] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i32.atomic.rmw16.sub_u] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i64.atomic.rmw.sub] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i64.atomic.rmw8.sub_u] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i64.atomic.rmw16.sub_u] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i64.atomic.rmw32.sub_u] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i32.atomic.rmw.and] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i32.atomic.rmw8.and_u] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i32.atomic.rmw16.and_u] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i64.atomic.rmw.and] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i64.atomic.rmw8.and_u] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i64.atomic.rmw16.and_u] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i64.atomic.rmw32.and_u] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i32.atomic.rmw.or] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i32.atomic.rmw8.or_u] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i32.atomic.rmw16.or_u] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i64.atomic.rmw.or] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i64.atomic.rmw8.or_u] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i64.atomic.rmw16.or_u] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i64.atomic.rmw32.or_u] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i32.atomic.rmw.xor] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i32.atomic.rmw8.xor_u] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i32.atomic.rmw16.xor_u] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i64.atomic.rmw.xor] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i64.atomic.rmw8.xor_u] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i64.atomic.rmw16.xor_u] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i64.atomic.rmw32.xor_u] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i32.atomic.rmw.xchg] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i32.atomic.rmw8.xchg_u] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i32.atomic.rmw16.xchg_u] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i64.atomic.rmw.xchg] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i64.atomic.rmw8.xchg_u] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i64.atomic.rmw16.xchg_u] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i64.atomic.rmw32.xchg_u] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i32.atomic.rmw.cmpxchg] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i32.atomic.rmw8.cmpxchg_u] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i32.atomic.rmw16.cmpxchg_u] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i64.atomic.rmw.cmpxchg] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i64.atomic.rmw8.cmpxchg_u] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i64.atomic.rmw16.cmpxchg_u] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i64.atomic.rmw32.cmpxchg_u] [keyword offset]=[number 32] [keyword align]=[number 4]'); })(); diff --git a/mode/wast/wast.js b/mode/wast/wast.js index cb64b26697..9bda3d56fc 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|call|drop|end|return|local\.(get|set|tee)|global\.(get|set)|i(32|64)\.(store(8|16)|(load(8|16)_(s|u)))|i64\.(load32_(s|u)|store16)|(i32|i64|f32|f64)\.(load|store)|(i32|i64|f32|f64)\.const|f(32|64)\.(abs|add|ceil|copysign|div|eq|floor|(g|l)(t|e)|max|min|mul|nearest|neg?|sqrt|sub|trunc)|i(32|64)\.(add|and|clz|ctz|(div|rem)_(s|u)|eqz?|(g|l)(e|t)_(s|u)|mul|ne|popcnt|or|rot(l|r)|sh(l|r_(s|u))|sub|xor)|i64\.extend_(s|u)_i32|i32\.wrap_i64|i(32|64)\.trunc_f(32|64)_(s|u)|f(32|64)\.convert_i(32|64)_(s|u)|f64\.promote_f32|f32\.demote_f64|f32\.reinterpret_i32|i32\.reinterpret_f32|f64\.reinterpret_i64|i64\.reinterpret_f64|select|unreachable|current_memory|memory\.(size|grow)|type|func|param|result|local|global|module|table|memory|start|elem|data|align|offset|import|export/, token: "keyword"}, - {regex: /\b(anyfunc|i32|i64|f32|f64)\b/, token: "atom"}, + {regex: /mut|nop|block|if|then|else|loop|br_if|br_table|br|call_indirect|call|drop|end|return|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\.(size|grow)|type|func|param|result|local|global|module|table|memory|start|elem|data|align|offset|import|export|atomic\.notify|i64\.atomic\.(load32_u|store32|rmw32\.(a[dn]d|sub|x?or|(cmp)?xchg)_u)|i(32|64)\.atomic\.(wait|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))/, token: "keyword"}, + {regex: /\b(anyfunc|[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 3bf49684d4c62965c1257421c2fe8593f7660d59 Mon Sep 17 00:00:00 2001 From: ZeeshanNoor Date: Mon, 15 Jun 2020 17:02:22 +0200 Subject: [PATCH 072/557] [sql-hint addon] Autocomplete suggestion on _ $ and # for ODBC --- addon/hint/sql-hint.js | 2 +- mode/sql/sql.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/addon/hint/sql-hint.js b/addon/hint/sql-hint.js index 444eba8b15..0b89b79fab 100644 --- a/addon/hint/sql-hint.js +++ b/addon/hint/sql-hint.js @@ -264,7 +264,7 @@ token.string = token.string.slice(0, cur.ch - token.start); } - if (token.string.match(/^[.`"\w@]\w*$/)) { + if (token.string.match(/^[.`"\w@][\w$#]*$/g)) { search = token.string; start = token.start; end = token.end; diff --git a/mode/sql/sql.js b/mode/sql/sql.js index e43495d271..4127cd9a05 100644 --- a/mode/sql/sql.js +++ b/mode/sql/sql.js @@ -96,7 +96,7 @@ CodeMirror.defineMode("sql", function(config, parserConfig) { return null // .table_name (ODBC) // // ref: http://dev.mysql.com/doc/refman/5.6/en/identifier-qualifiers.html - if (support.ODBCdotTable && stream.match(/^[\w\d_]+/)) + if (support.ODBCdotTable && stream.match(/^[\w\d_$#]+/)) return "variable-2"; } else if (operatorChars.test(ch)) { // operators From b937e09ce05d5d569e61383bb4a185c70e6e3972 Mon Sep 17 00:00:00 2001 From: Benedikt Meurer Date: Mon, 15 Jun 2020 19:38:06 +0200 Subject: [PATCH 073/557] [wast mode] Support WebAssembly tail-calls proposal This also adds more test coverage for all other control instructions, not just the new ones from the tail-calls proposal. --- mode/wast/test.js | 12 ++++++++++++ mode/wast/wast.js | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/mode/wast/test.js b/mode/wast/test.js index 435cf6670b..a8097768a7 100644 --- a/mode/wast/test.js +++ b/mode/wast/test.js @@ -34,6 +34,18 @@ '[keyword i32.add]', '[keyword local.get]'); + MT('control-instructions', + '[keyword unreachable]', + '[keyword nop]', + '[keyword br] [variable-2 $label0]', + '[keyword br_if] [variable-2 $label0]', + '[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 return_call] [variable-2 $func0]', + '[keyword return_call_indirect] ([keyword param] [atom f32] [atom f64]) ([keyword result] [atom i32] [atom i64])'); + MT('memory-instructions', '[keyword i32.load] [keyword offset]=[number 4] [keyword align]=[number 4]', '[keyword i32.load8_s] [keyword offset]=[number 4] [keyword align]=[number 4]', diff --git a/mode/wast/wast.js b/mode/wast/wast.js index 9bda3d56fc..8c517a4985 100644 --- a/mode/wast/wast.js +++ b/mode/wast/wast.js @@ -14,7 +14,7 @@ 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|call|drop|end|return|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\.(size|grow)|type|func|param|result|local|global|module|table|memory|start|elem|data|align|offset|import|export|atomic\.notify|i64\.atomic\.(load32_u|store32|rmw32\.(a[dn]d|sub|x?or|(cmp)?xchg)_u)|i(32|64)\.atomic\.(wait|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))/, token: "keyword"}, + {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\.(size|grow)|type|func|param|result|local|global|module|table|memory|start|elem|data|align|offset|import|export|atomic\.notify|i64\.atomic\.(load32_u|store32|rmw32\.(a[dn]d|sub|x?or|(cmp)?xchg)_u)|i(32|64)\.atomic\.(wait|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))/, token: "keyword"}, {regex: /\b(anyfunc|[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"}, From 215c1dc644873190e3ad6aed77641017b10823e1 Mon Sep 17 00:00:00 2001 From: Ealton Date: Tue, 16 Jun 2020 13:11:38 +0800 Subject: [PATCH 074/557] [real-world uses] Add Innovay Web Tools --- doc/realworld.html | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/realworld.html b/doc/realworld.html index b308b39adf..a08d754550 100644 --- a/doc/realworld.html +++ b/doc/realworld.html @@ -103,6 +103,7 @@

        CodeMirror real-world uses

      • Histone template engine playground
      • Homegenie (home automation server)
      • ICEcoder (web IDE)
      • +
      • Innovay Web Tools (HTML, JS, CSS code beautifier)
      • IPython (interactive computing shell)
      • iTrading (Algorithmic Trading)
      • i-MOS (modeling and simulation platform)
      • From 001e07fcf8b2cbd7191906c5f963e0760d7cfcc9 Mon Sep 17 00:00:00 2001 From: BrianHung Date: Thu, 18 Jun 2020 06:08:48 -0700 Subject: [PATCH 075/557] [runmode addon] Reuse existing support code for standalone/node versions of runmode --- .gitignore | 3 + addon/runmode/runmode-standalone.js | 164 ----------------- addon/runmode/runmode.js | 9 +- addon/runmode/runmode.node.js | 197 --------------------- demo/runmode-standalone.html | 61 +++++++ package.json | 7 +- rollup.config.js | 56 ++++-- src/addon/runmode/codemirror-standalone.js | 20 +++ src/addon/runmode/codemirror.node.js | 19 ++ src/addon/runmode/runmode-standalone.js | 2 + src/addon/runmode/runmode.node.js | 2 + 11 files changed, 155 insertions(+), 385 deletions(-) delete mode 100644 addon/runmode/runmode-standalone.js delete mode 100644 addon/runmode/runmode.node.js create mode 100644 demo/runmode-standalone.html create mode 100644 src/addon/runmode/codemirror-standalone.js create mode 100644 src/addon/runmode/codemirror.node.js create mode 100644 src/addon/runmode/runmode-standalone.js create mode 100644 src/addon/runmode/runmode.node.js diff --git a/.gitignore b/.gitignore index 1767b6d833..f552109d20 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,6 @@ .idea *.iml /lib/codemirror.js +/addon/runmode/runmode-standalone.js +/addon/runmode/runmode.node.js +**/.DS_Store \ No newline at end of file diff --git a/addon/runmode/runmode-standalone.js b/addon/runmode/runmode-standalone.js deleted file mode 100644 index c339aa2bd3..0000000000 --- a/addon/runmode/runmode-standalone.js +++ /dev/null @@ -1,164 +0,0 @@ -// CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: https://codemirror.net/LICENSE - -var root = typeof globalThis !== 'undefined' ? globalThis : window; -root.CodeMirror = {}; - -(function() { -"use strict"; - -function splitLines(string){ return string.split(/\r?\n|\r/); }; - -function StringStream(string, _tabSize, oracle) { - this.pos = this.start = 0; - this.string = string - this.oracle = oracle -} -StringStream.prototype = { - eol: function() {return this.pos >= this.string.length;}, - sol: function() {return this.pos == 0;}, - peek: function() {return this.string.charAt(this.pos) || null;}, - next: function() { - if (this.pos < this.string.length) - return this.string.charAt(this.pos++); - }, - eat: function(match) { - var ch = this.string.charAt(this.pos); - if (typeof match == "string") var ok = ch == match; - else var ok = ch && (match.test ? match.test(ch) : match(ch)); - if (ok) {++this.pos; return ch;} - }, - eatWhile: function(match) { - var start = this.pos; - while (this.eat(match)){} - return this.pos > start; - }, - eatSpace: function() { - var start = this.pos; - while (/[\s\u00a0]/.test(this.string.charAt(this.pos))) ++this.pos; - return this.pos > start; - }, - skipToEnd: function() {this.pos = this.string.length;}, - skipTo: function(ch) { - var found = this.string.indexOf(ch, this.pos); - if (found > -1) {this.pos = found; return true;} - }, - backUp: function(n) {this.pos -= n;}, - column: function() {return this.start - this.lineStart;}, - indentation: function() {return 0;}, - match: function(pattern, consume, caseInsensitive) { - if (typeof pattern == "string") { - var cased = function(str) {return caseInsensitive ? str.toLowerCase() : str;}; - var substr = this.string.substr(this.pos, pattern.length); - if (cased(substr) == cased(pattern)) { - if (consume !== false) this.pos += pattern.length; - return true; - } - } else { - var match = this.string.slice(this.pos).match(pattern); - if (match && match.index > 0) return null; - if (match && consume !== false) this.pos += match[0].length; - return match; - } - }, - current: function(){return this.string.slice(this.start, this.pos);}, - hideFirstChars: function(n, inner) { - this.lineStart += n; - try { return inner(); } - finally { this.lineStart -= n; } - }, - lookAhead: function(n) { return this.oracle && this.oracle.lookAhead(n) } -}; -CodeMirror.StringStream = StringStream; - -CodeMirror.startState = function (mode, a1, a2) { - return mode.startState ? mode.startState(a1, a2) : true; -}; - -var modes = CodeMirror.modes = {}, mimeModes = CodeMirror.mimeModes = {}; -CodeMirror.defineMode = function (name, mode) { - if (arguments.length > 2) - mode.dependencies = Array.prototype.slice.call(arguments, 2); - modes[name] = mode; -}; -CodeMirror.defineMIME = function (mime, spec) { mimeModes[mime] = spec; }; -CodeMirror.resolveMode = function(spec) { - if (typeof spec == "string" && mimeModes.hasOwnProperty(spec)) { - spec = mimeModes[spec]; - } else if (spec && typeof spec.name == "string" && mimeModes.hasOwnProperty(spec.name)) { - spec = mimeModes[spec.name]; - } - if (typeof spec == "string") return {name: spec}; - else return spec || {name: "null"}; -}; -CodeMirror.getMode = function (options, spec) { - spec = CodeMirror.resolveMode(spec); - var mfactory = modes[spec.name]; - if (!mfactory) throw new Error("Unknown mode: " + spec); - return mfactory(options, spec); -}; -CodeMirror.registerHelper = CodeMirror.registerGlobalHelper = Math.min; -CodeMirror.defineMode("null", function() { - return {token: function(stream) {stream.skipToEnd();}}; -}); -CodeMirror.defineMIME("text/plain", "null"); - -CodeMirror.runMode = function (string, modespec, callback, options) { - var mode = CodeMirror.getMode({ indentUnit: 2 }, modespec); - var ie = /MSIE \d/.test(navigator.userAgent); - var ie_lt9 = ie && (document.documentMode == null || document.documentMode < 9); - - if (callback.appendChild) { - var tabSize = (options && options.tabSize) || 4; - var node = callback, col = 0; - node.innerHTML = ""; - callback = function (text, style) { - if (text == "\n") { - // Emitting LF or CRLF on IE8 or earlier results in an incorrect display. - // Emitting a carriage return makes everything ok. - node.appendChild(document.createTextNode(ie_lt9 ? '\r' : text)); - col = 0; - return; - } - var content = ""; - // replace tabs - for (var pos = 0; ;) { - var idx = text.indexOf("\t", pos); - if (idx == -1) { - content += text.slice(pos); - col += text.length - pos; - break; - } else { - col += idx - pos; - content += text.slice(pos, idx); - var size = tabSize - col % tabSize; - col += size; - for (var i = 0; i < size; ++i) content += " "; - pos = idx + 1; - } - } - - if (style) { - var sp = node.appendChild(document.createElement("span")); - sp.className = "cm-" + style.replace(/ +/g, " cm-"); - sp.appendChild(document.createTextNode(content)); - } else { - node.appendChild(document.createTextNode(content)); - } - }; - } - - var lines = splitLines(string), state = (options && options.state) || CodeMirror.startState(mode); - var oracle = {lookAhead: function(n) { return lines[i + n] }} - for (var i = 0, e = lines.length; i < e; ++i) { - if (i) callback("\n"); - var stream = new CodeMirror.StringStream(lines[i], tabSize, oracle); - if (!stream.string && mode.blankLine) mode.blankLine(state); - while (!stream.eol()) { - var style = mode.token(stream, state); - callback(stream.current(), style, i, stream.start, state); - stream.start = stream.pos; - } - } -}; -})(); diff --git a/addon/runmode/runmode.js b/addon/runmode/runmode.js index ca8d9a9c79..2cae68635d 100644 --- a/addon/runmode/runmode.js +++ b/addon/runmode/runmode.js @@ -13,11 +13,12 @@ CodeMirror.runMode = function(string, modespec, callback, options) { var mode = CodeMirror.getMode(CodeMirror.defaults, modespec); - var ie = /MSIE \d/.test(navigator.userAgent); - var ie_lt9 = ie && (document.documentMode == null || document.documentMode < 9); + var tabSize = (options && options.tabSize) || CodeMirror.defaults.tabSize; + // Create a tokenizing callback function if passed-in callback is a DOM element. if (callback.appendChild) { - var tabSize = (options && options.tabSize) || CodeMirror.defaults.tabSize; + var ie = /MSIE \d/.test(navigator.userAgent); + var ie_lt9 = ie && (document.documentMode == null || document.documentMode < 9); var node = callback, col = 0; node.innerHTML = ""; callback = function(text, style) { @@ -45,7 +46,7 @@ CodeMirror.runMode = function(string, modespec, callback, options) { pos = idx + 1; } } - + // Create a node with token style and append it to the callback DOM element. if (style) { var sp = node.appendChild(document.createElement("span")); sp.className = "cm-" + style.replace(/ +/g, " cm-"); diff --git a/addon/runmode/runmode.node.js b/addon/runmode/runmode.node.js deleted file mode 100644 index 53b6994c28..0000000000 --- a/addon/runmode/runmode.node.js +++ /dev/null @@ -1,197 +0,0 @@ -// CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: https://codemirror.net/LICENSE - -/* Just enough of CodeMirror to run runMode under node.js */ - -function splitLines(string){return string.split(/\r\n?|\n/);}; - -// Counts the column offset in a string, taking tabs into account. -// Used mostly to find indentation. -var countColumn = exports.countColumn = function(string, end, tabSize, startIndex, startValue) { - if (end == null) { - end = string.search(/[^\s\u00a0]/); - if (end == -1) end = string.length; - } - for (var i = startIndex || 0, n = startValue || 0;;) { - var nextTab = string.indexOf("\t", i); - if (nextTab < 0 || nextTab >= end) - return n + (end - i); - n += nextTab - i; - n += tabSize - (n % tabSize); - i = nextTab + 1; - } -}; - -function StringStream(string, tabSize, context) { - this.pos = this.start = 0; - this.string = string; - this.tabSize = tabSize || 8; - this.lastColumnPos = this.lastColumnValue = 0; - this.lineStart = 0; - this.context = context -}; - -StringStream.prototype = { - eol: function() {return this.pos >= this.string.length;}, - sol: function() {return this.pos == this.lineStart;}, - peek: function() {return this.string.charAt(this.pos) || undefined;}, - next: function() { - if (this.pos < this.string.length) - return this.string.charAt(this.pos++); - }, - eat: function(match) { - var ch = this.string.charAt(this.pos); - if (typeof match == "string") var ok = ch == match; - else var ok = ch && (match.test ? match.test(ch) : match(ch)); - if (ok) {++this.pos; return ch;} - }, - eatWhile: function(match) { - var start = this.pos; - while (this.eat(match)){} - return this.pos > start; - }, - eatSpace: function() { - var start = this.pos; - while (/[\s\u00a0]/.test(this.string.charAt(this.pos))) ++this.pos; - return this.pos > start; - }, - skipToEnd: function() {this.pos = this.string.length;}, - skipTo: function(ch) { - var found = this.string.indexOf(ch, this.pos); - if (found > -1) {this.pos = found; return true;} - }, - backUp: function(n) {this.pos -= n;}, - column: function() { - if (this.lastColumnPos < this.start) { - this.lastColumnValue = countColumn(this.string, this.start, this.tabSize, this.lastColumnPos, this.lastColumnValue); - this.lastColumnPos = this.start; - } - return this.lastColumnValue - (this.lineStart ? countColumn(this.string, this.lineStart, this.tabSize) : 0); - }, - indentation: function() { - return countColumn(this.string, null, this.tabSize) - - (this.lineStart ? countColumn(this.string, this.lineStart, this.tabSize) : 0); - }, - match: function(pattern, consume, caseInsensitive) { - if (typeof pattern == "string") { - var cased = function(str) {return caseInsensitive ? str.toLowerCase() : str;}; - var substr = this.string.substr(this.pos, pattern.length); - if (cased(substr) == cased(pattern)) { - if (consume !== false) this.pos += pattern.length; - return true; - } - } else { - var match = this.string.slice(this.pos).match(pattern); - if (match && match.index > 0) return null; - if (match && consume !== false) this.pos += match[0].length; - return match; - } - }, - current: function(){return this.string.slice(this.start, this.pos);}, - hideFirstChars: function(n, inner) { - this.lineStart += n; - try { return inner(); } - finally { this.lineStart -= n; } - }, - lookAhead: function(n) { - var line = this.context.line + n - return line >= this.context.lines.length ? null : this.context.lines[line] - } -}; -exports.StringStream = StringStream; - -exports.startState = function(mode, a1, a2) { - return mode.startState ? mode.startState(a1, a2) : true; -}; - -var modes = exports.modes = {}, mimeModes = exports.mimeModes = {}; -exports.defineMode = function(name, mode) { - if (arguments.length > 2) - mode.dependencies = Array.prototype.slice.call(arguments, 2); - modes[name] = mode; -}; -exports.defineMIME = function(mime, spec) { mimeModes[mime] = spec; }; - -exports.defineMode("null", function() { - return {token: function(stream) {stream.skipToEnd();}}; -}); -exports.defineMIME("text/plain", "null"); - -exports.resolveMode = function(spec) { - if (typeof spec == "string" && mimeModes.hasOwnProperty(spec)) { - spec = mimeModes[spec]; - } else if (spec && typeof spec.name == "string" && mimeModes.hasOwnProperty(spec.name)) { - spec = mimeModes[spec.name]; - } - if (typeof spec == "string") return {name: spec}; - else return spec || {name: "null"}; -}; - -function copyObj(obj, target, overwrite) { - if (!target) target = {}; - for (var prop in obj) - if (obj.hasOwnProperty(prop) && (overwrite !== false || !target.hasOwnProperty(prop))) - target[prop] = obj[prop]; - return target; -} - -// This can be used to attach properties to mode objects from -// outside the actual mode definition. -var modeExtensions = exports.modeExtensions = {}; -exports.extendMode = function(mode, properties) { - var exts = modeExtensions.hasOwnProperty(mode) ? modeExtensions[mode] : (modeExtensions[mode] = {}); - copyObj(properties, exts); -}; - -exports.getMode = function(options, spec) { - var spec = exports.resolveMode(spec); - var mfactory = modes[spec.name]; - if (!mfactory) return exports.getMode(options, "text/plain"); - var modeObj = mfactory(options, spec); - if (modeExtensions.hasOwnProperty(spec.name)) { - var exts = modeExtensions[spec.name]; - for (var prop in exts) { - if (!exts.hasOwnProperty(prop)) continue; - if (modeObj.hasOwnProperty(prop)) modeObj["_" + prop] = modeObj[prop]; - modeObj[prop] = exts[prop]; - } - } - modeObj.name = spec.name; - if (spec.helperType) modeObj.helperType = spec.helperType; - if (spec.modeProps) for (var prop in spec.modeProps) - modeObj[prop] = spec.modeProps[prop]; - - 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) { - var mode = exports.getMode({indentUnit: 2}, modespec); - var lines = splitLines(string), state = (options && options.state) || exports.startState(mode); - var context = {lines: lines, line: 0} - for (var i = 0, e = lines.length; i < e; ++i, ++context.line) { - if (i) callback("\n"); - var stream = new exports.StringStream(lines[i], 4, context); - if (!stream.string && mode.blankLine) mode.blankLine(state); - while (!stream.eol()) { - var style = mode.token(stream, state); - callback(stream.current(), style, i, stream.start, state); - stream.start = stream.pos; - } - } -}; - -require.cache[require.resolve("../../lib/codemirror")] = require.cache[require.resolve("./runmode.node")]; -require.cache[require.resolve("../../addon/runmode/runmode")] = require.cache[require.resolve("./runmode.node")]; diff --git a/demo/runmode-standalone.html b/demo/runmode-standalone.html new file mode 100644 index 0000000000..f3503b98d8 --- /dev/null +++ b/demo/runmode-standalone.html @@ -0,0 +1,61 @@ + + +CodeMirror: Mode Runner Demo + + + + + + + + +
        +

        Mode Runner Demo

        + + +
        + +
        
        +
        +    
        +
        +    

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

        + +
        +
        text (string)
        +
        The document to run through the highlighter.
        +
        mode (mode spec)
        +
        The mode to use (must be loaded as normal).
        +
        output (function or DOM node)
        +
        If this is a function, it will be called for each token with + two arguments, the token's text and the token's style class (may + be null for unstyled tokens). If it is a DOM node, + the tokens will be converted to span elements as in + an editor, and inserted into the node + (through innerHTML).
        +
        + +
        diff --git a/package.json b/package.json index 7956d37b97..f784cea808 100644 --- a/package.json +++ b/package.json @@ -21,11 +21,11 @@ "lint": "bin/lint" }, "devDependencies": { + "@rollup/plugin-buble": "^0.21.3", "blint": "^1.1.0", "node-static": "0.7.11", "puppeteer": "^1.20.0", - "rollup": "^1.26.3", - "rollup-plugin-buble": "^0.19.8" + "rollup": "^1.26.3" }, "bugs": "http://github.com/codemirror/CodeMirror/issues", "keywords": [ @@ -42,5 +42,6 @@ "directories": {}, "dependencies": {}, "devDependencies": {} - } + }, + "dependencies": {} } diff --git a/rollup.config.js b/rollup.config.js index fbb4357175..88c94411f8 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -1,20 +1,42 @@ -import buble from 'rollup-plugin-buble'; +import buble from '@rollup/plugin-buble'; -export default { - input: "src/codemirror.js", - output: { - banner: `// CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: https://codemirror.net/LICENSE +export default [ + { + input: "src/codemirror.js", + output: { + banner: `// CodeMirror, copyright (c) by Marijn Haverbeke and others + // Distributed under an MIT license: https://codemirror.net/LICENSE -// This is CodeMirror (https://codemirror.net), a code editor -// implemented in JavaScript on top of the browser's DOM. -// -// You can find some technical background for some of the code below -// at http://marijnhaverbeke.nl/blog/#cm-internals . -`, - format: "umd", - file: "lib/codemirror.js", - name: "CodeMirror" + // This is CodeMirror (https://codemirror.net), a code editor + // implemented in JavaScript on top of the browser's DOM. + // + // You can find some technical background for some of the code below + // at http://marijnhaverbeke.nl/blog/#cm-internals . + `, + format: "umd", + file: "lib/codemirror.js", + name: "CodeMirror" + }, + plugins: [ buble({namedFunctionExpressions: false}) ] }, - plugins: [ buble({namedFunctionExpressions: false}) ] -}; + { + input: ["src/addon/runmode/runmode-standalone.js"], + output: { + format: "iife", + file: "addon/runmode/runmode-standalone.js", + name: "CodeMirror", + freeze: false, // IE8 doesn't support Object.freeze. + }, + plugins: [ buble({namedFunctionExpressions: false}) ] + }, + { + input: ["src/addon/runmode/runmode.node.js"], + output: { + format: "cjs", + file: "addon/runmode/runmode.node.js", + name: "CodeMirror", + freeze: false, // IE8 doesn't support Object.freeze. + }, + plugins: [ buble({namedFunctionExpressions: false}) ] + }, +]; diff --git a/src/addon/runmode/codemirror-standalone.js b/src/addon/runmode/codemirror-standalone.js new file mode 100644 index 0000000000..bb246c9b9f --- /dev/null +++ b/src/addon/runmode/codemirror-standalone.js @@ -0,0 +1,20 @@ +import StringStream from "../../util/StringStream.js" +import * as modeMethods from "../../modes.js" + +// Create a minimal CodeMirror needed to use runMode, and assign to root. +var root = typeof globalThis !== 'undefined' ? globalThis : window +root.CodeMirror = {} + +// Copy StringStream and mode methods into CodeMirror object. +CodeMirror.StringStream = StringStream +for (var exported in modeMethods) CodeMirror[exported] = modeMethods[exported] + +// Minimal default mode. +CodeMirror.defineMode("null", () => ({token: stream => stream.skipToEnd()})) +CodeMirror.defineMIME("text/plain", "null") + +CodeMirror.registerHelper = CodeMirror.registerGlobalHelper = Math.min +CodeMirror.splitLines = function(string) { return string.split(/\r?\n|\r/); } + +CodeMirror.defaults = { indentUnit: 2 } +export default CodeMirror; \ No newline at end of file diff --git a/src/addon/runmode/codemirror.node.js b/src/addon/runmode/codemirror.node.js new file mode 100644 index 0000000000..11a142eee0 --- /dev/null +++ b/src/addon/runmode/codemirror.node.js @@ -0,0 +1,19 @@ +import StringStream from "../../util/StringStream.js" +import * as modeMethods from "../../modes.js" + +// Copy StringStream and mode methods into exports (CodeMirror) object. +exports.StringStream = StringStream +for (var exported in modeMethods) exports[exported] = modeMethods[exported] + +// Shim library CodeMirror with the minimal CodeMirror defined above. +require.cache[require.resolve("../../lib/codemirror")] = require.cache[require.resolve("./runmode.node")] +require.cache[require.resolve("../../addon/runmode/runmode")] = require.cache[require.resolve("./runmode.node")] + +// Minimal default mode. +exports.defineMode("null", () => ({token: stream => stream.skipToEnd()})) +exports.defineMIME("text/plain", "null") + +exports.registerHelper = exports.registerGlobalHelper = Math.min +exports.splitLines = function(string) { return string.split(/\r?\n|\r/); } + +exports.defaults = { indentUnit: 2 } \ No newline at end of file diff --git a/src/addon/runmode/runmode-standalone.js b/src/addon/runmode/runmode-standalone.js new file mode 100644 index 0000000000..0d7aa6bb2c --- /dev/null +++ b/src/addon/runmode/runmode-standalone.js @@ -0,0 +1,2 @@ +import "./codemirror-standalone.js" +import "../../../addon/runmode/runmode.js" \ No newline at end of file diff --git a/src/addon/runmode/runmode.node.js b/src/addon/runmode/runmode.node.js new file mode 100644 index 0000000000..4f2ed817f8 --- /dev/null +++ b/src/addon/runmode/runmode.node.js @@ -0,0 +1,2 @@ +import "./codemirror.node.js" +import "../../../addon/runmode/runmode.js" \ No newline at end of file From f87e1181c092bd01dc9acb9e91745fa97c9360e6 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Thu, 18 Jun 2020 15:07:36 +0200 Subject: [PATCH 076/557] [runmode.node addon] Export countColumn again --- src/addon/runmode/codemirror.node.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/addon/runmode/codemirror.node.js b/src/addon/runmode/codemirror.node.js index 11a142eee0..f3b5fa6e0e 100644 --- a/src/addon/runmode/codemirror.node.js +++ b/src/addon/runmode/codemirror.node.js @@ -1,8 +1,10 @@ import StringStream from "../../util/StringStream.js" import * as modeMethods from "../../modes.js" +import {countColumn} from "../../util/misc.js" // Copy StringStream and mode methods into exports (CodeMirror) object. exports.StringStream = StringStream +exports.countColumn = countColumn for (var exported in modeMethods) exports[exported] = modeMethods[exported] // Shim library CodeMirror with the minimal CodeMirror defined above. @@ -16,4 +18,4 @@ exports.defineMIME("text/plain", "null") exports.registerHelper = exports.registerGlobalHelper = Math.min exports.splitLines = function(string) { return string.split(/\r?\n|\r/); } -exports.defaults = { indentUnit: 2 } \ No newline at end of file +exports.defaults = { indentUnit: 2 } From 6bb912b3e2b518806c28a00082df0a60c062c1bb Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Thu, 18 Jun 2020 15:13:27 +0200 Subject: [PATCH 077/557] [runmode addon] Fix lint issues --- rollup.config.js | 14 +++++++------- src/addon/runmode/codemirror-standalone.js | 6 ++++-- src/addon/runmode/codemirror.node.js | 4 ++-- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/rollup.config.js b/rollup.config.js index 88c94411f8..f50f62fae2 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -5,14 +5,14 @@ export default [ input: "src/codemirror.js", output: { banner: `// CodeMirror, copyright (c) by Marijn Haverbeke and others - // Distributed under an MIT license: https://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE - // This is CodeMirror (https://codemirror.net), a code editor - // implemented in JavaScript on top of the browser's DOM. - // - // You can find some technical background for some of the code below - // at http://marijnhaverbeke.nl/blog/#cm-internals . - `, +// This is CodeMirror (https://codemirror.net), a code editor +// implemented in JavaScript on top of the browser's DOM. +// +// You can find some technical background for some of the code below +// at http://marijnhaverbeke.nl/blog/#cm-internals . +`, format: "umd", file: "lib/codemirror.js", name: "CodeMirror" diff --git a/src/addon/runmode/codemirror-standalone.js b/src/addon/runmode/codemirror-standalone.js index bb246c9b9f..b463a5cf59 100644 --- a/src/addon/runmode/codemirror-standalone.js +++ b/src/addon/runmode/codemirror-standalone.js @@ -1,6 +1,8 @@ import StringStream from "../../util/StringStream.js" import * as modeMethods from "../../modes.js" +// declare global: globalThis, CodeMirror + // Create a minimal CodeMirror needed to use runMode, and assign to root. var root = typeof globalThis !== 'undefined' ? globalThis : window root.CodeMirror = {} @@ -14,7 +16,7 @@ CodeMirror.defineMode("null", () => ({token: stream => stream.skipToEnd()})) CodeMirror.defineMIME("text/plain", "null") CodeMirror.registerHelper = CodeMirror.registerGlobalHelper = Math.min -CodeMirror.splitLines = function(string) { return string.split(/\r?\n|\r/); } +CodeMirror.splitLines = function(string) { return string.split(/\r?\n|\r/) } CodeMirror.defaults = { indentUnit: 2 } -export default CodeMirror; \ No newline at end of file +export default CodeMirror diff --git a/src/addon/runmode/codemirror.node.js b/src/addon/runmode/codemirror.node.js index f3b5fa6e0e..58efc5286b 100644 --- a/src/addon/runmode/codemirror.node.js +++ b/src/addon/runmode/codemirror.node.js @@ -7,7 +7,7 @@ exports.StringStream = StringStream exports.countColumn = countColumn for (var exported in modeMethods) exports[exported] = modeMethods[exported] -// Shim library CodeMirror with the minimal CodeMirror defined above. +// Shim library CodeMirror with the minimal CodeMirror defined above. require.cache[require.resolve("../../lib/codemirror")] = require.cache[require.resolve("./runmode.node")] require.cache[require.resolve("../../addon/runmode/runmode")] = require.cache[require.resolve("./runmode.node")] @@ -16,6 +16,6 @@ exports.defineMode("null", () => ({token: stream => stream.skipToEnd()})) exports.defineMIME("text/plain", "null") exports.registerHelper = exports.registerGlobalHelper = Math.min -exports.splitLines = function(string) { return string.split(/\r?\n|\r/); } +exports.splitLines = function(string) { return string.split(/\r?\n|\r/) } exports.defaults = { indentUnit: 2 } From ddb3334726d8e265f4dec3d6b59baf8d9c9d0d75 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Sun, 21 Jun 2020 15:17:59 +0200 Subject: [PATCH 078/557] [closetag addon] Make whenClosing/whenOpening properly default to true Closes #6322 --- addon/edit/closetag.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addon/edit/closetag.js b/addon/edit/closetag.js index b8cbf95089..8689765eec 100644 --- a/addon/edit/closetag.js +++ b/addon/edit/closetag.js @@ -40,9 +40,9 @@ cm.removeKeyMap("autoCloseTags"); if (!val) return; var map = {name: "autoCloseTags"}; - if (typeof val != "object" || val.whenClosing) + if (typeof val != "object" || val.whenClosing !== false) map["'/'"] = function(cm) { return autoCloseSlash(cm); }; - if (typeof val != "object" || val.whenOpening) + if (typeof val != "object" || val.whenOpening !== false) map["'>'"] = function(cm) { return autoCloseGT(cm); }; cm.addKeyMap(map); }); From 41077c866c65c9c905f662306a67d54a7cf56d85 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Sun, 21 Jun 2020 15:40:04 +0200 Subject: [PATCH 079/557] Mark version 5.55.0 --- AUTHORS | 4 ++++ CHANGELOG.md | 20 ++++++++++++++++++++ doc/manual.html | 2 +- doc/releases.html | 13 +++++++++++++ index.html | 2 +- package.json | 2 +- src/edit/main.js | 2 +- 7 files changed, 41 insertions(+), 4 deletions(-) diff --git a/AUTHORS b/AUTHORS index f5b5d7a6b6..f041a0572a 100644 --- a/AUTHORS +++ b/AUTHORS @@ -235,6 +235,7 @@ Dror BG Duncan Lilley duralog dwelle +Ealton eborden edoroshenko edsharp @@ -347,6 +348,7 @@ Ingo Richter Irakli Gozalishvili Ivan Kurnosov Ivoah +Jack Douglas Jacob Lee Jaimin Jake Peyser @@ -756,6 +758,7 @@ Shiv Deepak Shmuel Englard Shubham Jain Siamak Mokhtari +Siddhartha Gunti silverwind Simon Edwards sinkuu @@ -870,6 +873,7 @@ Yuvi Panda Yvonnick Esnault Zac Anger Zachary Dremann +ZeeshanNoor Zeno Rocha Zhang Hao Ziv diff --git a/CHANGELOG.md b/CHANGELOG.md index a445dd913a..b87340b524 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,23 @@ +## 5.55.0 (2020-05-20) + +### Bug fixes + +The editor no longer overrides the rendering of zero-width joiners (allowing combined emoji to be shown). + +[vim bindings](https://codemirror.net/demo/vim.html): Fix an issue where the `vim-mode-change` event was fired twice. + +[javascript mode](https://codemirror.net/mode/javascript/): Only allow `-->`-style comments at the start of a line. + +[julia mode](https://codemirror.net/mode/julia/): Improve indentation. + +[pascal mode](https://codemirror.net/mode/pascal/index.html): Recognize curly bracket comments. + +[runmode addon](https://codemirror.net/doc/manual.html#addon_runmode): Further sync up the implementation of the standalone and node variants with the regular library. + +### New features + +[loadmode addon](https://codemirror.net/doc/manual.html#addon_loadmode): Allow overriding the way the addon constructs filenames and loads modules. + ## 5.54.0 (2020-05-20) ### Bug fixes diff --git a/doc/manual.html b/doc/manual.html index e85ec25b66..8f42eeff60 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -69,7 +69,7 @@

        User manual and reference guide - version 5.54.0 + version 5.55.0

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

        Release notes and version history

        Version 5.x

        +

        21-06-2020: Version 5.55.0:

        + +
          +
        • The editor no longer overrides the rendering of zero-width joiners (allowing combined emoji to be shown).
        • +
        • vim bindings: Fix an issue where the vim-mode-change event was fired twice.
        • +
        • javascript mode: Only allow -->-style comments at the start of a line.
        • +
        • julia mode: Improve indentation.
        • +
        • pascal mode: Recognize curly bracket comments.
        • +
        • runmode addon: Further sync up the implementation of the standalone and node variants with the regular library.
        • +
        • New features

        • +
        • loadmode addon: Allow overriding the way the addon constructs filenames and loads modules.
        • +
        +

        20-05-2020: Version 5.54.0:

          diff --git a/index.html b/index.html index 59cac746fd..520fce4ec2 100644 --- a/index.html +++ b/index.html @@ -99,7 +99,7 @@

          This is CodeMirror

      - Get the current version: 5.54.0.
      + Get the current version: 5.55.0.
      You can see the code,
      read the release notes,
      or study the user manual. diff --git a/package.json b/package.json index f784cea808..dcffa6d998 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "codemirror", - "version": "5.54.0", + "version": "5.55.0", "main": "lib/codemirror.js", "style": "lib/codemirror.css", "author": { diff --git a/src/edit/main.js b/src/edit/main.js index e15243a415..04efb81564 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.54.0" +CodeMirror.version = "5.55.0" From dfb497cb797667850f1908bcc57cfe6a2c8c1e39 Mon Sep 17 00:00:00 2001 From: Benedikt Meurer Date: Mon, 22 Jun 2020 21:08:44 +0200 Subject: [PATCH 080/557] [wast mode] Rename atomic.notify and *.atomic.wait Refs: WebAssembly/threads#149 --- mode/wast/test.js | 6 +++--- mode/wast/wast.js | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mode/wast/test.js b/mode/wast/test.js index a8097768a7..f167087f63 100644 --- a/mode/wast/test.js +++ b/mode/wast/test.js @@ -72,9 +72,9 @@ '[keyword f64.store] [keyword offset]=[number 4] [keyword align]=[number 4]'); MT('atomic-memory-instructions', - '[keyword atomic.notify] [keyword offset]=[number 32] [keyword align]=[number 4]', - '[keyword i32.atomic.wait] [keyword offset]=[number 32] [keyword align]=[number 4]', - '[keyword i64.atomic.wait] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword memory.atomic.notify] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword memory.atomic.wait32] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword memory.atomic.wait64] [keyword offset]=[number 32] [keyword align]=[number 4]', '[keyword i32.atomic.load] [keyword offset]=[number 32] [keyword align]=[number 4]', '[keyword i32.atomic.load8_u] [keyword offset]=[number 32] [keyword align]=[number 4]', '[keyword i32.atomic.load16_u] [keyword offset]=[number 32] [keyword align]=[number 4]', diff --git a/mode/wast/wast.js b/mode/wast/wast.js index 8c517a4985..a0112a5176 100644 --- a/mode/wast/wast.js +++ b/mode/wast/wast.js @@ -14,7 +14,7 @@ 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\.(size|grow)|type|func|param|result|local|global|module|table|memory|start|elem|data|align|offset|import|export|atomic\.notify|i64\.atomic\.(load32_u|store32|rmw32\.(a[dn]d|sub|x?or|(cmp)?xchg)_u)|i(32|64)\.atomic\.(wait|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))/, token: "keyword"}, + {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))/, token: "keyword"}, {regex: /\b(anyfunc|[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"}, From c0120793f1e9986b631411b6112e207866d3db81 Mon Sep 17 00:00:00 2001 From: Ng Zhi An Date: Fri, 26 Jun 2020 11:57:14 -0700 Subject: [PATCH 081/557] [wast mode] Support some Wasm SIMD instructions These keywords can be found at https://github.com/WebAssembly/simd/blob/master/proposals/simd/BinarySIMD.md. --- mode/wast/test.js | 55 +++++++++++++++++++++++++++++++++++++++++++++++ mode/wast/wast.js | 2 +- 2 files changed, 56 insertions(+), 1 deletion(-) diff --git a/mode/wast/test.js b/mode/wast/test.js index f167087f63..b6ee52a60e 100644 --- a/mode/wast/test.js +++ b/mode/wast/test.js @@ -138,4 +138,59 @@ '[keyword i64.atomic.rmw8.cmpxchg_u] [keyword offset]=[number 32] [keyword align]=[number 4]', '[keyword i64.atomic.rmw16.cmpxchg_u] [keyword offset]=[number 32] [keyword align]=[number 4]', '[keyword i64.atomic.rmw32.cmpxchg_u] [keyword offset]=[number 32] [keyword align]=[number 4]'); + + MT('simd-instructions', + '[keyword v128.load] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword v128.store] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword v128.const] [number 0] [number 1] [number 2] [number 3] [number 4] [number 5] [number 6] [number 7] [number 8] [number 9] [number 10] [number 11] [number 12] [number 13] [number 14] [number 15]', + '[keyword i8x16.splat]', + '[keyword i16x8.splat]', + '[keyword i32x4.splat]', + '[keyword i64x2.splat]', + '[keyword f32x4.splat]', + '[keyword f64x2.splat]', + '[keyword i8x16.extract_lane_s] [number 1]', + '[keyword i8x16.extract_lane_u] [number 1]', + '[keyword i8x16.replace_lane] [number 1]', + '[keyword i16x8.extract_lane_s] [number 1]', + '[keyword i16x8.extract_lane_u] [number 1]', + '[keyword i16x8.replace_lane] [number 1]', + '[keyword i32x4.extract_lane] [number 1]', + '[keyword i32x4.replace_lane] [number 1]', + '[keyword i64x2.extract_lane] [number 1]', + '[keyword i64x2.replace_lane] [number 1]', + '[keyword f32x4.extract_lane] [number 1]', + '[keyword f32x4.replace_lane] [number 1]', + '[keyword f64x2.extract_lane] [number 1]', + '[keyword f64x2.replace_lane] [number 1]', + '[keyword v128.not]', + '[keyword v128.andnot]', + '[keyword v128.and]', + '[keyword v128.or]', + '[keyword v128.xor]', + '[keyword v128.bitselect]', + '[keyword i8x16.neg]', + '[keyword i8x16.shl]', + '[keyword i8x16.shr_s]', + '[keyword i8x16.shr_u]', + '[keyword i8x16.add]', + '[keyword i8x16.sub]', + '[keyword i16x8.add]', + '[keyword i16x8.neg]', + '[keyword i16x8.shl]', + '[keyword i16x8.shr_s]', + '[keyword i16x8.shr_u]', + '[keyword i16x8.sub]', + '[keyword i32x4.add]', + '[keyword i32x4.neg]', + '[keyword i32x4.shl]', + '[keyword i32x4.shr_s]', + '[keyword i32x4.shr_u]', + '[keyword i32x4.sub]', + '[keyword i64x2.add]', + '[keyword i64x2.neg]', + '[keyword i64x2.shl]', + '[keyword i64x2.shr_s]', + '[keyword i64x2.shr_u]', + '[keyword i64x2.sub]'); })(); diff --git a/mode/wast/wast.js b/mode/wast/wast.js index a0112a5176..7d3d111f5f 100644 --- a/mode/wast/wast.js +++ b/mode/wast/wast.js @@ -14,7 +14,7 @@ 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))/, token: "keyword"}, + {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|32x4|64x2)|f(32x4|64x2))\.(splat|replace_lane|neg|add|sub)|i(8x16|16x8)\.extract_lane_[su]|[fi](32x4|64x2)\.extract_lane/, token: "keyword"}, {regex: /\b(anyfunc|[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"}, From 4a36584eacad26521adddc468cd0f741cf2d0aa2 Mon Sep 17 00:00:00 2001 From: Ng Zhi An Date: Fri, 26 Jun 2020 14:07:27 -0700 Subject: [PATCH 082/557] [wast mode] Add more SIMD instructions This adds all comparison (eq, ne, lt, gt, le, ge), and v8x16.shuffle and v8x16.swizzle. Full list of instructions found at: https://github.com/WebAssembly/simd/blob/master/proposals/simd/BinarySIMD.md The ordering in the test file follows this the ordering in the binary form. The regex ordering is more arbitrary due to grouping. --- mode/wast/test.js | 44 ++++++++++++++++++++++++++++++++++++++++++++ mode/wast/wast.js | 2 +- 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/mode/wast/test.js b/mode/wast/test.js index b6ee52a60e..1812b115ec 100644 --- a/mode/wast/test.js +++ b/mode/wast/test.js @@ -143,6 +143,8 @@ '[keyword v128.load] [keyword offset]=[number 32] [keyword align]=[number 4]', '[keyword v128.store] [keyword offset]=[number 32] [keyword align]=[number 4]', '[keyword v128.const] [number 0] [number 1] [number 2] [number 3] [number 4] [number 5] [number 6] [number 7] [number 8] [number 9] [number 10] [number 11] [number 12] [number 13] [number 14] [number 15]', + '[keyword v8x16.shuffle] [number 0] [number 1] [number 2] [number 3] [number 4] [number 5] [number 6] [number 7] [number 8] [number 9] [number 10] [number 11] [number 12] [number 13] [number 14] [number 15]', + '[keyword v8x16.swizzle]', '[keyword i8x16.splat]', '[keyword i16x8.splat]', '[keyword i32x4.splat]', @@ -163,6 +165,48 @@ '[keyword f32x4.replace_lane] [number 1]', '[keyword f64x2.extract_lane] [number 1]', '[keyword f64x2.replace_lane] [number 1]', + '[keyword i8x16.eq]', + '[keyword i8x16.ne]', + '[keyword i8x16.lt_s]', + '[keyword i8x16.lt_u]', + '[keyword i8x16.gt_s]', + '[keyword i8x16.gt_u]', + '[keyword i8x16.le_s]', + '[keyword i8x16.le_u]', + '[keyword i8x16.ge_s]', + '[keyword i8x16.ge_u]', + '[keyword i16x8.eq]', + '[keyword i16x8.ne]', + '[keyword i16x8.lt_s]', + '[keyword i16x8.lt_u]', + '[keyword i16x8.gt_s]', + '[keyword i16x8.gt_u]', + '[keyword i16x8.le_s]', + '[keyword i16x8.le_u]', + '[keyword i16x8.ge_s]', + '[keyword i16x8.ge_u]', + '[keyword i32x4.eq]', + '[keyword i32x4.ne]', + '[keyword i32x4.lt_s]', + '[keyword i32x4.lt_u]', + '[keyword i32x4.gt_s]', + '[keyword i32x4.gt_u]', + '[keyword i32x4.le_s]', + '[keyword i32x4.le_u]', + '[keyword i32x4.ge_s]', + '[keyword i32x4.ge_u]', + '[keyword f32x4.eq]', + '[keyword f32x4.ne]', + '[keyword f32x4.lt]', + '[keyword f32x4.gt]', + '[keyword f32x4.le]', + '[keyword f32x4.ge]', + '[keyword f64x2.eq]', + '[keyword f64x2.ne]', + '[keyword f64x2.lt]', + '[keyword f64x2.gt]', + '[keyword f64x2.le]', + '[keyword f64x2.ge]', '[keyword v128.not]', '[keyword v128.andnot]', '[keyword v128.and]', diff --git a/mode/wast/wast.js b/mode/wast/wast.js index 7d3d111f5f..90bf57fc46 100644 --- a/mode/wast/wast.js +++ b/mode/wast/wast.js @@ -14,7 +14,7 @@ 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|32x4|64x2)|f(32x4|64x2))\.(splat|replace_lane|neg|add|sub)|i(8x16|16x8)\.extract_lane_[su]|[fi](32x4|64x2)\.extract_lane/, token: "keyword"}, + {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|32x4|64x2)|f(32x4|64x2))\.(splat|replace_lane|neg|add|sub)|i(8x16|16x8)\.extract_lane_[su]|i(8x16|16x8|32x4)\.(eq|ne|([lg][te]_[su]))|f(32x4|64x2)\.(eq|ne|[lg][te])|[fi](32x4|64x2)\.extract_lane|v8x16\.(shuffle|swizzle)/, token: "keyword"}, {regex: /\b(anyfunc|[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"}, From cab432b243cd0c505bf384ee93b8350de778aa75 Mon Sep 17 00:00:00 2001 From: Ng Zhi An Date: Fri, 26 Jun 2020 15:00:42 -0700 Subject: [PATCH 083/557] [wast mode] Add more SIMD instructions Some arithmetic instructions, had to shuffle the regex a bit so that we will attempt to match i8x16.add_saturate_s first before i8x16.add. Full list available at: https://github.com/WebAssembly/simd/blob/master/proposals/simd/BinarySIMD.md --- mode/wast/test.js | 40 +++++++++++++++++++++++++++++++++++++++- mode/wast/wast.js | 2 +- 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/mode/wast/test.js b/mode/wast/test.js index 1812b115ec..5cc12e29c2 100644 --- a/mode/wast/test.js +++ b/mode/wast/test.js @@ -201,36 +201,74 @@ '[keyword f32x4.gt]', '[keyword f32x4.le]', '[keyword f32x4.ge]', + '[keyword f32x4.abs]', + '[keyword f32x4.neg]', '[keyword f64x2.eq]', '[keyword f64x2.ne]', '[keyword f64x2.lt]', '[keyword f64x2.gt]', '[keyword f64x2.le]', '[keyword f64x2.ge]', + '[keyword f64x2.abs]', + '[keyword f64x2.neg]', '[keyword v128.not]', '[keyword v128.andnot]', '[keyword v128.and]', '[keyword v128.or]', '[keyword v128.xor]', '[keyword v128.bitselect]', + '[keyword i8x16.abs]', '[keyword i8x16.neg]', + '[keyword i8x16.any_true]', + '[keyword i8x16.all_true]', + '[keyword i8x16.bitmask]', '[keyword i8x16.shl]', '[keyword i8x16.shr_s]', '[keyword i8x16.shr_u]', '[keyword i8x16.add]', + '[keyword i8x16.add_saturate_s]', + '[keyword i8x16.add_saturate_u]', '[keyword i8x16.sub]', - '[keyword i16x8.add]', + '[keyword i8x16.sub_saturate_s]', + '[keyword i8x16.sub_saturate_u]', + '[keyword i8x16.min_s]', + '[keyword i8x16.min_u]', + '[keyword i8x16.max_s]', + '[keyword i8x16.max_u]', + '[keyword i8x16.avgr_u]', + '[keyword i16x8.abs]', '[keyword i16x8.neg]', + '[keyword i16x8.any_true]', + '[keyword i16x8.all_true]', + '[keyword i16x8.bitmask]', '[keyword i16x8.shl]', '[keyword i16x8.shr_s]', '[keyword i16x8.shr_u]', + '[keyword i16x8.add]', + '[keyword i16x8.add_saturate_s]', + '[keyword i16x8.add_saturate_u]', '[keyword i16x8.sub]', + '[keyword i16x8.sub_saturate_s]', + '[keyword i16x8.sub_saturate_u]', + '[keyword i16x8.min_s]', + '[keyword i16x8.min_u]', + '[keyword i16x8.max_s]', + '[keyword i16x8.max_u]', + '[keyword i16x8.avgr_u]', '[keyword i32x4.add]', + '[keyword i32x4.abs]', '[keyword i32x4.neg]', + '[keyword i32x4.any_true]', + '[keyword i32x4.all_true]', + '[keyword i32x4.bitmask]', '[keyword i32x4.shl]', '[keyword i32x4.shr_s]', '[keyword i32x4.shr_u]', '[keyword i32x4.sub]', + '[keyword i32x4.min_s]', + '[keyword i32x4.min_u]', + '[keyword i32x4.max_s]', + '[keyword i32x4.max_u]', '[keyword i64x2.add]', '[keyword i64x2.neg]', '[keyword i64x2.shl]', diff --git a/mode/wast/wast.js b/mode/wast/wast.js index 90bf57fc46..15b384d6f8 100644 --- a/mode/wast/wast.js +++ b/mode/wast/wast.js @@ -14,7 +14,7 @@ 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|32x4|64x2)|f(32x4|64x2))\.(splat|replace_lane|neg|add|sub)|i(8x16|16x8)\.extract_lane_[su]|i(8x16|16x8|32x4)\.(eq|ne|([lg][te]_[su]))|f(32x4|64x2)\.(eq|ne|[lg][te])|[fi](32x4|64x2)\.extract_lane|v8x16\.(shuffle|swizzle)/, token: "keyword"}, + {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)|[fi](32x4|64x2)\.extract_lane|v8x16\.(shuffle|swizzle)/, token: "keyword"}, {regex: /\b(anyfunc|[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"}, From ae507dc0c4c39ebed999cde806889fac1ded2076 Mon Sep 17 00:00:00 2001 From: Ng Zhi An Date: Fri, 26 Jun 2020 15:07:25 -0700 Subject: [PATCH 084/557] [wast mode] More SIMD instructions f32x4 and f64x2 arithmetic instructions. Sorted test cases to match the order in https://github.com/WebAssembly/simd/blob/master/proposals/simd/BinarySIMD.md to make it easier to spot missing instructions. --- mode/wast/test.js | 24 +++++++++++++++++++----- mode/wast/wast.js | 2 +- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/mode/wast/test.js b/mode/wast/test.js index 5cc12e29c2..ca6de4640c 100644 --- a/mode/wast/test.js +++ b/mode/wast/test.js @@ -201,16 +201,12 @@ '[keyword f32x4.gt]', '[keyword f32x4.le]', '[keyword f32x4.ge]', - '[keyword f32x4.abs]', - '[keyword f32x4.neg]', '[keyword f64x2.eq]', '[keyword f64x2.ne]', '[keyword f64x2.lt]', '[keyword f64x2.gt]', '[keyword f64x2.le]', '[keyword f64x2.ge]', - '[keyword f64x2.abs]', - '[keyword f64x2.neg]', '[keyword v128.not]', '[keyword v128.andnot]', '[keyword v128.and]', @@ -274,5 +270,23 @@ '[keyword i64x2.shl]', '[keyword i64x2.shr_s]', '[keyword i64x2.shr_u]', - '[keyword i64x2.sub]'); + '[keyword i64x2.sub]', + '[keyword f32x4.abs]', + '[keyword f32x4.neg]', + '[keyword f32x4.sqrt]', + '[keyword f32x4.add]', + '[keyword f32x4.sub]', + '[keyword f32x4.mul]', + '[keyword f32x4.div]', + '[keyword f32x4.min]', + '[keyword f32x4.max]', + '[keyword f64x2.abs]', + '[keyword f64x2.neg]', + '[keyword f64x2.sqrt]', + '[keyword f64x2.add]', + '[keyword f64x2.sub]', + '[keyword f64x2.mul]', + '[keyword f64x2.div]', + '[keyword f64x2.min]', + '[keyword f64x2.max]'); })(); diff --git a/mode/wast/wast.js b/mode/wast/wast.js index 15b384d6f8..4b1c910e63 100644 --- a/mode/wast/wast.js +++ b/mode/wast/wast.js @@ -14,7 +14,7 @@ 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)|[fi](32x4|64x2)\.extract_lane|v8x16\.(shuffle|swizzle)/, token: "keyword"}, + {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)/, token: "keyword"}, {regex: /\b(anyfunc|[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"}, From c8ef5e8e9a52e94e6199021155b9097ab57803c6 Mon Sep 17 00:00:00 2001 From: Ng Zhi An Date: Fri, 26 Jun 2020 15:30:19 -0700 Subject: [PATCH 085/557] [wast mode] Complete SIMD instructions This finished the set of SIMD instructions 178 of them in total, also sorted tests by their ordering in https://github.com/WebAssembly/simd/blob/master/proposals/simd/BinarySIMD.md. --- mode/wast/test.js | 37 +++++++++++++++++++++++++++++++++---- mode/wast/wast.js | 2 +- 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/mode/wast/test.js b/mode/wast/test.js index ca6de4640c..9998cfd965 100644 --- a/mode/wast/test.js +++ b/mode/wast/test.js @@ -141,6 +141,16 @@ MT('simd-instructions', '[keyword v128.load] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i16x8.load8x8_s] [keyword offset]=[number 64] [keyword align]=[number 0]', + '[keyword i16x8.load8x8_u] [keyword offset]=[number 64] [keyword align]=[number 0]', + '[keyword i32x4.load16x4_s] [keyword offset]=[number 64] [keyword align]=[number 0]', + '[keyword i32x4.load16x4_u] [keyword offset]=[number 64] [keyword align]=[number 0]', + '[keyword i64x2.load32x2_s] [keyword offset]=[number 64] [keyword align]=[number 0]', + '[keyword i64x2.load32x2_u] [keyword offset]=[number 64] [keyword align]=[number 0]', + '[keyword v8x16.load_splat] [keyword offset]=[number 64] [keyword align]=[number 0]', + '[keyword v16x8.load_splat] [keyword offset]=[number 64] [keyword align]=[number 0]', + '[keyword v32x4.load_splat] [keyword offset]=[number 64] [keyword align]=[number 0]', + '[keyword v64x2.load_splat] [keyword offset]=[number 64] [keyword align]=[number 0]', '[keyword v128.store] [keyword offset]=[number 32] [keyword align]=[number 4]', '[keyword v128.const] [number 0] [number 1] [number 2] [number 3] [number 4] [number 5] [number 6] [number 7] [number 8] [number 9] [number 10] [number 11] [number 12] [number 13] [number 14] [number 15]', '[keyword v8x16.shuffle] [number 0] [number 1] [number 2] [number 3] [number 4] [number 5] [number 6] [number 7] [number 8] [number 9] [number 10] [number 11] [number 12] [number 13] [number 14] [number 15]', @@ -208,8 +218,8 @@ '[keyword f64x2.le]', '[keyword f64x2.ge]', '[keyword v128.not]', - '[keyword v128.andnot]', '[keyword v128.and]', + '[keyword v128.andnot]', '[keyword v128.or]', '[keyword v128.xor]', '[keyword v128.bitselect]', @@ -218,6 +228,8 @@ '[keyword i8x16.any_true]', '[keyword i8x16.all_true]', '[keyword i8x16.bitmask]', + '[keyword i8x16.narrow_i16x8_s]', + '[keyword i8x16.narrow_i16x8_u]', '[keyword i8x16.shl]', '[keyword i8x16.shr_s]', '[keyword i8x16.shr_u]', @@ -237,6 +249,12 @@ '[keyword i16x8.any_true]', '[keyword i16x8.all_true]', '[keyword i16x8.bitmask]', + '[keyword i16x8.narrow_i32x4_s]', + '[keyword i16x8.narrow_i32x4_u]', + '[keyword i16x8.widen_low_i8x16_s]', + '[keyword i16x8.widen_high_i8x16_s]', + '[keyword i16x8.widen_low_i8x16_u]', + '[keyword i16x8.widen_high_i8x16_u]', '[keyword i16x8.shl]', '[keyword i16x8.shr_s]', '[keyword i16x8.shr_u]', @@ -246,31 +264,38 @@ '[keyword i16x8.sub]', '[keyword i16x8.sub_saturate_s]', '[keyword i16x8.sub_saturate_u]', + '[keyword i16x8.mul]', '[keyword i16x8.min_s]', '[keyword i16x8.min_u]', '[keyword i16x8.max_s]', '[keyword i16x8.max_u]', '[keyword i16x8.avgr_u]', - '[keyword i32x4.add]', '[keyword i32x4.abs]', '[keyword i32x4.neg]', '[keyword i32x4.any_true]', '[keyword i32x4.all_true]', '[keyword i32x4.bitmask]', + '[keyword i32x4.widen_low_i16x8_s]', + '[keyword i32x4.widen_high_i16x8_s]', + '[keyword i32x4.widen_low_i16x8_u]', + '[keyword i32x4.widen_high_i16x8_u]', '[keyword i32x4.shl]', '[keyword i32x4.shr_s]', '[keyword i32x4.shr_u]', + '[keyword i32x4.add]', '[keyword i32x4.sub]', + '[keyword i32x4.mul]', '[keyword i32x4.min_s]', '[keyword i32x4.min_u]', '[keyword i32x4.max_s]', '[keyword i32x4.max_u]', - '[keyword i64x2.add]', '[keyword i64x2.neg]', '[keyword i64x2.shl]', '[keyword i64x2.shr_s]', '[keyword i64x2.shr_u]', + '[keyword i64x2.add]', '[keyword i64x2.sub]', + '[keyword i64x2.mul]', '[keyword f32x4.abs]', '[keyword f32x4.neg]', '[keyword f32x4.sqrt]', @@ -288,5 +313,9 @@ '[keyword f64x2.mul]', '[keyword f64x2.div]', '[keyword f64x2.min]', - '[keyword f64x2.max]'); + '[keyword f64x2.max]', + '[keyword i32x4.trunc_sat_f32x4_s]', + '[keyword i32x4.trunc_sat_f32x4_u]', + '[keyword f32x4.convert_i32x4_s]', + '[keyword f32x4.convert_i32x4_u]'); })(); diff --git a/mode/wast/wast.js b/mode/wast/wast.js index 4b1c910e63..9348ad3e0a 100644 --- a/mode/wast/wast.js +++ b/mode/wast/wast.js @@ -14,7 +14,7 @@ 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)/, token: "keyword"}, + {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: /\$([a-zA-Z0-9_`\+\-\*\/\\\^~=<>!\?@#$%&|:\.]+)/, token: "variable-2"}, {regex: /"(?:[^"\\\x00-\x1f\x7f]|\\[nt\\'"]|\\[0-9a-fA-F][0-9a-fA-F])*"/, token: "string"}, From 3008203e8fd69195a47d39556ebe78cbf528fb84 Mon Sep 17 00:00:00 2001 From: Paul Schmidt Date: Tue, 30 Jun 2020 00:07:27 +0200 Subject: [PATCH 086/557] [sas mode] Add missing keywords I've noticed these few are missing. All from PROC MIXED --- mode/sas/sas.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mode/sas/sas.js b/mode/sas/sas.js index c6f528e0a9..49b96b66de 100755 --- a/mode/sas/sas.js +++ b/mode/sas/sas.js @@ -88,7 +88,7 @@ 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('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 ddfm 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 random ranexp rangam range ranks rannor ranpoi rantbl rantri ranuni rcorr read recfm register regr remote remove rename repeat repeated 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 sub 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 From e2d786c7583371dedc432cf70755f01df0299a49 Mon Sep 17 00:00:00 2001 From: benhormann Date: Wed, 8 Jul 2020 07:15:31 +0100 Subject: [PATCH 087/557] [vim bindings] Document events fired by vim mode --- doc/manual.html | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/doc/manual.html b/doc/manual.html index 8f42eeff60..e779008384 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -58,6 +58,7 @@
    • Vim Mode API
    • @@ -3559,6 +3560,21 @@

      Configuration

      +

      Events

      + +

      VIM mode signals a few events on the editor instance. For an example usage, see demo/vim.html#L101.

      + +
      +
      "vim-command-done" (reason: undefined)
      +
      Fired on keypress and mousedown where command has completed or no command found.
      + +
      "vim-keypress" (vimKey: string)
      +
      Fired on keypress, vimKey is in Vim's key notation.
      + +
      "vim-mode-change" (modeObj: object)
      +
      Fired after mode change, modeObj parameter is a {mode: string, ?subMode: string} object. Modes: "insert", "normal", "replace", "visual". Visual sub-modes: "linewise", "blockwise".
      +
      +

      Extending VIM

      CodeMirror's VIM mode implements a large subset of VIM's core From b5ce22f1e350431adaefbad40cbfc54dbfdb1c77 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Wed, 8 Jul 2020 08:35:24 +0200 Subject: [PATCH 088/557] Fix line-wise pasting on Chrome Windows Closes #6337 --- 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 8519ecfb7c..32adbf9b2a 100644 --- a/src/input/input.js +++ b/src/input/input.js @@ -51,7 +51,7 @@ export function applyTextInput(cm, inserted, deleted, sel, origin) { from = Pos(from.line, from.ch - deleted) else if (cm.state.overwrite && !paste) // Handle overwrite to = Pos(to.line, Math.min(getLine(doc, to.line).text.length, to.ch + lst(textLines).length)) - else if (paste && lastCopied && lastCopied.lineWise && lastCopied.text.join("\n") == inserted) + else if (paste && lastCopied && lastCopied.lineWise && lastCopied.text.join("\n") == textLines.join("\n")) from = to = Pos(from.line, 0) } let changeEvent = {from: from, to: to, text: multiPaste ? multiPaste[i % multiPaste.length] : textLines, @@ -132,4 +132,4 @@ export function hiddenTextarea() { if (ios) te.style.border = "1px solid black" disableBrowserMagic(te) return div -} \ No newline at end of file +} From 0682bcc8d5d5f03cebfbb9d14c3ffa7dcc3e0e6d Mon Sep 17 00:00:00 2001 From: Kaushik Kulkarni Date: Thu, 2 Jul 2020 00:54:59 -0500 Subject: [PATCH 089/557] [hardwrap addon] introduce forceBreak --- addon/wrap/hardwrap.js | 30 ++++++++++++++++++++++-------- doc/manual.html | 5 +++++ 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/addon/wrap/hardwrap.js b/addon/wrap/hardwrap.js index 29cc15f01f..2259e0e11e 100644 --- a/addon/wrap/hardwrap.js +++ b/addon/wrap/hardwrap.js @@ -29,11 +29,20 @@ return {from: start, to: end}; } - function findBreakPoint(text, column, wrapOn, killTrailingSpace) { + function findBreakPoint(text, column, wrapOn, killTrailingSpace, forceBreak) { var at = column while (at < text.length && text.charAt(at) == " ") at++ for (; at > 0; --at) if (wrapOn.test(text.slice(at - 1, at + 1))) break; + + if ((at == 0) && (!forceBreak)) { + // 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) { + if (wrapOn.test(text.slice(at - 1, at + 1))) break; + } + } + for (var first = true;; first = false) { var endOfText = at; if (killTrailingSpace) @@ -47,6 +56,7 @@ from = cm.clipPos(from); to = cm.clipPos(to); var column = options.column || 80; var wrapOn = options.wrapOn || /\s\S|-[^\.\d]/; + var forceBreak = options.forceBreak !== false; var killTrailing = options.killTrailingSpace !== false; var changes = [], curLine = "", curNo = from.line; var lines = cm.getRange(from, to, false); @@ -68,7 +78,7 @@ curLine += text; if (i) { var firstBreak = curLine.length > column && leadingSpace == spaceTrimmed && - findBreakPoint(curLine, column, wrapOn, killTrailing); + findBreakPoint(curLine, column, wrapOn, killTrailing, forceBreak); // If this isn't broken, or is broken at a different point, remove old break if (!firstBreak || firstBreak.from != oldLen || firstBreak.to != oldLen + spaceInserted) { changes.push({text: [spaceInserted ? " " : ""], @@ -80,12 +90,16 @@ } } while (curLine.length > column) { - var bp = findBreakPoint(curLine, column, wrapOn, killTrailing); - changes.push({text: ["", leadingSpace], - from: Pos(curNo, bp.from), - to: Pos(curNo, bp.to)}); - curLine = leadingSpace + curLine.slice(bp.to); - ++curNo; + var bp = findBreakPoint(curLine, column, wrapOn, killTrailing, forceBreak); + if ((bp.from != bp.to) || (forceBreak)) { + changes.push({text: ["", leadingSpace], + from: Pos(curNo, bp.from), + to: Pos(curNo, bp.to)}); + curLine = leadingSpace + curLine.slice(bp.to); + ++curNo; + } else { + break; + } } } if (changes.length) cm.operation(function() { diff --git a/doc/manual.html b/doc/manual.html index e779008384..8008002a40 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -3135,6 +3135,11 @@

      Addons

      killTrailingSpace: boolean
      Whether trailing space caused by wrapping should be preserved, or deleted. Defaults to true.
      +
      forceBreak: boolean
      +
      If set to true forces a break at column in the case + when no wrapOn pattern is found in the range. If set to + false allows line to overflow the column limit if no + wrapOn pattern found. Defaults to true.
      A demo of the addon is available here. From 09943f9eafe7997747821946c67c4fd97c9700d9 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Wed, 8 Jul 2020 09:30:29 +0200 Subject: [PATCH 090/557] [hardbreak addon] Adjust formatting Issue #6338 --- addon/wrap/hardwrap.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/addon/wrap/hardwrap.js b/addon/wrap/hardwrap.js index 2259e0e11e..f194946c5d 100644 --- a/addon/wrap/hardwrap.js +++ b/addon/wrap/hardwrap.js @@ -35,10 +35,10 @@ for (; at > 0; --at) if (wrapOn.test(text.slice(at - 1, at + 1))) break; - if ((at == 0) && (!forceBreak)) { + if (at == 0 && !forceBreak) { // 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) { + for (at = column + 1; at < text.length - 1; ++at) { if (wrapOn.test(text.slice(at - 1, at + 1))) break; } } @@ -56,7 +56,7 @@ from = cm.clipPos(from); to = cm.clipPos(to); var column = options.column || 80; var wrapOn = options.wrapOn || /\s\S|-[^\.\d]/; - var forceBreak = options.forceBreak !== false; + var forceBreak = options.forceBreak !== false; var killTrailing = options.killTrailingSpace !== false; var changes = [], curLine = "", curNo = from.line; var lines = cm.getRange(from, to, false); @@ -91,7 +91,7 @@ } while (curLine.length > column) { var bp = findBreakPoint(curLine, column, wrapOn, killTrailing, forceBreak); - if ((bp.from != bp.to) || (forceBreak)) { + if (bp.from != bp.to || forceBreak) { changes.push({text: ["", leadingSpace], from: Pos(curNo, bp.from), to: Pos(curNo, bp.to)}); From a0179ed7e0f935d309b1874759a15ee37cc36b60 Mon Sep 17 00:00:00 2001 From: Axel Lewenhaupt Date: Fri, 3 Jul 2020 18:29:15 +0200 Subject: [PATCH 091/557] Add support for import expressions. Committer: Axel Lewenhaupt --- mode/soy/soy.js | 24 ++++++++++++++++++++++++ mode/soy/test.js | 3 +++ 2 files changed, 27 insertions(+) diff --git a/mode/soy/soy.js b/mode/soy/soy.js index 1b19923da5..c97109b27d 100644 --- a/mode/soy/soy.js +++ b/mode/soy/soy.js @@ -402,6 +402,26 @@ } return expression(stream, state); + case "import": + if (stream.eat(";")) { + state.soyState.pop(); + state.indent -= 2 * config.indentUnit; + return null; + } + if (stream.match(/\w+(?=\s+as)/)) { + return "variable"; + } + if (match = stream.match(/\w+/)) { + return /(from|as)/.test(match[0]) ? "keyword" : "def"; + } + if (match = stream.match(/^["']/)) { + state.soyState.push("string"); + state.quoteKind = match[0]; + return "string"; + } + stream.next(); + return null; + case "tag": var endTag = state.tag[0] == "/"; var tagName = endTag ? state.tag.substring(1) : state.tag; @@ -499,6 +519,10 @@ state.indent += 2 * config.indentUnit; state.soyState.push("tag"); return "keyword"; + } else if (!state.context && stream.match(/\bimport\b/)) { + state.soyState.push("import"); + 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 2fb450e32e..11b49bccaa 100644 --- a/mode/soy/test.js +++ b/mode/soy/test.js @@ -252,4 +252,7 @@ '[keyword {let] [def $myList]: [[[[[string \'a\'] ] ] [keyword /}] ' + '[keyword {let] [def $test]: [[[variable $a] [operator +] [atom 1] [keyword for] ' + '[def $a] [keyword in] [variable-2 $myList] [keyword if] [variable-2 $a] [operator >=] [atom 3] ] [keyword /}]'); + + MT('import', + '[keyword import] {[def Name], [variable Person] [keyword as] [def P]} [keyword from] [string \'examples/proto/example.proto\'];'); })(); From 82d0f4aacf307763cfae1ac6d60dbeefc221a230 Mon Sep 17 00:00:00 2001 From: Axel Lewenhaupt Date: Thu, 9 Jul 2020 15:58:34 +0200 Subject: [PATCH 092/557] [soy mode] Support template type Co-authored-by: Axel Lewenhaupt --- mode/soy/soy.js | 21 +++++++++++++++++++++ mode/soy/test.js | 7 +++++++ 2 files changed, 28 insertions(+) diff --git a/mode/soy/soy.js b/mode/soy/soy.js index c97109b27d..3539f313fc 100644 --- a/mode/soy/soy.js +++ b/mode/soy/soy.js @@ -256,6 +256,11 @@ // Otherwise return "variable"; } + if (match = stream.match(/^\$([\w]+)/)) { + state.soyState.pop(); + return ref(state.variables, match[1], !state.lookupVariables); + } + stream.next(); return null; @@ -300,6 +305,9 @@ } else if (peekChar == "[") { state.soyState.push('param-type-record'); return null; + } else if (peekChar == "(") { + state.soyState.push('param-type-template'); + return null; } else if (peekChar == "<") { state.soyState.push('param-type-parameter'); return null; @@ -334,6 +342,19 @@ stream.next(); return null; + case "param-type-template": + if (stream.match(/[>]/)) { + state.soyState.pop(); + state.soyState.push('param-type'); + return null; + } + if (stream.match(/^\w+/)) { + state.soyState.push('param-type'); + return "def"; + } + stream.next(); + return null; + case "var-def": if (match = stream.match(/^\$([\w]+)/)) { state.variables = prepend(state.variables, match[1]); diff --git a/mode/soy/test.js b/mode/soy/test.js index 11b49bccaa..8253b47357 100644 --- a/mode/soy/test.js +++ b/mode/soy/test.js @@ -178,6 +178,13 @@ '[keyword {/template}]', ''); + MT('param-type-template', + '[keyword {template] [def .foo][keyword }]', + ' [keyword {@param] [def renderer]: ([def s]:[type string])=>[type html][keyword }]', + ' [keyword {call] [variable-2 $renderer] [keyword /}]', + '[keyword {/template}]', + ''); + MT('single-quote-strings', '[keyword {][string "foo"] [string \'bar\'][keyword }]', ''); From 0ec092019c98ce39584f3cc814732e348b69d570 Mon Sep 17 00:00:00 2001 From: Axel Lewenhaupt Date: Thu, 9 Jul 2020 22:28:01 +0200 Subject: [PATCH 093/557] [soy mode] Add support for index in for loops - Fix variable scrope issue with list comprehensions. Co-authored-by: Axel Lewenhaupt --- mode/soy/soy.js | 24 ++++++++++++++++++------ mode/soy/test.js | 19 +++++++++++++++++++ 2 files changed, 37 insertions(+), 6 deletions(-) diff --git a/mode/soy/soy.js b/mode/soy/soy.js index 3539f313fc..d31c947eed 100644 --- a/mode/soy/soy.js +++ b/mode/soy/soy.js @@ -34,9 +34,9 @@ "switch": {}, "case": { noEndTag: true, reduceIndent: true}, "default": { noEndTag: true, reduceIndent: true}, - "foreach": { variableScope: true, soyState: "var-def" }, + "foreach": { variableScope: true, soyState: "for-loop" }, "ifempty": { noEndTag: true, reduceIndent: true}, - "for": { variableScope: true, soyState: "var-def" }, + "for": { variableScope: true, soyState: "for-loop" }, "call": { soyState: "templ-ref" }, "param": { soyState: "param-ref"}, "print": { noEndTag: true }, @@ -129,6 +129,7 @@ var match; if (stream.match(/[[]/)) { state.soyState.push("list-literal"); + state.context = new Context(state.context, "list-literal", state.variables); state.lookupVariables = false; return null; } else if (stream.match(/map\b/)) { @@ -364,6 +365,18 @@ stream.next(); return null; + case "for-loop": + if (stream.match(/\bin\b/)) { + state.soyState.pop(); + return "keyword"; + } + if (stream.peek() == "$") { + state.soyState.push('var-def'); + return null; + } + stream.next(); + return null; + case "record-literal": if (stream.match(/^[)]/)) { state.soyState.pop(); @@ -394,13 +407,12 @@ if (stream.match(/\]/)) { state.soyState.pop(); state.lookupVariables = true; + popcontext(state); return null; } - if (stream.match(/for\b/)) { - state.soyState.push("var-def") - return "keyword"; - } else if (stream.match(/in\b/)) { + if (stream.match(/\bfor\b/)) { state.lookupVariables = true; + state.soyState.push('for-loop'); return "keyword"; } return expression(stream, state); diff --git a/mode/soy/test.js b/mode/soy/test.js index 8253b47357..57cd4be477 100644 --- a/mode/soy/test.js +++ b/mode/soy/test.js @@ -138,6 +138,11 @@ '[keyword {/foreach}]', ''); + MT('foreach-index', + '[keyword {foreach] [def $foo],[def $index] [keyword in] [[]] [keyword }]', + ' [keyword {][variable-2 $foo][keyword }] [keyword {][variable-2 $index][keyword }]', + '[keyword {/foreach}]'); + MT('nested-kind-test', '[keyword {template] [def .foo] [attribute kind]=[string "html"][keyword }]', ' [tag&bracket <][tag div][tag&bracket >]', @@ -260,6 +265,20 @@ '[keyword {let] [def $test]: [[[variable $a] [operator +] [atom 1] [keyword for] ' + '[def $a] [keyword in] [variable-2 $myList] [keyword if] [variable-2 $a] [operator >=] [atom 3] ] [keyword /}]'); + MT('list-comprehension-index', + '[keyword {let] [def $test]: [[[variable $a] [operator +] [variable $index] [keyword for] ' + + '[def $a],[def $index] [keyword in] [[]] [keyword if] [variable-2 $a] [operator >=] [variable-2 $index] ] [keyword /}]'); + + + MT('list-comprehension-variable-scope', + '[keyword {let] [def $name]: [string "world"][keyword /}]', + '[keyword {let] [def $test]: [[[variable $a] [operator +] [variable $index] [keyword for] ' + + '[def $a],[def $index] [keyword in] [[]] [keyword if] [variable-2 $a] [operator >=] [variable-2 $index] ] [keyword /}]', + '[keyword {][variable-2&error $a][keyword }]', + '[keyword {][variable-2&error $index][keyword }]', + '[keyword {][variable-2 $test][keyword }]', + '[keyword {][variable-2 $name][keyword }]'); + MT('import', '[keyword import] {[def Name], [variable Person] [keyword as] [def P]} [keyword from] [string \'examples/proto/example.proto\'];'); })(); From f5bf57b39816f0e6524a1b7d0212e9f26135ba08 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Sun, 12 Jul 2020 13:26:09 +0200 Subject: [PATCH 094/557] [sql-hint addon] Treat single quotes like double quotes when looking at tokens See https://discuss.codemirror.net/t/codemirror-ignore-show-hints-if-the-class-is-cm-string/2513 --- 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 0b89b79fab..de84707db3 100644 --- a/addon/hint/sql-hint.js +++ b/addon/hint/sql-hint.js @@ -264,7 +264,7 @@ token.string = token.string.slice(0, cur.ch - token.start); } - if (token.string.match(/^[.`"\w@][\w$#]*$/g)) { + if (token.string.match(/^[.`"'\w@][\w$#]*$/g)) { search = token.string; start = token.start; end = token.end; From feed5d5325e97f7414bef999347db338aa93f340 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Mon, 20 Jul 2020 22:07:20 +0200 Subject: [PATCH 095/557] Stop linking to the github wiki --- doc/manual.html | 6 +++--- index.html | 5 ----- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/doc/manual.html b/doc/manual.html index 8008002a40..a76378470d 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -79,9 +79,9 @@

      functionality. It does provide a rich API on top of which such functionality can be straightforwardly implemented. See the addons included in the distribution, - and the list - of externally hosted addons, for reusable - implementations of extra features.

      + and 3rd party + packages on npm, for reusable implementations of extra + features.

      CodeMirror works with language-specific modes. Modes are JavaScript programs that help color (and optionally indent) text diff --git a/index.html b/index.html index 520fce4ec2..27cf8fc7fe 100644 --- a/index.html +++ b/index.html @@ -171,11 +171,6 @@

      Community

      that explicit, we have a code of conduct that applies to communication around the project.

      - -

      A list of CodeMirror-related software that is not part of the - main distribution is maintained - on our - wiki. Feel free to add your project.

    From c8c4565d09f240afc33a31561e42943dfeee4784 Mon Sep 17 00:00:00 2001 From: Bin Ni Date: Mon, 20 Jul 2020 13:09:25 -0700 Subject: [PATCH 096/557] [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 097/557] 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 098/557] [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 099/557] [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 100/557] [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 101/557] [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 102/557] [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 103/557] [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 104/557] [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 105/557] [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 106/557] [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 107/557] 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 108/557] 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 109/557] [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 110/557] 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 126/557] 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 127/557] [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 128/557] [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 129/557] 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 130/557] 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 131/557] 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 132/557] 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 133/557] [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 134/557] 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 135/557] [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 136/557] 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 137/557] [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 138/557] 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 139/557] 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 140/557] 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 141/557] 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 142/557] [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 143/557] [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 144/557] [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 145/557] [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 146/557] 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 147/557] 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 148/557] [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 149/557] [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 150/557] [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 151/557] 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 152/557] 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 153/557] 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 154/557] [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 155/557] [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 156/557] 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 157/557] [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 158/557] [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 159/557] [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 160/557] [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 161/557] 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 162/557] [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 163/557] [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 164/557] 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 165/557] 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 166/557] [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 167/557] [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 168/557] [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 169/557] [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 170/557] [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 171/557] [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 172/557] [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 173/557] [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 174/557] [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 175/557] [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 176/557] 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 177/557] 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 178/557] [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 179/557] [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 180/557] [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 181/557] [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 182/557] [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 183/557] 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 184/557] [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 185/557] 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 186/557] [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 187/557] [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 188/557] 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 189/557] 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 190/557] [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 191/557] 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 192/557] [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 193/557] [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 194/557] 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 195/557] 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 196/557] 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 197/557] [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 198/557] 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 199/557] [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 200/557] [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 201/557] [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 202/557] [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 203/557] [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 204/557] 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 205/557] [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 206/557] 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 207/557] [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 208/557] [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 209/557] 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 210/557] [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 211/557] [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 212/557] [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 213/557] [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 214/557] 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 215/557] 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 492/557] [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 493/557] [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 494/557] [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 495/557] [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 496/557] [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 497/557] 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 498/557] [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 499/557] [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 500/557] [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 501/557] [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 502/557] 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 503/557] 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 504/557] 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 505/557] 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 506/557] [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 507/557] 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 508/557] 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 509/557] [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 510/557] [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 511/557] 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 512/557] [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 513/557] [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 514/557] [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 515/557] [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 516/557] 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 517/557] 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 518/557] [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 519/557] [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 520/557] [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 521/557] 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 522/557] [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 523/557] 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 524/557] [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 525/557] 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 526/557] [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 527/557] [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 528/557] [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 529/557] 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 530/557] 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 531/557] [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 532/557] [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 533/557] 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 534/557] 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 535/557] [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 536/557] [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 537/557] 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 538/557] 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 539/557] 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 540/557] [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 541/557] 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 542/557] [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 543/557] [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 544/557] 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 545/557] 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 546/557] [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 547/557] [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 548/557] [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 549/557] 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 550/557] [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 551/557] 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 552/557] 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 553/557] [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 554/557] [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 555/557] 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 556/557] [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 557/557] [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,