@@ -3,7 +3,7 @@ import * as vscode from 'vscode';
3
3
4
4
const serializer = new class implements vscode . NotebookSerializer {
5
5
6
- dataToNotebook ( data : Uint8Array ) : vscode . NotebookData {
6
+ deserializeNotebook ( data : Uint8Array ) : vscode . NotebookData {
7
7
const cells : vscode . NotebookCellData [ ] = [ ] ;
8
8
const str = Buffer . from ( data ) . toString ( ) ;
9
9
const lines = str . split ( '\n' ) ;
@@ -36,7 +36,7 @@ const serializer = new class implements vscode.NotebookSerializer {
36
36
return new vscode . NotebookData ( cells ) ;
37
37
}
38
38
39
- notebookToData ( data : vscode . NotebookData ) : Uint8Array {
39
+ serializeNotebook ( data : vscode . NotebookData ) : Uint8Array {
40
40
const lines : string [ ] = [ ] ;
41
41
for ( const cell of data . cells ) {
42
42
if ( cell . kind === vscode . NotebookCellKind . Code ) {
@@ -55,22 +55,19 @@ export function activate(context: vscode.ExtensionContext) {
55
55
const registration = vscode . notebook . registerNotebookSerializer ( 'regexpnb' , serializer , { transientOutputs : true } ) ;
56
56
57
57
// "execute" a regular expression
58
- const controller = vscode . notebook . createNotebookController ( {
59
- id : 'regex-kernel' ,
60
- label : 'RegexNB' ,
61
- supportedLanguages : [ 'plaintext' ] ,
62
- selector : { viewType : 'regexpnb' } ,
63
- executeHandler : ( executions : vscode . NotebookCellExecutionTask [ ] ) => {
64
- for ( const execution of executions ) {
58
+ const controller = vscode . notebook . createNotebookController ( 'regex-kernel' , 'regexpnb' , 'Regex' ) ;
59
+ controller . supportedLanguages = [ 'plaintext' ] ;
60
+ controller . executeHandler = ( cells : vscode . NotebookCell [ ] ) => {
61
+ for ( const cell of cells ) {
65
62
66
- execution . start ( ) ;
67
- const cellContent = execution . cell . document . getText ( ) ;
68
- const regexOutput = new vscode . NotebookCellOutputItem ( 'application/x.regexp' , cellContent ) ;
69
- execution . replaceOutput ( new vscode . NotebookCellOutput ( [ regexOutput ] ) ) ;
70
- execution . end ( ) ;
71
- }
63
+ const execution = controller . createNotebookCellExecutionTask ( cell ) ;
64
+ execution . start ( ) ;
65
+ const cellContent = execution . cell . document . getText ( ) ;
66
+ const regexOutput = new vscode . NotebookCellOutputItem ( 'application/x.regexp' , cellContent ) ;
67
+ execution . replaceOutput ( new vscode . NotebookCellOutput ( [ regexOutput ] ) ) ;
68
+ execution . end ( ) ;
72
69
}
73
- } ) ;
70
+ } ;
74
71
75
72
context . subscriptions . push ( registration , controller ) ;
76
73
}
0 commit comments