Author Topic: Unsticky tabs  (Read 3986 times)

dunkers

  • Senior Community Member
  • Posts: 633
  • Hero Points: 28
Unsticky tabs
« on: April 14, 2008, 11:42:46 pm »
I have a file (.c extension) which has its tabs set to '1 9' when opened. My C indent setting is 4 (using tabs) and all other C files get opened with '1 5'. I can correct this setting, and if I then close SE and re-open it the setting remains. However, if I close the file and re-open it (even in the same SE session) it opens with tabs set to '1 9' again!

Presumably this is something to do with adaptive formatting? Any way I can get the proper tab setting to stick? I don't really want to disable adaptive formatting just becuase of this one file, but it really is seriously annoying.

chrisant

  • Senior Community Member
  • Posts: 1410
  • Hero Points: 131
Re: Unsticky tabs
« Reply #1 on: April 15, 2008, 05:19:15 am »
Please send the file to the SlickTeam via support@slickedit.com so they can debug the issue.  It's been noted, but having additional test case files helps them ensure they're tracked down all related issues, and confirm the fix(es) on a wider set of "real world" files.

dunkers

  • Senior Community Member
  • Posts: 633
  • Hero Points: 28
Re: Unsticky tabs
« Reply #2 on: April 15, 2008, 09:58:12 am »
I'll need to ask for permission to send it, I'm afraid - it contains substantial IPR for my client.

However, I've tracked down what caused it and will try and make up short sample to show the problem. Basically, for anyone else also caught with this, I had an initialised array of structs, each line indented by a tab. Except for a couple of line at the end of the array which were indented with spaces. However, these lines were indented to column 5 (to match the normal C indent) so I'm unsure as to why SE picked column 8 for the new indent.

Sandra

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 754
  • Hero Points: 35
Re: Unsticky tabs
« Reply #3 on: April 15, 2008, 01:14:40 pm »
We've already made some improvements for v13.0.1 with regards to Adaptive Formatting, particularly in the area of tabs.  If you can come up with a sample that reproduces the problem, do please send it in to support@slickedit.com and reference this thread.  If we've already fixed the problem, then hurrah!  Otherwise we'll see what we can do.

dunkers

  • Senior Community Member
  • Posts: 633
  • Hero Points: 28
Re: Unsticky tabs
« Reply #4 on: April 29, 2008, 11:54:17 am »
@Sandra: I believe I've found the cause for this and some other unexplained changes..

The following code causes spaces to be used instead of tabs for the indents in the array instance:

Code: [Select]
typedef struct {
    int    aInt;
    char   aChar;
} a_struct_t;

a_struct_t a_struct[] = {
   {0, 'a'},
   {1, 'b')
};

I think it's the use of '{}' to group the data which causes SE to override the tab setting. If another line is added, either at the end or between the existing lines, SE still uses spaces even if the other lines are manually changed to tabs.

This in itself is should just be an irritant, but if it's at the start of a file (where these things normally go) then SE may see it first when it scans the file for adaptive formatting. I'm unsure what happens here, but it looks like SE takes the first indent it comes across and makes assumptions about the file from that.

The result is that if the above array is first in the file (i.e the struct definition is in a separate file - the header, say) then SE will use 9 spaces for tabs. If the struct definition is in the same file then this doesn't occur because the first indent SE sees is the definition, and for that SE will have used the normal tab indent.

Hope that makes sense. I can try rephrasing if I confused you :)

Sandra

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 754
  • Hero Points: 35
Re: Unsticky tabs
« Reply #5 on: April 29, 2008, 02:18:56 pm »
I played with your example for a while and added some sample code to the bottom of it.  I did get your results in v13.  Then I tried it in our development copy of 13.0.1, and it seems to be doing better.  The disclaimer is that I was using some sample code, rather than your exact code, so I can't make any guarantee that your file will work.  However, I do think we've made a lot of improvement in this area in general, and so I'm willing to bet that your file will be fixed in the new code. 

If you like, I can see about getting the new stuff put into a hotfix and you can see for yourself whether your problems are solved.

dunkers

  • Senior Community Member
  • Posts: 633
  • Hero Points: 28
Re: Unsticky tabs
« Reply #6 on: April 29, 2008, 02:58:40 pm »
Thanks for the offer. Assuming 13.0.1 isn't far off I'm happy to wait for that - knowing the cause and workaround is fine for the moment.