Skip to content

Commit 8a894e6

Browse files
Fixes #80, ensure we check for registrations.
1 parent b00f395 commit 8a894e6

File tree

3 files changed

+5
-23
lines changed

3 files changed

+5
-23
lines changed

src/Protocol/Client/RegisterCapabilityExtensions.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,7 @@ public static class RegisterCapabilityExtensions
1111
{
1212
public static async Task RegisterCapability(this IResponseRouter mediator, RegistrationParams @params)
1313
{
14-
try
15-
{
1614
await mediator.SendRequest(Client.ClientNames.RegisterCapability, @params);
17-
}
18-
catch (Exception e)
19-
{
20-
// VsCode today does not implement LSP properly.
21-
await mediator.SendRequest("client/registerFeature", @params);
22-
}
2315
}
2416
}
2517
}

src/Protocol/Client/UnregisterCapabilityExtensions.cs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,7 @@ public static class UnregisterCapabilityExtensions
1616
{
1717
public static async Task UnregisterCapability(this IResponseRouter mediator, UnregistrationParams @params)
1818
{
19-
try
20-
{
21-
await mediator.SendRequest(ClientNames.UnregisterCapability, @params);
22-
}
23-
catch (Exception e)
24-
{
25-
// VsCode today does not implement LSP properly.
26-
await mediator.SendRequest("client/unregisterFeature", @params);
27-
}
19+
await mediator.SendRequest(ClientNames.UnregisterCapability, @params);
2820
}
2921
}
3022
}

src/Server/LanguageServer.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,8 @@ public IDisposable AddHandler(string method, IJsonRpcHandler handler)
107107
{
108108
var foundItems = _collection
109109
.Where(x => handler == x.Handler)
110-
.Where(x => x.AllowsDynamicRegistration)
110+
.Where(x => x.AllowsDynamicRegistration && x.HasRegistration)
111111
.Select(x => x.Registration)
112-
.Where(x => x != null)
113112
.ToArray();
114113

115114
Task.Run(() => this.UnregisterCapability(new UnregistrationParams()
@@ -140,9 +139,8 @@ public IDisposable AddHandlers(params IJsonRpcHandler[] handlers)
140139
var foundItems = handlers
141140
.SelectMany(handler => _collection
142141
.Where(x => handler == x.Handler)
143-
.Where(x => x.AllowsDynamicRegistration)
144-
.Select(x => x.Registration)
145-
.Where(x => x != null))
142+
.Where(x => x.AllowsDynamicRegistration && x.HasRegistration)
143+
.Select(x => x.Registration))
146144
.ToArray();
147145

148146
Task.Run(() => this.UnregisterCapability(new UnregistrationParams()
@@ -324,7 +322,7 @@ private void ProcessCapabilties(object instance)
324322
private async Task DynamicallyRegisterHandlers()
325323
{
326324
var registrations = _collection
327-
.Where(x => x.AllowsDynamicRegistration)
325+
.Where(x => x.AllowsDynamicRegistration && x.HasRegistration)
328326
.Select(handler => handler.Registration)
329327
.ToList();
330328

0 commit comments

Comments
 (0)