Author Topic: Comment wrapping in v11 indents with spaces, not tabs  (Read 7765 times)

timur

  • Senior Community Member
  • Posts: 172
  • Hero Points: 3
Comment wrapping in v11 indents with spaces, not tabs
« on: February 29, 2008, 10:33:23 pm »
I have configured Slickedit to indent C code with tabs.  However, if I enabled the comment wrap feature, Slickedit replaces those tabs with spaces.  This causes my code to violate my department's coding guidelines.  How can I fix this?

hs2

  • Senior Community Member
  • Posts: 2744
  • Hero Points: 288
Re: Comment wrapping in v11 indents with spaces, not tabs
« Reply #1 on: March 01, 2008, 12:16:32 am »
Hi Timur, would be helpful if you'd provide an example. This kind of bug report just contains too less information to track down the problem in a reasonable amount of time.
Hence bug report/question response times are closely coupled with the quality/level of detail of the bug report/question itself ;)

However, there was/is an issue with wrong TAB->SPACE conversions caused by a bug when lines are joined which might happen when using DEL but also when comments are wrapped e.g. when using BACKSPACE.
As I've seen in my backups this also applies to v11. So you could try the fix here http://community.slickedit.com/index.php?topic=2612.msg11388#msg11388 which should also work in v11 (stdcmds.e - join_line() [line 3080]).
Good luck, HS2
« Last Edit: March 01, 2008, 12:20:51 am by hs2 »

timur

  • Senior Community Member
  • Posts: 172
  • Hero Points: 3
Re: Comment wrapping in v11 indents with spaces, not tabs
« Reply #2 on: March 03, 2008, 10:44:53 pm »
I think we're talking about the same thing.  However, when I tried to add the work-around you mentioned to stdcmds.e, I got this error message when I tried to compile it:

Quote
Identifier 'auto' not declared


hs2

  • Senior Community Member
  • Posts: 2744
  • Hero Points: 288
Re: Comment wrapping in v11 indents with spaces, not tabs
« Reply #3 on: March 03, 2008, 11:54:42 pm »
Sorry, 'auto' was introduced in v12.
This is the v11 (and better) compatible version:
Code: [Select]
      // HS2-ADD: workaround: maybe revert leading SPACEs (padded by _JoinLineToCursor) to TABS
      if ( p_indent_with_tabs && (p_col <= _first_non_blank_col()) ) {
         _str line;
         get_line( line );
         replace_line( indent_string(text_col(line,p_col,'I')-1) :+ substr(line,p_col) );
      }
Good luck,
HS2

timur

  • Senior Community Member
  • Posts: 172
  • Hero Points: 3
Re: Comment wrapping in v11 indents with spaces, not tabs
« Reply #4 on: March 04, 2008, 04:01:00 pm »
Maybe we're not talking about the same thing.  I just wrote this comment in my code to test it:

        /* This is a test of the multi-line comment wrapping.  The first line
           was indented with a tab character.  The second line is indented with
           spaces.  After the second line was created, Slickedit replaced the
           tab in the first line with spaces.  All I'm doing is typing these
           sentences.  I want Slickedit to indent with tabs.  The only way I
           can fix this is to select the text after I'm done writing the
           comment and run "tabify-region" on it.  I sometimes forget to do
           that, and then my patches fail the code reviews.  Help me,
           Slickedit! */

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 5177
  • Hero Points: 429
Re: Comment wrapping in v11 indents with spaces, not tabs
« Reply #5 on: March 04, 2008, 08:16:00 pm »
This appears to be an adaptive formatting issue.  In the test case I used, I think it is a bug.  Turn off adaptive formatting or at least turn it off for the "Indent with tabs" option.  The "Indent with tabs" menu item on the Document menu needs to show a check mark to indicate the indent with tabs is on.

hs2

  • Senior Community Member
  • Posts: 2744
  • Hero Points: 288
Re: Comment wrapping in v11 indents with spaces, not tabs
« Reply #6 on: March 04, 2008, 08:19:20 pm »
@Clark: timur is using SE v11 - there is no such thing as 'Adapative Formatting' ;) - HS2

David_O

  • Senior Community Member
  • Posts: 152
  • Hero Points: 8
Re: Comment wrapping in v11 indents with spaces, not tabs
« Reply #7 on: March 06, 2008, 02:07:20 am »
I think I know what the problem is.  Originally in V11 there was a bug the caused comment wrap not to preserve indent with tabs.  This must be the error that timur is seeing.  This was fixed long ago.  It was at least in v12, and I think we there was a v11 hotfix for this, but I will have to double check.

In the meantime, Clark is also correct that there was a bug in the beta for SlickEdit 2008 that had the side effect of turning off indent with tabs.

I suggest that timur check that he has all the latest hotfixes for v11.  If that doesn't take care of it, we'll get one out for v11.

Thanks,

timur

  • Senior Community Member
  • Posts: 172
  • Hero Points: 3
Re: Comment wrapping in v11 indents with spaces, not tabs
« Reply #8 on: March 06, 2008, 03:56:57 pm »
Well, I definitely I don't have the latest hotfixes installed, and I think I know why.  Whenever I try to install a hotfix, I get an error message that says, "Cannot open input file".  I tried deleting my ~/.slickedit/11.0.2/hotfixes/ directory, but that didn't help.  I can't properly install hotfix_se1102_hotfix.zip.  This is what the hotfixes directory looks like after I try to install hotfix_se1102_hotfix.zip:

 ~/.slickedit/11.0.2/hotfixes$ ls -l
total 56
----------    1 b04825   sysperf     44340 Jan 18  2007 hotfix.e
-rw-r--r--    1 b04825   sysperf     10148 Mar  6 09:30 hotfix_se1102_hotfix.zip

It's obvious why it can't open hotfix.e, but I don't know what to do now.  If I change the permissions on hotfix.e to 664 and then try to install hotfix_se1102_hotfix.zip again, I get the same error message and the directory looks like this:

$ ls -l
total 100
----------    1 b04825   sysperf     44340 Jan 18  2007 hotfix.e
-rw-rw-r--    1 b04825   sysperf     44340 Jan 18  2007 hotfix.e.bak
-rw-r--r--    1 b04825   sysperf     10148 Mar  6 09:30 hotfix_se1102_hotfix.zip

So I fix this and then try to install hotfix_se1102_cumulative.zip.  Then I get an error about not being able to open bookmark.e, and then I get this:

s$ ls -l
total 820
----------    1 b04825   sysperf     55120 Jan 19  2007 bookmark.e
-rw-rw-r--    1 b04825   sysperf     44340 Jan 18  2007 hotfix.e
-rw-r--r--    1 b04825   sysperf    720858 Mar  6 09:33 hotfix_se1102_cumulative.zip
-rw-r--r--    1 b04825   sysperf     10148 Mar  6 09:30 hotfix_se1102_hotfix.zip

Now this is getting stupid.  Why is this thing so broken?

timur

  • Senior Community Member
  • Posts: 172
  • Hero Points: 3
Re: Comment wrapping in v11 indents with spaces, not tabs
« Reply #9 on: March 06, 2008, 04:03:09 pm »
Ugh, never mind.  I forgot this step from the instructions: "In SlickEdit, reload this file with its updated permissions".

However, even after applying hotfix_se1102_cumulative.zip, the problem with tabs and spaces is still there.  Every time I edit a multi-line comment, Slickedit replaces all tabs with spaces.

David_O

  • Senior Community Member
  • Posts: 152
  • Hero Points: 8
Re: Comment wrapping in v11 indents with spaces, not tabs
« Reply #10 on: March 06, 2008, 04:32:09 pm »
There are just a few changes to make it preserve tabs.  Assuming you have the file commentformat.e that came from the 11.2 hotfix:

Change line 1756 from

     _begin_line(); delete_end_line();

to

    replace_line(indent_string(CW_commentBorderLeftCol));

And change line 1922 from

    insert_line('');

to

    insert_line(indent_string(currentLMC +CafterBulletCol - 2));

That should fix it.

timur

  • Senior Community Member
  • Posts: 172
  • Hero Points: 3
Re: Comment wrapping in v11 indents with spaces, not tabs
« Reply #11 on: March 06, 2008, 04:46:36 pm »
Yes, that fixed!  Woohoo!  Thanks.