File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,8 @@ export function activate(
26
26
context : vscode . ExtensionContext ,
27
27
selector : vscode . DocumentSelector ,
28
28
) {
29
+ const documentUpdateVersions = new WeakMap < vscode . TextDocument , number > ( ) ;
30
+
29
31
let timeout : ReturnType < typeof setTimeout > | undefined ;
30
32
31
33
for ( const editor of vscode . window . visibleTextEditors ) {
@@ -42,11 +44,23 @@ export function activate(
42
44
const editor = vscode . window . activeTextEditor ;
43
45
if ( editor ) {
44
46
clearTimeout ( timeout ) ;
45
- timeout = setTimeout ( ( ) => updateDecorations ( editor ) , 250 ) ;
47
+ timeout = setTimeout (
48
+ ( ) => updateDecorations ( editor ) ,
49
+ getUpdateInterval ( editor . document ) ,
50
+ ) ;
46
51
}
47
52
} ) ,
48
53
) ;
49
54
55
+ function getUpdateInterval ( document : vscode . TextDocument ) {
56
+ const prevVersion = documentUpdateVersions . get ( document ) ;
57
+ if ( prevVersion !== document . version ) {
58
+ documentUpdateVersions . set ( document , document . version ) ;
59
+ return 250 ;
60
+ }
61
+ return 100 ;
62
+ }
63
+
50
64
async function updateDecorations ( editor : vscode . TextEditor ) {
51
65
const { document } = editor ;
52
66
if ( document . uri . scheme !== 'file' ) {
You can’t perform that action at this time.
0 commit comments