@@ -60,6 +60,7 @@ import {
6060 editorDidOpenFile ,
6161 editorGetValueRequest ,
6262 editorGetValueResponse ,
63+ editorGoto ,
6364 editorOpenFile ,
6465} from './actions' ;
6566import { EditorError } from './error' ;
@@ -265,6 +266,34 @@ function* handleEditorActivateFile(
265266 }
266267}
267268
269+ function * handleEditorGoto (
270+ editor : monaco . editor . ICodeEditor ,
271+ action : ReturnType < typeof editorGoto > ,
272+ ) : Generator {
273+ yield * put ( editorActivateFile ( action . uuid ) ) ;
274+
275+ const { didActivate, didFailToActivate } = yield * race ( {
276+ didActivate : take ( editorDidActivateFile . when ( ( a ) => a . uuid === action . uuid ) ) ,
277+ didFailToActivate : take (
278+ editorDidFailToActivateFile . when ( ( a ) => a . uuid === action . uuid ) ,
279+ ) ,
280+ } ) ;
281+
282+ if ( didFailToActivate ) {
283+ return ;
284+ }
285+
286+ defined ( didActivate ) ;
287+
288+ editor . revealLineInCenterIfOutsideViewport ( action . line ) ;
289+ editor . setSelection ( {
290+ startColumn : 1 ,
291+ startLineNumber : action . line ,
292+ endColumn : Infinity ,
293+ endLineNumber : action . line ,
294+ } ) ;
295+ }
296+
268297function * handleEditorDidCloseFile (
269298 activeFileHistory : ActiveFileHistoryManager ,
270299 action : ReturnType < typeof editorDidCloseFile > ,
@@ -356,6 +385,7 @@ function* handleDidCreateEditor(editor: monaco.editor.ICodeEditor): Generator {
356385 openFiles ,
357386 activeFileHistory ,
358387 ) ;
388+ yield * takeEvery ( editorGoto , handleEditorGoto , editor ) ;
359389 yield * takeEvery ( editorDidCloseFile , handleEditorDidCloseFile , activeFileHistory ) ;
360390 yield * fork ( monitorViewState , editor ) ;
361391
0 commit comments