@@ -1018,13 +1018,9 @@ define(function (require, exports) {
10181018
10191019 const OPEN_ALL_CONFIRM_THRESHOLD = 50 ;
10201020
1021- function _openChangedFiles ( files ) {
1022- const currentGitRoot = Preferences . get ( "currentGitRoot" ) ;
1021+ function _openChangedFiles ( fileList ) {
10231022 // addListToWorkingSet ignores files already present in any pane, so this is safe
10241023 // to run repeatedly or with some of the files already open
1025- const fileList = files . map ( function ( file ) {
1026- return FileSystem . getFileForPath ( currentGitRoot + file . file ) ;
1027- } ) ;
10281024 MainViewManager . addListToWorkingSet ( MainViewManager . ACTIVE_PANE , fileList ) ;
10291025
10301026 // if the user is already viewing one of the changed files, we don't switch the file then...
@@ -1059,18 +1055,29 @@ define(function (require, exports) {
10591055 return ;
10601056 }
10611057
1062- if ( files . length > OPEN_ALL_CONFIRM_THRESHOLD ) {
1058+ const currentGitRoot = Preferences . get ( "currentGitRoot" ) ;
1059+ const fileList = files . map ( function ( file ) {
1060+ return FileSystem . getFileForPath ( currentGitRoot + file . file ) ;
1061+ } ) ;
1062+
1063+ // count only the files the command would actually add, so re-running it
1064+ // when most of them are already open doesn't ask for confirmation again
1065+ const newFileCount = _ . filter ( fileList , function ( file ) {
1066+ return MainViewManager . findInAllWorkingSets ( file . fullPath ) . length === 0 ;
1067+ } ) . length ;
1068+
1069+ if ( newFileCount > OPEN_ALL_CONFIRM_THRESHOLD ) {
10631070 return Utils . askQuestion ( Strings . CMD_OPEN_CHANGED_FILES ,
1064- StringUtils . format ( Strings . OPEN_CHANGED_FILES_CONFIRM , files . length ) ,
1071+ StringUtils . format ( Strings . OPEN_CHANGED_FILES_CONFIRM , newFileCount ) ,
10651072 { booleanResponse : true } )
10661073 . then ( function ( response ) {
10671074 if ( response === true ) {
1068- _openChangedFiles ( files ) ;
1075+ _openChangedFiles ( fileList ) ;
10691076 }
10701077 } ) ;
10711078 }
10721079
1073- _openChangedFiles ( files ) ;
1080+ _openChangedFiles ( fileList ) ;
10741081 } ) . catch ( function ( err ) {
10751082 ErrorHandler . showError ( err , Strings . ERROR_OPENING_CHANGED_FILES ) ;
10761083 } ) ;
0 commit comments