@@ -372,6 +372,7 @@ def run_initialized
372
372
373
373
perform_initial_indexing
374
374
check_formatter_is_available
375
+ update_server
375
376
end
376
377
377
378
#: (Hash[Symbol, untyped] message) -> void
@@ -1417,8 +1418,36 @@ def compose_bundle(message)
1417
1418
1418
1419
# We compose the bundle in a thread so that the LSP continues to work while we're checking for its validity. Once
1419
1420
# we return the response back to the editor, then the restart is triggered
1421
+ launch_bundle_compose ( "Recomposing the bundle ahead of restart" ) do |stderr , status |
1422
+ if status &.exitstatus == 0
1423
+ # Create a signal for the restart that it can skip composing the bundle and launch directly
1424
+ FileUtils . touch ( already_composed_path )
1425
+ send_message ( Result . new ( id : id , response : { success : true } ) )
1426
+ else
1427
+ # This special error code makes the extension avoid restarting in case we already know that the composed
1428
+ # bundle is not valid
1429
+ send_message (
1430
+ Error . new ( id : id , code : BUNDLE_COMPOSE_FAILED_CODE , message : "Failed to compose bundle\n #{ stderr } " ) ,
1431
+ )
1432
+ end
1433
+ end
1434
+ end
1435
+
1436
+ #: -> void
1437
+ def update_server
1438
+ launch_bundle_compose ( "Trying to update server" ) do |stderr , status |
1439
+ if status &.exitstatus == 0
1440
+ send_log_message ( "Successfully updated the server" )
1441
+ else
1442
+ send_log_message ( "Failed to update server\n #{ stderr } " , type : Constant ::MessageType ::ERROR )
1443
+ end
1444
+ end
1445
+ end
1446
+
1447
+ #: (String) { (IO, Process::Status?) -> void } -> Thread
1448
+ def launch_bundle_compose ( log , &block )
1420
1449
Thread . new do
1421
- send_log_message ( "Recomposing the bundle ahead of restart" )
1450
+ send_log_message ( log )
1422
1451
1423
1452
_stdout , stderr , status = Bundler . with_unbundled_env do
1424
1453
Open3 . capture3 (
@@ -1433,17 +1462,7 @@ def compose_bundle(message)
1433
1462
)
1434
1463
end
1435
1464
1436
- if status &.exitstatus == 0
1437
- # Create a signal for the restart that it can skip composing the bundle and launch directly
1438
- FileUtils . touch ( already_composed_path )
1439
- send_message ( Result . new ( id : id , response : { success : true } ) )
1440
- else
1441
- # This special error code makes the extension avoid restarting in case we already know that the composed
1442
- # bundle is not valid
1443
- send_message (
1444
- Error . new ( id : id , code : BUNDLE_COMPOSE_FAILED_CODE , message : "Failed to compose bundle\n #{ stderr } " ) ,
1445
- )
1446
- end
1465
+ block . call ( stderr , status )
1447
1466
end
1448
1467
end
1449
1468
0 commit comments