@@ -15,6 +15,7 @@ define(function (require, exports) {
1515 Menus = brackets . getModule ( "command/Menus" ) ,
1616 Mustache = brackets . getModule ( "thirdparty/mustache/mustache" ) ,
1717 FindInFiles = brackets . getModule ( "search/FindInFiles" ) ,
18+ MainViewManager = brackets . getModule ( "view/MainViewManager" ) ,
1819 WorkspaceManager = brackets . getModule ( "view/WorkspaceManager" ) ,
1920 ProjectManager = brackets . getModule ( "project/ProjectManager" ) ,
2021 StringUtils = brackets . getModule ( "utils/StringUtils" ) ,
@@ -1007,6 +1008,49 @@ define(function (require, exports) {
10071008 } ) ;
10081009 }
10091010
1011+ function openAllChangedFiles ( ) {
1012+ return Git . status ( ) . then ( function ( files ) {
1013+ files = _ . filter ( files , function ( file ) {
1014+ if ( ! shouldShow ( file ) ) {
1015+ return false ;
1016+ }
1017+ // deleted files no longer exist on disk, so there is nothing to open
1018+ if ( file . status . indexOf ( Git . FILE_STATUS . DELETED ) !== - 1 ) {
1019+ return false ;
1020+ }
1021+ // respect the "show untracked files" panel toggle
1022+ if ( ! showingUntracked && file . status . indexOf ( Git . FILE_STATUS . UNTRACKED ) !== - 1 ) {
1023+ return false ;
1024+ }
1025+ return true ;
1026+ } ) ;
1027+
1028+ if ( files . length === 0 ) {
1029+ return ;
1030+ }
1031+
1032+ const currentGitRoot = Preferences . get ( "currentGitRoot" ) ;
1033+ // addListToWorkingSet ignores files already present in any pane, so this is safe
1034+ // to run repeatedly or with some of the files already open
1035+ const fileList = files . map ( function ( file ) {
1036+ return FileSystem . getFileForPath ( currentGitRoot + file . file ) ;
1037+ } ) ;
1038+ MainViewManager . addListToWorkingSet ( MainViewManager . ACTIVE_PANE , fileList ) ;
1039+
1040+ // if the user is already viewing one of the changed files, we don't switch the file then...
1041+ // if user is viewing a un-changed file, then we switch to the first changed file
1042+ const currentPath = MainViewManager . getCurrentlyViewedPath ( MainViewManager . ACTIVE_PANE ) ;
1043+ const viewingChangedFile = _ . any ( fileList , function ( file ) {
1044+ return file . fullPath === currentPath ;
1045+ } ) ;
1046+ if ( ! viewingChangedFile ) {
1047+ CommandManager . execute ( Commands . FILE_OPEN , { fullPath : fileList [ 0 ] . fullPath } ) ;
1048+ }
1049+ } ) . catch ( function ( err ) {
1050+ ErrorHandler . showError ( err , Strings . ERROR_OPENING_CHANGED_FILES ) ;
1051+ } ) ;
1052+ }
1053+
10101054 var lastCheckOneClicked = null ;
10111055
10121056 function attachDefaultTableHandlers ( ) {
@@ -1345,6 +1389,8 @@ define(function (require, exports) {
13451389 CommandManager . register ( Strings . VIEW_AUTHORS_SELECTION , Constants . CMD_GIT_AUTHORS_OF_SELECTION , handleAuthorsSelection ) ;
13461390 CommandManager . register ( Strings . VIEW_AUTHORS_FILE , Constants . CMD_GIT_AUTHORS_OF_FILE , handleAuthorsFile ) ;
13471391 CommandManager . register ( Strings . HIDE_UNTRACKED , Constants . CMD_GIT_TOGGLE_UNTRACKED , handleToggleUntracked ) ;
1392+ CommandManager . register ( Strings . CMD_OPEN_CHANGED_FILES ,
1393+ Constants . CMD_GIT_OPEN_CHANGED_FILES , openAllChangedFiles ) ;
13481394 CommandManager . register ( Strings . GIT_INIT , Constants . CMD_GIT_INIT , EventEmitter . getEmitter ( Events . HANDLE_GIT_INIT ) ) ;
13491395 CommandManager . register ( Strings . GIT_CLONE , Constants . CMD_GIT_CLONE , EventEmitter . getEmitter ( Events . HANDLE_GIT_CLONE ) ) ;
13501396 CommandManager . register ( Strings . GIT_SHOW_HISTORY , Constants . CMD_GIT_HISTORY_GLOBAL , ( ) => {
0 commit comments