Skip to content

Commit 95170e6

Browse files
authored
(fix) no html hover info for Svelte components (#712)
The HTML language service is case insensitive, and would provide hover info for Svelte components like `Option` which have the same name like a html tag. Prevent that by returning early. #711
1 parent 00264d9 commit 95170e6

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

packages/language-server/src/plugins/html/HTMLPlugin.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,14 @@ export class HTMLPlugin implements HoverProvider, CompletionsProvider {
5050
return null;
5151
}
5252

53+
const node = html.findNodeAt(document.offsetAt(position));
54+
if (!node || node.tag?.[0].match(/[A-Z]/)) {
55+
// The language service is case insensitive, and would provide
56+
// hover info for Svelte components like `Option` which have
57+
// the same name like a html tag.
58+
return null;
59+
}
60+
5361
return this.lang.doHover(document, position, html);
5462
}
5563

packages/language-server/test/plugins/html/HTMLPlugin.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ describe('HTML Plugin', () => {
3838
assert.strictEqual(plugin.doHover(document, Position.create(0, 10)), null);
3939
});
4040

41+
it('does not provide hover info for component having the same name as a html element but being uppercase', async () => {
42+
const { plugin, document } = setup('<Div></Div>');
43+
44+
assert.deepStrictEqual(plugin.doHover(document, Position.create(0, 2)), null);
45+
});
46+
4147
it('provides completions', async () => {
4248
const { plugin, document } = setup('<');
4349

0 commit comments

Comments
 (0)