vscode-matlab icon indicating copy to clipboard operation
vscode-matlab copied to clipboard

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

Open CelsoReyes opened this issue 8 years ago • 6 comments

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

CelsoReyes avatar Jan 03 '18 08:01 CelsoReyes

I'm not sure this can be done outside of the extension without an enhancement from the core. Per some similar issues like this one:

The command is currently implemented by adding or removing /* and */ from the selection edges. The actual text to be added/removed is configured via language configuration.

In theory this should also be able to handle block comment openings/closures defined with line breaks, as in your example, but as currently implemented it's not handling it properly and I'm not literate enough in the language to figure out where it's going wrong. I think it's worth an issue on the VSCode repo.

This can be implemented at the extension level but it would end up being a separate command from VSCode's.

sco1 avatar Feb 22 '18 22:02 sco1

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.

Gimly avatar Apr 17 '18 20:04 Gimly

Thanks @Gimly tackling this!

side note: Thanks for the acknowledgement, though my last name is misspelled in the release notes. Reyes (not Reys).

CelsoReyes avatar Apr 18 '18 07:04 CelsoReyes

Oops, sorry about the misspelling, will fix that in the next release.

Le mer. 18 avr. 2018 à 09:40, Celso [email protected] a écrit :

Thanks @Gimly https://github.com/Gimly tackling this!

side note: Thanks for the acknowledgement, though my last name is misspelled in the release notes. Reyes (not Reys).

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Gimly/vscode-matlab/issues/31#issuecomment-382294032, or mute the thread https://github.com/notifications/unsubscribe-auth/AAKS3bGmqZmLIn2wmySL0n4TT-dY2abTks5tpu3qgaJpZM4RReGy .

Gimly avatar Apr 18 '18 11:04 Gimly

With version 1.0 we've updated the syntax highlighting syntax which might have been the cause of the issue. Could you please tell me if you still experience the issue with that version?

Gimly avatar Mar 28 '19 21:03 Gimly

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)

AnnyCaroline avatar Mar 29 '19 02:03 AnnyCaroline