Skip to content

Commit fc5baea

Browse files
deathaxemath2001
authored andcommitted
Close all deleted file's views without saving (#65)
This commit makes sure to close all existing views for the file being deleted in all open windows without prompting to save changes.
1 parent 4eb001b commit fc5baea

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

commands/delete.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,11 @@ def run(self, paths=None, *args, **kwargs):
3838
def delete(self, index):
3939
if index == 0:
4040
for path in self.paths:
41-
view = self.window.find_open_file(path)
42-
if view is not None:
43-
close_view(view)
41+
for window in sublime.windows():
42+
view = window.find_open_file(path)
43+
while view is not None:
44+
close_view(view, dont_prompt_save=True)
45+
view = window.find_open_file(path)
4446

4547
try:
4648
send2trash(path)

libs/sublimefunctions.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,9 @@ def on_done(index):
136136
window.show_quick_panel(items, on_done, 0, 1)
137137

138138

139-
def close_view(view_to_close):
139+
def close_view(view_to_close, dont_prompt_save=False):
140+
if dont_prompt_save:
141+
view_to_close.set_scratch(True)
140142
if isST3():
141143
view_to_close.close()
142144
return

0 commit comments

Comments
 (0)