Resharper adjusting tabbing when typing open brace even with all typing assist is disabled

First, I've just started a trial of Resharper and, overall, it's been great! Specifically because we're using C++20 modules and MSVC's built-in Intellisense absolutely falls over with it and with Resharper it's almost entirely working! Thanks for that!

One issue I'm having is that our codebase has a convention I've never seen anywhere else. For single-line things such as if/for loops we still have the braces, but we inline them:

if (Something)
  { SingleLineStatement(); }
else
{
  ThisHas();
  TwoLines();
}

for (auto &&e : elements)
  { e.DoSomething(); }

 

There's no autoformatter that I've seen that can handle this particular arrangement of braces (plus I've been writing code since 1994 and my muscle memory for tabbing/untabbing/spacing/etc manually is locked in at this point), so all of the autoformatting stuff in both MSVC and Resharper are turned off.

However, when I type the following (minus the comment which is there to show the spacing):

for (auto &&e : elements)
  // There's a “tab” here but not yet the brace

 

and then type the opening brace, it untabs the brace back in line with the for loop, *even though I have all of the typing assist stuff turned off*

for (auto &&e : elements)
{ // now the brace is here instead of tabbed in like I specifically did with my typing

 

is there any way to disable this behavior that I've just missed? It's really a speedbump to my typing (again, long-ingrained muscle memory for formatting everything manually).

 

Thanks!

0
4 comments

Hello,

Unfortunately, it looks like there is no way to disable auto-indent in this scenario currently in R++. I believe we should disable auto-indent when the “Auto-insert closing brace” is turned off though.

How do you turn off auto-indent in Visual Studio here? I tried turning off “Automatic brace completion” in “C/C++ | General”, but it looks like Visual Studio still reindents the opening brace for me.

Thanks!

0

I'm not sure exactly which setting in Visual Studio turns it off, but I believe it's one of:

  • Set TextEditor→C/C++→Tabs→Indenting to “Block” instead of “Smart”
  • In TextEditor→C/C++→COde Style→Formatting, disable literally everything that says “Automatically”

.. if not those, it's definitely *one* of the “do something I didn't type, as I type” options. Anything that does any sort of adjustment of what I typed I have turned off 😀

Is this something that I should submit a bug/feature request on? I would love to have this behavior changed (or changeable) in a future version.

 

Thanks :)

0

You're right, I needed to change “Tabs | Indenting” in Visual Studio.

I've filed https://youtrack.jetbrains.com/issue/RSCPP-36603/ to track this, I'll fix this in a 2025.1 bugfix update.

Thanks!

1

Oh, awesome! Thanks, that would be amazing :)

0

Please sign in to leave a comment.