Skip to content

Commit

Permalink
Set a delay of 1 second between every check for flow errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
Pegase745 committed Jul 5, 2017
1 parent 282e2e2 commit 73dadb1
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 5 deletions.
5 changes: 4 additions & 1 deletion flowtype/commands/check_contents.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import time
import sublime

from .base import BaseCommand
from .exec_flow import ExecFlowCommand
from ..logger import Logger
from ..helpers import get_flow_bin, prepare_arguments
from ..helpers import get_flow_bin, prepare_arguments, FLOWTYPE

logger = Logger()

Expand Down Expand Up @@ -50,6 +51,7 @@ def handle_process(self, returncode, stdout, error):
self.view.erase_status('flow_single_error')
self.view.set_status(
'flow_errors', 'Flow %s: no errors' % flow_version)
FLOWTYPE['LAST_ERROR_CHECK'] = time.time()
return

# Errors
Expand Down Expand Up @@ -103,6 +105,7 @@ def handle_process(self, returncode, stdout, error):

self.viewport_pos = self.view.viewport_position()
self.selection = list(self.view.sel())
FLOWTYPE['LAST_ERROR_CHECK'] = time.time()

def run(self, view):
"""Execute `check_contents` command."""
Expand Down
1 change: 0 additions & 1 deletion flowtype/commands/coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ def handle_process(self, returncode, stdout, error):
logger.logger.debug(stdout)

if stdout:
logger.logger.info(stdout)
expressions = stdout['expressions']
covered = expressions['covered_count']
uncovered = expressions['uncovered_count']
Expand Down
5 changes: 5 additions & 0 deletions flowtype/helpers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import re
import os
import json
import time
import subprocess
from collections import namedtuple

Expand All @@ -10,6 +11,10 @@
'file_name', 'cursor_position', 'row', 'col'
])

FLOWTYPE = {
'LAST_ERROR_CHECK': time.time(),
}


def singleton(cls):
"""A decorator to make a class into a singleton."""
Expand Down
7 changes: 4 additions & 3 deletions flowtype/listeners/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import time
import sublime
import sublime_plugin

from .builtintypes import builtintypes
from ..logger import Logger
from ..helpers import get_settings, is_js_source
from ..helpers import get_settings, is_js_source, FLOWTYPE

logger = Logger()

Expand Down Expand Up @@ -41,8 +42,8 @@ def on_selection_modified_async(self, view):
view.run_command('flowtype_autocomplete')

if (get_settings('check_contents_on_edit', False)):
sublime.set_timeout_async(
lambda: view.run_command('flowtype_check_contents'), 5)
if time.time() - FLOWTYPE['LAST_ERROR_CHECK'] >= 1:
view.run_command('flowtype_check_contents')

def on_post_save_async(self, view):
"""Erase highlighted regions and status when saving file."""
Expand Down
5 changes: 5 additions & 0 deletions messages/1.0.2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FlowType 1.0.2
==============

## Fixed
* Set a delay of 1 second between every check for flow errors.

0 comments on commit 73dadb1

Please sign in to comment.