@@ -100,6 +100,7 @@ impl Message for TraceMessage {
100
100
}
101
101
}
102
102
103
+ #[ derive( Debug ) ]
103
104
struct RpcMessage {
104
105
message : String ,
105
106
}
@@ -156,6 +157,7 @@ impl LanguageServerKind {
156
157
}
157
158
}
158
159
160
+ #[ derive( Debug ) ]
159
161
pub struct LanguageServerRpcState {
160
162
rpc_messages : VecDeque < RpcMessage > ,
161
163
last_message_kind : Option < MessageKind > ,
@@ -177,7 +179,7 @@ pub struct LspLogToolbarItemView {
177
179
_log_view_subscription : Option < Subscription > ,
178
180
}
179
181
180
- #[ derive( Copy , Clone , PartialEq , Eq ) ]
182
+ #[ derive( Debug , Copy , Clone , PartialEq , Eq ) ]
181
183
enum MessageKind {
182
184
Send ,
183
185
Receive ,
@@ -571,7 +573,7 @@ impl LogStore {
571
573
return ;
572
574
} ;
573
575
574
- let mut line_before_message_to_send = None ;
576
+ let received = kind == MessageKind :: Receive ;
575
577
let rpc_log_lines = & mut state. rpc_messages ;
576
578
if state. last_message_kind != Some ( kind) {
577
579
while rpc_log_lines. len ( ) + 1 >= MAX_STORED_LOG_ENTRIES {
@@ -586,7 +588,12 @@ impl LogStore {
586
588
message : line_before_message. to_string ( ) ,
587
589
} ) ;
588
590
}
589
- line_before_message_to_send = Some ( line_before_message) ;
591
+ // Do not send a synthetic message over the wire, it will be derived from the actual RPC message
592
+ cx. emit ( Event :: NewServerLogEntry {
593
+ id : language_server_id,
594
+ kind : LanguageServerLogType :: Rpc { received } ,
595
+ text : line_before_message. to_string ( ) ,
596
+ } ) ;
590
597
}
591
598
592
599
while rpc_log_lines. len ( ) + 1 >= MAX_STORED_LOG_ENTRIES {
@@ -599,17 +606,6 @@ impl LogStore {
599
606
} ) ;
600
607
}
601
608
602
- let received = kind == MessageKind :: Receive ;
603
- if let Some ( line_before_message) = line_before_message_to_send {
604
- self . emit_event (
605
- Event :: NewServerLogEntry {
606
- id : language_server_id,
607
- kind : LanguageServerLogType :: Rpc { received } ,
608
- text : line_before_message. to_string ( ) ,
609
- } ,
610
- cx,
611
- ) ;
612
- }
613
609
self . emit_event (
614
610
Event :: NewServerLogEntry {
615
611
id : language_server_id,
@@ -822,7 +818,6 @@ impl LogStore {
822
818
}
823
819
. and_then ( |lsp_store| lsp_store. read ( cx) . downstream_client ( ) ) ;
824
820
if let Some ( ( client, project_id) ) = downstream_client {
825
- log:: error!( "|||||||||| {text}" ) ;
826
821
client
827
822
. send ( proto:: LanguageServerLog {
828
823
project_id,
@@ -882,48 +877,48 @@ impl LspLogView {
882
877
cx. notify ( ) ;
883
878
} ) ;
884
879
885
- let events_subscriptions =
886
- cx. subscribe_in ( & log_store, window, move |log_view, _, e, window, cx| {
887
- log:: error!( "@@@@@@ {e:?}" ) ;
888
- match e {
889
- Event :: NewServerLogEntry { id, kind, text } => {
890
- if log_view. current_server_id == Some ( * id)
891
- && LogKind :: from_server_log_type ( kind) == log_view. active_entry_kind
892
- {
893
- log_view. editor . update ( cx, |editor, cx| {
894
- editor. set_read_only ( false ) ;
895
- let last_offset = editor. buffer ( ) . read ( cx) . len ( cx) ;
896
- let newest_cursor_is_at_end =
897
- editor. selections . newest :: < usize > ( cx) . start >= last_offset;
898
- editor. edit (
899
- vec ! [
900
- ( last_offset..last_offset, text. as_str( ) ) ,
901
- ( last_offset..last_offset, "\n " ) ,
902
- ] ,
880
+ let events_subscriptions = cx. subscribe_in (
881
+ & log_store,
882
+ window,
883
+ move |log_view, _, e, window, cx| match e {
884
+ Event :: NewServerLogEntry { id, kind, text } => {
885
+ if log_view. current_server_id == Some ( * id)
886
+ && LogKind :: from_server_log_type ( kind) == log_view. active_entry_kind
887
+ {
888
+ log_view. editor . update ( cx, |editor, cx| {
889
+ editor. set_read_only ( false ) ;
890
+ let last_offset = editor. buffer ( ) . read ( cx) . len ( cx) ;
891
+ let newest_cursor_is_at_end =
892
+ editor. selections . newest :: < usize > ( cx) . start >= last_offset;
893
+ editor. edit (
894
+ vec ! [
895
+ ( last_offset..last_offset, text. as_str( ) ) ,
896
+ ( last_offset..last_offset, "\n " ) ,
897
+ ] ,
898
+ cx,
899
+ ) ;
900
+ if text. len ( ) > 1024
901
+ && let Some ( ( fold_offset, _) ) =
902
+ text. char_indices ( ) . dropping ( 1024 ) . next ( )
903
+ && fold_offset < text. len ( )
904
+ {
905
+ editor. fold_ranges (
906
+ vec ! [ last_offset + fold_offset..last_offset + text. len( ) ] ,
907
+ false ,
908
+ window,
903
909
cx,
904
910
) ;
905
- if text. len ( ) > 1024
906
- && let Some ( ( fold_offset, _) ) =
907
- text. char_indices ( ) . dropping ( 1024 ) . next ( )
908
- && fold_offset < text. len ( )
909
- {
910
- editor. fold_ranges (
911
- vec ! [ last_offset + fold_offset..last_offset + text. len( ) ] ,
912
- false ,
913
- window,
914
- cx,
915
- ) ;
916
- }
911
+ }
917
912
918
- if newest_cursor_is_at_end {
919
- editor. request_autoscroll ( Autoscroll :: bottom ( ) , cx) ;
920
- }
921
- editor. set_read_only ( true ) ;
922
- } ) ;
923
- }
913
+ if newest_cursor_is_at_end {
914
+ editor. request_autoscroll ( Autoscroll :: bottom ( ) , cx) ;
915
+ }
916
+ editor. set_read_only ( true ) ;
917
+ } ) ;
924
918
}
925
919
}
926
- } ) ;
920
+ } ,
921
+ ) ;
927
922
let ( editor, editor_subscriptions) = Self :: editor_for_logs ( String :: new ( ) , window, cx) ;
928
923
929
924
let focus_handle = cx. focus_handle ( ) ;
0 commit comments