vscode: Bracket pair guides incorrectly shown with Markdown fenced code blocks

Does this issue occur when all extensions are disabled?: Yes

  • VS Code Version: 1.61.0
  • OS Version: Windows_NT x64 10.0.22000

Steps to Reproduce:

  1. Enable editor.guides.bracketPairs
  2. Create a new Markdown document
  3. Insert the following content:
```cpp
{
```

This is just normal text and not part of the code block.

Here is the result:

image

The problem: The bracket pair guides continue past the end of the actual code block and continue into the text. This happens whenever a code block contains non-matching brackets.

Proposed solution: The bracket pair guides should only be drawn within each individual code block, and should not continue past the end of the block (nor start before the beginning of the block).

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 1
  • Comments: 18 (7 by maintainers)

Most upvoted comments

Hi @bshoshany I would consider disabling code fencing altogether for markdown files. It feels to me markdown is not the right use case te enable this editor feature for IMHO

  "[markdown]": {
    "editor.guides.bracketPairs": false
  }

I would recommend splitting your ‘markdown’ from your ‘code’.

My proposed workflow would be:

  1. SWITCH TO ASCIIDOC LANGUAGE WITH BUILTIN INCLUDE DIRECTIVES AND MORE
  • write your code in the actual coded files (ts, json, php, etc.) and have code fencing (ie. ‘guides.bracketPairs’) active
  • use include statements in Vscode
  • doing advanced stuff like ‘includes’ is probably a good reason to switch from markdown editing to a truly formal language syntax like Asciidoc and use the Asciidoctor vscode extension
  1. ALTERNATIVELY KEEP USING MARKDOWN BUT USE ‘IMPORT’ STATEMENTS THROUGH EXTENSION
  1. ALTERNATIVELY USE MANUAL COPY/PASTE
  • write your code in the actual coded files (ts, json, php, etc.) and have code fencing (ie. ‘guides.bracketPairs’) active
  • copy/paste from the actual code files into the markdown files code blocks is always possible of course

I totally agree… This doesn’t work for PHP. But here we’re talking about Markdown! Specifically, code that is within a Markdown fenced code block, i.e. between two ```.

That’s right. Everything should have its own issue 😉 In fact @fivemru’s issue had nothing to do with the main issue that involves embedded languages.

@hediet

If the green line is on the leftmost edge after pasting, you can format ALT + SHIFT + F

<!DOCTYPE html>
<html lang="en">

<head>
    <title>test</title>
</head>

<div>
    <div>
        <div>
            <div>
                <button data-op="+">+</button>
                <button data-op="-">-</button>
                <button data-op="log(">log</button>
                <button data-op="ln(">ln</button>
            </div>
        </div>
    </div>
</div>

</html>