question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Block Comments should force a new line, else they're treated as line comments

See original GitHub issue

Hi, I really enjoy your Matlab Extension. I find VSCode’s editing capabilities far outpace Matlab’s editor.
I noticed this anomaly while checking out various VSCode keyboard shortcuts.

How to reproduce:

% here follows code, the first line of which I'd like to block comment
disp(a)
disp(b)
disp(c)

select the first two disp(…) commands Toggle block comment (on mac, shift-alt-A)

Result:

%{ disp(a)
disp(b) %}
disp(c)

Expected:

%{ 
disp(a)
disp(b)
%}
disp(c)

Reasoning MATLAB only understands block comments when they’re alone on a line (with the exception of whitespace) In this particular case, the first line is treated as though it had the typical line comment. The second line is interpreted by MATLAB as though it ends with a commented-out closing brace.

What I tried: By modifying the matlab.configuration.json file, I could add the line feeds, but then the line comment no longer toggled back off. Still, this behavior might be preferable to the existing behavior.

"blockComment": [ "\n%{\n", "\n%}\n" ]

side note: even MATLAB (r2017a) doesn’t seem to have a shortcut key combo for this feature

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
Gimlycommented, Apr 17, 2018

I’ve updated the extension with your proposal @CelsoReyes, I find it better than the previous behavior.

I’m keeping the issue open for now, since it’s not completely fixed. I’m putting it on hold though, because as @sco1 has explained, it’s an issue related to how VSCode is managing those block comments.

I’ve opened an issue on VSCode’s repository: https://github.com/Microsoft/vscode/issues/48074

I’m putting this issue on hold until we know if that will be fixed.

0reactions
AnnyCarolinecommented, Mar 29, 2019

It seems to work fine.

But it adds 2 blank lines and doesn’t indent the comments (except for the first one). I tested on vs-code for Windows.

Result:

% here follows code, the first line of which I'd like to block comment

%{
 disp(a)
disp(b) 
%}

disp(c)

Expected:

% here follows code, the first line of which I'd like to block comment
%{
 disp(a)
 disp(b) 
%}
disp(c)
Read more comments on GitHub >

github_iconTop Results From Across the Web

Allow block comments characters to have new line in them
Use block comment for every line if line comments are not supported by language ... Block Comments should force a new line, else...
Read more >
Programming - Commenting - Utah School of Computing
Comments are specially marked lines of text in the program that are not evaluated. ... A block comment has a start symbol and...
Read more >
How do I create multiline comments in Python? - Stack Overflow
It would comment/uncomment a single/multi line/s of code with # . I find it the easiest. For example, a block comment: # =========== ......
Read more >
Comment before or after the relevant code [closed]
That being said, the placement can depend: If you use a separate line for the comment, put it before the actual code.
Read more >
Custom Filling and Breaking (CC Mode Manual) - GNU.org
The reason is that M-j could otherwise produce sequences of single line block comments for texts that should logically be treated as one...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found