@@ -335,9 +335,10 @@ export const activate = (context: vscode.ExtensionContext) => {
335335 value as UpdateMessageContents ;
336336 const doc = get_document ( current_update . file_path ) ;
337337 if ( doc === undefined ) {
338- send_result ( id , {
339- Err : `No open document for ${ current_update . file_path } ` ,
340- } ) ;
338+ sendResult (
339+ id ,
340+ `No open document for ${ current_update . file_path } ` ,
341+ ) ;
341342 break ;
342343 }
343344 if ( current_update . contents !== undefined ) {
@@ -421,7 +422,7 @@ export const activate = (context: vscode.ExtensionContext) => {
421422 ) ;
422423 }
423424 }
424- send_result ( id ) ;
425+ sendResult ( id ) ;
425426 break ;
426427 }
427428
@@ -438,12 +439,13 @@ export const activate = (context: vscode.ExtensionContext) => {
438439 document ,
439440 current_editor ?. viewColumn ,
440441 ) ;
441- send_result ( id ) ;
442+ sendResult ( id ) ;
442443 } ,
443444 ( reason ) =>
444- send_result ( id , {
445- Err : `Error: unable to open file ${ current_file } : ${ reason } ` ,
446- } ) ,
445+ sendResult (
446+ id ,
447+ `Error: unable to open file ${ current_file } : ${ reason } ` ,
448+ ) ,
447449 ) ;
448450 } else {
449451 // TODO: open using a custom document editor.
@@ -466,14 +468,15 @@ export const activate = (context: vscode.ExtensionContext) => {
466468 } ,
467469 )
468470 . then (
469- ( ) => send_result ( id ) ,
471+ ( ) => sendResult ( id ) ,
470472 ( reason ) =>
471- send_result ( id , {
472- Err : `Error: unable to open file ${ current_file } : ${ reason } ` ,
473- } ) ,
473+ sendResult (
474+ id ,
475+ `Error: unable to open file ${ current_file } : ${ reason } ` ,
476+ ) ,
474477 ) ;
475478 }
476- send_result ( id ) ;
479+ sendResult ( id ) ;
477480 }
478481 break ;
479482 }
@@ -509,19 +512,18 @@ export const activate = (context: vscode.ExtensionContext) => {
509512 const doc = get_document ( load_file ) ;
510513 const load_file_result =
511514 doc === undefined ? null : doc . getText ( ) ;
512- send_result ( id , {
513- Ok : {
514- LoadFile : load_file_result ,
515- } ,
516- } ) ;
515+ codeChatEditorServer . sendResultLoadfile (
516+ id ,
517+ load_file_result ,
518+ ) ;
517519 break ;
518520 }
519521
520522 case "ClientHtml" : {
521523 const client_html = value as string ;
522524 assert ( webview_panel !== undefined ) ;
523525 webview_panel . webview . html = client_html ;
524- send_result ( id ) ;
526+ sendResult ( id ) ;
525527 // Now that the Client is loaded, send the editor's
526528 // current file to the server.
527529 send_update ( false ) ;
@@ -599,22 +601,12 @@ const report_server_timeout = (message_id: number) => {
599601} ;
600602
601603// Send a result (a response to a message from the server) back to the server.
602- const send_result = ( id : number , result : MessageResult = { Ok : "Void" } ) => {
603- // We can't simply call `send_message` because that function expects a
604- // result message back from the server.
605- const jm : EditorMessage = {
606- id,
607- message : {
608- Result : result ,
609- } ,
610- } ;
604+ const sendResult = ( id : number , result : string | null = null ) => {
611605 assert ( codeChatEditorServer ) ;
612606 console_log (
613- `CodeChat Editor extension: sending result ${ JSON . stringify (
614- jm ,
615- ) . substring ( 0 , MAX_MESSAGE_LENGTH ) } .`,
607+ `CodeChat Editor extension: sending result ${ format_struct ( result ) } .` ,
616608 ) ;
617- codeChatEditorServer . sendMessage ( JSON . stringify ( jm ) ) ;
609+ codeChatEditorServer . sendResult ( id , result ) ;
618610} ;
619611
620612// This is called after an event such as an edit, when the CodeChat panel
0 commit comments