Pass along correct lsp type

Fixes #298733
This commit is contained in:
Matt Bierner
2026-06-04 09:31:54 -07:00
parent ea8e43b23f
commit 4eee2b2f6d
3 changed files with 17 additions and 13 deletions
+4 -4
View File
@@ -18,7 +18,7 @@
"punycode": "^2.3.1",
"vscode-languageclient": "^8.0.2",
"vscode-languageserver-textdocument": "^1.0.11",
"vscode-markdown-languageserver": "0.5.0-alpha.15",
"vscode-markdown-languageserver": "0.5.0-alpha.16",
"vscode-uri": "^3.0.3",
"yaml": "^2.8.3"
},
@@ -682,9 +682,9 @@
"license": "MIT"
},
"node_modules/vscode-markdown-languageserver": {
"version": "0.5.0-alpha.15",
"resolved": "https://registry.npmjs.org/vscode-markdown-languageserver/-/vscode-markdown-languageserver-0.5.0-alpha.15.tgz",
"integrity": "sha512-gXaVQKRJeOZ7uKkeWc3zS4fjtOUAZjQpPECWyN6dhVUJ4VWdSZ7iGip6mXfAT4ZUD9KpgQOFMSvvTmQzWDuMbg==",
"version": "0.5.0-alpha.16",
"resolved": "https://registry.npmjs.org/vscode-markdown-languageserver/-/vscode-markdown-languageserver-0.5.0-alpha.16.tgz",
"integrity": "sha512-UpjoYwCFcIcQL/vbIpTVy00p5WD3nO3lnrTrv0+wvS7mTDJVdQizkhc4iOTKSbIp5r0M1e+HeNWwSR2RlavMbA==",
"license": "MIT",
"dependencies": {
"@vscode/l10n": "^0.0.11",
@@ -893,7 +893,7 @@
"punycode": "^2.3.1",
"vscode-languageclient": "^8.0.2",
"vscode-languageserver-textdocument": "^1.0.11",
"vscode-markdown-languageserver": "0.5.0-alpha.15",
"vscode-markdown-languageserver": "0.5.0-alpha.16",
"vscode-uri": "^3.0.3",
"yaml": "^2.8.3"
},
@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import * as vscode from 'vscode';
import { BaseLanguageClient, LanguageClientOptions, NotebookDocumentSyncRegistrationType, Range, TextEdit } from 'vscode-languageclient';
import * as lsp from 'vscode-languageclient';
import { IMdParser } from '../markdownEngine';
import { IDisposable } from '../util/dispose';
import { looksLikeMarkdownPath, markdownFileExtensions, markdownLanguageIds } from '../util/file';
@@ -13,15 +13,19 @@ import { InMemoryDocument } from './inMemoryDocument';
import * as proto from './protocol';
import { VsCodeMdWorkspace } from './workspace';
export type LanguageClientConstructor = (name: string, description: string, clientOptions: LanguageClientOptions) => BaseLanguageClient;
export type LanguageClientConstructor = (name: string, description: string, clientOptions: lsp.LanguageClientOptions) => lsp.BaseLanguageClient;
function toLspRange(range: vscode.Range): lsp.Range {
return lsp.Range.create(range.start.line, range.start.character, range.end.line, range.end.character);
}
export class MdLanguageClient implements IDisposable {
readonly #client: BaseLanguageClient;
readonly #client: lsp.BaseLanguageClient;
readonly #workspace: VsCodeMdWorkspace;
constructor(
client: BaseLanguageClient,
client: lsp.BaseLanguageClient,
workspace: VsCodeMdWorkspace,
) {
this.#client = client;
@@ -48,7 +52,7 @@ export class MdLanguageClient implements IDisposable {
prepareUpdatePastedLinks(doc: vscode.Uri, ranges: readonly vscode.Range[], token: vscode.CancellationToken) {
return this.#client.sendRequest(proto.prepareUpdatePastedLinks, {
uri: doc.toString(),
ranges: ranges.map(range => Range.create(range.start.line, range.start.character, range.end.line, range.end.character)),
ranges: ranges.map(toLspRange),
}, token);
}
@@ -56,7 +60,7 @@ export class MdLanguageClient implements IDisposable {
return this.#client.sendRequest(proto.getUpdatePastedLinksEdit, {
metadata,
pasteIntoDoc: pastingIntoDoc.toString(),
edits: edits.map(edit => TextEdit.replace(edit.range, edit.newText)),
edits: edits.map(edit => lsp.TextEdit.replace(toLspRange(edit.range), edit.newText)),
}, token);
}
}
@@ -65,7 +69,7 @@ export async function startClient(factory: LanguageClientConstructor, parser: IM
const mdFileGlob = `**/*.{${markdownFileExtensions.join(',')}}`;
const clientOptions: LanguageClientOptions = {
const clientOptions: lsp.LanguageClientOptions = {
documentSelector: markdownLanguageIds,
synchronize: {
configurationSection: ['markdown'],
@@ -91,7 +95,7 @@ export async function startClient(factory: LanguageClientConstructor, parser: IM
client.registerProposedFeatures();
const notebookFeature = client.getFeature(NotebookDocumentSyncRegistrationType.method);
const notebookFeature = client.getFeature(lsp.NotebookDocumentSyncRegistrationType.method);
if (notebookFeature !== undefined) {
notebookFeature.register({
id: String(Date.now()),