Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ function preprocessSvelteFile(document: Document, options: SvelteSnapshotOptions
export class SvelteDocumentSnapshot implements DocumentSnapshot {
private mapper?: DocumentMapper;
private lineOffsets?: number[];
private url = pathToUrl(this.filePath);
private url = this.fileUrl;

version = this.parent.version;
isSvelte5Plus = Number(this.svelteVersion?.split('.')[0]) >= 5;
Expand All @@ -281,7 +281,11 @@ export class SvelteDocumentSnapshot implements DocumentSnapshot {
private readonly exportedNames: IExportedNames,
private readonly tsxMap?: EncodedSourceMap,
private readonly htmlAst?: TemplateNode
) {}
) { }

get fileUrl() {
return this.parent.getURL() || '';
}

get filePath() {
return this.parent.getFilePath() || '';
Expand Down
7 changes: 5 additions & 2 deletions packages/language-server/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,16 @@ export function clamp(num: number, min: number, max: number): number {

export function urlToPath(stringUrl: string): string | null {
const url = URI.parse(stringUrl);
if (url.scheme !== 'file') {
if (url.scheme === 'http' || url.scheme === 'https') {
return null;
}
return url.fsPath.replace(/\\/g, '/');
}

export function pathToUrl(path: string) {
export function pathToUrl(path: string, scheme?: string) {
const baseUri = URI.file(path);
if (scheme)
return baseUri.with({ scheme: scheme }).toString();
return URI.file(path).toString();
}

Expand Down
2 changes: 1 addition & 1 deletion packages/svelte-vscode/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ export function activateSvelteLanguageServer(context: ExtensionContext) {
}

const clientOptions: LanguageClientOptions = {
documentSelector: [{ scheme: 'file', language: 'svelte' }],
documentSelector: [{ scheme: '*', language: 'svelte' }],
revealOutputChannelOn: RevealOutputChannelOn.Never,
synchronize: {
// TODO deprecated, rework upon next VS Code minimum version bump
Expand Down