Home Download Buy Blog Forum Support

Split/iterate [regions]

Re: Split/iterate [regions]

Postby bizoo on Mon Oct 08, 2012 2:08 pm

agibsonsw wrote:I've fixed the first issue at my GitHub

I can confirm it's fixed.

For the undo issue, I suppose only jps can give an answer...
bizoo
 
Posts: 880
Joined: Wed Dec 08, 2010 6:53 am
Location: Switzerland

Re: Split/iterate [regions]

Postby agibsonsw on Mon Oct 08, 2012 2:57 pm

I can confirm it's fixed.


Undo seems to behave a little better now, as a result of the other fix. I think cutting and pasting the same content will be one way to correct edited regions, or even over-writing an area with a space or character, and then using Undo.

It just occurred to me that it might be useful to have another shortcut to specifically add the currently highlighted text as an edit-region. I might play with this. However, cutting and pasting achieves the same (or similar) result.
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
agibsonsw
 
Posts: 901
Joined: Fri Jan 27, 2012 9:11 pm

Re: Split/iterate [regions]

Postby bizoo on Mon Oct 08, 2012 3:21 pm

agibsonsw wrote:Undo seems to behave a little better now, as a result of the other fix

Didn't change anything for my test case but maybe it's better for other test case.
Strangely, soft undo works without any issue for me.

So it looks more and more like a ST2 bug.
As jps not very active in this forum since a few weeks, anyone has it's phone number ;)
bizoo
 
Posts: 880
Joined: Wed Dec 08, 2010 6:53 am
Location: Switzerland

Re: Split/iterate [regions]

Postby agibsonsw on Mon Oct 08, 2012 3:38 pm

I believe Undo (and other features - Duplicate, Cut, Paste) can be problematic with any plug-in. But for this simple plug-in it shouldn't be a major concern, and most of these features seem to behave well. I find if I highlight an area, press Space and then Undo (Ctrl-Z) the whole area becomes a single edit-region. This process also removes any smaller edit regions within this larger area. In view of this, I don't think it's necessary for me to create a shortcut to do this (as mentioned in my previous post).

If anyone can think of something useful that might be added to this, please let me know - I might consider it ;) . Otherwise, I think it's complete - and I'm very pleased with it :D 8-)
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
agibsonsw
 
Posts: 901
Joined: Fri Jan 27, 2012 9:11 pm

Re: Split/iterate [regions]

Postby bizoo on Mon Oct 08, 2012 5:00 pm

agibsonsw wrote:I believe Undo (and other features - Duplicate, Cut, Paste) can be problematic with any plug-in. But for this simple plug-in it shouldn't be a major concern

IMHO, it's a major issue. I had the same issue with another plugin (Edit History).
If every time I trigger an undo (which is fairly often for me :( ) it remove a line that don't have to be removed, and keep a line that have to be removed, it quickly become a mess.

I really like this plugin, but without this issue resolved I don't think I will use it since I've no confidence in it.
bizoo
 
Posts: 880
Joined: Wed Dec 08, 2010 6:53 am
Location: Switzerland

Re: Split/iterate [regions]

Postby agibsonsw on Mon Oct 08, 2012 5:07 pm

I really like this plugin, but without this issue resolved I don't think I will use it since I've no confidence in it.


I shall investigate! Is it just Undo that causes you concern/issues?
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
agibsonsw
 
Posts: 901
Joined: Fri Jan 27, 2012 9:11 pm

Re: Split/iterate [regions]

Postby agibsonsw on Mon Oct 08, 2012 8:27 pm

Trying a few things with this Undo issue, including doing nothing :lol: :

Code: Select all
def doNothing(view):
    view.add_regions("doh", [sublime.Region(0, 0)], "nothing", sublime.HIDDEN)


It's kind-of a catch-22: writing code to correct Undo, the code we write becomes the thing that is undone. I recall others discussing this before; hopefully someone might offer some advice based on their experience :).

I've edited my GitHub so that the region for the currently edited line doesn't extend beyond the end of the line. So, for example, pressing Backspace doesn't cause the region to extend to the next line. This means that we can use, for example, Ctrl-Backspace to delete the previous word, in preference to Ctrl-Z.
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
agibsonsw
 
Posts: 901
Joined: Fri Jan 27, 2012 9:11 pm

Re: Split/iterate [regions]

Postby bizoo on Tue Oct 09, 2012 6:12 am

agibsonsw wrote:
I really like this plugin, but without this issue resolved I don't think I will use it since I've no confidence in it.


I shall investigate! Is it just Undo that causes you concern/issues?

Actually yes.
I don't have any other issue with your plugin, and this undo issue is not an issue from your plugin.

Do you mind if I try to open a new [BUG] topic about this subject ? Maybe jps will give us more info about this issue.
bizoo
 
Posts: 880
Joined: Wed Dec 08, 2010 6:53 am
Location: Switzerland

Re: Split/iterate [regions]

Postby agibsonsw on Tue Oct 09, 2012 11:07 am

Do you mind if I try to open a new [BUG] topic about this subject ? Maybe jps will give us more info about this issue.


That's fine. I shall still pursue this Undo issue myself: if I can trace the "sequence of events" then there might be a way around it.

I was thinking if I store variables x, y that represent the previous edit position (perhaps as globals), then I can check for "undo" being pressed once so that "on the next update" - re-instate the region x,y. The difference here is that x,y would be integers, rather than reflecting part of the buffer; and this change would occur on the next update, rather than happening straight-away (and being undone!). But it would help if I fully understood the sequence of events.

Andy.
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
agibsonsw
 
Posts: 901
Joined: Fri Jan 27, 2012 9:11 pm

Re: Split/iterate [regions]

Postby bizoo on Tue Oct 09, 2012 11:46 am

I tried briefly to create a test case but actually found that the problem is not where I thought it was :(
Not sure if it's really a bug or simply a limitation of the current API.

What I've found so far:
-the problem, as you probably already found, is that an undo command trigger an on_modified event that recreate the region.
-it looks like when entering the on_modified event after an undo, the region is correct (last region is removed).
-undo command trigger an on_modified event, but soft_undo not (???)
-multi-selection edition doesn't work ?

I wrote a plugin last week (https://github.com/bizoo/SmartCursor) that have to deal with on_modified/on_selection_modified and found this about events sequence:
When you type a char or paste from clipboard:
# on_modified (23, 15)
# on_selection_modified (23, 15)
When you trigger undo:
# on_selection_modified (23, 14)
# on_modified (23, 14)

So, maybe storing the actual view.sel() in the on_selection_modified event and compare it with the one in on_modified event could be used to identify an undo command.
If they are the same, it's an undo, otherwise it's an edition.
bizoo
 
Posts: 880
Joined: Wed Dec 08, 2010 6:53 am
Location: Switzerland

PreviousNext

Return to Technical Support

Who is online

Users browsing this forum: Exabot [Bot], Google [Bot] and 10 guests