@@ -45,23 +45,23 @@ function createFolderAtPath (path) {
4545}
4646
4747
48- export function openFile ( obj ) {
48+ export function openFile ( obj , callback ) {
4949 if ( ! obj . path ) return
5050 // 做一些encoding的调度
5151 if ( FileState . initData . get ( '_init' ) ) {
5252 when ( ( ) => ! FileState . initData . get ( '_init' ) , ( ) => {
5353 const { encoding } = FileState . initData . get ( obj . path ) || { }
54- openFileWithEncoding ( { ...obj , encoding } )
54+ openFileWithEncoding ( { ...obj , encoding, callback } )
5555 FileState . initData . set ( obj . path , { } )
5656 } )
5757 } else {
5858 const { encoding } = FileState . initData . get ( obj . path ) || { }
59- openFileWithEncoding ( { ...obj , encoding } )
59+ openFileWithEncoding ( { ...obj , encoding, callback } )
6060 FileState . initData . set ( obj . path , { } )
6161 }
6262}
6363
64- export function openFileWithEncoding ( { path, editor = { } , others = { } , allGroup = false , encoding } ) {
64+ export function openFileWithEncoding ( { path, editor = { } , others = { } , allGroup = false , encoding, callback } ) {
6565 const { encoding : currentEncoding } = FileStore . get ( path ) || { }
6666 return api . readFile ( path , encoding || currentEncoding )
6767 . then ( ( data ) => {
@@ -79,6 +79,7 @@ export function openFileWithEncoding ({ path, editor = {}, others = {}, allGroup
7979 existingTab . editor . gitBlame = editor . gitBlame
8080 }
8181 existingTab . activate ( )
82+ if ( callback ) callback ( )
8283 } else {
8384 TabStore . createTab ( {
8485 icon : icons . getClassWithColor ( path . split ( '/' ) . pop ( ) ) || 'fa fa-file-text-o' ,
@@ -88,6 +89,9 @@ export function openFileWithEncoding ({ path, editor = {}, others = {}, allGroup
8889 } ,
8990 ...others
9091 } )
92+ if ( callback ) {
93+ callback ( )
94+ }
9195 }
9296 } )
9397}
@@ -162,8 +166,10 @@ const fileCommands = {
162166 } ,
163167 'file:highlight_line' : ( c ) => {
164168 console . log ( 'file:highlight_line' , c )
165- // const { path, lineNumber } = c.data
166- emitter . emit ( FILE_HIGHLIGHT , c . data )
169+ const { path, lineNumber } = c . data
170+ openFile ( { path, allGroup : true } , ( ) => {
171+ emitter . emit ( FILE_HIGHLIGHT , c . data )
172+ } )
167173 } ,
168174 'file:new_file' : ( c ) => {
169175 const node = c . context
0 commit comments