);
}
if (model.loading.get()) {
let height = this.model.savedHeight;
return (
-
- ...
+
+ loading content
);
}
@@ -262,7 +269,6 @@ class SimpleBlobRenderer extends React.Component<
if (Comp == null) {
(no component found in plugin)
;
}
- let simpleModel = model as SimpleBlobRendererModel;
let { festate, cmdstr, exitcode } = this.props.initParams.rawCmd;
return (
@@ -270,15 +276,16 @@ class SimpleBlobRenderer extends React.Component<
cwd={festate.cwd}
cmdstr={cmdstr}
exitcode={exitcode}
- data={simpleModel.dataBlob}
- readOnly={simpleModel.readOnly}
- notFound={simpleModel.notFound}
- lineState={simpleModel.lineState}
- context={simpleModel.context}
- opts={simpleModel.opts}
- savedHeight={simpleModel.savedHeight}
+ data={model.dataBlob}
+ readOnly={model.readOnly}
+ notFound={model.notFound}
+ lineState={model.lineState}
+ context={model.context}
+ opts={model.opts}
+ savedHeight={model.savedHeight}
scrollToBringIntoViewport={this.props.scrollToBringIntoViewport}
isSelected={this.props.isSelected}
+ shouldFocus={this.props.shouldFocus}
/>
);
diff --git a/src/types.ts b/src/types.ts
index 3571ff306..dd914848c 100644
--- a/src/types.ts
+++ b/src/types.ts
@@ -413,6 +413,7 @@ type SimpleBlobRendererComponent = React.ComponentType<{
readOnly?: boolean;
notFound?: boolean;
isSelected?: boolean;
+ shouldFocus?: boolean;
cmdstr?: string;
cwd?: string;
exitcode?: number;
diff --git a/src/view/code.tsx b/src/view/code.tsx
index 6ee57f642..a00d381f8 100644
--- a/src/view/code.tsx
+++ b/src/view/code.tsx
@@ -26,6 +26,7 @@ class SourceCodeRenderer extends React.Component<
scrollToBringIntoViewport: () => void;
lineState: LineStateType;
isSelected: boolean;
+ shouldFocus: boolean;
},
{
code: string;
@@ -70,12 +71,21 @@ class SourceCodeRenderer extends React.Component<
const code = SourceCodeRenderer.codeCache.get(this.cacheKey);
if (code) {
this.setState({ code, isClosed: this.props.lineState["prompt:closed"] });
- } else
+ } else {
this.props.data.text().then((code) => {
this.originalData = code;
this.setState({ code, isClosed: this.props.lineState["prompt:closed"] });
SourceCodeRenderer.codeCache.set(this.cacheKey, code);
});
+ }
+ }
+
+ componentDidUpdate(prevProps: any): void {
+ if (!prevProps.shouldFocus && this.props.shouldFocus) {
+ if (this.monacoEditor) {
+ this.monacoEditor.focus();
+ }
+ }
}
setInitialLanguage = (editor) => {
@@ -125,6 +135,9 @@ class SourceCodeRenderer extends React.Component<
this.doClose();
}
});
+ if (this.props.shouldFocus) {
+ this.monacoEditor.focus();
+ }
};
handleLanguageChange = (event) => {