Author Topic: Some problem on if() {} auto-expansion ?  (Read 7252 times)

abcd

  • Guest
Some problem on if() {} auto-expansion ?
« on: June 08, 2010, 03:34:20 AM »
when on follow code
      if ()
      {
           // insert if() here     
             int a;
       }
insert if() before "int a;

the slickEdit will auto-expanse as follow:
      if ()
      {
           if()
           {
             int a;
           }
           }  // this } becomes the inner if's "}" when I using up/down arrow to expanse, it's not correct, the expanse inner } should be the actual } fit for if expression.


abcd

  • Guest
Re: Some problem on if() {} auto-expansion ?
« Reply #1 on: June 17, 2010, 02:13:56 AM »
 ??? ???

abcd

  • Guest
Re: Some problem on if() {} auto-expansion ?
« Reply #2 on: June 22, 2010, 03:49:19 AM »
 ;D ;D :D :D ;) ;)

Graeme

  • Senior Community Member
  • Posts: 2793
  • Hero Points: 347
Re: Some problem on if() {} auto-expansion ?
« Reply #3 on: June 22, 2010, 09:57:21 AM »
I can't reproduce this problem. 

What version of slickedit are you using and what operating system?

I'm assuming this is in a C++ file.  When I enter if () before the int a I get this
Code: [Select]
    if (1) {
        if () {
        }
        int a;
    }
and if I press down arrow to "expand" I get this
Code: [Select]
    if (1) {
        if () {
            int a;
        }
    }
and if I press down arrow again it won't expand any further. 
Maybe you can post a screen capture that shows exactly what's happening.

Graeme


chrisant

  • Senior Community Member
  • Posts: 1410
  • Hero Points: 131
Re: Some problem on if() {} auto-expansion ?
« Reply #4 on: June 22, 2010, 05:35:42 PM »
abcd is using Style 2.
Graeme is using Style 1.

Style 2 and Style 3 have some nits, and this is one of them.
I apologize that I haven't been good about filing support cases for the nits.

One that I recall off the top of my head is try/catch.
Indentation goes awry in Style 3:
Code: [Select]
void Foo()
{
    try
        {
        }
    catch
        {
    } // typing this closing brace assigns incorrect indentation
}

There are indentation problems with try/catch with Style 2 as well, but I don't remember how to trigger them.

I use Style 2 mostly, and I frequently run into the nit described by abcd during dynamic surround, I just don't have enough free time to report stuff all the time.

(This is all with v14).

abcd

  • Guest
Re: Some problem on if() {} auto-expansion ?
« Reply #5 on: June 23, 2010, 01:48:29 AM »
I can't reproduce this problem.  

What version of slickedit are you using and what operating system?

I'm assuming this is in a C++ file.  When I enter if () before the int a I get this
Code: [Select]
   if (1) {
        if () {
        }
        int a;
    }
and if I press down arrow to "expand" I get this
Code: [Select]
   if (1) {
        if () {
            int a;
        }
    }
and if I press down arrow again it won't expand any further.  
Maybe you can post a screen capture that shows exactly what's happening.

Graeme


My SE is 15.0.0.6, c language. The problem I reported isn't upon pressing down button twice. It expands over the outer if expression's } when I just press the down button one time. But now I can't reappear it.

But not as you said, when I press the "down" button twice, the if surround will expand over the outer if expression, as my attached picture showing.But I think this problem isn't so terrible.
« Last Edit: June 23, 2010, 01:54:19 AM by abcd »

Graeme

  • Senior Community Member
  • Posts: 2793
  • Hero Points: 347
Re: Some problem on if() {} auto-expansion ?
« Reply #6 on: June 23, 2010, 12:07:05 PM »
Quote
But not as you said, when I press the "down" button twice, the if surround will expand over the outer if expression, as my attached picture showing.But I think this problem isn't so terrible.

ok, my mistake.  As chrisant pointed out, I was using a different brace style - I should've noticed.  You should probably report this to slickedit support to be sure it gets into their system - on the slickedit help menu, click "contact product support".

Graeme

Lee

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 1299
  • Hero Points: 130
Re: Some problem on if() {} auto-expansion ?
« Reply #7 on: June 23, 2010, 12:43:03 PM »
@abcd: Is there more to the example that I'm not seeing?  I cannot reproduce the error you describe with Style 2 braces with the example pictured with a otherwise default configuration.  I have seen that sort of error where there are unclosed braces that throw off all the brace matching.  You need to provide an entire sample and more details about your configuration settings (Platform, Emulation, C++ Formatting settings).

@chrisant:  There was indeed an error in the try .. catch statement surround.  It has already been reported and addressed in the cumulative hotfix for v15.

abcd

  • Guest
Re: Some problem on if() {} auto-expansion ?
« Reply #8 on: June 24, 2010, 01:50:33 AM »
Here is the SE about, and the attach is all SE's option exported.
SlickEdit Version 15.0.0.6

Build Date: May 07, 2010
Emulation: Visual C++ 6

OS: Windows XP
OS Version: 5.01.2600  Service Pack 3
Memory: 38% Load, 804MB/2087MB Physical, 228MB/2097MB Virtual
Shell Info: C:\WINDOWS\system32\cmd.exe /q
Screen Size: 1280 x 1024

Project Type: gnuc
Language: .c (C/C++)

Installation Directory: C:\Program Files\SlickEditV15.0.0\ (non-removable drive,NTFS,20150MB free)
Configuration Directory: G:\documents\My SlickEdit Config\15.0.0\ (non-removable drive,NTFS,58820MB free)
Spill File: C:\Documents and Settings\shichen\Local Settings\Temp\$slk.10 (non-removable drive,NTFS,20150MB free)


chrisant

  • Senior Community Member
  • Posts: 1410
  • Hero Points: 131
Re: Some problem on if() {} auto-expansion ?
« Reply #9 on: June 24, 2010, 07:48:50 AM »
@Lee -- v15 might have this already, but I'll toss this idea out in case it doesn't:

Problem Description:
SE has lots of handy auto-insertion things.  But sometimes given the surrounding context in a file they may not have the desired effect.  For example if braces are unmatched because of how I'm editing code or because of how #ifdef statements are used then it can do weird things to the code when I type { (open brace).  I can Undo, but typing the brace again does the weird thing again.  So I am left with a choice:  I can fix the context to make the SE feature happy and then type the open brace, or I can type the open brace and then fix the auto-inserted stuff.  In cases like this the SE features can be painful.

Feature Suggestion:
I'd like to be able to press a key such as open brace and have SE do its usually-cool stuff.  But I'd like two stages of undo:  Press Undo the first time would undo the auto-insertion cool stuff and make it as if SE had only inserted the literal key I pressed.  Press Undo a second time would undo the literal key.  This is how Microsoft Word handles auto-text features and it is very natural and works well.

Prototype Patch:
I've attached a prototype I threw together of this Undo feature with dynamic surround (it also includes a fix for dynamic surround with try/catch with Style2 where it was off by one line for the catch block).
The patch actually has three undo levels for dynamic surround:  Undo1 undoes the braces (retains the autocompleted parens), Undo2 undoes the autocompleted parens (retains the literal key pressed), Undo3 goes back to the original state before pressing the expansion key (space, paren, etc).
To see the diffs for the patch, compare the files in the "before" folder with the files in the "after" folder.

Warning:  copying the "after" files into the macros folder and using them verbatim is probably not going to work because I have a bunch of other patches in the files.  To anyone who wants to try applying this patch, be sure to compare the "before" and "after" folders and just apply the differences.
« Last Edit: June 24, 2010, 07:50:46 AM by chrisant »