microsoft / microsoft/monaco-editor

[Bug] Adding backtick to close open string adds two backticks instead of one

Open
#4,641 1 comment 12 reactions 1 assignee View on GitHub

@hediet is already working on this.

Since Dec 18, 2024.

editor-autoclosing under-discussion
Dominant language
JavaScript
Stars
46.8k
Forks
4.1k
Avg merge
17h 58m
Merged PRs (30d)
1

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?
Monaco Editor Playground Link

https://microsoft.github.io/monaco-editor/playground.html?source=v0.50.0#XQAAAAKqAQAAAAAAAABBqQkHQ5NjdMjwa-jY7SIQ9S7DNlzs5W-mwj0fe1ZCDRFc9ws9XQE0SJE1jc2VKxhaLFIw9vEWSxW3yscwzzLUOdbD0yTm9PBkbpAuszLxat513xdup2C2_l1CzjuFyfDT_1lBACVOelNXBZUA0aTd3YOq41L39_jFWz3QNsV05mTliiBfNCKKLW91xEFfo5Ia2iCTcGUAeENH9EEeNbWncVb1ysStiTcXRbS83Awk7N3kD6KG0bZBpeB4tKX2o-_hu4qYfnS7dQTTbxoaoU6mP2pHrqNkECt2KpJbFkL5t9N23v-dUz1AnYyuhlbXd_7esWTXyawqdK6cMlmdTfFlJnetBlBCV0506BC7CYRea9T__6t0bwA

Monaco Editor Playground Code
monaco.languages.register({ id: "mySpecialLanguage" });

monaco.languages.setLanguageConfiguration('mySpecialLanguage', {
  autoClosingPairs: [
    { open: "'", close: "'" },
    { open: '`', close: '`' },
  ],
  // autoCloseBefore not helping in this case
});

monaco.editor.create(document.getElementById("container"), {
	language: "mySpecialLanguage",
});
Reproduction Steps
  1. type in a word string

  2. type a quote (' or ") at the beginning of the string

  3. type a quote at the end of the string. only one quote is added.

  4. enter into a new line and type a word string

  5. type a backtick (`) at the beginning of the string

  6. type a backtick at the end of the string. two backticks get added, when there should only be one

https://github.com/user-attachments/assets/d955ebfb-f411-45ab-89c2-3d581e5600da

Actual (Problematic) Behavior

Adding a backtick at the end of an open string (in attempt to close it) adds two backticks instead of 1

Expected Behavior

Adding a backtick at the end of an open string should only add 1 backtick

Additional Context

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.