diff --git a/src/client/datascience/interactive-common/synchronization.ts b/src/client/datascience/interactive-common/synchronization.ts index 1f3b3dacb180..1907039ada87 100644 --- a/src/client/datascience/interactive-common/synchronization.ts +++ b/src/client/datascience/interactive-common/synchronization.ts @@ -7,13 +7,16 @@ import { BaseReduxActionPayload } from './types'; // Licensed under the MIT License. export enum MessageType { - other = 0, /** - * Messages must be re-broadcasted across other editors of the same file in the same session. + * Action dispatched as result of some user action. + */ + userAction = 0, + /** + * Action dispatched to re-broadcast a message across other editors of the same file in the same session. */ syncAcrossSameNotebooks = 1 << 0, /** - * Messages must be re-broadcasted across all sessions. + * Action dispatched to re-broadcast a message across other sessions (live share). */ syncWithLiveShare = 1 << 1, noIdea = 1 << 2 @@ -30,7 +33,7 @@ export type IInteractiveActionMapping = MessageMapping & MessageMapping = { - [CommonActionType.ADD_AND_FOCUS_NEW_CELL]: MessageType.other, + [CommonActionType.ADD_AND_FOCUS_NEW_CELL]: MessageType.userAction, [CommonActionType.ADD_NEW_CELL]: MessageType.syncAcrossSameNotebooks | MessageType.syncWithLiveShare, [CommonActionType.ARROW_DOWN]: MessageType.syncWithLiveShare, [CommonActionType.ARROW_UP]: MessageType.syncWithLiveShare, @@ -38,135 +41,135 @@ const messageWithMessageTypes: MessageMapping & Messa [CommonActionType.CLICK_CELL]: MessageType.syncWithLiveShare, [CommonActionType.DELETE_CELL]: MessageType.syncWithLiveShare, [CommonActionType.CODE_CREATED]: MessageType.noIdea, - [CommonActionType.COPY_CELL_CODE]: MessageType.other, - [CommonActionType.EDITOR_LOADED]: MessageType.other, + [CommonActionType.COPY_CELL_CODE]: MessageType.userAction, + [CommonActionType.EDITOR_LOADED]: MessageType.userAction, [CommonActionType.EDIT_CELL]: MessageType.syncAcrossSameNotebooks | MessageType.syncWithLiveShare, - [CommonActionType.EXECUTE_CELL_AND_ADVANCE]: MessageType.other, - [CommonActionType.EXECUTE_ABOVE]: MessageType.other, - [CommonActionType.EXECUTE_ALL_CELLS]: MessageType.other, - [CommonActionType.EXECUTE_CELL]: MessageType.other, - [CommonActionType.EXECUTE_CELL_AND_BELOW]: MessageType.other, - [CommonActionType.EXPORT]: MessageType.other, + [CommonActionType.EXECUTE_CELL_AND_ADVANCE]: MessageType.userAction, + [CommonActionType.EXECUTE_ABOVE]: MessageType.userAction, + [CommonActionType.EXECUTE_ALL_CELLS]: MessageType.userAction, + [CommonActionType.EXECUTE_CELL]: MessageType.userAction, + [CommonActionType.EXECUTE_CELL_AND_BELOW]: MessageType.userAction, + [CommonActionType.EXPORT]: MessageType.userAction, [CommonActionType.FOCUS_CELL]: MessageType.syncWithLiveShare, - [CommonActionType.GATHER_CELL]: MessageType.other, - [CommonActionType.GET_VARIABLE_DATA]: MessageType.other, + [CommonActionType.GATHER_CELL]: MessageType.userAction, + [CommonActionType.GET_VARIABLE_DATA]: MessageType.userAction, [CommonActionType.GOTO_CELL]: MessageType.syncWithLiveShare, - [CommonActionType.INSERT_ABOVE_AND_FOCUS_NEW_CELL]: MessageType.other, + [CommonActionType.INSERT_ABOVE_AND_FOCUS_NEW_CELL]: MessageType.userAction, [CommonActionType.INSERT_ABOVE]: MessageType.syncAcrossSameNotebooks | MessageType.syncWithLiveShare, - [CommonActionType.INSERT_ABOVE_FIRST_AND_FOCUS_NEW_CELL]: MessageType.other, + [CommonActionType.INSERT_ABOVE_FIRST_AND_FOCUS_NEW_CELL]: MessageType.userAction, [CommonActionType.INSERT_ABOVE_FIRST]: MessageType.syncAcrossSameNotebooks | MessageType.syncWithLiveShare, [CommonActionType.INSERT_BELOW]: MessageType.syncAcrossSameNotebooks | MessageType.syncWithLiveShare, - [CommonActionType.INSERT_BELOW_AND_FOCUS_NEW_CELL]: MessageType.other, - [CommonActionType.INTERRUPT_KERNEL]: MessageType.other, - [CommonActionType.LOADED_ALL_CELLS]: MessageType.other, - [CommonActionType.LINK_CLICK]: MessageType.other, + [CommonActionType.INSERT_BELOW_AND_FOCUS_NEW_CELL]: MessageType.userAction, + [CommonActionType.INTERRUPT_KERNEL]: MessageType.userAction, + [CommonActionType.LOADED_ALL_CELLS]: MessageType.userAction, + [CommonActionType.LINK_CLICK]: MessageType.userAction, [CommonActionType.MOVE_CELL_DOWN]: MessageType.syncAcrossSameNotebooks | MessageType.syncWithLiveShare, [CommonActionType.MOVE_CELL_UP]: MessageType.syncAcrossSameNotebooks | MessageType.syncWithLiveShare, - [CommonActionType.RESTART_KERNEL]: MessageType.other, - [CommonActionType.SAVE]: MessageType.other, + [CommonActionType.RESTART_KERNEL]: MessageType.userAction, + [CommonActionType.SAVE]: MessageType.userAction, [CommonActionType.SCROLL]: MessageType.syncWithLiveShare, [CommonActionType.SELECT_CELL]: MessageType.syncWithLiveShare, - [CommonActionType.SELECT_SERVER]: MessageType.other, - [CommonActionType.SEND_COMMAND]: MessageType.other, - [CommonActionType.SHOW_DATA_VIEWER]: MessageType.other, - [CommonActionType.SUBMIT_INPUT]: MessageType.other, + [CommonActionType.SELECT_SERVER]: MessageType.userAction, + [CommonActionType.SEND_COMMAND]: MessageType.userAction, + [CommonActionType.SHOW_DATA_VIEWER]: MessageType.userAction, + [CommonActionType.SUBMIT_INPUT]: MessageType.userAction, [CommonActionType.TOGGLE_INPUT_BLOCK]: MessageType.syncAcrossSameNotebooks | MessageType.syncWithLiveShare, [CommonActionType.TOGGLE_LINE_NUMBERS]: MessageType.syncWithLiveShare, [CommonActionType.TOGGLE_OUTPUT]: MessageType.syncWithLiveShare, [CommonActionType.TOGGLE_VARIABLE_EXPLORER]: MessageType.syncWithLiveShare, [CommonActionType.UNFOCUS_CELL]: MessageType.syncWithLiveShare, - [CommonActionType.UNMOUNT]: MessageType.other, - [CommonActionType.PostOutgoingMessage]: MessageType.other, - [CommonActionType.REFRESH_VARIABLES]: MessageType.other, + [CommonActionType.UNMOUNT]: MessageType.userAction, + [CommonActionType.PostOutgoingMessage]: MessageType.userAction, + [CommonActionType.REFRESH_VARIABLES]: MessageType.userAction, // Types from InteractiveWindowMessages - [InteractiveWindowMessages.Activate]: MessageType.other, - [InteractiveWindowMessages.AddedSysInfo]: MessageType.other, - [InteractiveWindowMessages.CancelCompletionItemsRequest]: MessageType.other, - [InteractiveWindowMessages.CancelHoverRequest]: MessageType.other, - [InteractiveWindowMessages.CancelResolveCompletionItemRequest]: MessageType.other, - [InteractiveWindowMessages.CancelSignatureHelpRequest]: MessageType.other, + [InteractiveWindowMessages.Activate]: MessageType.userAction, + [InteractiveWindowMessages.AddedSysInfo]: MessageType.userAction, + [InteractiveWindowMessages.CancelCompletionItemsRequest]: MessageType.userAction, + [InteractiveWindowMessages.CancelHoverRequest]: MessageType.userAction, + [InteractiveWindowMessages.CancelResolveCompletionItemRequest]: MessageType.userAction, + [InteractiveWindowMessages.CancelSignatureHelpRequest]: MessageType.userAction, [InteractiveWindowMessages.ClearAllOutputs]: MessageType.syncAcrossSameNotebooks | MessageType.syncWithLiveShare, [InteractiveWindowMessages.CollapseAll]: MessageType.syncWithLiveShare, - [InteractiveWindowMessages.CopyCodeCell]: MessageType.other, + [InteractiveWindowMessages.CopyCodeCell]: MessageType.userAction, [InteractiveWindowMessages.DeleteAllCells]: MessageType.syncAcrossSameNotebooks | MessageType.syncWithLiveShare, - [InteractiveWindowMessages.DoSave]: MessageType.other, - [InteractiveWindowMessages.ExecutionRendered]: MessageType.other, + [InteractiveWindowMessages.DoSave]: MessageType.userAction, + [InteractiveWindowMessages.ExecutionRendered]: MessageType.userAction, [InteractiveWindowMessages.ExpandAll]: MessageType.syncWithLiveShare, - [InteractiveWindowMessages.Export]: MessageType.other, - [InteractiveWindowMessages.FinishCell]: MessageType.other, + [InteractiveWindowMessages.Export]: MessageType.userAction, + [InteractiveWindowMessages.FinishCell]: MessageType.userAction, [InteractiveWindowMessages.FocusedCellEditor]: MessageType.syncWithLiveShare, - [InteractiveWindowMessages.GatherCodeRequest]: MessageType.other, - [InteractiveWindowMessages.GetAllCells]: MessageType.other, - [InteractiveWindowMessages.GetVariablesRequest]: MessageType.other, - [InteractiveWindowMessages.GetVariablesResponse]: MessageType.other, + [InteractiveWindowMessages.GatherCodeRequest]: MessageType.userAction, + [InteractiveWindowMessages.GetAllCells]: MessageType.userAction, + [InteractiveWindowMessages.GetVariablesRequest]: MessageType.userAction, + [InteractiveWindowMessages.GetVariablesResponse]: MessageType.userAction, [InteractiveWindowMessages.GotoCodeCell]: MessageType.syncWithLiveShare, [InteractiveWindowMessages.GotoCodeCell]: MessageType.syncWithLiveShare, - [InteractiveWindowMessages.Interrupt]: MessageType.other, - [InteractiveWindowMessages.LoadAllCells]: MessageType.other, - [InteractiveWindowMessages.LoadAllCellsComplete]: MessageType.other, - [InteractiveWindowMessages.LoadOnigasmAssemblyRequest]: MessageType.other, - [InteractiveWindowMessages.LoadOnigasmAssemblyResponse]: MessageType.other, - [InteractiveWindowMessages.LoadTmLanguageRequest]: MessageType.other, - [InteractiveWindowMessages.LoadTmLanguageResponse]: MessageType.other, - [InteractiveWindowMessages.MonacoReady]: MessageType.other, - [InteractiveWindowMessages.NativeCommand]: MessageType.other, + [InteractiveWindowMessages.Interrupt]: MessageType.userAction, + [InteractiveWindowMessages.LoadAllCells]: MessageType.userAction, + [InteractiveWindowMessages.LoadAllCellsComplete]: MessageType.userAction, + [InteractiveWindowMessages.LoadOnigasmAssemblyRequest]: MessageType.userAction, + [InteractiveWindowMessages.LoadOnigasmAssemblyResponse]: MessageType.userAction, + [InteractiveWindowMessages.LoadTmLanguageRequest]: MessageType.userAction, + [InteractiveWindowMessages.LoadTmLanguageResponse]: MessageType.userAction, + [InteractiveWindowMessages.MonacoReady]: MessageType.userAction, + [InteractiveWindowMessages.NativeCommand]: MessageType.userAction, [InteractiveWindowMessages.NotebookAddCellBelow]: MessageType.syncAcrossSameNotebooks | MessageType.syncWithLiveShare, - [InteractiveWindowMessages.NotebookClean]: MessageType.other, - [InteractiveWindowMessages.NotebookDirty]: MessageType.other, - [InteractiveWindowMessages.NotebookExecutionActivated]: MessageType.other, - [InteractiveWindowMessages.NotebookIdentity]: MessageType.other, - [InteractiveWindowMessages.NotebookRunAllCells]: MessageType.other, - [InteractiveWindowMessages.NotebookRunSelectedCell]: MessageType.other, - [InteractiveWindowMessages.OpenLink]: MessageType.other, - [InteractiveWindowMessages.ProvideCompletionItemsRequest]: MessageType.other, - [InteractiveWindowMessages.ProvideCompletionItemsResponse]: MessageType.other, - [InteractiveWindowMessages.ProvideHoverRequest]: MessageType.other, - [InteractiveWindowMessages.ProvideHoverResponse]: MessageType.other, - [InteractiveWindowMessages.ProvideSignatureHelpRequest]: MessageType.other, - [InteractiveWindowMessages.ProvideSignatureHelpResponse]: MessageType.other, - [InteractiveWindowMessages.ReExecuteCell]: MessageType.other, - [InteractiveWindowMessages.Redo]: MessageType.other, - [InteractiveWindowMessages.RemoteAddCode]: MessageType.other, - [InteractiveWindowMessages.ReceivedUpdateModel]: MessageType.other, - [InteractiveWindowMessages.RemoteReexecuteCode]: MessageType.other, - [InteractiveWindowMessages.ResolveCompletionItemRequest]: MessageType.other, - [InteractiveWindowMessages.ResolveCompletionItemResponse]: MessageType.other, - [InteractiveWindowMessages.RestartKernel]: MessageType.other, - [InteractiveWindowMessages.ReturnAllCells]: MessageType.other, - [InteractiveWindowMessages.SaveAll]: MessageType.other, - [InteractiveWindowMessages.SavePng]: MessageType.other, + [InteractiveWindowMessages.NotebookClean]: MessageType.userAction, + [InteractiveWindowMessages.NotebookDirty]: MessageType.userAction, + [InteractiveWindowMessages.NotebookExecutionActivated]: MessageType.userAction, + [InteractiveWindowMessages.NotebookIdentity]: MessageType.userAction, + [InteractiveWindowMessages.NotebookRunAllCells]: MessageType.userAction, + [InteractiveWindowMessages.NotebookRunSelectedCell]: MessageType.userAction, + [InteractiveWindowMessages.OpenLink]: MessageType.userAction, + [InteractiveWindowMessages.ProvideCompletionItemsRequest]: MessageType.userAction, + [InteractiveWindowMessages.ProvideCompletionItemsResponse]: MessageType.userAction, + [InteractiveWindowMessages.ProvideHoverRequest]: MessageType.userAction, + [InteractiveWindowMessages.ProvideHoverResponse]: MessageType.userAction, + [InteractiveWindowMessages.ProvideSignatureHelpRequest]: MessageType.userAction, + [InteractiveWindowMessages.ProvideSignatureHelpResponse]: MessageType.userAction, + [InteractiveWindowMessages.ReExecuteCell]: MessageType.userAction, + [InteractiveWindowMessages.Redo]: MessageType.userAction, + [InteractiveWindowMessages.RemoteAddCode]: MessageType.userAction, + [InteractiveWindowMessages.ReceivedUpdateModel]: MessageType.userAction, + [InteractiveWindowMessages.RemoteReexecuteCode]: MessageType.userAction, + [InteractiveWindowMessages.ResolveCompletionItemRequest]: MessageType.userAction, + [InteractiveWindowMessages.ResolveCompletionItemResponse]: MessageType.userAction, + [InteractiveWindowMessages.RestartKernel]: MessageType.userAction, + [InteractiveWindowMessages.ReturnAllCells]: MessageType.userAction, + [InteractiveWindowMessages.SaveAll]: MessageType.userAction, + [InteractiveWindowMessages.SavePng]: MessageType.userAction, [InteractiveWindowMessages.ScrollToCell]: MessageType.syncWithLiveShare, - [InteractiveWindowMessages.SelectJupyterServer]: MessageType.other, - [InteractiveWindowMessages.SelectKernel]: MessageType.other, - [InteractiveWindowMessages.SendInfo]: MessageType.other, - [InteractiveWindowMessages.SettingsUpdated]: MessageType.other, - [InteractiveWindowMessages.ShowDataViewer]: MessageType.other, - [InteractiveWindowMessages.ShowPlot]: MessageType.other, - [InteractiveWindowMessages.StartCell]: MessageType.other, - [InteractiveWindowMessages.StartDebugging]: MessageType.other, - [InteractiveWindowMessages.StartProgress]: MessageType.other, - [InteractiveWindowMessages.Started]: MessageType.other, - [InteractiveWindowMessages.StopDebugging]: MessageType.other, - [InteractiveWindowMessages.StopProgress]: MessageType.other, - [InteractiveWindowMessages.SubmitNewCell]: MessageType.other, - [InteractiveWindowMessages.Sync]: MessageType.other, - [InteractiveWindowMessages.Undo]: MessageType.other, + [InteractiveWindowMessages.SelectJupyterServer]: MessageType.userAction, + [InteractiveWindowMessages.SelectKernel]: MessageType.userAction, + [InteractiveWindowMessages.SendInfo]: MessageType.userAction, + [InteractiveWindowMessages.SettingsUpdated]: MessageType.userAction, + [InteractiveWindowMessages.ShowDataViewer]: MessageType.userAction, + [InteractiveWindowMessages.ShowPlot]: MessageType.userAction, + [InteractiveWindowMessages.StartCell]: MessageType.userAction, + [InteractiveWindowMessages.StartDebugging]: MessageType.userAction, + [InteractiveWindowMessages.StartProgress]: MessageType.userAction, + [InteractiveWindowMessages.Started]: MessageType.userAction, + [InteractiveWindowMessages.StopDebugging]: MessageType.userAction, + [InteractiveWindowMessages.StopProgress]: MessageType.userAction, + [InteractiveWindowMessages.SubmitNewCell]: MessageType.userAction, + [InteractiveWindowMessages.Sync]: MessageType.userAction, + [InteractiveWindowMessages.Undo]: MessageType.userAction, [InteractiveWindowMessages.UnfocusedCellEditor]: MessageType.syncWithLiveShare, - [InteractiveWindowMessages.UpdateCell]: MessageType.other, + [InteractiveWindowMessages.UpdateCell]: MessageType.userAction, [InteractiveWindowMessages.UpdateModel]: MessageType.syncAcrossSameNotebooks | MessageType.syncWithLiveShare, - [InteractiveWindowMessages.UpdateKernel]: MessageType.other, - [InteractiveWindowMessages.VariableExplorerToggle]: MessageType.other, - [InteractiveWindowMessages.VariablesComplete]: MessageType.other, + [InteractiveWindowMessages.UpdateKernel]: MessageType.userAction, + [InteractiveWindowMessages.VariableExplorerToggle]: MessageType.userAction, + [InteractiveWindowMessages.VariablesComplete]: MessageType.userAction, // Types from CssMessages - [CssMessages.GetCssRequest]: MessageType.other, - [CssMessages.GetCssResponse]: MessageType.other, - [CssMessages.GetMonacoThemeRequest]: MessageType.other, - [CssMessages.GetMonacoThemeResponse]: MessageType.other, + [CssMessages.GetCssRequest]: MessageType.userAction, + [CssMessages.GetCssResponse]: MessageType.userAction, + [CssMessages.GetMonacoThemeRequest]: MessageType.userAction, + [CssMessages.GetMonacoThemeResponse]: MessageType.userAction, // Types from Shared Messages - [SharedMessages.LocInit]: MessageType.other, - [SharedMessages.Started]: MessageType.other, - [SharedMessages.UpdateSettings]: MessageType.other + [SharedMessages.LocInit]: MessageType.userAction, + [SharedMessages.Started]: MessageType.userAction, + [SharedMessages.UpdateSettings]: MessageType.userAction }; export function isActionPerformedByUser(action: BaseReduxActionPayload<{}> | BaseReduxActionPayload) { @@ -178,7 +181,7 @@ export function shouldRebroadcast(message: keyof IInteractiveWindowMapping): [bo // Support for liveshare is turned off for now, we can enable that later. // I.e. we only support synchronizing across editors in the same session. if (messageType === undefined || (messageType & MessageType.syncAcrossSameNotebooks) !== MessageType.syncAcrossSameNotebooks) { - return [false, MessageType.other]; + return [false, MessageType.userAction]; } return [(messageType & MessageType.syncAcrossSameNotebooks) > 0 || (messageType & MessageType.syncWithLiveShare) > 0, messageType]; diff --git a/src/datascience-ui/history-react/redux/reducers/creation.ts b/src/datascience-ui/history-react/redux/reducers/creation.ts index a91183029fea..2678345ce770 100644 --- a/src/datascience-ui/history-react/redux/reducers/creation.ts +++ b/src/datascience-ui/history-react/redux/reducers/creation.ts @@ -5,7 +5,7 @@ import { Identifiers } from '../../../../client/datascience/constants'; import { InteractiveWindowMessages } from '../../../../client/datascience/interactive-common/interactiveWindowTypes'; import { ICell, IDataScienceExtraSettings } from '../../../../client/datascience/types'; import { createCellVM, extractInputText, ICellViewModel, IMainState } from '../../../interactive-common/mainState'; -import { createPostableAction } from '../../../interactive-common/redux/helpers'; +import { postActionToExtension } from '../../../interactive-common/redux/helpers'; import { Helpers } from '../../../interactive-common/redux/reducers/helpers'; import { IAddCellAction, ICellAction } from '../../../interactive-common/redux/reducers/types'; import { InteractiveReducerArg } from '../mapping'; @@ -85,17 +85,15 @@ export namespace Creation { const cellVM = result.cellVMs[result.cellVMs.length - 1]; // We're adding a new cell here. Tell the intellisense engine we have a new cell - arg.queueAction( - createPostableAction(InteractiveWindowMessages.UpdateModel, { - source: 'user', - kind: 'add', - oldDirty: arg.prevState.dirty, - newDirty: true, - cell: cellVM.cell, - fullText: extractInputText(cellVM, result.settings), - currentText: cellVM.inputBlockText - }) - ); + postActionToExtension(arg, InteractiveWindowMessages.UpdateModel, { + source: 'user', + kind: 'add', + oldDirty: arg.prevState.dirty, + newDirty: true, + cell: cellVM.cell, + fullText: extractInputText(cellVM, result.settings), + currentText: cellVM.inputBlockText + }); } return result; @@ -119,7 +117,7 @@ export namespace Creation { export function deleteAllCells(arg: InteractiveReducerArg): IMainState { // Send messages to other side to indicate the deletes - arg.queueAction(createPostableAction(InteractiveWindowMessages.DeleteAllCells)); + postActionToExtension(arg, InteractiveWindowMessages.DeleteAllCells); return { ...arg.prevState, @@ -132,16 +130,14 @@ export namespace Creation { const index = arg.prevState.cellVMs.findIndex(c => c.cell.id === arg.payload.data.cellId); if (index >= 0 && arg.payload.data.cellId) { // Send messages to other side to indicate the delete - arg.queueAction( - createPostableAction(InteractiveWindowMessages.UpdateModel, { - source: 'user', - kind: 'remove', - index, - oldDirty: arg.prevState.dirty, - newDirty: true, - cell: arg.prevState.cellVMs[index].cell - }) - ); + postActionToExtension(arg, InteractiveWindowMessages.UpdateModel, { + source: 'user', + kind: 'remove', + index, + oldDirty: arg.prevState.dirty, + newDirty: true, + cell: arg.prevState.cellVMs[index].cell + }); const newVMs = arg.prevState.cellVMs.filter((_c, i) => i !== index); return { diff --git a/src/datascience-ui/history-react/redux/reducers/effects.ts b/src/datascience-ui/history-react/redux/reducers/effects.ts index 5cb22db9ae94..b2de7aa98677 100644 --- a/src/datascience-ui/history-react/redux/reducers/effects.ts +++ b/src/datascience-ui/history-react/redux/reducers/effects.ts @@ -6,7 +6,7 @@ import { IScrollToCell } from '../../../../client/datascience/interactive-common import { CssMessages } from '../../../../client/datascience/messages'; import { IDataScienceExtraSettings } from '../../../../client/datascience/types'; import { IMainState } from '../../../interactive-common/mainState'; -import { createPostableAction } from '../../../interactive-common/redux/helpers'; +import { postActionToExtension } from '../../../interactive-common/redux/helpers'; import { Helpers } from '../../../interactive-common/redux/reducers/helpers'; import { ICellAction, IScrollAction } from '../../../interactive-common/redux/reducers/types'; import { computeEditorOptions } from '../../../react-common/settingsReactSide'; @@ -62,8 +62,8 @@ export namespace Effects { if (newSettings && newSettings.extraSettings && newSettings.extraSettings.theme !== arg.prevState.vscodeThemeName) { const knownDark = Helpers.computeKnownDark(newSettings); // User changed the current theme. Rerender - arg.queueAction(createPostableAction(CssMessages.GetCssRequest, { isDark: knownDark })); - arg.queueAction(createPostableAction(CssMessages.GetMonacoThemeRequest, { isDark: knownDark })); + postActionToExtension(arg, CssMessages.GetCssRequest, { isDark: knownDark }); + postActionToExtension(arg, CssMessages.GetMonacoThemeRequest, { isDark: knownDark }); } // Update our input cell state if the user changed this setting diff --git a/src/datascience-ui/history-react/redux/reducers/execution.ts b/src/datascience-ui/history-react/redux/reducers/execution.ts index 407911183a67..72cf839f7674 100644 --- a/src/datascience-ui/history-react/redux/reducers/execution.ts +++ b/src/datascience-ui/history-react/redux/reducers/execution.ts @@ -11,7 +11,7 @@ import { CellState } from '../../../../client/datascience/types'; import { generateMarkdownFromCodeLines } from '../../../common'; import { createCellFrom } from '../../../common/cellFactory'; import { createCellVM, IMainState } from '../../../interactive-common/mainState'; -import { createPostableAction } from '../../../interactive-common/redux/helpers'; +import { postActionToExtension } from '../../../interactive-common/redux/helpers'; import { Helpers } from '../../../interactive-common/redux/reducers/helpers'; import { ICodeAction } from '../../../interactive-common/redux/reducers/types'; import { InteractiveReducerArg } from '../mapping'; @@ -24,7 +24,7 @@ export namespace Execution { const cells = arg.prevState.undoStack[arg.prevState.undoStack.length - 1]; const undoStack = arg.prevState.undoStack.slice(0, arg.prevState.undoStack.length - 1); const redoStack = Helpers.pushStack(arg.prevState.redoStack, arg.prevState.cellVMs); - arg.queueAction(createPostableAction(InteractiveWindowMessages.Undo)); + postActionToExtension(arg, InteractiveWindowMessages.Undo); return { ...arg.prevState, cellVMs: cells, @@ -43,7 +43,7 @@ export namespace Execution { const cells = arg.prevState.redoStack[arg.prevState.redoStack.length - 1]; const redoStack = arg.prevState.redoStack.slice(0, arg.prevState.redoStack.length - 1); const undoStack = Helpers.pushStack(arg.prevState.undoStack, arg.prevState.cellVMs); - arg.queueAction(createPostableAction(InteractiveWindowMessages.Redo)); + postActionToExtension(arg, InteractiveWindowMessages.Redo); return { ...arg.prevState, cellVMs: cells, @@ -107,7 +107,7 @@ export namespace Execution { // Send a message to execute this code if necessary. if (newCell.cell.state !== CellState.finished) { - arg.queueAction(createPostableAction(InteractiveWindowMessages.SubmitNewCell, { code: arg.payload.data.code, id: newCell.cell.id })); + postActionToExtension(arg, InteractiveWindowMessages.SubmitNewCell, { code: arg.payload.data.code, id: newCell.cell.id }); } // Stick in a new cell at the bottom that's editable and update our state diff --git a/src/datascience-ui/interactive-common/redux/helpers.ts b/src/datascience-ui/interactive-common/redux/helpers.ts index 3717e514d350..24a0a807420c 100644 --- a/src/datascience-ui/interactive-common/redux/helpers.ts +++ b/src/datascience-ui/interactive-common/redux/helpers.ts @@ -7,6 +7,7 @@ import * as Redux from 'redux'; import { IInteractiveWindowMapping, InteractiveWindowMessages } from '../../../client/datascience/interactive-common/interactiveWindowTypes'; import { BaseReduxActionPayload } from '../../../client/datascience/interactive-common/types'; import { CssMessages, SharedMessages } from '../../../client/datascience/messages'; +import { QueueAnotherFunc } from '../../react-common/reduxUtils'; import { CommonAction, CommonActionType, CommonActionTypeMapping } from './reducers/types'; const AllowedMessages = [...Object.values(InteractiveWindowMessages), ...Object.values(CssMessages), ...Object.values(SharedMessages), ...Object.values(CommonActionType)]; @@ -26,14 +27,31 @@ export function createIncomingAction(type: CommonActionType | InteractiveWindowM return { type, payload: { messageDirection: 'incoming', data: undefined } }; } -// Actions created from messages -export function createPostableAction(message: T, payload?: M[T]): Redux.AnyAction { - const newPayload: BaseReduxActionPayload = ({ +type ReducerArg = { + // tslint:disable-next-line: no-any + queueAction: QueueAnotherFunc; + // tslint:disable-next-line: no-any + payload?: BaseReduxActionPayload; +}; +/** + * Post a message to the extension (via dispatcher actions). + */ +export function postActionToExtension(originalReducerArg: ReducerArg, message: T, payload?: M[T]): void; +/** + * Post a message to the extension (via dispatcher actions). + */ +// tslint:disable-next-line: unified-signatures +export function postActionToExtension(originalReducerArg: ReducerArg, message: T, payload?: M[T]): void; +// tslint:disable-next-line: no-any +export function postActionToExtension(originalReducerArg: ReducerArg, message: any, payload?: any) { + // tslint:disable-next-line: no-any + const newPayload: BaseReduxActionPayload = ({ data: payload, messageDirection: 'outgoing' // tslint:disable-next-line: no-any - } as any) as BaseReduxActionPayload; - return { type: CommonActionType.PostOutgoingMessage, payload: { payload: newPayload, type: message } }; + } as any) as BaseReduxActionPayload; + const action = { type: CommonActionType.PostOutgoingMessage, payload: { payload: newPayload, type: message } }; + originalReducerArg.queueAction(action); } export function unwrapPostableAction(action: Redux.AnyAction): { type: keyof IInteractiveWindowMapping; payload?: BaseReduxActionPayload<{}> } { // Unwrap the payload that was created in `createPostableAction`. diff --git a/src/datascience-ui/interactive-common/redux/reducers/kernel.ts b/src/datascience-ui/interactive-common/redux/reducers/kernel.ts index cbf2d10bada1..58e4c3eae343 100644 --- a/src/datascience-ui/interactive-common/redux/reducers/kernel.ts +++ b/src/datascience-ui/interactive-common/redux/reducers/kernel.ts @@ -4,23 +4,23 @@ import { InteractiveWindowMessages } from '../../../../client/datascience/interactive-common/interactiveWindowTypes'; import { CellState } from '../../../../client/datascience/types'; import { IMainState, IServerState } from '../../mainState'; -import { createPostableAction } from '../helpers'; +import { postActionToExtension } from '../helpers'; import { CommonActionType, CommonReducerArg } from './types'; export namespace Kernel { // tslint:disable-next-line: no-any export function selectKernel(arg: CommonReducerArg): IMainState { - arg.queueAction(createPostableAction(InteractiveWindowMessages.SelectKernel)); + postActionToExtension(arg, InteractiveWindowMessages.SelectKernel); return arg.prevState; } export function selectJupyterURI(arg: CommonReducerArg): IMainState { - arg.queueAction(createPostableAction(InteractiveWindowMessages.SelectJupyterServer)); + postActionToExtension(arg, InteractiveWindowMessages.SelectJupyterServer); return arg.prevState; } export function restartKernel(arg: CommonReducerArg): IMainState { - arg.queueAction(createPostableAction(InteractiveWindowMessages.RestartKernel)); + postActionToExtension(arg, InteractiveWindowMessages.RestartKernel); // Set busy until kernel is restarted return { @@ -30,7 +30,7 @@ export namespace Kernel { } export function interruptKernel(arg: CommonReducerArg): IMainState { - arg.queueAction(createPostableAction(InteractiveWindowMessages.Interrupt)); + postActionToExtension(arg, InteractiveWindowMessages.Interrupt); // Set busy until kernel is finished interrupting return { diff --git a/src/datascience-ui/interactive-common/redux/reducers/transfer.ts b/src/datascience-ui/interactive-common/redux/reducers/transfer.ts index cc01008ea56b..d89efc5d7b11 100644 --- a/src/datascience-ui/interactive-common/redux/reducers/transfer.ts +++ b/src/datascience-ui/interactive-common/redux/reducers/transfer.ts @@ -6,7 +6,7 @@ import { IEditorContentChange, InteractiveWindowMessages, NotebookModelChange } import { CssMessages } from '../../../../client/datascience/messages'; import { ICell } from '../../../../client/datascience/types'; import { extractInputText, getSelectedAndFocusedInfo, IMainState } from '../../mainState'; -import { createPostableAction } from '../helpers'; +import { postActionToExtension } from '../helpers'; import { Helpers } from './helpers'; import { CommonActionType, CommonReducerArg, ICellAction, IEditCellAction, ILinkClickAction, ISendCommandAction, IShowDataViewerAction } from './types'; @@ -14,7 +14,7 @@ import { CommonActionType, CommonReducerArg, ICellAction, IEditCellAction, ILink export namespace Transfer { export function exportCells(arg: CommonReducerArg): IMainState { const cellContents = arg.prevState.cellVMs.map(v => v.cell); - arg.queueAction(createPostableAction(InteractiveWindowMessages.Export, cellContents)); + postActionToExtension(arg, InteractiveWindowMessages.Export, cellContents); // Indicate busy return { @@ -27,46 +27,46 @@ export namespace Transfer { // Note: this is assuming editor contents have already been saved. That should happen as a result of focus change // Actually waiting for save results before marking as not dirty, so don't do it here. - arg.queueAction(createPostableAction(InteractiveWindowMessages.SaveAll, { cells: arg.prevState.cellVMs.map(cvm => cvm.cell) })); + postActionToExtension(arg, InteractiveWindowMessages.SaveAll, { cells: arg.prevState.cellVMs.map(cvm => cvm.cell) }); return arg.prevState; } export function showDataViewer(arg: CommonReducerArg): IMainState { - arg.queueAction(createPostableAction(InteractiveWindowMessages.ShowDataViewer, { variable: arg.payload.data.variable, columnSize: arg.payload.data.columnSize })); + postActionToExtension(arg, InteractiveWindowMessages.ShowDataViewer, { variable: arg.payload.data.variable, columnSize: arg.payload.data.columnSize }); return arg.prevState; } export function sendCommand(arg: CommonReducerArg): IMainState { - arg.queueAction(createPostableAction(InteractiveWindowMessages.NativeCommand, { command: arg.payload.data.command, source: arg.payload.data.commandType })); + postActionToExtension(arg, InteractiveWindowMessages.NativeCommand, { command: arg.payload.data.command, source: arg.payload.data.commandType }); return arg.prevState; } export function showPlot(arg: CommonReducerArg): IMainState { if (arg.payload.data) { - arg.queueAction(createPostableAction(InteractiveWindowMessages.ShowPlot, arg.payload.data)); + postActionToExtension(arg, InteractiveWindowMessages.ShowPlot, arg.payload.data); } return arg.prevState; } export function linkClick(arg: CommonReducerArg): IMainState { if (arg.payload.data.href.startsWith('data:image/png')) { - arg.queueAction(createPostableAction(InteractiveWindowMessages.SavePng, arg.payload.data.href)); + postActionToExtension(arg, InteractiveWindowMessages.SavePng, arg.payload.data.href); } else { - arg.queueAction(createPostableAction(InteractiveWindowMessages.OpenLink, arg.payload.data.href)); + postActionToExtension(arg, InteractiveWindowMessages.OpenLink, arg.payload.data.href); } return arg.prevState; } export function getAllCells(arg: CommonReducerArg): IMainState { const cells = arg.prevState.cellVMs.map(c => c.cell); - arg.queueAction(createPostableAction(InteractiveWindowMessages.ReturnAllCells, cells)); + postActionToExtension(arg, InteractiveWindowMessages.ReturnAllCells, cells); return arg.prevState; } export function gotoCell(arg: CommonReducerArg): IMainState { const cellVM = arg.prevState.cellVMs.find(c => c.cell.id === arg.payload.data.cellId); if (cellVM && cellVM.cell.data.cell_type === 'code') { - arg.queueAction(createPostableAction(InteractiveWindowMessages.GotoCodeCell, { file: cellVM.cell.file, line: cellVM.cell.line })); + postActionToExtension(arg, InteractiveWindowMessages.GotoCodeCell, { file: cellVM.cell.file, line: cellVM.cell.line }); } return arg.prevState; } @@ -79,7 +79,7 @@ export namespace Transfer { // Send a message to the other side to jump to a particular cell if (cellVM) { - arg.queueAction(createPostableAction(InteractiveWindowMessages.CopyCodeCell, { source: extractInputText(cellVM, arg.prevState.settings) })); + postActionToExtension(arg, InteractiveWindowMessages.CopyCodeCell, { source: extractInputText(cellVM, arg.prevState.settings) }); } return arg.prevState; @@ -88,13 +88,13 @@ export namespace Transfer { export function gather(arg: CommonReducerArg): IMainState { const cellVM = arg.prevState.cellVMs.find(c => c.cell.id === arg.payload.data.cellId); if (cellVM) { - arg.queueAction(createPostableAction(InteractiveWindowMessages.GatherCodeRequest, cellVM.cell)); + postActionToExtension(arg, InteractiveWindowMessages.GatherCodeRequest, cellVM.cell); } return arg.prevState; } function postModelUpdate(arg: CommonReducerArg, update: NotebookModelChange) { - arg.queueAction(createPostableAction(InteractiveWindowMessages.UpdateModel, update)); + postActionToExtension(arg, InteractiveWindowMessages.UpdateModel, update); } export function postModelEdit(arg: CommonReducerArg, forward: IEditorContentChange[], reverse: IEditorContentChange[], id: string) { @@ -199,16 +199,16 @@ export namespace Transfer { export function started(arg: CommonReducerArg): IMainState { // Send all of our initial requests - arg.queueAction(createPostableAction(InteractiveWindowMessages.Started)); - arg.queueAction(createPostableAction(CssMessages.GetCssRequest, { isDark: arg.prevState.baseTheme !== 'vscode-light' })); - arg.queueAction(createPostableAction(CssMessages.GetMonacoThemeRequest, { isDark: arg.prevState.baseTheme !== 'vscode-light' })); - arg.queueAction(createPostableAction(InteractiveWindowMessages.LoadOnigasmAssemblyRequest)); - arg.queueAction(createPostableAction(InteractiveWindowMessages.LoadTmLanguageRequest)); + postActionToExtension(arg, InteractiveWindowMessages.Started); + postActionToExtension(arg, CssMessages.GetCssRequest, { isDark: arg.prevState.baseTheme !== 'vscode-light' }); + postActionToExtension(arg, CssMessages.GetMonacoThemeRequest, { isDark: arg.prevState.baseTheme !== 'vscode-light' }); + postActionToExtension(arg, InteractiveWindowMessages.LoadOnigasmAssemblyRequest); + postActionToExtension(arg, InteractiveWindowMessages.LoadTmLanguageRequest); return arg.prevState; } export function loadedAllCells(arg: CommonReducerArg): IMainState { - arg.queueAction(createPostableAction(InteractiveWindowMessages.LoadAllCellsComplete, { cells: arg.prevState.cellVMs.map(c => c.cell) })); + postActionToExtension(arg, InteractiveWindowMessages.LoadAllCellsComplete, { cells: arg.prevState.cellVMs.map(c => c.cell) }); return arg.prevState; } } diff --git a/src/datascience-ui/interactive-common/redux/reducers/variables.ts b/src/datascience-ui/interactive-common/redux/reducers/variables.ts index 32c46ce09759..396062991b6d 100644 --- a/src/datascience-ui/interactive-common/redux/reducers/variables.ts +++ b/src/datascience-ui/interactive-common/redux/reducers/variables.ts @@ -6,7 +6,7 @@ import { IInteractiveWindowMapping, InteractiveWindowMessages } from '../../../. import { BaseReduxActionPayload } from '../../../../client/datascience/interactive-common/types'; import { ICell, IJupyterVariable, IJupyterVariablesRequest, IJupyterVariablesResponse } from '../../../../client/datascience/types'; import { combineReducers, QueuableAction, ReducerArg, ReducerFunc } from '../../../react-common/reduxUtils'; -import { createPostableAction } from '../helpers'; +import { postActionToExtension } from '../helpers'; import { CommonActionType, CommonActionTypeMapping } from './types'; export type IVariableState = { @@ -23,15 +23,13 @@ type VariableReducerArg = ReducerArg): IVariableState { const newExecutionCount = arg.payload.data.executionCount !== undefined ? arg.payload.data.executionCount : arg.prevState.currentExecutionCount; - arg.queueAction( - createPostableAction(InteractiveWindowMessages.GetVariablesRequest, { - executionCount: newExecutionCount, - sortColumn: arg.payload.data.sortColumn, - startIndex: arg.payload.data.startIndex, - sortAscending: arg.payload.data.sortAscending, - pageSize: arg.payload.data.pageSize - }) - ); + postActionToExtension(arg, InteractiveWindowMessages.GetVariablesRequest, { + executionCount: newExecutionCount, + sortColumn: arg.payload.data.sortColumn, + startIndex: arg.payload.data.startIndex, + sortAscending: arg.payload.data.sortAscending, + pageSize: arg.payload.data.pageSize + }); return { ...arg.prevState, pageSize: Math.max(arg.prevState.pageSize, arg.payload.data.pageSize) @@ -44,7 +42,7 @@ function toggleVariableExplorer(arg: VariableReducerArg): IVariableState { visible: !arg.prevState.visible }; - arg.queueAction(createPostableAction(InteractiveWindowMessages.VariableExplorerToggle, newState.visible)); + postActionToExtension(arg, InteractiveWindowMessages.VariableExplorerToggle, newState.visible); // If going visible for the first time, refresh our variables if (newState.visible) { diff --git a/src/datascience-ui/interactive-common/redux/store.ts b/src/datascience-ui/interactive-common/redux/store.ts index 7fdd655335f6..df0bbb44ac53 100644 --- a/src/datascience-ui/interactive-common/redux/store.ts +++ b/src/datascience-ui/interactive-common/redux/store.ts @@ -16,7 +16,7 @@ import { combineReducers, createQueueableActionMiddleware, QueuableAction } from import { computeEditorOptions, getDefaultSettings } from '../../react-common/settingsReactSide'; import { createEditableCellVM, generateTestState } from '../mainState'; import { forceLoad } from '../transforms'; -import { createPostableAction, isAllowedAction, isAllowedMessage } from './helpers'; +import { isAllowedAction, isAllowedMessage, postActionToExtension } from './helpers'; import { generatePostOfficeSendReducer } from './postOffice'; import { generateMonacoReducer, IMonacoState } from './reducers/monaco'; import { generateVariableReducer, IVariableState } from './reducers/variables'; @@ -87,14 +87,12 @@ function createSendInfoMiddleware(): Redux.Middleware<{}, IStore> { prevState.main.undoStack.length !== afterState.main.undoStack.length || prevState.main.redoStack.length !== afterState.main.redoStack.length ) { - store.dispatch( - createPostableAction(InteractiveWindowMessages.SendInfo, { - cellCount: afterState.main.cellVMs.length, - undoCount: afterState.main.undoStack.length, - redoCount: afterState.main.redoStack.length, - selectedCell: currentSelection.selectedCellId - }) - ); + postActionToExtension({ queueAction: store.dispatch }, InteractiveWindowMessages.SendInfo, { + cellCount: afterState.main.cellVMs.length, + undoCount: afterState.main.undoStack.length, + redoCount: afterState.main.redoStack.length, + selectedCell: currentSelection.selectedCellId + }); } return res; }; @@ -111,11 +109,7 @@ function createTestMiddleware(): Redux.Middleware<{}, IStore> { // tslint:disable-next-line: no-any const sendMessage = (message: any, payload?: any) => { setTimeout(() => { - transformPromise - .then(() => { - store.dispatch(createPostableAction(message, payload)); - }) - .ignoreErrors(); + transformPromise.then(() => postActionToExtension({ queueAction: store.dispatch }, message, payload)).ignoreErrors(); }); }; diff --git a/src/datascience-ui/native-editor/redux/reducers/effects.ts b/src/datascience-ui/native-editor/redux/reducers/effects.ts index 08eae3efd7f5..204966fa963f 100644 --- a/src/datascience-ui/native-editor/redux/reducers/effects.ts +++ b/src/datascience-ui/native-editor/redux/reducers/effects.ts @@ -4,7 +4,7 @@ import { CssMessages } from '../../../../client/datascience/messages'; import { IDataScienceExtraSettings } from '../../../../client/datascience/types'; import { getSelectedAndFocusedInfo, IMainState } from '../../../interactive-common/mainState'; -import { createPostableAction } from '../../../interactive-common/redux/helpers'; +import { postActionToExtension } from '../../../interactive-common/redux/helpers'; import { Helpers } from '../../../interactive-common/redux/reducers/helpers'; import { ICellAction, ICellAndCursorAction, ICodeAction } from '../../../interactive-common/redux/reducers/types'; import { computeEditorOptions } from '../../../react-common/settingsReactSide'; @@ -210,8 +210,8 @@ export namespace Effects { if (newSettings && newSettings.extraSettings && newSettings.extraSettings.theme !== arg.prevState.vscodeThemeName) { const knownDark = Helpers.computeKnownDark(newSettings); // User changed the current theme. Rerender - arg.queueAction(createPostableAction(CssMessages.GetCssRequest, { isDark: knownDark })); - arg.queueAction(createPostableAction(CssMessages.GetMonacoThemeRequest, { isDark: knownDark })); + postActionToExtension(arg, CssMessages.GetCssRequest, { isDark: knownDark }); + postActionToExtension(arg, CssMessages.GetMonacoThemeRequest, { isDark: knownDark }); } return { diff --git a/src/datascience-ui/native-editor/redux/reducers/execution.ts b/src/datascience-ui/native-editor/redux/reducers/execution.ts index 3aad08b20371..f8d502613c69 100644 --- a/src/datascience-ui/native-editor/redux/reducers/execution.ts +++ b/src/datascience-ui/native-editor/redux/reducers/execution.ts @@ -10,16 +10,16 @@ import { CellState } from '../../../../client/datascience/types'; import { concatMultilineStringInput } from '../../../common'; import { createCellFrom } from '../../../common/cellFactory'; import { CursorPos, getSelectedAndFocusedInfo, ICellViewModel, IMainState } from '../../../interactive-common/mainState'; -import { createIncomingActionWithPayload, createPostableAction } from '../../../interactive-common/redux/helpers'; +import { createIncomingActionWithPayload, postActionToExtension } from '../../../interactive-common/redux/helpers'; import { Helpers } from '../../../interactive-common/redux/reducers/helpers'; import { Transfer } from '../../../interactive-common/redux/reducers/transfer'; import { CommonActionType, ICellAction, IChangeCellTypeAction, ICodeAction, IExecuteAction } from '../../../interactive-common/redux/reducers/types'; -import { QueueAnotherFunc } from '../../../react-common/reduxUtils'; import { NativeEditorReducerArg } from '../mapping'; import { Effects } from './effects'; export namespace Execution { - function executeRange(prevState: IMainState, start: number, end: number, codes: string[], queueAction: QueueAnotherFunc): IMainState { + // tslint:disable-next-line: no-any + function executeRange(prevState: IMainState, start: number, end: number, codes: string[], originalArg: NativeEditorReducerArg): IMainState { const newVMs = [...prevState.cellVMs]; for (let pos = start; pos <= end; pos += 1) { const orig = prevState.cellVMs[pos]; @@ -40,7 +40,7 @@ export namespace Execution { }); // Send a message if a code cell - queueAction(createPostableAction(InteractiveWindowMessages.ReExecuteCell, { code, id: orig.cell.id })); + postActionToExtension(originalArg, InteractiveWindowMessages.ReExecuteCell, { code, id: orig.cell.id }); } else { // Update our input to be our new code newVMs[pos] = Helpers.asCellViewModel({ ...orig, inputBlockText: code, cell: { ...orig.cell, data: clonedCell } }); @@ -58,7 +58,7 @@ export namespace Execution { const index = arg.prevState.cellVMs.findIndex(c => c.cell.id === arg.payload.data.cellId); if (index > 0) { const codes = arg.prevState.cellVMs.filter((_c, i) => i < index).map(c => concatMultilineStringInput(c.cell.data.source)); - return executeRange(arg.prevState, 0, index - 1, codes, arg.queueAction); + return executeRange(arg.prevState, 0, index - 1, codes, arg); } return arg.prevState; } @@ -79,7 +79,7 @@ export namespace Execution { const index = arg.prevState.cellVMs.findIndex(c => c.cell.id === arg.payload.data.cellId); if (index >= 0) { // Start executing this cell. - const executeResult = executeRange(arg.prevState, index, index, [arg.payload.data.code], arg.queueAction); + const executeResult = executeRange(arg.prevState, index, index, [arg.payload.data.code], arg); // Modify the execute result if moving if (arg.payload.data.moveOp === 'select') { @@ -116,7 +116,7 @@ export namespace Execution { const index = arg.prevState.cellVMs.findIndex(c => c.cell.id === arg.payload.data.cellId); if (index >= 0) { const codes = arg.prevState.cellVMs.filter((_c, i) => i > index).map(c => concatMultilineStringInput(c.cell.data.source)); - return executeRange(arg.prevState, index, index + codes.length, [arg.payload.data.code, ...codes], arg.queueAction); + return executeRange(arg.prevState, index, index + codes.length, [arg.payload.data.code, ...codes], arg); } return arg.prevState; } @@ -203,7 +203,7 @@ export namespace Execution { const cells = arg.prevState.undoStack[arg.prevState.undoStack.length - 1]; const undoStack = arg.prevState.undoStack.slice(0, arg.prevState.undoStack.length - 1); const redoStack = Helpers.pushStack(arg.prevState.redoStack, arg.prevState.cellVMs); - arg.queueAction(createPostableAction(InteractiveWindowMessages.Undo)); + postActionToExtension(arg, InteractiveWindowMessages.Undo); return { ...arg.prevState, cellVMs: cells, @@ -222,7 +222,7 @@ export namespace Execution { const cells = arg.prevState.redoStack[arg.prevState.redoStack.length - 1]; const redoStack = arg.prevState.redoStack.slice(0, arg.prevState.redoStack.length - 1); const undoStack = Helpers.pushStack(arg.prevState.undoStack, arg.prevState.cellVMs); - arg.queueAction(createPostableAction(InteractiveWindowMessages.Redo)); + postActionToExtension(arg, InteractiveWindowMessages.Redo); return { ...arg.prevState, cellVMs: cells,