Beispiel #1
0
    def run(
        self, group=-1, index=-1,
        close_type="single", unsaved_prompt=True, close_unsaved=True
    ):
        """Close the specified tabs and cleanup sticky states."""

        TabsExtraListener.extra_command_call = True

        if group >= 0 and index >= 0:
            self.init(close_type, group, index)

            if (
                len(self.targets) and
                not unsaved_prompt and
                not all(not target.view().is_dirty() for target in self.targets) and
                not sublime.ok_cancel_dialog(
                    "Are you sure you want to dismiss all targeted unsaved buffers?"
                )
            ):
                return

            for s in self.targets:
                v = s.view()
                if v is not None:
                    if self.can_close(v.settings().get("tabs_extra_sticky", False), close_type == "single"):
                        if not self.persistent:
                            v.settings().erase("tabs_extra_sticky")
                        self.window.focus_view(v)
                        if not v.is_dirty() or close_unsaved:
                            if not unsaved_prompt:
                                v.set_scratch(True)
                            sublime_api.window_close_file(self.window.id(), v.id())
                    elif not self.persistent:
                        v.settings().erase("tabs_extra_sticky")
                else:
                    self.window.focus_sheet(s)
                    self.window.run_command('close_file')

            if not self.persistent and self.cleanup:
                self.window.run_command("tabs_extra_clear_all_sticky", {"group": group})

            self.select_view()

        TabsExtraListener.extra_command_call = False
Beispiel #2
0
    def run(
        self, group=-1, index=-1,
        close_type="single", unsaved_prompt=True, close_unsaved=True
    ):
        """Close the specified tabs and cleanup sticky states."""

        TabsExtraListener.extra_command_call = True

        if group >= 0 and index >= 0:
            self.init(close_type, group, index)

            if (
                len(self.targets) and
                not unsaved_prompt and
                not all(not target.view().is_dirty() for target in self.targets) and
                not sublime.ok_cancel_dialog(
                    "Are you sure you want to dismiss all targeted unsaved buffers?"
                )
            ):
                return

            for s in self.targets:
                v = s.view()
                if v is not None:
                    if self.can_close(v.settings().get("tabs_extra_sticky", False), close_type == "single"):
                        if not self.persistent:
                            v.settings().erase("tabs_extra_sticky")
                        self.window.focus_view(v)
                        if not v.is_dirty() or close_unsaved:
                            if not unsaved_prompt:
                                v.set_scratch(True)
                            sublime_api.window_close_file(self.window.id(), v.id())
                    elif not self.persistent:
                        v.settings().erase("tabs_extra_sticky")
                else:
                    self.window.focus_sheet(s)
                    self.window.run_command('close_file')

            if not self.persistent and self.cleanup:
                self.window.run_command("tabs_extra_clear_all_sticky", {"group": group})

            self.select_view()

        TabsExtraListener.extra_command_call = False
Beispiel #3
0
 def close(self):
     window_id = sublime_api.view_window(self.view_id)
     return sublime_api.window_close_file(window_id, self.view_id)
Beispiel #4
0
 def close(self):
     window_id = sublime_api.view_window(self.view_id)
     return sublime_api.window_close_file(window_id, self.view_id)