Author Topic: Dynamic surround and undo (nosplit-insert-line?)  (Read 6170 times)

jbhurst

  • Senior Community Member
  • Posts: 405
  • Hero Points: 33
Dynamic surround and undo (nosplit-insert-line?)
« on: May 16, 2007, 09:07:16 pm »
Hi,

There's a behavior with undo and dynamic surround that keep catching me. Example:

I type while and press space. SlickEdit inserts parens and braces, and places me in dynamic surround mode. The screen now has this code:
Code: [Select]
while (|) {
}

What I usually do next is type my condition, then invoke nosplit-insert-line (Ctrl+Enter in my setup) to get a new line inside the braces. I guess I could use next-hotspot then press Enter to get my new line, but that seems like more work. Invoking nosplit-insert-line cancels dynamic surround, and gives me this:
Code: [Select]
while (status) {
  |
}

If I now decide I made a small mistake in my condition, I press undo. But what happens?! It undoes all my typing in the condition! I get back to:
Code: [Select]
while|

I can use redo to get the condition back, but I think undo should only undo the nosplit-insert-line, as it usually does.

Regards

John Hurst
Wellington
New Zealand

StephenW

  • Senior Community Member
  • Posts: 189
  • Hero Points: 21
Re: Dynamic surround and undo (nosplit-insert-line?)
« Reply #1 on: May 16, 2007, 09:52:17 pm »
I am with John on this one.  I have been caught by this a number of times now, and it has annoyed me every time.  If I really wanted to be undone all the way back to the "while" only, I could get there by using undo a second time, but the condition should not disappear on the first undo.

hs2

  • Senior Community Member
  • Posts: 2744
  • Hero Points: 288
Re: Dynamic surround and undo (nosplit-insert-line?)
« Reply #2 on: May 17, 2007, 08:52:11 am »
I agree with John and StephenW. This should be changed.

@SlickTeam:
I'm running out of keybindings (again) - especially for the next/prev family commands. Hence I want to use a wrapper command for next/prev-error (->next/prev-hotspot) using in_dynamic_surround_mode(). But curr. this remains returning 'true' after 1st time activation of dynam. srround b/c gSurroundMarkerStartLine is never reset. So I added
Code: [Select]
   // HS2-ADD: reset gSurroundMarkerStartLine - see in_dynamic_surround_mode()
   gSurroundMarkerStartLine=0;
to TerminateDynamicSurroundEditing().
Seems that this hack doesn't break too much. Could you provide sth. similar that 'in_dynamic_surround_mode()' really reflects what it's name suggests ?

Thanks,

HS2

ScottW, VP of Dev

  • Senior Community Member
  • Posts: 1471
  • Hero Points: 64
Re: Dynamic surround and undo (nosplit-insert-line?)
« Reply #3 on: May 18, 2007, 02:36:06 pm »
Dennis has fixed this for v12.0.1, which should be coming out soon.

--Scott

hs2

  • Senior Community Member
  • Posts: 2744
  • Hero Points: 288
Re: Dynamic surround and undo (nosplit-insert-line?)
« Reply #4 on: May 18, 2007, 03:02:49 pm »
Great (and thanks Dennis) ! Can't wait any longer ... just release it today ;)

HS2

ScottW, VP of Dev

  • Senior Community Member
  • Posts: 1471
  • Hero Points: 64
Re: Dynamic surround and undo (nosplit-insert-line?)
« Reply #5 on: May 18, 2007, 03:26:42 pm »
Oh, you wouldn't like it if we released it today. Trust me on that! :)

Well, actually, I'm hoping today's build is OK. If so, we will release it early next week.

--Scott

hs2

  • Senior Community Member
  • Posts: 2744
  • Hero Points: 288
Re: Dynamic surround and undo (nosplit-insert-line?)
« Reply #6 on: May 18, 2007, 03:34:49 pm »
Ok - that's fair enough.  And I'll keep my fingers crossed !

HS2

hs2

  • Senior Community Member
  • Posts: 2744
  • Hero Points: 288
Re: Dynamic surround and undo (nosplit-insert-line?)
« Reply #7 on: May 25, 2007, 09:31:56 am »
@Dennis: Am I right that this didn't make it into v12.01 ?
Or what do you propose howto 'overload' next/prev_error when dynam. surrounding sth. ?

Thanks,

HS2

ScottW, VP of Dev

  • Senior Community Member
  • Posts: 1471
  • Hero Points: 64
Re: Dynamic surround and undo (nosplit-insert-line?)
« Reply #8 on: May 25, 2007, 01:46:09 pm »
Oops, it looks like there were to many this's in this thread. The this that I was talking about was the fix to the undo issue posted by StephenW. I can't say about the surround marker thing.

--Scott

hs2

  • Senior Community Member
  • Posts: 2744
  • Hero Points: 288
Re: Dynamic surround and undo (nosplit-insert-line?)
« Reply #9 on: May 25, 2007, 01:50:00 pm »
 ;D
However, I reapplied my patch and it seems working (as before).
Would be fine if Dennis could confirm that it doesn't harm sth. else.

HS2

jbhurst

  • Senior Community Member
  • Posts: 405
  • Hero Points: 33
Re: Dynamic surround and undo (nosplit-insert-line?)
« Reply #10 on: May 25, 2007, 07:51:25 pm »
Yes, I can confirm. Undo is working nicely now.

Thanks!

John Hurst
Wellington, New Zealand

hs2

  • Senior Community Member
  • Posts: 2744
  • Hero Points: 288
Re: Dynamic surround and undo (nosplit-insert-line?)
« Reply #11 on: July 17, 2007, 02:54:34 pm »
There is minor issue with 'else' completion incl. dyn. surround when the 'wrong' brace style e.g. '2' is used:
Completing 'else' leads to:
Code: [Select]
else<cursor here>
{
}

There is no 'next-hotspot' available placing the cursor
Code: [Select]
else
{<cursor here>
}
as it's working with 'if' completions.

Although it would be even better if I could finish completions/dyn. surround somehow to get:
Code: [Select]
if/else
{
   <indent><cursor here>
}

which is implicitely achieved by using the one-and-only brace style (I don't use) and pressing <ENTER> :(

HS2