From ae56434cedc2039828dceafc598d75aad693c396 Mon Sep 17 00:00:00 2001 From: cooolbros Date: Sun, 16 Apr 2023 22:32:07 +1000 Subject: [PATCH] Use posix object in path/posix --- extension/lib/server/VDF/VDFLanguageServer.ts | 18 +++++++++--------- .../lib/server/VDF/VGUI/VGUILanguageServer.ts | 14 +++++++------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/extension/lib/server/VDF/VDFLanguageServer.ts b/extension/lib/server/VDF/VDFLanguageServer.ts index 75bc0e17..46c8b372 100644 --- a/extension/lib/server/VDF/VDFLanguageServer.ts +++ b/extension/lib/server/VDF/VDFLanguageServer.ts @@ -13,7 +13,7 @@ import type { VDFDocumentSymbol } from "$lib/VDFDocumentSymbols/VDFDocumentSymbo import { VDFDocumentSymbols } from "$lib/VDFDocumentSymbols/VDFDocumentSymbols" import { VDFFormat } from "$lib/VDFFormat/VDFFormat" import type { VDFFormatStringifyOptions } from "$lib/VDFFormat/VDFFormatStringifyOptions" -import { basename, dirname, relative } from "path/posix" +import { posix } from "path" import { findBestMatch } from "string-similarity" import { CodeAction, CodeActionKind, CodeActionParams, CodeLens, CodeLensParams, ColorInformation, ColorPresentation, ColorPresentationParams, Command, CompletionItem, CompletionItemKind, CompletionParams, Connection, Definition, DefinitionParams, Diagnostic, DiagnosticSeverity, DocumentColorParams, DocumentFormattingParams, DocumentLink, DocumentLinkParams, Location, Position, PrepareRenameParams, Range, ReferenceParams, RenameParams, ServerCapabilities, TextDocumentChangeEvent, TextEdit, WorkspaceEdit } from "vscode-languageserver" import type { TextDocument } from "vscode-languageserver-textdocument" @@ -117,10 +117,10 @@ export abstract class VDFLanguageServer extends LanguageServer documentSymbol.key == "#base" && documentSymbol.detail != undefined) @@ -567,8 +567,8 @@ export abstract class VDFLanguageServer extends LanguageServer => { const hudRoot = this.documentHUDRoots.get(documentLink.data.uri) if (hudRoot) { - const vmtPath = `${hudRoot}/${normalize(`materials/vgui/${documentLink.data.value}.vmt`)}` + const vmtPath = `${hudRoot}/${posix.normalize(`materials/vgui/${documentLink.data.value}.vmt`)}` if (await this.fileSystem.exists(vmtPath)) { documentLink.target = vmtPath return documentLink } } - documentLink.target = `vpk:///${normalize(`materials/vgui/${documentLink.data.value.toLowerCase()}.vmt`)}?vpk=misc` + documentLink.target = `vpk:///${posix.normalize(`materials/vgui/${documentLink.data.value.toLowerCase()}.vmt`)}?vpk=misc` return documentLink } }, @@ -156,7 +156,7 @@ export class VGUILanguageServer extends VDFLanguageServer { } } - const vpkFilePath = `vpk:///${normalize(`${encodeBaseValue(documentLink.data.value.toLowerCase())}`)}?vpk=misc` + const vpkFilePath = `vpk:///${posix.normalize(`${encodeBaseValue(documentLink.data.value.toLowerCase())}`)}?vpk=misc` if (await this.fileSystem.exists(vpkFilePath)) { documentLink.target = vpkFilePath } @@ -261,7 +261,7 @@ export class VGUILanguageServer extends VDFLanguageServer { promises.push(...iterateDirectory(entryUri)) } } - else if (type == 1 && extname(entry) == ".res") { + else if (type == 1 && posix.extname(entry) == ".res") { const file = this.fileSystem.readFile(entryUri) promises.push(file) file @@ -306,7 +306,7 @@ export class VGUILanguageServer extends VDFLanguageServer { return documentSymbols })() - const folderUri = dirname(uri) + const folderUri = posix.dirname(uri) const baseFiles: string[] = [] // Add definition file even if no definitions are declared, since they can be added later e.g. If the entry file has only #base statements @@ -492,7 +492,7 @@ export class VGUILanguageServer extends VDFLanguageServer { const folder = "materials/vgui" const detail = encodeBaseValue(documentSymbol.detail!.toLowerCase()) - const newPath = relative(folder, `${folder}/${detail}`) + const newPath = posix.relative(folder, `${folder}/${detail}`) if (detail != newPath) { return {