+6

command_history does not help determine last command

colinta 13 jaar geleden bijgewerkt door Carlos Rodriguez 13 jaar geleden 1
The plugin I'm trying to fix is MoveText.  When you drag text up or down, it stores the initial column location, so that if you move to a row that doesn't have enough columns, it can remember the original column and use that if you move up to a  row that does have enough columns in it.  The important thing here is that I need to find out what the previous command was.

The mechanism for this is View.command_history, but it is not giving me the command I want.  This is a recent bug.  The way undo history works has changed.  It now groups more commands into one history entry (and I for one wish it didn't!).  And there is no way to control this.  It would be great to say "this is a change that should not be grouped with other changes".

The extra special frustration is that the console does return the most recent command, even though in the plugin it reports something different.

One easy way to fix this, if people disagree that undo history should be more granular, is to add a command to View that tells you the last command that was run, but not based on undo history.
+1
The command history did indeed change.

I'm having an issue with my plugin as well (https://github.com/eddorre/SublimeERB/issues/6)

It looks like the API for the command history has

changed a bit.


In the stable release of Sublime Text, when running my command, the

command history (self.view.command_history) is listed as such:


(None, None, 0)

COMMAND HISTORY

(u'erb', None, 1)

COMMAND HISTORY

(u'erb', None, 1)

COMMAND HISTORY

(u'erb', None, 1)

COMMAND HISTORY

(u'erb', None, 1)

COMMAND HISTORY

(u'erb', None, 1)

COMMAND HISTORY

(u'erb', None, 1)

COMMAND HISTORY

(u'erb', None, 1)

COMMAND HISTORY

(u'erb', None, 1)


As you can see this allows me to find out of they have not done

anything else in between key presses which allows me to toggle ERB

blocks.


In the latest dev build, the command history looks something like this:


COMMAND HISTORY

(None, None, 0)

COMMAND HISTORY

(None, None, 0)

COMMAND HISTORY

(u'erb', None, 2)

COMMAND HISTORY

(u'erb', None, 2)

COMMAND HISTORY

(u'left_delete', None, 1)

COMMAND HISTORY

(u'left_delete', None, 1)

COMMAND HISTORY

(u'left_delete', None, 1)

COMMAND HISTORY

(u'erb', None, 3)

COMMAND HISTORY

(u'erb', None, 3)

COMMAND HISTORY

(u'erb', None, 3)

COMMAND HISTORY

(u'erb', None, 3)

COMMAND HISTORY

(u'erb', None, 3)

COMMAND HISTORY

(u'erb', None, 3)

COMMAND HISTORY

(u'erb', None, 6)

COMMAND HISTORY

(u'erb', None, 6)