Skip to content

Commit

Permalink
Fix prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
james-pre committed Oct 13, 2024
1 parent 00153b2 commit dd87a5e
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/shell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,16 +108,18 @@ function handleData($: ShellContext, data: string) {
/**
* Creates a new shell using the provided options
*/
export function createShell({ terminal, prompt = '', onLine = () => {} }: ShellOptions): ShellContext {
export function createShell(options: ShellOptions): ShellContext {
const context: ShellContext = {
terminal,
prompt,
onLine,
terminal: options.terminal,
get prompt() {
return options.prompt ?? '';
},
onLine: options.onLine ?? (() => {}),
input: '',
index: -1,
currentInput: '',
inputs: [],
};
terminal.onData(data => handleData(context, data));
options.terminal.onData(data => handleData(context, data));
return context;
}

0 comments on commit dd87a5e

Please sign in to comment.