Author Topic: No cursor movements in undo?  (Read 5860 times)

myk

  • Community Member
  • Posts: 12
  • Hero Points: 0
No cursor movements in undo?
« on: October 26, 2007, 02:35:32 am »
I would like to prevent cursor movements from being recorded in the history at all.

I've already search the forum, and the only information I've found pertains to choosing whether to undo cursor movements one-by-one or in a single step between text edits.  However, I would much prefer the undo history to track text edits only.

Is this possible?

jbhurst

  • Senior Community Member
  • Posts: 405
  • Hero Points: 33
Re: No cursor movements in undo?
« Reply #1 on: October 26, 2007, 03:03:12 am »
Hi,

Try setting the macro variable def_undo_with_cursor to 0.

(You can use Macro > Set Macro Variable on the menu, or use the command "set-var def_undo_with_cursor 0".)

Regards

John Hurst
Wellington, New Zealand

myk

  • Community Member
  • Posts: 12
  • Hero Points: 0
Re: No cursor movements in undo?
« Reply #2 on: October 26, 2007, 05:46:17 am »
Thanks... I've already set that to 0, and it still includes some cursor movement in the history.

If I make one text edit, then move to a new line and make a second text edit, I will have three distinct steps when undoing:

- The second edit is undone.
- The cursor is positioned back to where it was at the end of the first edit.
- The first edit is undone.

I would like to remove the undo-aggregated-cursor-movements altogether.

Graeme

  • Senior Community Member
  • Posts: 2289
  • Hero Points: 298
Re: No cursor movements in undo?
« Reply #3 on: October 26, 2007, 07:54:07 am »

You could try this macro - can't guarantee it's exactly what you want.

Code: [Select]
_command void myundo() name_info(',')
{
   undo_cursor();
   undo();
}

Graeme

myk

  • Community Member
  • Posts: 12
  • Hero Points: 0
Re: No cursor movements in undo?
« Reply #4 on: October 30, 2007, 12:12:07 am »
Thanks for the attempt Graeme, that's almost what I want.  I can't quite get it to behave the way I'm used to (which is essentially the norm for pretty much every other application): I would like a single undo step to undo the last text edit and leave the cursor at that location.  Playing around with your suggested macro, I can get it to undo the last text edit and skip the cursor stuff, but it leaves the cursor at the location of the previous text edit, which can hide what has just been changed.

Also, changing the code in a macro doesn't seem to "stick" very well.  It looks like I have to restart the IDE to get code changes to apply...

Lastly, including cursor movements in the undo history tends to break the undo/redo behaviour.  If I make 10 edits, undo half of them, then happen to move the cursor, I lose the redo "history".  As far as I'm concerned, that's fundamentally broken.

Graeme

  • Senior Community Member
  • Posts: 2289
  • Hero Points: 298
Re: No cursor movements in undo?
« Reply #5 on: October 30, 2007, 08:32:25 am »

You could always use the backup history mechanism  - write a macro that does a save as well as an undo  -
            save();
            undo();

and use that instead of undo.  Maybe not as convenient but at least you don't risk losing anything.  I don't think it takes up a lot of disk space - for the file being saved - as it's diff based.  I think the +DD option in the save command selects the backup history thing but I recall having some problems getting it to work.

If you send in a feature request it ought to be fairly easy to provide an option to keep cursor movements out of the undo history, I would have thought.

Graeme

jbhurst

  • Senior Community Member
  • Posts: 405
  • Hero Points: 33
Re: No cursor movements in undo?
« Reply #6 on: October 30, 2007, 05:50:37 pm »
Hi,

Just thought I'd pitch in with a comment.

I wouldn't mind if SlickEdit added an option for the behavior you're after, but it should be optional. I love the current behaviour and rely on it. I would be frustrated if SlickEdit's undo were changed to be like "pretty much every other application", since I get frustrated on those applications at not being able to undo cursor movement!

:-)

John Hurst
Wellington, New Zealand