Author Topic: wrapping comments  (Read 5416 times)

dunkers

  • Senior Community Member
  • Posts: 687
  • Hero Points: 28
wrapping comments
« on: June 11, 2007, 07:47:50 pm »
Consider the following code:
Code: [Select]
   // SomeCommentedFunction();
   AUsefulFunction();        // Useful!

As sometimes happens, you want to comment out the second line, so you go and bung // at the start. The line auto-wraps and you end up with:

Code: [Select]
   // SomeCommentedFunction();
   //AUsefulFunction();        //
   // Useful!

With other auto-wrap problems (such as starting a new line without comments, or backspacing over the //) it was possible to hold down shift to temporarily disable the auto-wrap. Can't see any way of doing that here.

Note that if the // is placed at the start of the line the effect doesn't happen.

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 5145
  • Hero Points: 425
Re: wrapping comments
« Reply #1 on: June 12, 2007, 01:53:22 pm »
I've hit this too.  I think that it would be nice if inserting "//" did not wrap.  This should be doable and I have mentioned this case to Dave.  The backspace code is a bit trickier.  The backspace logic only works if there has to be a space after the //.  Instead, we decided that you need to use Del to remove the // characters.  However, it seems to me we could have backspace be smarter for the case where there was a space after the //.

dunkers

  • Senior Community Member
  • Posts: 687
  • Hero Points: 28
Re: wrapping comments
« Reply #2 on: June 12, 2007, 03:12:48 pm »
Thanks Clark :)

David_O

  • Senior Community Member
  • Posts: 152
  • Hero Points: 8
Re: wrapping comments
« Reply #3 on: June 12, 2007, 06:12:08 pm »
There are a number of subtle changes planned for the next release that target the wrapping of line comments.  The new line quirks are definitely to be addressed.  We will get in as many other requests, such as the inserting '//', that we can.

Comment wrapping will add a '//' on Enter (as it should).  So it is quite common to end up with something like (the '|' is the cursor location):

  // First line of comment.
  // Last line of comment.
  // |

Getting rid of the '//' on the 3rd line is a problem.  We have been suggesting Delete to remove these, but that is not ideal.  We can special case 'Backspace' on the last line when it is just a '//' so that it will not wrap back up to the second line.  However, if the comment is indented and the user does want to keep backspacing and erase a few lines of the comment, then we've just slowed down that operation. 

We could also set it up so that when Enter creates something like the above, Ctrl-Z (undo) once would take you back to:

  // First line of comment.
  // Last line of comment.
  |

and undo twice would take you back to:

  // First line of comment.
  // Last line of comment.|

Of course, so users will not like this extra undo step and that kind of undo is not commonly used in other parts of SlickEdit.

We will listen to any feedback or other ideas.

Ryan

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 986
  • Hero Points: 77
Re: wrapping comments
« Reply #4 on: June 12, 2007, 07:20:52 pm »
Quote
We could also set it up so that when Enter creates something like the above, Ctrl-Z (undo) once would take you back to:

  // First line of comment.
  // Last line of comment.
  |


and undo twice would take you back to:

  // First line of comment.
  // Last line of comment.|

I support this solution :).  Hitting undo twice is not a big issue for me...

- Ryan

dunkers

  • Senior Community Member
  • Posts: 687
  • Hero Points: 28
Re: wrapping comments
« Reply #5 on: June 12, 2007, 10:14:16 pm »
I've fallen into using shift-left_arrow to highlight the // and the hit del to vape it. I'd be happy if you could make shift-backspace not rewrap (so it's consistent with using shift-enter the other way). Maybe shift-del also escapes wrap mode?

Ctl-Z twice sounds cool, but it's inconsistent and gets to be so irritating. When I'm typing in some printf() string and I start '"APP:', a space then causes SE to replace that with some weirdo #define it's pulled up from somewhere. A Ctl-Z then retyping fixes it (just as you propose for the wrapping). Trouble is, after the first 20 times I know it's going to happen and would die for a single keystroke to say "Yes, I know what you're planning to do but this time DON'T DO IT OR ELSE", but instead I have to type, be mildly amused by what it dredges up, Ctl-Z, re-type...

hs2

  • Senior Community Member
  • Posts: 2744
  • Hero Points: 288
Re: wrapping comments
« Reply #6 on: June 13, 2007, 09:28:22 am »
I agree with Ryan. IMHO it's the best solution.
The 'special' undo seems ok for 'Line comment wrapping mode == ON'.
Using add. commands which needs to be bound to extra keys just moves the problem of doing something special in a special case.
@dunkers: You should check your File ext. setup. Maybe you should un-check 'Completion on space' in the Context Tagging tab->List members section (as I did - I'm doing this on-demand using ALT-<COMMA>).

HS2

dunkers

  • Senior Community Member
  • Posts: 687
  • Hero Points: 28
Re: wrapping comments
« Reply #7 on: June 13, 2007, 11:20:16 am »
Unfortunately I lurve the completion on space facility :)

I think the trick is to do shift-space, which I do for expanding if/while/etc but just never think of when I'm typing text.

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 5145
  • Hero Points: 425
Re: wrapping comments
« Reply #8 on: June 14, 2007, 08:20:35 pm »
I just wanted to nix my backspace idea since as Dave pointed it out, it's too ambigous.  Del key works for me and then I always know what to expect.  shift+backspace as a no-wrap backspace is a nice idea.