-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Open
Description
Reproducible in vscode.dev or in VS Code Desktop?
- Not reproducible in vscode.dev or VS Code Desktop
Reproducible in the monaco editor playground?
- Not reproducible in the monaco editor playground
Monaco Editor Playground Link
My goal is to have angle brackets as an autoClosingPair, but make an exception for codeblocks which are assigned the variable/variable.source classes for inlineBlock and multiline blocks respectively.
When I use variable/variable.source, the notIn doesn't respect the configuration and still autoCloses the open angle bracket in either type of codeblock.
Monaco Editor Playground Code
const conf = {
comments: {
blockComment: ["<!--", "-->"],
},
brackets: [
["{", "}"],
["[", "]"],
["(", ")"],
],
autoClosingPairs: [
{ open: "{", close: "}" },
{ open: "[", close: "]" },
{ open: "(", close: ")" },
{ open: "`", close: "`", notIn: ["string", "comment"] },
{ open: "", close: "", notIn: ["string", "comment"] },
{ open: "<", close: ">", notIn: ["string", "variable", "variable.source"] },
],
surroundingPairs: [
{ open: "(", close: ")" },
{ open: "[", close: "]" },
{ open: "`", close: "`" },
],
folding: {
markers: {
start: new RegExp("^\\s*<!--\\s*#?region\\b.*-->"),
end: new RegExp("^\\s*<!--\\s*#?endregion\\b.*-->"),
},
},
wordPattern: /(-?\d*\.\d\w*)|(#\w)/g,
}
const language = {
defaultToken: "",
tokenPostfix: ".md",
// escape codes
control: /[\\`*_\[\]{}()#+\-\.!]/,
noncontrol: /[^\\`*_\[\]{}()#+\-\.!]/,
escapes: /\\(?:@control)/,
// escape codes for javascript/CSS strings
jsescapes: /\\(?:[btnfr\\"']|[0-7][0-7]?|[0-3][0-7]{2})/,
// non matched elements
empty: [
"area",
"base",
"basefont",
"br",
"col",
"frame",
"hr",
"img",
"input",
"isindex",
"link",
"meta",
"param",
],
tokenizer: {
root: [
// headers (with #)
[/^(\s{0,3})(#+)((?:[^\\#]|@escapes)+)((?:#+)?)/, ["white", "keyword", "keyword", "keyword"]],
// headers (with =)
[/^\s*(=+|\-+)\s*$/, "keyword"],
// headers (with ***)
[/^\s*((\*[ ]?)+)\s*$/, "meta.separator"],
// quote
[/^\s*>+/, "comment"],
// list (starting with * or number)
[/^\s*([\*\-+:]|\d+\.)\s/, "keyword"],
// code block (4 spaces indent)
[/^(\t|[ ]{4})[^ ].*$/, "string"],
// code block (3 tilde)
[/^\s*~~~\s*((?:\w|[\/\-#])+)?\s*$/, { token: "string", next: "@codeblock" }],
// footnote reference
[/\[\^\d+\]/, "footnote-ref"],
// footnote definition
[/\[\^\d+\]:\s+(.*)$/gm, "footnote-def"],
// github style code blocks (with backticks and language)
[
/^\s*\s*((?:\w|[\/\-#])+).*$/,
{ token: "string", next: "@codeblockgh", nextEmbedded: "$1" },
],
// github style code blocks (with backticks but no language)
[/^\s*\s*$/, { token: "string", next: "@codeblock" }],
// markup within lines
{ include: "@linecontent" },
],
codeblock: [
[/^\s*~~~\s*$/, { token: "string", next: "@pop" }],
[/^\s*\s*$/, { token: "string", next: "@pop" }],
[/.*$/, "variable.source"],
],
// github style code blocks
codeblockgh: [
[/\s*$/, { token: "string", next: "@pop", nextEmbedded: "@pop" }],
[/[^`]+/, "variable.source"],
],
linecontent: [
// inline code blocks
[/`([^`\\]|\\[`\\])*`/, "variable"],
],
comment: [
[/[^<\-]+/, "comment.content"],
[/-->/, "comment", "@pop"],
[/<!--/, "comment.content.invalid"],
[/[<\-]/, "comment.content"],
],
},
}
monaco.languages.setLanguageConfiguration("markdown", conf)
monaco.languages.setMonarchTokensProvider("markdown", language)
// // Hover on each property to see its docs!
const editor = monaco.editor.create(document.getElementById("container"), {
value:"\n\n\n\n``",
language: "markdown",
automaticLayout: true,
});Reproduction Steps
Type an open angle bracket (<) into the multiline and inline blocks.
Actual (Problematic) Behavior
The open angle bracket is auto closed.
Expected Behavior
Expected it to not auto close based on the notIn configuration of autoClosingPairs for the angle brackets.
Additional Context
No response
Metadata
Metadata
Assignees
Labels
No labels