@@ -162,9 +162,6 @@ export const handle_fast_replace = async (
162162 Buffer . from ( new_content , 'utf8' )
163163 )
164164
165- const document = await vscode . workspace . openTextDocument ( safe_path )
166- await vscode . window . showTextDocument ( document , { preview : false } )
167-
168165 original_states . push ( {
169166 file_path : file . file_path ,
170167 content : rename_source_content ,
@@ -201,23 +198,24 @@ export const handle_fast_replace = async (
201198 content : original_content ,
202199 workspace_name : file . workspace_name
203200 } )
204- const editor = await vscode . window . showTextDocument ( document )
205201 let final_content = file . content
206202 if (
207203 original_content . endsWith ( '\n' ) &&
208204 ! final_content . endsWith ( '\n' )
209205 ) {
210206 final_content += '\n'
211207 }
212- await editor . edit ( ( edit ) => {
213- edit . replace (
214- new vscode . Range (
215- document . positionAt ( 0 ) ,
216- document . positionAt ( document . getText ( ) . length )
217- ) ,
218- final_content
219- )
220- } )
208+
209+ const edit = new vscode . WorkspaceEdit ( )
210+ edit . replace (
211+ document . uri ,
212+ new vscode . Range (
213+ document . positionAt ( 0 ) ,
214+ document . positionAt ( document . getText ( ) . length )
215+ ) ,
216+ final_content
217+ )
218+ await vscode . workspace . applyEdit ( edit )
221219
222220 await document . save ( )
223221 Logger . info ( {
@@ -263,8 +261,6 @@ export const handle_fast_replace = async (
263261 message : 'New file created' ,
264262 data : safe_path
265263 } )
266- const document = await vscode . workspace . openTextDocument ( safe_path )
267- await vscode . window . showTextDocument ( document , { preview : false } )
268264 } catch ( error ) {
269265 Logger . error ( {
270266 function_name : 'handle_fast_replace' ,
0 commit comments