Skip to content

Commit cc6fab2

Browse files
author
zhuangyao
committed
fix: fire timer for cpplint to avoid long time freeze
1 parent 3b7b4d1 commit cc6fab2

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ All notable changes to the "cpplint" extension will be documented in this file.
33

44
Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file.
55

6+
## [0.1.2]
7+
### Change
8+
9+
- fix cpplint in 500ms when setting and save happened to avoid large file freeze
10+
611
## [0.1.0]
712
### Change
813

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "cpplint",
33
"displayName": "cpplint",
44
"description": "code style check tool extension for cpplint",
5-
"version": "0.1.1",
5+
"version": "0.1.2",
66
"publisher": "mine",
77
"repository": {
88
"type": "Git",

src/extension.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,16 @@ function startLint() {
101101
timer = global.setTimeout(doLint, 1.5 * 1000);
102102
}
103103

104+
function startLint2() {
105+
timer = global.setTimeout(doLint, 500);
106+
}
107+
104108
function loadConfigure() {
105109
ConfigManager.getInstance().initialize();
106110
if (ConfigManager.getInstance().isSingleMode()) {
107-
doLint();
108-
vscode.window.onDidChangeActiveTextEditor((() => doLint()).bind(this));
109-
vscode.workspace.onDidSaveTextDocument((() => doLint()).bind(this));
111+
startLint2();
112+
vscode.window.onDidChangeActiveTextEditor((() => startLint2()).bind(this));
113+
vscode.workspace.onDidSaveTextDocument((() => startLint2()).bind(this));
110114
} else {
111115
// start timer to do workspace lint
112116
startLint();

0 commit comments

Comments
 (0)