@@ -866,7 +866,7 @@ export class Dispatcher {
866866 }
867867 break
868868
869- case 'open-repository-from-path' :
869+ case 'open-repository-from-path' : {
870870 const state = this . appStore . getState ( )
871871 const repositories = state . repositories
872872 const existingRepository = repositories . find ( r => {
@@ -888,6 +888,40 @@ export class Dispatcher {
888888 } )
889889 }
890890 break
891+ }
892+
893+ case 'open-sketch-file' : {
894+ const state = this . appStore . getState ( )
895+ const repositories = state . repositories
896+ const existingRepository = repositories . find ( r => {
897+ if ( __WIN32__ ) {
898+ // Windows is guaranteed to be case-insensitive so we can be a
899+ // bit more accepting.
900+ return Path . normalize ( action . path ) . toLowerCase ( ) . indexOf ( Path . normalize ( r . path ) . toLowerCase ( ) ) === 0
901+ } else {
902+ return Path . normalize ( action . path ) . indexOf ( Path . normalize ( r . path ) ) === 0
903+ }
904+ } )
905+
906+ if ( existingRepository ) {
907+ this . selectRepository ( existingRepository )
908+ if ( existingRepository instanceof Repository ) {
909+ const repositoryState = this . appStore . getRepositoryState ( existingRepository )
910+ const existingFile = repositoryState . kactus . files . find ( f => {
911+ return Path . normalize ( f . path + '.sketch' ) === Path . normalize ( action . path )
912+ } )
913+ if ( existingFile ) {
914+ this . changeSketchFileSelection ( existingRepository , existingFile )
915+ }
916+ }
917+ } else {
918+ return this . showPopup ( {
919+ type : PopupType . AddRepository ,
920+ path : Path . dirname ( action . path ) ,
921+ } )
922+ }
923+ break
924+ }
891925
892926 default :
893927 const unknownAction : IUnknownAction = action
0 commit comments