I’m trying to write a command to rearrange tabs with ctrl+alt+pageup/pagedown. Now I think that there is a small off-by-one bug in the new setViewPosition call. You can test this by using the console, but I also created the following command to help. With this you can move a view by typing ctrl+m followed by the new index.
[code]
class MoveTab(sublimeplugin.TextCommand):
def run(self, view, args):
win = view.window()
group, tab = win.getViewPosition(view)
win.setViewPosition(view, group, int(args[0]))
print “MoveTab from %d to %s: end position is %d” % (tab, args[0], win.getViewPosition(view)[1])
[/code]
I opened a new empty editor window, created four new tabs and named them 1, 2, 3 and 4. Then I selected tab 4 and typed ctrl+m,2,ctrl+m,1,ctrl+m,0. Now all is good – the tab is moved as expected (one step left each time) and console shows:
MoveTab from 3 to 2: end position is 2
MoveTab from 2 to 1: end position is 1
MoveTab from 1 to 0: end position is 0
Here comes the problem: continue moving the tab with ctrl+m,1,ctrl+m,2,ctrl+m,3. With the first command, tab does not move and after that the tab is always one position ‘behind’. You can also see this from the console:
MoveTab from 0 to 1: end position is 0
MoveTab from 0 to 2: end position is 1
MoveTab from 1 to 3: end position is 2