Skip to content

Commit 178aaa1

Browse files
committed
Fix failing tests.
1 parent ce40438 commit 178aaa1

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

src/Protocol/Models/DocumentSelector.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ public static implicit operator DocumentSelector(List<DocumentFilter> items)
3939

4040
public static implicit operator string(DocumentSelector documentSelector)
4141
{
42-
return string.Join(", ", documentSelector.Select(x => (string)x));
42+
return documentSelector != null ?
43+
string.Join(", ", documentSelector.Select(x => (string)x)) :
44+
null;
4345
}
4446

4547
public bool IsMatch(TextDocumentAttributes attributes)

src/Server/Matchers/ResolveCommandMatcher.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,8 @@ public object Process(ILspHandlerDescriptor descriptor, object parameters)
127127

128128
public object Process(ILspHandlerDescriptor descriptor, object parameters, object response)
129129
{
130-
var registrationOptions = descriptor.Registration.RegisterOptions as TextDocumentRegistrationOptions;
131-
132130
// Only pin the handler type, if we know the source handler (codelens) is also the resolver.
133-
if (registrationOptions?.DocumentSelector != null &&
131+
if (descriptor is HandlerDescriptor handlerDescriptor &&
134132
response is IEnumerable<ICanBeResolved> canBeResolveds &&
135133
descriptor?.CanBeResolvedHandlerType?.GetTypeInfo().IsAssignableFrom(descriptor.Handler.GetType()) == true)
136134
{
@@ -145,7 +143,7 @@ response is IEnumerable<ICanBeResolved> canBeResolveds &&
145143
var data = new JObject();
146144
data["data"] = item.Data;
147145
data[PrivateHandlerTypeName] = descriptor.Handler.GetType().FullName;
148-
data[PrivateHandlerKey] = registrationOptions.DocumentSelector.ToString();
146+
data[PrivateHandlerKey] = handlerDescriptor.Key;
149147
item.Data = data;
150148
}
151149
}

test/Lsp.Tests/Matchers/ResolveCommandMatcherTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,7 @@ public void Should_Update_CompletionItems_With_HandlerType()
374374
(response as CompletionList).Items.Should().Contain(item);
375375
var responseItem = (response as CompletionList).Items.First();
376376
responseItem.Data[ResolveCommandMatcher.PrivateHandlerTypeName].Value<string>().Should().NotBeNullOrEmpty();
377+
responseItem.Data[ResolveCommandMatcher.PrivateHandlerKey].Value<string>().Should().NotBeNullOrEmpty();
377378
responseItem.Data["data"]["hello"].Value<string>().Should().Be("world");
378379
}
379380

@@ -412,6 +413,7 @@ public void Should_Update_CodeLensContainer_With_HandlerType()
412413
(response as CodeLensContainer).Should().Contain(item);
413414
var responseItem = (response as CodeLensContainer).First();
414415
responseItem.Data[ResolveCommandMatcher.PrivateHandlerTypeName].Value<string>().Should().NotBeNullOrEmpty();
416+
responseItem.Data[ResolveCommandMatcher.PrivateHandlerKey].Value<string>().Should().NotBeNullOrEmpty();
415417
responseItem.Data["data"]["hello"].Value<string>().Should().Be("world");
416418
}
417419

0 commit comments

Comments
 (0)