@@ -6,7 +6,8 @@ import * as fs from 'fs';
66import * as path from 'path' ;
77import { readFile } from 'fs/promises' ;
88import { WebSocketConstants } from './WebSocketConstants' ;
9- import { buildFolderHierarchy } from './utilites' ;
9+ import { Constants } from './Constants' ;
10+ import { buildFolderHierarchy , debounce } from './utilites' ;
1011//import { MessageProcessor } from './MessageProcessor';
1112import { FollowAndAuthorRulesProcessor } from './FollowAndAuthorRulesProcessor' ;
1213import { MiningRulesProcessor } from './MiningRulesProcessor' ;
@@ -23,6 +24,8 @@ export class FileChangeManager {
2324 private constructor ( projectPath :string , ws :WebSocket ) {
2425 this . projectPath = projectPath ;
2526 this . ws = ws ;
27+ //second argument to the debounce function sets the delay timer
28+ this . debouncedHandleChangeTextDocument = debounce ( this . handleChangeTextDocument . bind ( this ) , Constants . DEBOUNCER_DELAY ) ;
2629 this . watchWorkspaceChanges ( ) ;
2730 if ( vscode . workspace . workspaceFolders ) {
2831 //const projectPath = vscode.workspace.workspaceFolders[0].uri.fsPath;
@@ -109,13 +112,14 @@ export class FileChangeManager {
109112 return FileChangeManager . instance ;
110113 }
111114
115+ private debouncedHandleChangeTextDocument : ( event : vscode . TextDocumentChangeEvent ) => void ;
112116
113117
114118 private watchWorkspaceChanges ( ) {
115119
116120 this . handleActiveTextEditorChange ( ) ;
117121
118- vscode . workspace . onDidChangeTextDocument ( this . handleChangeTextDocument . bind ( this ) ) ;
122+ vscode . workspace . onDidChangeTextDocument ( this . debouncedHandleChangeTextDocument ) ;
119123 vscode . workspace . onDidCreateFiles ( this . handleCreateFile . bind ( this ) ) ;
120124 vscode . workspace . onDidDeleteFiles ( this . handleDeleteFile . bind ( this ) ) ;
121125 vscode . workspace . onDidRenameFiles ( this . handleRenameFile . bind ( this ) ) ;
0 commit comments