Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not use persistent status sections for status messages #5

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 7 additions & 14 deletions sublack/blacker.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,12 +280,12 @@ def finalize(self, edit: sublime.Edit, extra, returncode, out, err, content, com
self.log.debug(f"Black returned: {error_message}")
# failure
if returncode != 0:
self.view.set_status(consts.STATUS_KEY, error_message)
self.view.window().status_message(error_message)
return returncode

# already formated, nothing changes
# already formatted, nothing changes
elif "unchanged" in error_message:
self.view.set_status(consts.STATUS_KEY, consts.ALREADY_FORMATTED_MESSAGE)
self.view.window().status_message(consts.ALREADY_FORMATTED_MESSAGE)
self.add_to_cache(content, command)

# diff mode
Expand All @@ -311,7 +311,7 @@ def finalize(self, edit: sublime.Edit, extra, returncode, out, err, content, com
self.view.sel().add(old_sel)

# status and caching
self.view.set_status(consts.STATUS_KEY, consts.REFORMATTED_MESSAGE)
self.view.window().status_message(consts.REFORMATTED_MESSAGE)
sublime.set_timeout_async(lambda: self.add_to_cache(new_content, command))

def format_via_precommit(self, edit: sublime.Edit, content, cwd, env):
Expand Down Expand Up @@ -378,7 +378,7 @@ def __call__(
# check the cache
# cache may not be used with pre-commit
if self.is_cached(content, command):
self.view.set_status(consts.STATUS_KEY, consts.ALREADY_FORMATTED_MESSAGE_CACHE)
self.view.window().status_message(consts.ALREADY_FORMATTED_MESSAGE_CACHE)
return

if use_blackd:
Expand Down Expand Up @@ -500,16 +500,9 @@ def run(self, extra: list[str] = []):
if success_list
else consts.REFORMAT_ERRORS
)
# if success_list and error_list:
# error_message = consts.REFORMATTED_ALL_PARTIAL_MESSAGE
if window := self.view.window():
window.status_message(error_message)

# elif success_list:
# error_message = consts.REFORMATTED_ALL_MESSAGE

# else:
# error_message = consts.REFORMAT_ERRORS

self.view.set_status(consts.STATUS_KEY, error_message)
for result in success_list:
folder, code, output = result
self.log.debug(
Expand Down
4 changes: 2 additions & 2 deletions sublack/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,9 @@ def run(self):
view = sublime.active_window().active_view()
assert view, "No view found!"
if server.stop_blackd_server():
view.set_status(consts.STATUS_KEY, consts.BLACKD_STOPPED)
sublime.active_window().status_message(consts.BLACKD_STOPPED)
else:
view.set_status(consts.STATUS_KEY, consts.BLACKD_STOP_FAILED)
sublime.active_window().status_message(consts.BLACKD_STOP_FAILED)


class BlackFormatAllCommand(sublime_plugin.WindowCommand):
Expand Down