Skip to content

Commit 98430ee

Browse files
committed
initial like the others for now
1 parent 6e7d247 commit 98430ee

File tree

1 file changed

+11
-5
lines changed
  • packages/browser-repl/src/components

1 file changed

+11
-5
lines changed

packages/browser-repl/src/components/shell.tsx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,11 @@ interface ShellProps {
128128
initialHistory: readonly string[];
129129

130130
/**
131-
* A boolean so we can keep the isOperationInProgress state between sessions.
131+
* Initial value of the isOperationInProgress field.
132+
*
133+
* Can be used to restore the value between sessions.
132134
*/
133-
isOperationInProgress?: boolean;
135+
initialIsOperationInProgress?: boolean;
134136

135137
darkMode?: boolean;
136138

@@ -140,6 +142,7 @@ interface ShellProps {
140142
interface ShellState {
141143
output: readonly ShellOutputEntry[];
142144
history: readonly string[];
145+
isOperationInProgress: boolean;
143146
passwordPrompt: string;
144147
shellPrompt: string;
145148
}
@@ -171,7 +174,7 @@ export class _Shell extends Component<ShellProps, ShellState> {
171174
initialInput: '',
172175
initialOutput: [],
173176
initialHistory: [],
174-
isOperationInProgress: false,
177+
initialIsOperationInProgress: false,
175178
};
176179

177180
private shellInputElement: HTMLElement | null = null;
@@ -182,6 +185,7 @@ export class _Shell extends Component<ShellProps, ShellState> {
182185
readonly state: ShellState = {
183186
output: this.props.initialOutput.slice(-this.props.maxOutputLength),
184187
history: this.props.initialHistory.slice(0, this.props.maxHistoryLength),
188+
isOperationInProgress: !!this.props.initialIsOperationInProgress,
185189
passwordPrompt: '',
186190
shellPrompt: '>',
187191
};
@@ -209,6 +213,7 @@ export class _Shell extends Component<ShellProps, ShellState> {
209213
let outputLine: ShellOutputEntry;
210214

211215
try {
216+
this.setState({ isOperationInProgress: true });
212217
this.props.onOperationStarted();
213218

214219
this.props.runtime.setEvaluationListener(this);
@@ -225,6 +230,7 @@ export class _Shell extends Component<ShellProps, ShellState> {
225230
};
226231
} finally {
227232
await this.updateShellPrompt();
233+
this.setState({ isOperationInProgress: false });
228234
this.props.onOperationEnd();
229235
}
230236

@@ -405,7 +411,7 @@ export class _Shell extends Component<ShellProps, ShellState> {
405411

406412
private onSigInt = (): Promise<boolean> => {
407413
if (
408-
this.props.isOperationInProgress &&
414+
this.state.isOperationInProgress &&
409415
(this.props.runtime as WorkerRuntime).interrupt
410416
) {
411417
return (this.props.runtime as WorkerRuntime).interrupt();
@@ -434,7 +440,7 @@ export class _Shell extends Component<ShellProps, ShellState> {
434440
history={this.state.history}
435441
onClearCommand={this.onClearCommand}
436442
onInput={this.onInput}
437-
operationInProgress={this.props.isOperationInProgress}
443+
operationInProgress={this.state.isOperationInProgress}
438444
editorRef={this.setEditor}
439445
onSigInt={this.onSigInt}
440446
/>

0 commit comments

Comments
 (0)