Merge pull request #2064 from MartinFournier/feature/focus-editor-on-open

Give focus to editor when opening or changing tabs
This commit is contained in:
hydroflame
2021-12-20 10:19:14 -05:00
committed by GitHub

View File

@ -291,6 +291,8 @@ export function Root(props: IProps): React.ReactElement {
editorRef.current.revealLineInCenter(currentScript.lastPosition.lineNumber);
updateRAM(currentScript.code);
}
editorRef.current.focus();
}
function infLoop(newCode: string): void {
@ -505,6 +507,7 @@ export function Root(props: IProps): React.ReactElement {
editorRef.current.setPosition(openScripts[index].lastPosition);
editorRef.current.revealLineInCenter(openScripts[index].lastPosition.lineNumber);
updateRAM(openScripts[index].code);
editorRef.current.focus();
}
}
@ -550,6 +553,7 @@ export function Root(props: IProps): React.ReactElement {
editorRef.current.setModel(openScripts[index + indexOffset].model);
editorRef.current.setPosition(openScripts[index + indexOffset].lastPosition);
editorRef.current.revealLineInCenter(openScripts[index + indexOffset].lastPosition.lineNumber)
editorRef.current.focus();
}
} else {
// No more scripts are open