Files
vscode/extensions/markdown-language-features/src/client/inMemoryDocument.ts
Matt Bierner 7df46143a1 Experiment with switching markdown extension to use native privates
Let's try this out with one extension to start
2026-03-10 23:13:16 -07:00

36 lines
1.1 KiB
TypeScript

/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { TextDocument } from 'vscode-languageserver-textdocument';
import * as vscode from 'vscode';
import { ITextDocument } from '../types/textDocument';
export class InMemoryDocument implements ITextDocument {
readonly #doc: TextDocument;
public readonly uri: vscode.Uri;
public readonly version: number;
constructor(
uri: vscode.Uri,
contents: string,
version: number = 0,
) {
this.uri = uri;
this.version = version;
this.#doc = TextDocument.create(this.uri.toString(), 'markdown', 0, contents);
}
getText(range?: vscode.Range): string {
return this.#doc.getText(range);
}
positionAt(offset: number): vscode.Position {
const pos = this.#doc.positionAt(offset);
return new vscode.Position(pos.line, pos.character);
}
}