@@ -38,7 +38,7 @@ pub struct LogStore {
3838}
3939
4040struct ProjectState {
41- _subscriptions : [ gpui:: Subscription ; 3 ] ,
41+ _subscriptions : [ gpui:: Subscription ; 2 ] ,
4242}
4343
4444trait Message : AsRef < str > {
@@ -259,13 +259,13 @@ impl LogStore {
259259
260260 let copilot_subscription = Copilot :: global ( cx) . map ( |copilot| {
261261 let copilot = & copilot;
262- cx. subscribe ( copilot, |this , copilot, edit_prediction_event, cx| {
262+ cx. subscribe ( copilot, |log_store , copilot, edit_prediction_event, cx| {
263263 if let copilot:: Event :: CopilotLanguageServerStarted = edit_prediction_event
264264 && let Some ( server) = copilot. read ( cx) . language_server ( )
265265 {
266266 let server_id = server. server_id ( ) ;
267267 let weak_this = cx. weak_entity ( ) ;
268- this . copilot_log_subscription =
268+ log_store . copilot_log_subscription =
269269 Some ( server. on_notification :: < copilot:: request:: LogMessage , _ > (
270270 move |params, cx| {
271271 weak_this
@@ -280,8 +280,9 @@ impl LogStore {
280280 . ok ( ) ;
281281 } ,
282282 ) ) ;
283+
283284 let name = LanguageServerName :: new_static ( "copilot" ) ;
284- this . add_language_server (
285+ log_store . add_language_server (
285286 LanguageServerKind :: Global ,
286287 server. server_id ( ) ,
287288 Some ( name) ,
@@ -293,7 +294,7 @@ impl LogStore {
293294 } )
294295 } ) ;
295296
296- let this = Self {
297+ let log_store = Self {
297298 copilot_log_subscription : None ,
298299 _copilot_subscription : copilot_subscription,
299300 projects : HashMap :: default ( ) ,
@@ -302,9 +303,9 @@ impl LogStore {
302303 io_tx,
303304 } ;
304305
305- cx. spawn ( async move |this , cx| {
306+ cx. spawn ( async move |log_store , cx| {
306307 while let Some ( ( server_id, io_kind, message) ) = io_rx. next ( ) . await {
307- if let Some ( log_store) = this . upgrade ( ) {
308+ if let Some ( log_store) = log_store . upgrade ( ) {
308309 log_store. update ( cx, |log_store, cx| {
309310 log_store. on_io ( server_id, io_kind, & message, cx) ;
310311 } ) ?;
@@ -313,17 +314,11 @@ impl LogStore {
313314 anyhow:: Ok ( ( ) )
314315 } )
315316 . detach_and_log_err ( cx) ;
316- this
317+ log_store
317318 }
318319
319320 pub fn add_project ( & mut self , project : & Entity < Project > , cx : & mut Context < Self > ) {
320- log:: error!(
321- "?????????????? ssh: {} local: {}" ,
322- project. read( cx) . is_via_ssh( ) ,
323- project. read( cx) . is_local( )
324- ) ;
325321 let weak_project = project. downgrade ( ) ;
326- let subscription_weak_project = weak_project. clone ( ) ;
327322 self . projects . insert (
328323 project. downgrade ( ) ,
329324 ProjectState {
@@ -395,29 +390,6 @@ impl LogStore {
395390 _ => { }
396391 }
397392 } ) ,
398- cx. subscribe ( & cx. entity ( ) , move |_, _, e, cx| {
399- log:: error!( "||??????????????????????????????????????||||||@@@@|| {e:?}" ) ;
400- match e {
401- Event :: NewServerLogEntry { id, kind, text } => {
402- subscription_weak_project
403- . update ( cx, |project, cx| {
404- if let Some ( ( client, project_id) ) =
405- project. lsp_store ( ) . read ( cx) . downstream_client ( )
406- {
407- client
408- . send ( proto:: LanguageServerLog {
409- project_id,
410- language_server_id : id. to_proto ( ) ,
411- message : text. clone ( ) ,
412- log_type : Some ( kind. to_proto ( ) ) ,
413- } )
414- . log_err ( ) ;
415- } ;
416- } )
417- . ok ( ) ;
418- }
419- }
420- } ) ,
421393 ] ,
422394 } ,
423395 ) ;
@@ -855,11 +827,28 @@ impl LspLogView {
855827
856828 cx. notify ( ) ;
857829 } ) ;
830+
831+ let weak_lsp_store = project. read ( cx) . lsp_store ( ) . downgrade ( ) ;
858832 let events_subscriptions =
859833 cx. subscribe_in ( & log_store, window, move |log_view, _, e, window, cx| {
860834 log:: error!( "||||||||@@@@|| {e:?}" ) ;
861835 match e {
862836 Event :: NewServerLogEntry { id, kind, text } => {
837+ weak_lsp_store
838+ . update ( cx, |lsp_store, _| {
839+ if let Some ( ( client, project_id) ) = lsp_store. downstream_client ( ) {
840+ client
841+ . send ( proto:: LanguageServerLog {
842+ project_id,
843+ language_server_id : id. to_proto ( ) ,
844+ message : text. clone ( ) ,
845+ log_type : Some ( kind. to_proto ( ) ) ,
846+ } )
847+ . log_err ( ) ;
848+ } ;
849+ } )
850+ . ok ( ) ;
851+
863852 if log_view. current_server_id == Some ( * id)
864853 && LogKind :: from_server_log_type ( kind) == log_view. active_entry_kind
865854 {
@@ -904,7 +893,7 @@ impl LspLogView {
904893 window. focus ( & log_view. editor . focus_handle ( cx) ) ;
905894 } ) ;
906895
907- let mut this = Self {
896+ let mut lsp_log_view = Self {
908897 focus_handle,
909898 editor,
910899 editor_subscriptions,
@@ -919,9 +908,9 @@ impl LspLogView {
919908 ] ,
920909 } ;
921910 if let Some ( server_id) = server_id {
922- this . show_logs_for_server ( server_id, window, cx) ;
911+ lsp_log_view . show_logs_for_server ( server_id, window, cx) ;
923912 }
924- this
913+ lsp_log_view
925914 }
926915
927916 fn editor_for_logs (
@@ -1849,12 +1838,6 @@ const SERVER_LOGS: &str = "Server Logs";
18491838const SERVER_TRACE : & str = "Server Trace" ;
18501839const SERVER_INFO : & str = "Server Info" ;
18511840
1852- impl Default for LspLogToolbarItemView {
1853- fn default ( ) -> Self {
1854- Self :: new ( )
1855- }
1856- }
1857-
18581841impl LspLogToolbarItemView {
18591842 pub fn new ( ) -> Self {
18601843 Self {
0 commit comments