I’m working on making my plugin stand-alone - I thought this one issue stemmed from a different plugin but the same happens under different circumstances which leads me to believe it may be SublimeText related…
Note: With the CodeMap addon - it happens about every single time you open the code-map panel and close it using the show_code_map command from a menu or the key command… alt + m + m + release-alt… The group opens with a blank file… When the group closes it closes the next file which takes focus on top of the blank file and the empty group… This is an issue…
With CodeMap this issue occurs whether I use the middle mouse to close the panel, or if I use the command…
With my plugin it only happens if I use middle-mouse to close the file ( and the empty group is closed automatically by Sublime Text ) - but if I use the code to open and close the layout, then it works as expected unless I save a file which is auto-refreshed which erases some vars ( because it is still in development I don’t have logic to detect if the panel is already open in these cases but I will - the problem for me is that I don’t trust user input, and being able to close the file in the group with middle-mouse and having sublime text close the group needs to be allowed but the issue of it taking other files with it is highly problematic…
Code Map and I use different code - I saw this bug in his addon earlier and I added some checks to fix it - and it does in some cases except when using the middle-mouse… but I’m using the default addon right now and phasing it out while I code my addon…
The user should be able to close the group any way they see fit whether using the context menu, main plugin settings / options menu, using reset layout from Sublime Text, middle-mouse or X button on the tab, etc… without any of their files being closed in the process…
I am leaning towards this being an issue with SublimeText, but I haven’t tried everything in terms of debugging, but I’m almost out of ideas… The code is very simple…
Adjust the window layout by multiplying 0.25 for all open cells ( this shrinks the size of them relatively so the 0.25 or 25% width will be available for the new panel / cell / column being added – use division to undo it )… Below is a list of the differences…
Layout Before: {‘cols’: [0.0, 1.0], ‘cells’: [[0, 0, 1, 1]], ‘rows’: [0.0, 1.0]}
Layout After: {‘cols’: [0.0, 0.75, 1.0], ‘cells’: [[0, 0, 1, 1], [1, 0, 2, 1]], ‘rows’: [0.0, 1.0]}
In short - columns, as said above, are multiplied by 0.25 to modify the size, divide to undo it, so 1 becomes 0.75… then 1.0 is added to the end… divide to undo and pop the last… A new cell is added using x1, y1, x2, y2 format for column / row positioning. rows aren’t changed…
Here are the changes from the undo operation:
Layout Before: {‘cols’: [0.0, 0.75, 1.0], ‘cells’: [[0, 0, 1, 1], [1, 0, 2, 1]], ‘rows’: [0.0, 1.0]}
Layout After: {‘cols’: [0.0, 1.0], ‘cells’: [[0, 0, 1, 1]], ‘rows’: [0.0, 1.0]}
– and again, when using code to remove it, it all works great - the problem is when closing the tab / view open in the new group… All cases of closing the group / panel needs to work without any issues…
I have yet to create the ‘as small as possible’ code sample.
…
Expected behavior
I expect to be able to open a column and a file in that column using code, and then close it any way I want - using middle mouse or via code, or via menu to reset layout… without it closing any other files…
…
Actual behavior
If I create it with code, and use middle mouse to close - then 2 files are actually removed - the blank file within the right panel opened up and the next file which takes focus on the left after the right panel closes…
I have noticed odd issues with one of the minimaps closing when adjusting panels with code - I’m attempting to pin down exactly how to do this because this would be gold for my addon…
Does anyone know why this is happening? Does anyone have experience with it, and why?
It could be with how the group is created so the pseudocode is:
Window get layout as _layout
grab column and cell info as _cols and _cells
for each column modify the width by multiplying 0.25 ( or dividing on removal )
If showing then add another column value by pushing 1.0 onto the list. and add the cell
if hiding then pop the last value from columns and pop the last cell
Run command set layout with new information
if show then open the blank file and then call a callback to set up options for that view - ie font face, size, etc…
if hide then call close on the blank file after ensuring focus is set to that particular and making sure the view and all still exists…
That works flawlessly - but closing with middle mouse just causes 2 files to be closed and I have no code which executes when something is closed…