@@ -130,7 +130,8 @@ export const setup_workspace_listeners = (
130130 is_new = true
131131 } else {
132132 try {
133- original_content = fs . readFileSync ( doc . uri . fsPath , 'utf8' )
133+ const contentBytes = await vscode . workspace . fs . readFile ( doc . uri )
134+ original_content = Buffer . from ( contentBytes ) . toString ( 'utf8' )
134135 } catch ( e ) {
135136 is_new = true // File on disk does not exist, but buffer does.
136137 }
@@ -280,7 +281,7 @@ export const setup_workspace_listeners = (
280281 }
281282 } )
282283
283- const file_created_listener = vscode . workspace . onDidCreateFiles ( ( event ) => {
284+ const file_created_listener = vscode . workspace . onDidCreateFiles ( async ( event ) => {
284285 for ( const uri of event . files ) {
285286 if ( uri . scheme !== 'file' ) continue
286287
@@ -295,7 +296,8 @@ export const setup_workspace_listeners = (
295296 // Read the content of the newly created file (may be empty)
296297 let new_content = ''
297298 try {
298- new_content = fs . readFileSync ( uri . fsPath , 'utf8' )
299+ const doc = await vscode . workspace . openTextDocument ( uri )
300+ new_content = doc . getText ( )
299301 } catch ( e ) {
300302 new_content = ''
301303 }
@@ -361,7 +363,7 @@ export const setup_workspace_listeners = (
361363 }
362364 } )
363365
364- const file_renamed_listener = vscode . workspace . onDidRenameFiles ( ( event ) => {
366+ const file_renamed_listener = vscode . workspace . onDidRenameFiles ( async ( event ) => {
365367 for ( const { oldUri, newUri } of event . files ) {
366368 if ( oldUri . scheme !== 'file' || newUri . scheme !== 'file' ) continue
367369
@@ -396,7 +398,8 @@ export const setup_workspace_listeners = (
396398 // Read new file content (post-rename)
397399 let new_content = ''
398400 try {
399- new_content = fs . readFileSync ( newUri . fsPath , 'utf8' )
401+ const doc = await vscode . workspace . openTextDocument ( newUri )
402+ new_content = doc . getText ( )
400403 } catch {
401404 new_content = ''
402405 }
0 commit comments