@@ -9,6 +9,10 @@ import { ERR_UNKNOWN } from "@open-rpc/client-js/build/Error";
99
1010import { onWsMessage , sendMessage } from "@features/ws/services" ;
1111import { ClientMessageKind , ServerMessageKind } from "@features/ws/types" ;
12+ import { ProgressParams } from "../types" ;
13+ import { endLoadingLsp , updateLoadingLsp } from "../services" ;
14+ import { MessageType , ShowMessageParams } from "vscode-languageserver-protocol" ;
15+ import { showToast , ToastKind } from "@services/toast" ;
1216
1317const ignoredNotify = {
1418 "textDocument/didOpen" : "open" ,
@@ -18,11 +22,57 @@ const ignoredNotify = {
1822export class RsLspTransport extends Transport {
1923 public async connect ( ) : Promise < void > {
2024 onWsMessage ( ServerMessageKind . Lsp , ( { data } ) => {
25+ if (
26+ "method" in data && "params" in data &&
27+ this . handleWorkDone ( data . method as string , data . params )
28+ ) {
29+ return ;
30+ }
31+
2132 // @ts -expect-error -- resolveRes is private, but needed for performance issues
2233 this . transportRequestManager . resolveRes ( data ) ;
2334 } ) ;
2435 }
2536
37+ private handleWorkDone ( method : string , params_ : unknown ) : boolean {
38+ if ( method == "window/showMessage" ) {
39+ let params = params_ as ShowMessageParams ;
40+
41+ let kind : ToastKind = "info" ;
42+
43+ if ( params . type == MessageType . Debug ) {
44+ kind = "debug" ;
45+ } else if ( params . type == MessageType . Error ) {
46+ kind = "error" ;
47+ } else if ( params . type == MessageType . Warning ) {
48+ kind = "warn" ;
49+ }
50+
51+ showToast ( kind , { text : params . message } ) ;
52+
53+ return true ;
54+ }
55+
56+ if ( method != "$/progress" ) {
57+ return false ;
58+ }
59+
60+ const progress = ( params_ as ProgressParams ) . value ;
61+
62+ if ( progress . kind == "begin" ) {
63+ updateLoadingLsp ( { title : progress . title , message : "" } ) ;
64+ } else if ( progress . kind == "report" ) {
65+ updateLoadingLsp ( {
66+ message : progress . message ,
67+ percentage : progress . percentage ,
68+ } ) ;
69+ } else if ( progress . kind == "end" ) {
70+ endLoadingLsp ( ) ;
71+ }
72+
73+ return true ;
74+ }
75+
2676 public async sendData (
2777 data : JSONRPCRequestData ,
2878 timeout : number | null = 5000 ,
0 commit comments