@@ -6,15 +6,15 @@ import { IEditorContentChange, InteractiveWindowMessages, NotebookModelChange }
66import { CssMessages } from '../../../../client/datascience/messages' ;
77import { ICell } from '../../../../client/datascience/types' ;
88import { extractInputText , getSelectedAndFocusedInfo , IMainState } from '../../mainState' ;
9- import { createPostableAction } from '../helpers' ;
9+ import { postActionToExtension } from '../helpers' ;
1010import { Helpers } from './helpers' ;
1111import { CommonActionType , CommonReducerArg , ICellAction , IEditCellAction , ILinkClickAction , ISendCommandAction , IShowDataViewerAction } from './types' ;
1212
1313// These are all reducers that don't actually change state. They merely dispatch a message to the other side.
1414export namespace Transfer {
1515 export function exportCells ( arg : CommonReducerArg ) : IMainState {
1616 const cellContents = arg . prevState . cellVMs . map ( v => v . cell ) ;
17- arg . queueAction ( createPostableAction ( InteractiveWindowMessages . Export , cellContents ) ) ;
17+ postActionToExtension ( arg , InteractiveWindowMessages . Export , cellContents ) ;
1818
1919 // Indicate busy
2020 return {
@@ -27,46 +27,46 @@ export namespace Transfer {
2727 // Note: this is assuming editor contents have already been saved. That should happen as a result of focus change
2828
2929 // Actually waiting for save results before marking as not dirty, so don't do it here.
30- arg . queueAction ( createPostableAction ( InteractiveWindowMessages . SaveAll , { cells : arg . prevState . cellVMs . map ( cvm => cvm . cell ) } ) ) ;
30+ postActionToExtension ( arg , InteractiveWindowMessages . SaveAll , { cells : arg . prevState . cellVMs . map ( cvm => cvm . cell ) } ) ;
3131 return arg . prevState ;
3232 }
3333
3434 export function showDataViewer ( arg : CommonReducerArg < CommonActionType , IShowDataViewerAction > ) : IMainState {
35- arg . queueAction ( createPostableAction ( InteractiveWindowMessages . ShowDataViewer , { variable : arg . payload . data . variable , columnSize : arg . payload . data . columnSize } ) ) ;
35+ postActionToExtension ( arg , InteractiveWindowMessages . ShowDataViewer , { variable : arg . payload . data . variable , columnSize : arg . payload . data . columnSize } ) ;
3636 return arg . prevState ;
3737 }
3838
3939 export function sendCommand ( arg : CommonReducerArg < CommonActionType , ISendCommandAction > ) : IMainState {
40- arg . queueAction ( createPostableAction ( InteractiveWindowMessages . NativeCommand , { command : arg . payload . data . command , source : arg . payload . data . commandType } ) ) ;
40+ postActionToExtension ( arg , InteractiveWindowMessages . NativeCommand , { command : arg . payload . data . command , source : arg . payload . data . commandType } ) ;
4141 return arg . prevState ;
4242 }
4343
4444 export function showPlot ( arg : CommonReducerArg < CommonActionType | InteractiveWindowMessages , string | undefined > ) : IMainState {
4545 if ( arg . payload . data ) {
46- arg . queueAction ( createPostableAction ( InteractiveWindowMessages . ShowPlot , arg . payload . data ) ) ;
46+ postActionToExtension ( arg , InteractiveWindowMessages . ShowPlot , arg . payload . data ) ;
4747 }
4848 return arg . prevState ;
4949 }
5050
5151 export function linkClick ( arg : CommonReducerArg < CommonActionType , ILinkClickAction > ) : IMainState {
5252 if ( arg . payload . data . href . startsWith ( 'data:image/png' ) ) {
53- arg . queueAction ( createPostableAction ( InteractiveWindowMessages . SavePng , arg . payload . data . href ) ) ;
53+ postActionToExtension ( arg , InteractiveWindowMessages . SavePng , arg . payload . data . href ) ;
5454 } else {
55- arg . queueAction ( createPostableAction ( InteractiveWindowMessages . OpenLink , arg . payload . data . href ) ) ;
55+ postActionToExtension ( arg , InteractiveWindowMessages . OpenLink , arg . payload . data . href ) ;
5656 }
5757 return arg . prevState ;
5858 }
5959
6060 export function getAllCells ( arg : CommonReducerArg ) : IMainState {
6161 const cells = arg . prevState . cellVMs . map ( c => c . cell ) ;
62- arg . queueAction ( createPostableAction ( InteractiveWindowMessages . ReturnAllCells , cells ) ) ;
62+ postActionToExtension ( arg , InteractiveWindowMessages . ReturnAllCells , cells ) ;
6363 return arg . prevState ;
6464 }
6565
6666 export function gotoCell ( arg : CommonReducerArg < CommonActionType , ICellAction > ) : IMainState {
6767 const cellVM = arg . prevState . cellVMs . find ( c => c . cell . id === arg . payload . data . cellId ) ;
6868 if ( cellVM && cellVM . cell . data . cell_type === 'code' ) {
69- arg . queueAction ( createPostableAction ( InteractiveWindowMessages . GotoCodeCell , { file : cellVM . cell . file , line : cellVM . cell . line } ) ) ;
69+ postActionToExtension ( arg , InteractiveWindowMessages . GotoCodeCell , { file : cellVM . cell . file , line : cellVM . cell . line } ) ;
7070 }
7171 return arg . prevState ;
7272 }
@@ -79,7 +79,7 @@ export namespace Transfer {
7979
8080 // Send a message to the other side to jump to a particular cell
8181 if ( cellVM ) {
82- arg . queueAction ( createPostableAction ( InteractiveWindowMessages . CopyCodeCell , { source : extractInputText ( cellVM , arg . prevState . settings ) } ) ) ;
82+ postActionToExtension ( arg , InteractiveWindowMessages . CopyCodeCell , { source : extractInputText ( cellVM , arg . prevState . settings ) } ) ;
8383 }
8484
8585 return arg . prevState ;
@@ -88,13 +88,13 @@ export namespace Transfer {
8888 export function gather ( arg : CommonReducerArg < CommonActionType , ICellAction > ) : IMainState {
8989 const cellVM = arg . prevState . cellVMs . find ( c => c . cell . id === arg . payload . data . cellId ) ;
9090 if ( cellVM ) {
91- arg . queueAction ( createPostableAction ( InteractiveWindowMessages . GatherCodeRequest , cellVM . cell ) ) ;
91+ postActionToExtension ( arg , InteractiveWindowMessages . GatherCodeRequest , cellVM . cell ) ;
9292 }
9393 return arg . prevState ;
9494 }
9595
9696 function postModelUpdate < T > ( arg : CommonReducerArg < CommonActionType , T > , update : NotebookModelChange ) {
97- arg . queueAction ( createPostableAction ( InteractiveWindowMessages . UpdateModel , update ) ) ;
97+ postActionToExtension ( arg , InteractiveWindowMessages . UpdateModel , update ) ;
9898 }
9999
100100 export function postModelEdit < T > ( arg : CommonReducerArg < CommonActionType , T > , forward : IEditorContentChange [ ] , reverse : IEditorContentChange [ ] , id : string ) {
@@ -199,16 +199,16 @@ export namespace Transfer {
199199
200200 export function started ( arg : CommonReducerArg ) : IMainState {
201201 // Send all of our initial requests
202- arg . queueAction ( createPostableAction ( InteractiveWindowMessages . Started ) ) ;
203- arg . queueAction ( createPostableAction ( CssMessages . GetCssRequest , { isDark : arg . prevState . baseTheme !== 'vscode-light' } ) ) ;
204- arg . queueAction ( createPostableAction ( CssMessages . GetMonacoThemeRequest , { isDark : arg . prevState . baseTheme !== 'vscode-light' } ) ) ;
205- arg . queueAction ( createPostableAction ( InteractiveWindowMessages . LoadOnigasmAssemblyRequest ) ) ;
206- arg . queueAction ( createPostableAction ( InteractiveWindowMessages . LoadTmLanguageRequest ) ) ;
202+ postActionToExtension ( arg , InteractiveWindowMessages . Started ) ;
203+ postActionToExtension ( arg , CssMessages . GetCssRequest , { isDark : arg . prevState . baseTheme !== 'vscode-light' } ) ;
204+ postActionToExtension ( arg , CssMessages . GetMonacoThemeRequest , { isDark : arg . prevState . baseTheme !== 'vscode-light' } ) ;
205+ postActionToExtension ( arg , InteractiveWindowMessages . LoadOnigasmAssemblyRequest ) ;
206+ postActionToExtension ( arg , InteractiveWindowMessages . LoadTmLanguageRequest ) ;
207207 return arg . prevState ;
208208 }
209209
210210 export function loadedAllCells ( arg : CommonReducerArg ) : IMainState {
211- arg . queueAction ( createPostableAction ( InteractiveWindowMessages . LoadAllCellsComplete , { cells : arg . prevState . cellVMs . map ( c => c . cell ) } ) ) ;
211+ postActionToExtension ( arg , InteractiveWindowMessages . LoadAllCellsComplete , { cells : arg . prevState . cellVMs . map ( c => c . cell ) } ) ;
212212 return arg . prevState ;
213213 }
214214}
0 commit comments