Current the command_history in python API, only stores view specific commands. Keeping track also on the commands executed from the command_pallete would be quite useful.
Nevermind, I was pointer to the eventListener which solved the issue I think.
import sublime
import sublime_plugin
history = [("no history","")]
class ShowHistoryCommand(sublime_plugin.TextCommand):
def run(self, edit):
global history
history_list = ["%s\n %s" % pair for pair in history]
flags = sublime.KEEP_OPEN_ON_FOCUS_LOST
sublime.active_window().show_quick_panel(history_list, lambda x: print(x), flags)
class CaptureWindowCommand(sublime_plugin.EventListener):
def appendCommand(self, cmd, args):
global history
item = (cmd, args)
blacklist = ['show_panel', 'quick_panel', 'hide_panel']
if cmd in blacklist: # skip opening panels etc.
return
if item in history: # skip duplicates
return
history.insert(0,item)
limit = 20 # keep last 20
history = history[:limit]
def on_post_window_command(self, window, command_name, args):
self.appendCommand(command_name, args)