@@ -434,6 +434,43 @@ console.log('test');]]></replace></change>`
434434 expect ( isNearCursor ) . toBe ( true )
435435 } )
436436
437+ it ( "should filter out changes to non-active documents" , async ( ) => {
438+ const initialContent = `console.log('test');`
439+ const { mockDocument } = await setupTestDocument ( "inactive.js" , initialContent )
440+
441+ // Create a different document for the active editor
442+ const activeContent = `console.log('active');`
443+ const activeUri = vscode . Uri . parse ( "file://active.js" )
444+ mockWorkspace . addDocument ( activeUri , activeContent )
445+ const activeDocument = await mockWorkspace . openTextDocument ( activeUri )
446+
447+ // Mock active editor with a different document
448+ ; ( vscode . window as any ) . activeTextEditor = {
449+ document : activeDocument ,
450+ selection : {
451+ active : new vscode . Position ( 0 , 10 ) ,
452+ } ,
453+ }
454+
455+ // Simulate change to the non-active document
456+ const event = {
457+ document : mockDocument ,
458+ contentChanges : [
459+ {
460+ range : new vscode . Range ( new vscode . Position ( 0 , 10 ) , new vscode . Position ( 0 , 10 ) ) ,
461+ rangeLength : 0 ,
462+ text : "a" ,
463+ } ,
464+ ] ,
465+ reason : undefined ,
466+ }
467+
468+ // Should be filtered out - document doesn't match active editor
469+ const editor = ( vscode . window as any ) . activeTextEditor
470+ const shouldProcess = editor && editor . document === event . document
471+ expect ( shouldProcess ) . toBe ( false )
472+ } )
473+
437474 it ( "should allow small paste operations near cursor" , async ( ) => {
438475 const initialContent = `console.log('test');`
439476 const { mockDocument } = await setupTestDocument ( "paste.js" , initialContent )
0 commit comments