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(
2626 context : vscode . ExtensionContext ,
2727 selector : vscode . DocumentSelector ,
2828) {
29+ const documentUpdateVersions = new WeakMap < vscode . TextDocument , number > ( ) ;
30+
2931 let timeout : ReturnType < typeof setTimeout > | undefined ;
3032
3133 for ( const editor of vscode . window . visibleTextEditors ) {
@@ -42,11 +44,23 @@ export function activate(
4244 const editor = vscode . window . activeTextEditor ;
4345 if ( editor ) {
4446 clearTimeout ( timeout ) ;
45- timeout = setTimeout ( ( ) => updateDecorations ( editor ) , 250 ) ;
47+ timeout = setTimeout (
48+ ( ) => updateDecorations ( editor ) ,
49+ getUpdateInterval ( editor . document ) ,
50+ ) ;
4651 }
4752 } ) ,
4853 ) ;
4954
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+
5064 async function updateDecorations ( editor : vscode . TextEditor ) {
5165 const { document } = editor ;
5266 if ( document . uri . scheme !== 'file' ) {
You can’t perform that action at this time.
0 commit comments