@@ -182,31 +182,37 @@ parentPort.onMessage('previewDiff', previewDiff)
182182parentPort . onMessage ( 'dismissDiff' , dismissDiff )
183183parentPort . onMessage ( 'search' , refreshDiff )
184184parentPort . onMessage ( 'commitChange' , onCommitChange )
185- parentPort . onMessage (
186- 'applyEdit' ,
187- async function onApplyEdit ( payload : ChildToParent [ 'applyEdit' ] ) {
188- const workspaceEdit = new WorkspaceEdit ( )
185+ parentPort . onMessage ( 'applyEdit' , onApplyEdit )
189186
190- for ( const { filePath, replacements } of payload ) {
191- const documentUri = workspaceUriFromFilePath ( filePath ) !
187+ async function onApplyEdit ( payload : ChildToParent [ 'applyEdit' ] ) {
188+ const confirmed = await window . showInformationMessage (
189+ 'Replace all occurrences across all files?' ,
190+ { modal : true } ,
191+ 'Replace' ,
192+ )
193+ if ( confirmed !== 'Replace' ) {
194+ return
195+ }
196+ for ( const { filePath, replacements } of payload ) {
197+ const workspaceEdit = new WorkspaceEdit ( )
198+ const documentUri = workspaceUriFromFilePath ( filePath ) !
192199
193- for ( const { range, text } of replacements ) {
194- workspaceEdit . replace (
195- documentUri ,
196- new Range (
197- range . start . line ,
198- range . start . column ,
199- range . end . line ,
200- range . end . column ,
201- ) ,
202- text ,
203- )
204- }
200+ for ( const { range, text } of replacements ) {
201+ workspaceEdit . replace (
202+ documentUri ,
203+ new Range (
204+ range . start . line ,
205+ range . start . column ,
206+ range . end . line ,
207+ range . end . column ,
208+ ) ,
209+ text ,
210+ )
205211 }
206-
207212 await workspace . applyEdit ( workspaceEdit )
208- } ,
209- )
213+ await workspace . save ( documentUri )
214+ }
215+ }
210216
211217async function onCommitChange ( payload : ChildToParent [ 'commitChange' ] ) {
212218 const { filePath, inputValue, rewrite } = payload
0 commit comments