Skip to content

Commit

Permalink
fix(packages/core): bottomInput clients that use splits do not proper…
Browse files Browse the repository at this point in the history
…ly preserve command history

part of kubernetes-sigs#7522
  • Loading branch information
starpit authored and k8s-ci-robot committed Jun 4, 2021
1 parent bf6d6c1 commit f3df6ff
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
3 changes: 3 additions & 0 deletions packages/core/src/models/execOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ export interface ExecOptions {
/** force execution in a given tab? */
tab?: Tab

/** Tab id to use for recording history */
tabUUIDForHistory?: string

/** execution UUID */
execUUID?: string

Expand Down
11 changes: 9 additions & 2 deletions packages/core/src/repl/exec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ class InProcessExecutor implements Executor {
if (!execOptions || !execOptions.noHistory) {
if (!execOptions || !execOptions.quiet) {
if (!execOptions || execOptions.type !== ExecType.Nested) {
const historyModel = getHistoryForTab(tab.uuid)
const tabUUIDForHistory = execOptions.tabUUIDForHistory || tab.uuid
const historyModel = getHistoryForTab(tabUUIDForHistory)
return (execOptions.history = historyModel.add({
raw: command
}))
Expand Down Expand Up @@ -587,8 +588,14 @@ export const exec = (commandUntrimmed: string, execOptions = emptyExecOptions())
*/
export const doEval = (_tab: Tab, block: Block, command: string, execUUID?: string) => {
const tab = splitFor(_tab)
const tabUUIDForHistory = _tab.uuid
const defaultExecOptions = new DefaultExecOptionsForTab(tab, block, execUUID)
const execOptions = !execUUID ? defaultExecOptions : Object.assign(defaultExecOptions, { type: ExecType.Rerun })
const execOptions: ExecOptions = Object.assign(
{
tabUUIDForHistory
},
!execUUID ? defaultExecOptions : Object.assign(defaultExecOptions, { type: ExecType.Rerun })
)

return exec(command, execOptions)
}
Expand Down

0 comments on commit f3df6ff

Please sign in to comment.