Skip to content

Commit

Permalink
When there is a batch performance for some chain of execution, and
Browse files Browse the repository at this point in the history
there are error on them, we cannot show a error message dialog for
each one of them immediately, otherwise we would flood the user
with messages.

See:
Sublime Text Files syntax error flooding
sublimehq/sublime_text#1510
  • Loading branch information
evandrocoan committed Jun 16, 2017
1 parent b4cb03d commit 9bb8d43
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion package_control/show_error.py
@@ -1,7 +1,14 @@
import sublime

from . import text
from .console_write import console_write

from threading import Timer

# When there is a batch performance for some chain of execution, and there are error on them,
# we cannot show a error message dialog for each one of them immediately, otherwise we would
# flood the user with messages. See: https://github.com/SublimeTextIssues/Core/issues/1510
is_error_recentely_displayed = False

def show_error(string, params=None, strip=True, indent=None):
"""
Expand All @@ -21,5 +28,19 @@ def show_error(string, params=None, strip=True, indent=None):
If all lines should be indented by a set indent after being dedented
"""

global is_error_recentely_displayed
string = text.format(string, params, strip=strip, indent=indent)
sublime.error_message(u'Package Control\n\n%s' % string)

if is_error_recentely_displayed:
console_write( string )
else:
sublime.error_message(u'Package Control\n\n%s' % string)
is_error_recentely_displayed = True

# Enable the message dialog after x.x seconds
thread = Timer(60.0, _restart_error_messages)
thread.start()

def _restart_error_messages():
global is_error_recentely_displayed
is_error_recentely_displayed = False

0 comments on commit 9bb8d43

Please sign in to comment.