Author Topic: B2: Extra space added after closing paren after typing "if<space>" in C++  (Read 2975 times)

rowbearto

  • Senior Community Member
  • Posts: 2335
  • Hero Points: 132
Here is an example C++ code in a C++ project:

Code: [Select]
void main(int argc, char *argv[]) {
    if
}

Place the cursor to the right of the "f" in "if", and press space, it expands to this:

Code: [Select]
if ()<space>
{
}

The problem is that an extra "space" character is added after the closing parenthesis of the "if".

I was able to reproduce this in Beta2 with the attached project, just add the "if" in "RunContext.cc"

I'm able to reproduce this by creating a new configuration in an empty directory ("-sc <emptydir>"), and then modifying the brace style for "if" statements to "next line". After this modification of the configuration, put the cursor to the right of the "f" in "if" and press <space>.
« Last Edit: August 19, 2017, 03:39:43 AM by rowbearto »

patrick

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 1818
  • Hero Points: 151
Reproduced.  I think I know what this is.  We sometimes preserve spaces that otherwise wouldn't be allowed if a cursor is adjacent to the space.  That's desirable for some situations, like an alias expansion like this: "if (%\c) %\c".  But it doesn't make sense for your example, since we already know the brace is going to be on the next line.

Thanks for the report, I can probably get this in for beta 3.

patrick

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 1818
  • Hero Points: 151
Fixed for beta 3.  Looking back, I think we've had to address this problem before, but the fixes never ended up working in all cases, because I missed the root cause.  The short version is the logic was good, but the data about where cursors/hotspots were was not so good.  Your example made that obvious, since there are no hotspots or cursors in a position to make us retain the space.

Thanks again for the report.

microcode

  • Community Member
  • Posts: 59
  • Hero Points: 10
Will the fix apply to C# too?  I see the same problem.

patrick

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 1818
  • Hero Points: 151
Yes, it covers the beautifiers added since v16, which includes C#.  I just double checked it to be paranoid.