Author Topic: [Beta 4] Adaptive formatting tab fail with Chrome source  (Read 574 times)

jc44

  • Senior Community Member
  • Posts: 286
  • Hero Points: 18
[Beta 4] Adaptive formatting tab fail with Chrome source
« on: September 18, 2020, 10:36:24 am »
[Beta 4, Win 10 x64, Brief] With defaults of hard-tab, 8 space tabs (last thing I was doing was kernel work) adaptive formatting fails to detect the tab-stop of 2-spaces as used by Chrome.  It correctly determines that we are using spaces (hurrah), but has no idea about tabs.  The indenting in this file is complex but consistent - I would hope SE could do better.  To reproduce the problem pick any line ending in "{" and hit return you will end up indented as if the tab stops were 8. Adaptive formatting stats don't mention tabs at all.

A suggestion for this case where there is already text in the block: If you are inserting on the first line of a block take then take the existing indent from the next line in the same way that you normally copy the indent of the previous line.  This fixes the cases where indenting has been inconsistent through the file as well as cases where adaptive format has failed.  (You did something similar for switch statements a number of versions ago.)

patrick

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 1490
  • Hero Points: 135
Re: [Beta 4] Adaptive formatting tab fail with Chrome source
« Reply #1 on: September 18, 2020, 05:16:30 pm »
I'll take a look at it.  I'm not sure why it's not making a guess on the syntax indent for that file.

patrick

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 1490
  • Hero Points: 135
Re: [Beta 4] Adaptive formatting tab fail with Chrome source
« Reply #2 on: September 18, 2020, 08:51:28 pm »
So it's seeing that the highest number of samples have an indent of 2.  But the total incidence of 65% is less than the cutoff of 66%.  When it falls below that cutoff, it doesn't recommend a syntax indent.

For this file, if you set-var def_adaptive_formatting_min_confidence 64, it wil pick up the syntax indent.

I'm checking the code to see if we're counting indents for C++ that we shouldn't be and diluting the spacing result that way. 

jc44

  • Senior Community Member
  • Posts: 286
  • Hero Points: 18
Re: [Beta 4] Adaptive formatting tab fail with Chrome source
« Reply #3 on: September 18, 2020, 09:10:03 pm »
I think that the file has a 100% 2 space statement start indent.  It has a lot of statement continuations indented 4 from that (which appears to be googles style).

jc44

  • Senior Community Member
  • Posts: 286
  • Hero Points: 18
Re: [Beta 4] Adaptive formatting tab fail with Chrome source
« Reply #4 on: September 25, 2020, 10:31:34 am »
[RC1] (still the same behaviour) I've rechecked the file - and I'm pretty sure that it has a "syntax indent" (start of statement) of 2 throughout, with a "line continuation indent" that is either 4 (most cases) or sometimes lining up with a previous bracket and sometimes just a bit random.  Does adaptive formatting distinguish between syntax and line continuation in the way that the main C formatting dialog does?

patrick

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 1490
  • Hero Points: 135
Re: [Beta 4] Adaptive formatting tab fail with Chrome source
« Reply #5 on: September 25, 2020, 01:22:02 pm »
I didn't check anything in for that.  And the problem is from sampling in continuation indents.  It has heuristics that work at getting the correct indent out of the sampled indents, but it's breaking down here.  I had hoped I would be able to work around it for the time being, and address it fully in the point release, but it got a little complicated.

For languages with statement parsing, we have access to the information we need to filter-out/not-visit the continuation indents, and my plan is to integrate that into adaptive formatting for the point release.