|
17 | 17 | LINT_DEBOUNCE_S = 0.5 # 500 ms
|
18 | 18 | PARENT_PROCESS_WATCH_INTERVAL = 10 # 10 s
|
19 | 19 | MAX_WORKERS = 64
|
| 20 | +# We also watch for changes in config files |
| 21 | +PYTHON_FILE_EXTENSIONS = ('.py', '.pyi', 'pycodestyle.cfg', 'setup.cfg', 'tox.ini', '.flake8') |
20 | 22 |
|
21 | 23 |
|
22 | 24 | class _StreamHandlerWrapper(socketserver.StreamRequestHandler, object):
|
@@ -294,10 +296,17 @@ def m_workspace__did_change_configuration(self, settings=None):
|
294 | 296 | for doc_uri in self.workspace.documents:
|
295 | 297 | self.lint(doc_uri)
|
296 | 298 |
|
297 |
| - def m_workspace__did_change_watched_files(self, **_kwargs): |
298 |
| - # Externally changed files may result in changed diagnostics |
| 299 | + def m_workspace__did_change_watched_files(self, changes=None, **_kwargs): |
| 300 | + changed_py_files = set(d['uri'] for d in changes if d['uri'].endswith(PYTHON_FILE_EXTENSIONS)) |
| 301 | + # Only externally changed python files and lint configs may result in changed diagnostics. |
| 302 | + if not changed_py_files: |
| 303 | + return |
| 304 | + # TODO: We currently don't cache settings therefor we can just lint again. |
| 305 | + # Here would be the right point to update the settings after a change to config files. |
299 | 306 | for doc_uri in self.workspace.documents:
|
300 |
| - self.lint(doc_uri) |
| 307 | + # Changes in doc_uri are already handled by m_text_document__did_save |
| 308 | + if doc_uri not in changed_py_files: |
| 309 | + self.lint(doc_uri) |
301 | 310 |
|
302 | 311 | def m_workspace__execute_command(self, command=None, arguments=None):
|
303 | 312 | return self.execute_command(command, arguments)
|
|
0 commit comments