From 612ecae1dad08775729a5199896fc700c6fd4752 Mon Sep 17 00:00:00 2001 From: herr kaste Date: Fri, 1 Mar 2024 18:13:40 +0100 Subject: [PATCH] Fix drawing diff output You can't use an `edit` object for any possible view, just for the view it was created for by Sublime. Just typically, use a command to draw to the view. --- sublack/blacker.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sublack/blacker.py b/sublack/blacker.py index be9c7ae..7479851 100644 --- a/sublack/blacker.py +++ b/sublack/blacker.py @@ -223,14 +223,14 @@ def run_black(self, command: list[str], env: dict[str, Any], cwd: str | None, co self.log.debug("run_black: returncode %s, err: %s", process.returncode, err) return process.returncode, out, err - def create_diff_view(self, edit: sublime.Edit, content: bytes, encoding: str): + def create_diff_view(self, content: bytes, encoding: str): window = sublime.active_window() view = window.new_file() window.focus_view(view) view.set_scratch(True) view.set_name(f"sublack diff {self.view.name()}") view.set_syntax_file("Packages/Diff/Diff.sublime-syntax") - view.insert(edit, 0, content.decode(encoding)) + view.run_command('append', {'characters': content.decode(encoding)}) def get_working_directory(self): filename = self.view.file_name() @@ -290,7 +290,7 @@ def finalize(self, edit: sublime.Edit, extra, returncode, out, err, content, com # diff mode elif "--diff" in extra: - self.create_diff_view(edit, out, encoding) + self.create_diff_view(out, encoding) # standard mode else: