Author Topic: Doc comments "Edit Expansion" change won't stick  (Read 5425 times)

mrothman

  • Senior Community Member
  • Posts: 120
  • Hero Points: 1
Doc comments "Edit Expansion" change won't stick
« on: November 17, 2009, 03:01:07 pm »
I have 14.0.2.2, linux.

I'm trying to change the Doc comments option for c++ files to use the /*! start instead of /** (which is probably left over from years ago when only javadoc was supported in SlickEdit).  I bring up the options for comments under the C/C++ section, press Edit Expansion..., and select /*! in the left hand part of the GUI.  Then I say OK.  But if I try to use that style in my c++ file it fails, and if I bring the dialog up again, I notice that it has always reverted to /**.  Changes to the skeleton template for /** DO stick, it's only trying to move to the /*! start that doesn't.

Any clues?  Maybe some macro variable I have set oddly?  Some file permission that SlickEdit needs to save this particular option? (Boy does that seem unlikely - I'm grasping here).

David_O

  • Senior Community Member
  • Posts: 152
  • Hero Points: 8
Re: Doc comments "Edit Expansion" change won't stick
« Reply #1 on: November 18, 2009, 06:32:02 pm »
I may have misunderstood your problem, but I'll try to help.

That said, it sound to me like you may have misunderstood the Doc Comment Editor GUI.  As you noted, there are four character sequences listed on the left (/*! /** //! ////).  These are just aliases, and all four are available in C++.  If you like the doc comment format you see when you click on /*!, then when editing your code, you should type above your function declaration:

/*!<cursor>

SlickEdit will automatically expand this to:

/*!<cursor>*/

Then when you hit Enter, it will expand a doc comment using the corresponding alias.  If in another C++ file, you use doc comments that start with /**, then type /**<cursor> etc. for that file.

True, when you bring up the Doc Comment Editor in C++, the '/**' alias is selected by default.  That doesn't mean that the /*! Doc comment expansion is not available.  I'll see if we can make it select whatever was shown last time, so that it will be less confusing.

Remember, all four of the doc comment aliases (I call them doc comment expansion triggers) are just aliases.  You can make the /** trigger expand to anything you want.  If you are used to typing /**, then you could just change the alias expansion associated with /**.

Hope this helps.
« Last Edit: November 23, 2009, 05:19:54 pm by David_O »

mrothman

  • Senior Community Member
  • Posts: 120
  • Hero Points: 1
Re: Doc comments "Edit Expansion" change won't stick
« Reply #2 on: November 18, 2009, 07:44:41 pm »
Thanks!  Now, I was about to write that you HAD misunderstood my problem, but I think you're right.  The SlickEdit doc is less than clear on the topic... here's an excerpt (my italics added):

Quote
Click the Edit expansion button to configure the start characters and comment templates for the doc comment style you plan to use for the selected language. For comments formatted in Javadoc, select /**. For XMLdoc, select ///. For Doxygen, select /*! or //!.

The word "select" apparently refers just to how to see what the template says (and maybe modify it), but the phrase "configure the start characters" sure makes it sound as if you are selecting a default for this file extension.  But, let's assume that's just my confusion.

So...
That's cool, except that then I have a different bug, which I had been attributing to not being able to "select" a default alias, but which I now realize is instead an issue with one of the aliases not expanding correctly.  When I use the /*! sequence, instead of expanding as called for, I get the following sequence of events (assume in each case that I'm doing this on the line before a c++ function definition).

I type the /*, and a symmetrical */ appears right after it (this makes sense).  So now I have on the line in front of the method:

/**/

I now type the '!', and SlickEdit inserts 3 spaces in addition (huh?).  Now I have:

/*!   */

I now hit Enter, and all I get is... Enter.  In other words, I have:

/*!
   */

An important clue - if (by hand) I edit out the 3 spaces before hitting "Enter", it does the right thing.

Now that I understand the issue better, it seems as if perhaps two different auto-completion rules are maybe battling it out.  That is, perhaps the sequence /*!*/ is defined somewhere else as a code template (although I certainly don't remember doing that!), or some other alias which takes precedence over the one here, inserts 3 spaces, and boom.  I'll snoop around.  Meanwhile if you have any other ideas, post, and thanks again!

P.S. the other start character cases work fine.

David_O

  • Senior Community Member
  • Posts: 152
  • Hero Points: 8
Re: Doc comments "Edit Expansion" change won't stick
« Reply #3 on: November 20, 2009, 07:37:42 pm »
Does pressing the '!' add extra spaces in other places in your C file?  Or only in the middle of /**/?

mrothman

  • Senior Community Member
  • Posts: 120
  • Hero Points: 1
Re: Doc comments "Edit Expansion" change won't stick
« Reply #4 on: November 20, 2009, 09:53:33 pm »
I don't want to say "only" there, but I did try several different cases.  Only way I could make it happen was to start the expansion.


David_O

  • Senior Community Member
  • Posts: 152
  • Hero Points: 8
Re: Doc comments "Edit Expansion" change won't stick
« Reply #5 on: November 23, 2009, 02:50:25 pm »
Try this and let me know what you get.  Type this on a line before a method:

/*

Let SE expand this to:

/*<cursor>*/

Then on the command line (hit Esc to activate it), enter the command 'what-is.'  SE will prompt you to enter a key.  Press '!'.  This will tell you if '!' has been bound to any other command that might be responsible for the extra spaces.  This seems unlikely, but we need to rule these simple things out because I can not reproduce this yet.

Thanks for your cooperation.

mrothman

  • Senior Community Member
  • Posts: 120
  • Hero Points: 1
Re: Doc comments "Edit Expansion" change won't stick
« Reply #6 on: November 23, 2009, 03:52:45 pm »
Nice, I should have thought of that.  Unfortunately, the answer is "! is not defined".

BUT, I noticed something else while testing it - essentially ANY character seems to behave the same way ! behaves, that is, if I type
/*<any character>

I end up with

/*<any character>    */

That is, the spaces get inserted in front of the comment close (which was inserted by slick edit as soon as I typed /*)

David_O

  • Senior Community Member
  • Posts: 152
  • Hero Points: 8
Re: Doc comments "Edit Expansion" change won't stick
« Reply #7 on: November 23, 2009, 06:37:20 pm »
Does this happen if you use a default config?

chrisant

  • Senior Community Member
  • Posts: 1410
  • Hero Points: 131
Re: Doc comments "Edit Expansion" change won't stick
« Reply #8 on: November 24, 2009, 12:31:29 am »
Turning on "Enable block comment wrap" causes the problem.
See screenshot.

I was able to repro 100% consistently, and I have that option on.
When I turn that option off I cannot repro anymore.
There might be other options needed as well, so I exported my settings and attached them (my user.vlx file is readonly, which caused Export Options to get an error trying to copy from it -- that seems mysterious).

mrothman

  • Senior Community Member
  • Posts: 120
  • Hero Points: 1
Re: Doc comments "Edit Expansion" change won't stick
« Reply #9 on: December 01, 2009, 02:04:56 pm »
Thanks Chrisant.  To be more specific, it seems that enabling block comment wrap is all that's necessary to produce the problem.  I spent a little time walking through the logic in commentformat.e, but I had to get back to my actual job.  I suspect there's some nit in the logic which tries to detect whether we're in a doxygen comment, and it comes back thinking its a block comment rather than a doc comment.  Why that should in turn cause some spaces to be inserted is not clear.  And of course, my theory could be wrong.

David_O

  • Senior Community Member
  • Posts: 152
  • Hero Points: 8
Re: Doc comments "Edit Expansion" change won't stick
« Reply #10 on: December 03, 2009, 10:08:39 pm »
I have not been able to reproduce this on either windows or linux.  I even tried Chrisant's attachment.  Could you send me your linux settings for 'Comments' and 'Comment Wrap' for C/C++?  In the 'Comment block' section, be sure to note all spaces you have in the border settings.  Will it happen in a small sample file such as a header file with just one declaration, or only in a larger context.

Thank you,

chrisant

  • Senior Community Member
  • Posts: 1410
  • Hero Points: 131
Re: Doc comments "Edit Expansion" change won't stick
« Reply #11 on: December 04, 2009, 05:58:24 am »
Thanks, David_O, I'm sorry the exported settings didn't work.  I think here are the minimal settings needed to reproduce this in an empty .CPP file in a stock install with a fresh config:

In Tools|Options:
1.  Set "Language\Comment Wrap\Enable block comment wrap" = checked
2.  Set "Language\Comments\Comment block top left corner" = "/*"
3.  Set "Language\Comments\Comment block left edge" = "{space}*"
4.  Set "Language\Comments\Comment block bottom left corner" = "{space}*/"
5.  Clear the other five "Language\Comments\Comment block" boxes

In a new .CPP file:
1.  Type "/*" on a new line (without the quotations) expands to "/**/" with the insertion point between the asterisks.
2.  Type "!" (without the quotations) expands to "/*!   */" with the insertion point just after the exclamation point.

David_O

  • Senior Community Member
  • Posts: 152
  • Hero Points: 8
Re: Doc comments "Edit Expansion" change won't stick
« Reply #12 on: December 04, 2009, 03:06:40 pm »
Thank you.  I can get it to happen now.  We'll have this fixed for the next release and/or hotfix.

mrothman

  • Senior Community Member
  • Posts: 120
  • Hero Points: 1
Re: Doc comments "Edit Expansion" change won't stick
« Reply #13 on: December 04, 2009, 03:24:43 pm »
Thanks chrisant and David_O!  I wasn't sure if David was asking me or chrisant, but he got there first, and I appreciate the effort.