vscode-markdown-shortcuts
vscode-markdown-shortcuts copied to clipboard
Toggle Code Block adds an unnecessary line break
What is the problem?
Any time I use the Toggle Code Block
, it adds an extra blank line at the end of my code.
- Whether I select every line of code (including or excluding the last line break) or just leave the cursor in the current single line of code.
- Whether I use the keyboard shortcut or invoke the function via the Command Palette.
How can I reproduce it?
Invoke the function.
Just to clarify, if you select the following text:
Some code with
an empty line
and use Toggle Code Block
, then you would expect the result to be (with backticks instead of apostrophes):
'''
Some code with
an empty line
'''
correct?
I think the behaviour should be
- do not modify the selected text (so don't remove any trailing or leading new lines if the user wants them there for whatever reason)
- end with the entire code block plus the lines with surrounding bacticks selected so that the user can indent the whole lot if needed.
So if have my cursor in the middle of a single line when I run the code block function:
some code
I should end up with the following (all selected):
```
some code
```
And if I have these three lines when I run the function:
some code
with an empty line
I should end up with the following (all selected):
```
some code
with an empty line
```
I'm not sure how this is different from current behavior
Before:
After:
Before:
After:
If this doesn't match what you're seeing, can you tell me what OS you're using and the version of VSCode?
Going back and re-reading your last comment, is this about line breaks or is it about text selection? With the text selection, I agree, it doesn't currently select the entire text inside the code block.
Hi @mdickin , try putting some extra lines at the end of of your file, then you might see the behaviour..
Before:
After:
Before:
After:
My core issue is about the empty lines being added, but as I was typing my reply I thought I would try to sneak a feature request into a bug report... or something like that :)
Rob :)
Ok, I see now. Thank you for being patient with me!
That's a weird one, I'll dig into it.