WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Conversation

@bwat47
Copy link
Contributor

@bwat47 bwat47 commented Dec 6, 2025

Overview

Addresses #12569 by extending the auto-pair feature to support fenced code blocks. When typing three backticks at the start of a line, the editor automatically inserts closing backticks and positions the cursor for quick language specification

Implementation notes

This is a very basic implementation:

  • Only triggers the auto-completion when typing 3 backticks on line with no preceding (non whitespace) text
  • No list handling (there are many edge cases with code blocks in lists, uses intersectsSyntaxNode to completely avoid triggering auto complete fenced code inside lists)
  • No change in behavior for selected text (uses the standard closeBrackets behavior, no attempt to wrap multi-line selected text in code blocks for now)

Testing

  • Verify that auto complete of code fence only triggers on line with no preceding text
  • Verify that auto complete of code fence doesn't trigger inside lists
  • Test normal auto-pair behavior with inline code, quotes, parentheses
  • Verify that behavior with selected text is unchanged
  • Test with auto-pair disabled and verify behavior is not triggered after typing 3 backticks

Example

Recording.2025-12-05.215357.mp4

@bwat47
Copy link
Contributor Author

bwat47 commented Dec 6, 2025

apologies, I'm closing this as I found that it breaks existing plugins that handle creating code blocks (such as better code blocks), if this were added it would probably need to be as a separate setting rather than tied to auto-pair braces (or should be handled by just not adding the 4th backtick per the comment in #12569)

@bwat47 bwat47 closed this Dec 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant