Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
User name:
Password:
Save Password
Forgot your password?

 All Forums
 Visual Assist
 Feature Requests
 Uncomment should handle leading spaces
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

geno
New Member

Germany
5 Posts

Posted - Oct 29 2019 :  4:39:13 PM  Show Profile  Reply with Quote
Hi,

Could you please add an option to allow Line Comment toggling to either react to leading spaces or not?

I'm using this feature: VAssistX.SelectionToggleLineComment

Example 1

I have a line of code:
int x = 1;


Now I move my cursor to this code line and use the toggle comment feature which results in:
// int x = 1;


All fine. But ... In a real world scenario where the line is indented a few levels to the right and using some auto-formatter we have a problem.

Example 2

I have this code:

int calculate(int a, int b) {
  int result = 0;
  result = 42;
  return result;
}


I want to temporarily comment out the assignment statement so now I have:

int calculate(int a, int b) {
  int result = 0;
//  result = 42;
  return result;
}


Now I hit save which will trigger my auto formatter. Unfortunately, it will now indent the comment to match the indentation level of the surrounding code lines. I cannot control this. There's no option in the auto formatter (using the CodeMaid plugin).

So the end result after the formatter has done its (unwanted) work is this:



int calculate(int a, int b) {
  int result = 0;
  //  result = 42;
  return result;
}


Notice the two spaces in front of the commented line.

Here's the actual problem with the VAX comment toggling. VAX seems to expect single line comments to start with two forward slashes or else it is not a comment. The result is another two forward slashes instead of removing them. This is inconvenient to work with this way.

I also tested the comment / uncomment feature of Visual Studio itself and it does detect the comment properly. However, Visual Studio does not have a toggle shortcut for commenting/uncommenting and thus cannot bind it to just one shortcut for toggling comments. *Sigh*

accord
Whole Tomato Software

United Kingdom
3287 Posts

Posted - Oct 29 2019 :  7:23:20 PM  Show Profile  Reply with Quote
Ideally, you would like a setting which would make VA toggle comment work the same way as Visual Studio's variant of comment/uncomment? Meaning that it would put leading spaces before the '//'s, essentially starting where the indentation is, and then able to remove it.

Edited by - accord on Oct 29 2019 7:27:28 PM
Go to Top of Page

geno
New Member

Germany
5 Posts

Posted - Oct 29 2019 :  10:57:36 PM  Show Profile  Reply with Quote
That could also work but maybe that's even another option ;-)

That's because when I'm writing code I actually like those commented out lines to stand out a bit from the rest.

So personally speaking, I'd prefer the '//'s to appear at the start of the line (just as it is already) but in the case that the commented out line or lines are having leading whitespace the toggle feature should still understand this and execute the "uncomment" action instead of "comment" action on top of the commented out line(s).

What I currently get due to the interplay of "VAX toggle comment" and "CodeMaid Code Formatter" is something like this:

Step 1: Starting with this snippet


int calculate(int a, int b) {
  int result = 0;
  result = 42;
  return result;
}


Step 2: Toggle line with VAX


int calculate(int a, int b) {
  int result = 0;
//  result = 42;
  return result;
}


Step 3: Saving the file (CodeMaid Code Formatter kicks in by doing this)


int calculate(int a, int b) {
  int result = 0;
  // result = 42;
  return result;
}


Step 4: Changed my mind, going to uncomment the same line again using VAX toggle line -> problem


int calculate(int a, int b) {
  int result = 0;
// // result = 42;
  return result;
}


And this is kind of annoying. I hope this step-by-step procedure makes it more clear what I mean. :-)
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18724 Posts

Posted - Oct 30 2019 :  07:56:53 AM  Show Profile  Reply with Quote
This makes more sense. This is something we are considering doing:

case=87353

but unfortunately I don't currently have an estimate for when we will have a go at this.

zen is the art of being at one with the two'ness
Go to Top of Page

accord
Whole Tomato Software

United Kingdom
3287 Posts

Posted - Oct 30 2019 :  2:52:19 PM  Show Profile  Reply with Quote
oh wow, Visual Studio 2019 16.3 is able to toggle comments via Ctrl + K, Ctrl + /



I've just read this:
https://devblogs.microsoft.com/visualstudio/dot-net-core-support-in-visual-studio-2019-version-16-3/

Edited by - accord on Oct 30 2019 2:57:43 PM
Go to Top of Page

geno
New Member

Germany
5 Posts

Posted - Oct 30 2019 :  4:17:55 PM  Show Profile  Reply with Quote
Amazing. It's like getting Unix newline support in notepad.exe after decades of torture. :-D
Seriously, thanks for the info. Unfortunately I will be stuck on VS 17 for a while.
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18724 Posts

Posted - Nov 02 2019 :  08:08:23 AM  Show Profile  Reply with Quote
For now, have you considered using a find and replace regular expression on the selected lines to uncomment the blocks? On it's own this is less helpful, but if this works well for you, you may be able to use one of the IDE macro extensions to automate this.

A bit of a messy work around, but worth mentioning in case it helps.

zen is the art of being at one with the two'ness
Go to Top of Page

tony.riviere
Ketchup Master

France
57 Posts

Posted - Nov 04 2019 :  04:34:57 AM  Show Profile  Reply with Quote
You can setup your own shortcut on the Visual Studio (2019) toggle block comment: Tools > Options > Keyboard, search for Edit.ToggleBlockComment and then you can assign '/' so that you can use it the same way as the VAX shortcut works.

Edit: I don't know your setup but you can use VS2019 with VS2017 projects. You don't need to migrate them.

Edited by - tony.riviere on Nov 04 2019 05:07:25 AM
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000