Author Topic: [Beta 4] Switch statement oddity with suggested case value  (Read 742 times)

jc44

  • Senior Community Member
  • Posts: 302
  • Hero Points: 19
[Beta 4] Switch statement oddity with suggested case value
« on: September 18, 2020, 10:56:07 am »
[Beta 4, Win 10 x64, Brief] With the enclosed file (same as my previous report) if I add a case to a switch statement  by hitting return at the end of an existing line of the switch and typing case then I am indented correctly - so far so good.  But if I type a few more chars and pick a value from the drop down I am suddenly over intended by some amount (varies in a way I haven't yet determined from 1 space to 7). This fixes itself when I hit ":" so no harm done but it is disconcerting.  All is well if I just type the case value.

New case bodies are indented with the default tabs - I thought they were meant to pick the indent from elsewhere in the switch statement (Previous case if it exists, next case otherwise and only use the defaults if it is a new switch)? 

Again this is with the default tabs misset to 8 and adaptive failure.

Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 3401
  • Hero Points: 465
Re: [Beta 4] Switch statement oddity with suggested case value
« Reply #1 on: September 21, 2020, 04:19:56 pm »
This appears to be entirely beautifier-related, so I'll leave Patrick to address that.

However, I am filing a feature request for a future version to do argument compatibility matching on case statements so that we can screen auto-complete suggesting after a case statement down to items that match the variable being switched on, in particular, the enumerators of an enumerated type (if that is what we are dealing with).
« Last Edit: September 21, 2020, 04:25:14 pm by Dennis »

patrick

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 1591
  • Hero Points: 140
Re: [Beta 4] Switch statement oddity with suggested case value
« Reply #2 on: September 21, 2020, 10:49:27 pm »
And I'll take a look at the beautifier part.  I think I know what's happening with that.

patrick

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 1591
  • Hero Points: 140
Re: [Beta 4] Switch statement oddity with suggested case value
« Reply #3 on: September 25, 2020, 02:17:23 pm »
The problem is we don't infer the indent width for case indents in adaptive formatting.  We see that the case indented, but don't record the indent.

When you select an expansion like that, it's getting sent to the beautifier to take care of the formatting, and the beautifier has to go strictly by what's in the beautifier profile.  The "picking the indent from elsewhere in the switch" is an editing heuristic, and not usable by the beautifier.   Adaptive formatting tweaks buffer profile settings to match what's going on in the file, but doesn't set this particular setting.

So I'll need to add case indent width as a value we can infer.  I'll fold that into the other adaptive formatting changes I'm doing for the point release.

The only workaround is to disable the beautification of codehelp expansions like that by going to Documents -> C/C++ Options -> Editing, and under the "Beautify" group, uncheck "Beautify alias expansions".