@@ -285,82 +285,6 @@ export function registerCommands(
285285 ) ,
286286 ) ;
287287
288- context . subscriptions . push (
289- vscode . commands . registerCommand ( 'review.suggestDiff' , async e => {
290- const hasShownMessageKey = 'githubPullRequest.suggestDiffMessage' ;
291- const hasShownMessage = context . globalState . get ( hasShownMessageKey , false ) ;
292- if ( ! hasShownMessage ) {
293- await context . globalState . update ( hasShownMessageKey , true ) ;
294- const documentation = vscode . l10n . t ( 'Open documentation' ) ;
295- const result = await vscode . window . showInformationMessage ( vscode . l10n . t ( 'You can now make suggestions from review comments, just like on GitHub.com. See the documentation for more details.' ) ,
296- { modal : true } , documentation ) ;
297- if ( result === documentation ) {
298- return vscode . env . openExternal ( vscode . Uri . parse ( 'https://github.com/microsoft/vscode-pull-request-github/blob/main/documentation/suggestAChange.md' ) ) ;
299- }
300- }
301- try {
302- const folderManager = await chooseItem < FolderRepositoryManager > (
303- reposManager . folderManagers ,
304- itemValue => pathLib . basename ( itemValue . repository . rootUri . fsPath ) ,
305- ) ;
306- if ( ! folderManager || ! folderManager . activePullRequest ) {
307- return ;
308- }
309-
310- const { indexChanges, workingTreeChanges } = folderManager . repository . state ;
311-
312- if ( ! indexChanges . length ) {
313- if ( workingTreeChanges . length ) {
314- const yes = vscode . l10n . t ( 'Yes' ) ;
315- const stageAll = await vscode . window . showWarningMessage (
316- vscode . l10n . t ( 'There are no staged changes to suggest.\n\nWould you like to automatically stage all your of changes and suggest them?' ) ,
317- { modal : true } ,
318- yes ,
319- ) ;
320- if ( stageAll === yes ) {
321- await vscode . commands . executeCommand ( 'git.stageAll' ) ;
322- } else {
323- return ;
324- }
325- } else {
326- vscode . window . showInformationMessage ( vscode . l10n . t ( 'There are no changes to suggest.' ) ) ;
327- return ;
328- }
329- }
330-
331- const diff = await folderManager . repository . diff ( true ) ;
332-
333- let suggestEditMessage = vscode . l10n . t ( 'Suggested edit:\n' ) ;
334- if ( e && e . inputBox && e . inputBox . value ) {
335- suggestEditMessage = `${ e . inputBox . value } \n` ;
336- e . inputBox . value = '' ;
337- }
338-
339- const suggestEditText = `${ suggestEditMessage } \`\`\`diff\n${ diff } \n\`\`\`` ;
340- await folderManager . activePullRequest . createIssueComment ( suggestEditText ) ;
341-
342- // Reset HEAD and then apply reverse diff
343- await vscode . commands . executeCommand ( 'git.unstageAll' ) ;
344-
345- const tempFilePath = pathLib . join (
346- folderManager . repository . rootUri . fsPath ,
347- '.git' ,
348- `${ folderManager . activePullRequest . number } .diff` ,
349- ) ;
350- const encoder = new TextEncoder ( ) ;
351- const tempUri = vscode . Uri . file ( tempFilePath ) ;
352-
353- await vscode . workspace . fs . writeFile ( tempUri , encoder . encode ( diff ) ) ;
354- await folderManager . repository . apply ( tempFilePath , true ) ;
355- await vscode . workspace . fs . delete ( tempUri ) ;
356- } catch ( err ) {
357- const moreError = `${ err } ${ err . stderr ? `\n${ err . stderr } ` : '' } ` ;
358- Logger . error ( `Applying patch failed: ${ moreError } ` , logId ) ;
359- vscode . window . showErrorMessage ( vscode . l10n . t ( 'Applying patch failed: {0}' , formatError ( err ) ) ) ;
360- }
361- } ) ,
362- ) ;
363-
364288 context . subscriptions . push (
365289 vscode . commands . registerCommand ( 'pr.openFileOnGitHub' , async ( e : GitFileChangeNode | RemoteFileChangeNode ) => {
366290 if ( e instanceof RemoteFileChangeNode ) {
0 commit comments