Permalink
Browse files

Delete duplicated views when closing a group

Fixes #23
  • Loading branch information...
1 parent 10d01b1 commit 79fc0ad3f68bad92d12258f83e7692e3b32901aa @adzenith adzenith committed Feb 8, 2013
Showing with 20 additions and 0 deletions.
  1. +20 −0 origami.py
View
@@ -62,6 +62,16 @@ def adjacent_cells(self, direction):
current_group = self.window.active_group()
return cells_adjacent_to_cell_in_direction(cells, cells[current_group], direction)
+ def duplicated_views(self, original_group, duplicating_group):
+ original_views = self.window.views_in_group(original_group)
+ original_buffers = [v.buffer_id() for v in original_views]
+ potential_dupe_views = self.window.views_in_group(duplicating_group)
+ dupe_views = []
+ for pd in potential_dupe_views:
+ if pd.buffer_id() in original_buffers:
+ dupe_views.append(pd)
+ return dupe_views
+
def travel_to_pane(self, direction):
adjacent_cells = self.adjacent_cells(direction)
if len(adjacent_cells) > 0:
@@ -145,6 +155,15 @@ def destroy_pane(self, direction):
cell_to_remove = adjacent_cells[0]
if cell_to_remove:
+ active_view = window.active_view()
+ group_to_remove = cells.index(cell_to_remove)
+ dupe_views = self.duplicated_views(current_group, group_to_remove)
+ for d in dupe_views:
+ window.focus_view(d)
+ window.run_command('close')
+ if active_view:
+ window.focus_view(active_view)
+
cells.remove(cell_to_remove)
if direction == "up":
rows.pop(cell_to_remove[YMAX])
@@ -170,6 +189,7 @@ def destroy_pane(self, direction):
for cell in adjacent_cells:
cells[cells.index(cell)][XMIN] = cell_to_remove[XMIN]
cells = pull_left_cells_after(cells, cell_to_remove[XMAX])
+
layout = {"cols": cols, "rows": rows, "cells": cells}
print(layout)
window.set_layout(layout)

0 comments on commit 79fc0ad

Please sign in to comment.