Archived Beta Discussions > SlickEdit 2020 v25 Beta Discussion

[Beta 4] Switch statement oddity with suggested case value


[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.

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).

And I'll take a look at the beautifier part.  I think I know what's happening with that.

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".


[0] Message Index

Go to full version