@@ -6,15 +6,15 @@ import { IEditorContentChange, InteractiveWindowMessages, NotebookModelChange }
6
6
import { CssMessages } from '../../../../client/datascience/messages' ;
7
7
import { ICell } from '../../../../client/datascience/types' ;
8
8
import { extractInputText , getSelectedAndFocusedInfo , IMainState } from '../../mainState' ;
9
- import { createPostableAction } from '../helpers' ;
9
+ import { postActionToExtension } from '../helpers' ;
10
10
import { Helpers } from './helpers' ;
11
11
import { CommonActionType , CommonReducerArg , ICellAction , IEditCellAction , ILinkClickAction , ISendCommandAction , IShowDataViewerAction } from './types' ;
12
12
13
13
// These are all reducers that don't actually change state. They merely dispatch a message to the other side.
14
14
export namespace Transfer {
15
15
export function exportCells ( arg : CommonReducerArg ) : IMainState {
16
16
const cellContents = arg . prevState . cellVMs . map ( v => v . cell ) ;
17
- arg . queueAction ( createPostableAction ( InteractiveWindowMessages . Export , cellContents ) ) ;
17
+ postActionToExtension ( arg , InteractiveWindowMessages . Export , cellContents ) ;
18
18
19
19
// Indicate busy
20
20
return {
@@ -27,46 +27,46 @@ export namespace Transfer {
27
27
// Note: this is assuming editor contents have already been saved. That should happen as a result of focus change
28
28
29
29
// 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 ) } ) ;
31
31
return arg . prevState ;
32
32
}
33
33
34
34
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 } ) ;
36
36
return arg . prevState ;
37
37
}
38
38
39
39
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 } ) ;
41
41
return arg . prevState ;
42
42
}
43
43
44
44
export function showPlot ( arg : CommonReducerArg < CommonActionType | InteractiveWindowMessages , string | undefined > ) : IMainState {
45
45
if ( arg . payload . data ) {
46
- arg . queueAction ( createPostableAction ( InteractiveWindowMessages . ShowPlot , arg . payload . data ) ) ;
46
+ postActionToExtension ( arg , InteractiveWindowMessages . ShowPlot , arg . payload . data ) ;
47
47
}
48
48
return arg . prevState ;
49
49
}
50
50
51
51
export function linkClick ( arg : CommonReducerArg < CommonActionType , ILinkClickAction > ) : IMainState {
52
52
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 ) ;
54
54
} else {
55
- arg . queueAction ( createPostableAction ( InteractiveWindowMessages . OpenLink , arg . payload . data . href ) ) ;
55
+ postActionToExtension ( arg , InteractiveWindowMessages . OpenLink , arg . payload . data . href ) ;
56
56
}
57
57
return arg . prevState ;
58
58
}
59
59
60
60
export function getAllCells ( arg : CommonReducerArg ) : IMainState {
61
61
const cells = arg . prevState . cellVMs . map ( c => c . cell ) ;
62
- arg . queueAction ( createPostableAction ( InteractiveWindowMessages . ReturnAllCells , cells ) ) ;
62
+ postActionToExtension ( arg , InteractiveWindowMessages . ReturnAllCells , cells ) ;
63
63
return arg . prevState ;
64
64
}
65
65
66
66
export function gotoCell ( arg : CommonReducerArg < CommonActionType , ICellAction > ) : IMainState {
67
67
const cellVM = arg . prevState . cellVMs . find ( c => c . cell . id === arg . payload . data . cellId ) ;
68
68
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 } ) ;
70
70
}
71
71
return arg . prevState ;
72
72
}
@@ -79,7 +79,7 @@ export namespace Transfer {
79
79
80
80
// Send a message to the other side to jump to a particular cell
81
81
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 ) } ) ;
83
83
}
84
84
85
85
return arg . prevState ;
@@ -88,13 +88,13 @@ export namespace Transfer {
88
88
export function gather ( arg : CommonReducerArg < CommonActionType , ICellAction > ) : IMainState {
89
89
const cellVM = arg . prevState . cellVMs . find ( c => c . cell . id === arg . payload . data . cellId ) ;
90
90
if ( cellVM ) {
91
- arg . queueAction ( createPostableAction ( InteractiveWindowMessages . GatherCodeRequest , cellVM . cell ) ) ;
91
+ postActionToExtension ( arg , InteractiveWindowMessages . GatherCodeRequest , cellVM . cell ) ;
92
92
}
93
93
return arg . prevState ;
94
94
}
95
95
96
96
function postModelUpdate < T > ( arg : CommonReducerArg < CommonActionType , T > , update : NotebookModelChange ) {
97
- arg . queueAction ( createPostableAction ( InteractiveWindowMessages . UpdateModel , update ) ) ;
97
+ postActionToExtension ( arg , InteractiveWindowMessages . UpdateModel , update ) ;
98
98
}
99
99
100
100
export function postModelEdit < T > ( arg : CommonReducerArg < CommonActionType , T > , forward : IEditorContentChange [ ] , reverse : IEditorContentChange [ ] , id : string ) {
@@ -199,16 +199,16 @@ export namespace Transfer {
199
199
200
200
export function started ( arg : CommonReducerArg ) : IMainState {
201
201
// 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 ) ;
207
207
return arg . prevState ;
208
208
}
209
209
210
210
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 ) } ) ;
212
212
return arg . prevState ;
213
213
}
214
214
}
0 commit comments