From d883f1e58cc733dc31e9e2b174a870b79b46c162 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=98=BF=E5=8D=A1=E7=90=B3?= Date: Fri, 2 Aug 2019 20:46:07 +0800 Subject: [PATCH 1/6] feat: Add relativeFilePath config --- src/commands/show.ts | 84 +++++++++++++++++++++++++++++------------ src/leetCodeExecutor.ts | 8 +--- 2 files changed, 61 insertions(+), 31 deletions(-) diff --git a/src/commands/show.ts b/src/commands/show.ts index 896516a9..a5cbee5f 100644 --- a/src/commands/show.ts +++ b/src/commands/show.ts @@ -1,7 +1,6 @@ // Copyright (c) jdneo. All rights reserved. // Licensed under the MIT license. -import * as fse from "fs-extra"; import * as path from "path"; import * as unescapeJS from "unescape-js"; import * as vscode from "vscode"; @@ -11,13 +10,14 @@ import { leetCodeChannel } from "../leetCodeChannel"; import { leetCodeExecutor } from "../leetCodeExecutor"; import { leetCodeManager } from "../leetCodeManager"; import { IProblem, IQuickItemEx, languages, ProblemState } from "../shared"; -import { getNodeIdFromFile } from "../utils/problemUtils"; +import { getNodeIdFromFile, genFileName, genFileExt } from "../utils/problemUtils"; import { DialogOptions, DialogType, openSettingsEditor, promptForOpenOutputChannel, promptForSignIn, promptHintMessage } from "../utils/uiUtils"; import { selectWorkspaceFolder } from "../utils/workspaceUtils"; import * as wsl from "../utils/wslUtils"; import { leetCodePreviewProvider } from "../webview/leetCodePreviewProvider"; import { leetCodeSolutionProvider } from "../webview/leetCodeSolutionProvider"; import * as list from "./list"; +import * as _ from "lodash"; export async function previewProblem(input: IProblem | vscode.Uri, isSideMode: boolean = false): Promise { let node: IProblem; @@ -132,20 +132,22 @@ async function showProblemInternal(node: IProblem): Promise { return; } - let relativePath: string = (leetCodeConfig.get("outputFolder", "")).trim(); - if (relativePath) { - relativePath = await resolveRelativePath(relativePath, node, language); - if (!relativePath) { + let outputFolder = leetCodeConfig.get("outputFolder", "").trim(); + let defaultRelativeFilePath = leetCodeConfig.get("relativeFilePath.default", path.join(outputFolder, genFileName(node, language))).trim(); + let relativeFilePath = leetCodeConfig.get(`relativeFilePath.${language}`, defaultRelativeFilePath).trim(); + + if (relativeFilePath) { + relativeFilePath = await resolveRelativePath(relativeFilePath, node, language); + if (!relativeFilePath) { leetCodeChannel.appendLine("Showing problem canceled by user."); return; } } - outDir = path.join(outDir, relativePath); - await fse.ensureDir(outDir); - - const originFilePath: string = await leetCodeExecutor.showProblem(node, language, outDir, leetCodeConfig.get("showCommentDescription")); + const originFilePath = path.join(outDir, relativeFilePath); const filePath: string = wsl.useWsl() ? await wsl.toWinPath(originFilePath) : originFilePath; + + await leetCodeExecutor.showProblem(node, language, originFilePath, leetCodeConfig.get("showCommentDescription")); await Promise.all([ vscode.window.showTextDocument(vscode.Uri.file(filePath), { preview: false, viewColumn: vscode.ViewColumn.One }), movePreviewAsideIfNeeded(node), @@ -191,26 +193,47 @@ function parseProblemDecorator(state: ProblemState, locked: boolean): string { } async function resolveRelativePath(relativePath: string, node: IProblem, selectedLanguage: string): Promise { + let tag = ""; if (/\$\{tag\}/i.test(relativePath)) { - const tag: string | undefined = await resolveTagForProblem(node); - if (!tag) { - return ""; - } - relativePath = relativePath.replace(/\$\{tag\}/ig, tag); + tag = (await resolveTagForProblem(node)) || ""; } - relativePath = relativePath.replace(/\$\{language\}/ig, selectedLanguage); - relativePath = relativePath.replace(/\$\{difficulty\}/ig, node.difficulty.toLocaleLowerCase()); - - // Check if there is any unsupported configuration - const matchResult: RegExpMatchArray | null = relativePath.match(/\$\{(.*?)\}/); - if (matchResult && matchResult.length >= 1) { - const errorMsg: string = `The config '${matchResult[1]}' is not supported.`; - leetCodeChannel.appendLine(errorMsg); - throw new Error(errorMsg); + let company = ""; + if (/\$\{company\}/i.test(relativePath)) { + company = (await resolveCompanyForProblem(node)) || ""; } - return relativePath; + return relativePath.replace(/\$\{(.*?)\}/g, (_substring, ...args) => { + const placeholder = (args[0] as string).toLowerCase().trim(); + switch (placeholder) { + case "id": + return node.id; + case "name": + return node.name; + case "camelcasename": + return _.camelCase(node.name); + case "pascalcasename": + return _.upperFirst(_.camelCase(node.name)); + case "kebab-case-name": + return _.kebabCase(node.name); + case "snake_case_name": + return _.snakeCase(node.name); + case "ext": + return genFileExt(selectedLanguage); + case "language": + return selectedLanguage; + case "difficulty": + return node.difficulty.toLocaleLowerCase(); + case "tag": + return tag; + case "company": + return company; + default: + const errorMsg: string = `The config '${placeholder}' is not supported.`; + leetCodeChannel.appendLine(errorMsg); + throw new Error(errorMsg); + } + }); } async function resolveTagForProblem(problem: IProblem): Promise { @@ -226,3 +249,14 @@ async function resolveTagForProblem(problem: IProblem): Promise { + if (problem.companies.length === 1) { + return problem.companies[0]; + } + return await vscode.window.showQuickPick(problem.companies, { + matchOnDetail: true, + placeHolder: "Multiple tags available, please select one", + ignoreFocusOut: true + }); +} diff --git a/src/leetCodeExecutor.ts b/src/leetCodeExecutor.ts index 8bef00fa..38f549c7 100644 --- a/src/leetCodeExecutor.ts +++ b/src/leetCodeExecutor.ts @@ -8,7 +8,6 @@ import * as requireFromString from "require-from-string"; import { ConfigurationChangeEvent, Disposable, MessageItem, window, workspace, WorkspaceConfiguration } from "vscode"; import { Endpoint, IProblem, supportedPlugins } from "./shared"; import { executeCommand, executeCommandWithProgress } from "./utils/cpUtils"; -import { genFileName } from "./utils/problemUtils"; import { DialogOptions, openUrl } from "./utils/uiUtils"; import * as wsl from "./utils/wslUtils"; import { toWslPath, useWsl } from "./utils/wslUtils"; @@ -96,17 +95,14 @@ class LeetCodeExecutor implements Disposable { ); } - public async showProblem(problemNode: IProblem, language: string, outDir: string, detailed: boolean = false): Promise { - const fileName: string = genFileName(problemNode, language); - const filePath: string = path.join(outDir, fileName); + public async showProblem(problemNode: IProblem, language: string, filePath: string, detailed: boolean = false): Promise { const templateType: string = detailed ? "-cx" : "-c"; if (!await fse.pathExists(filePath)) { + await fse.createFile(filePath); const codeTemplate: string = await this.executeCommandWithProgressEx("Fetching problem data...", this.nodeExecutable, [await this.getLeetCodeBinaryPath(), "show", problemNode.id, templateType, "-l", language]); await fse.writeFile(filePath, codeTemplate); } - - return filePath; } public async showSolution(input: string, language: string): Promise { From 60996e86eb64c98c51b2193586f22c91d7aaec17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=98=BF=E5=8D=A1=E7=90=B3?= Date: Fri, 2 Aug 2019 20:47:14 +0800 Subject: [PATCH 2/6] feat: Add configuration of leetcode.relativeFilePath --- package.json | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 67 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 722a0916..8fe49009 100644 --- a/package.json +++ b/package.json @@ -319,7 +319,73 @@ "leetcode.outputFolder": { "type": "string", "scope": "application", - "description": "The relative path to save the problem files." + "description": "[Deprecated] The output folder to save the problem files." + }, + "leetcode.relativeFilePath.default": { + "type": "string", + "scope": "application", + "description": "The relative Path to save the problem files.", + "default": "${id}.${camelCaseName}.${ext}" + }, + "leetcode.relativeFilePath.bash": { + "type": "string", + "scope": "application" + }, + "leetcode.relativeFilePath.c": { + "type": "string", + "scope": "application" + }, + "leetcode.relativeFilePath.cpp": { + "type": "string", + "scope": "application" + }, + "leetcode.relativeFilePath.csharp": { + "type": "string", + "scope": "application" + }, + "leetcode.relativeFilePath.golang": { + "type": "string", + "scope": "application" + }, + "leetcode.relativeFilePath.java": { + "type": "string", + "scope": "application" + }, + "leetcode.relativeFilePath.javascript": { + "type": "string", + "scope": "application" + }, + "leetcode.relativeFilePath.kotlin": { + "type": "string", + "scope": "application" + }, + "leetcode.relativeFilePath.mysql": { + "type": "string", + "scope": "application" + }, + "leetcode.relativeFilePath.php": { + "type": "string", + "scope": "application" + }, + "leetcode.relativeFilePath.python": { + "type": "string", + "scope": "application" + }, + "leetcode.relativeFilePath.python3": { + "type": "string", + "scope": "application" + }, + "leetcode.relativeFilePath.ruby": { + "type": "string", + "scope": "application" + }, + "leetcode.relativeFilePath.scala": { + "type": "string", + "scope": "application" + }, + "leetcode.relativeFilePath.swift": { + "type": "string", + "scope": "application" }, "leetcode.enableStatusBar": { "type": "boolean", From 3dc8c8dd0b935ddaddf7cbe637f63d77752e5a47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=98=BF=E5=8D=A1=E7=90=B3?= Date: Fri, 2 Aug 2019 20:58:38 +0800 Subject: [PATCH 3/6] fix: make lint happy --- src/commands/show.ts | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/commands/show.ts b/src/commands/show.ts index a5cbee5f..b1044a8f 100644 --- a/src/commands/show.ts +++ b/src/commands/show.ts @@ -1,6 +1,7 @@ // Copyright (c) jdneo. All rights reserved. // Licensed under the MIT license. +import * as _ from "lodash"; import * as path from "path"; import * as unescapeJS from "unescape-js"; import * as vscode from "vscode"; @@ -10,14 +11,13 @@ import { leetCodeChannel } from "../leetCodeChannel"; import { leetCodeExecutor } from "../leetCodeExecutor"; import { leetCodeManager } from "../leetCodeManager"; import { IProblem, IQuickItemEx, languages, ProblemState } from "../shared"; -import { getNodeIdFromFile, genFileName, genFileExt } from "../utils/problemUtils"; +import { genFileExt, genFileName, getNodeIdFromFile } from "../utils/problemUtils"; import { DialogOptions, DialogType, openSettingsEditor, promptForOpenOutputChannel, promptForSignIn, promptHintMessage } from "../utils/uiUtils"; import { selectWorkspaceFolder } from "../utils/workspaceUtils"; import * as wsl from "../utils/wslUtils"; import { leetCodePreviewProvider } from "../webview/leetCodePreviewProvider"; import { leetCodeSolutionProvider } from "../webview/leetCodeSolutionProvider"; import * as list from "./list"; -import * as _ from "lodash"; export async function previewProblem(input: IProblem | vscode.Uri, isSideMode: boolean = false): Promise { let node: IProblem; @@ -127,14 +127,14 @@ async function showProblemInternal(node: IProblem): Promise { } const leetCodeConfig: vscode.WorkspaceConfiguration = vscode.workspace.getConfiguration("leetcode"); - let outDir: string = await selectWorkspaceFolder(); + const outDir: string = await selectWorkspaceFolder(); if (!outDir) { return; } - let outputFolder = leetCodeConfig.get("outputFolder", "").trim(); - let defaultRelativeFilePath = leetCodeConfig.get("relativeFilePath.default", path.join(outputFolder, genFileName(node, language))).trim(); - let relativeFilePath = leetCodeConfig.get(`relativeFilePath.${language}`, defaultRelativeFilePath).trim(); + const outputFolder: string = leetCodeConfig.get("outputFolder", "").trim(); + const defaultRelativeFilePath: string = leetCodeConfig.get("relativeFilePath.default", path.join(outputFolder, genFileName(node, language))).trim(); + let relativeFilePath: string = leetCodeConfig.get(`relativeFilePath.${language}`, defaultRelativeFilePath).trim(); if (relativeFilePath) { relativeFilePath = await resolveRelativePath(relativeFilePath, node, language); @@ -144,7 +144,7 @@ async function showProblemInternal(node: IProblem): Promise { } } - const originFilePath = path.join(outDir, relativeFilePath); + const originFilePath: string = path.join(outDir, relativeFilePath); const filePath: string = wsl.useWsl() ? await wsl.toWinPath(originFilePath) : originFilePath; await leetCodeExecutor.showProblem(node, language, originFilePath, leetCodeConfig.get("showCommentDescription")); @@ -193,18 +193,18 @@ function parseProblemDecorator(state: ProblemState, locked: boolean): string { } async function resolveRelativePath(relativePath: string, node: IProblem, selectedLanguage: string): Promise { - let tag = ""; + let tag: string = ""; if (/\$\{tag\}/i.test(relativePath)) { tag = (await resolveTagForProblem(node)) || ""; } - let company = ""; + let company: string = ""; if (/\$\{company\}/i.test(relativePath)) { company = (await resolveCompanyForProblem(node)) || ""; } - return relativePath.replace(/\$\{(.*?)\}/g, (_substring, ...args) => { - const placeholder = (args[0] as string).toLowerCase().trim(); + return relativePath.replace(/\$\{(.*?)\}/g, (_substring: string, ...args: string[]) => { + const placeholder: string = args[0].toLowerCase().trim(); switch (placeholder) { case "id": return node.id; @@ -257,6 +257,6 @@ async function resolveCompanyForProblem(problem: IProblem): Promise Date: Tue, 6 Aug 2019 15:58:22 +0800 Subject: [PATCH 4/6] update: split relativeFilePath into path and filename --- package.json | 304 ++++++++++++++++++++++++++++++++++--------- src/commands/show.ts | 28 ++-- 2 files changed, 257 insertions(+), 75 deletions(-) diff --git a/package.json b/package.json index 8fe49009..a27b8c48 100644 --- a/package.json +++ b/package.json @@ -258,6 +258,7 @@ "python", "python3", "ruby", + "rust", "scala", "swift" ], @@ -321,71 +322,246 @@ "scope": "application", "description": "[Deprecated] The output folder to save the problem files." }, - "leetcode.relativeFilePath.default": { - "type": "string", + "leetcode.output": { + "type": "object", "scope": "application", - "description": "The relative Path to save the problem files.", - "default": "${id}.${camelCaseName}.${ext}" - }, - "leetcode.relativeFilePath.bash": { - "type": "string", - "scope": "application" - }, - "leetcode.relativeFilePath.c": { - "type": "string", - "scope": "application" - }, - "leetcode.relativeFilePath.cpp": { - "type": "string", - "scope": "application" - }, - "leetcode.relativeFilePath.csharp": { - "type": "string", - "scope": "application" - }, - "leetcode.relativeFilePath.golang": { - "type": "string", - "scope": "application" - }, - "leetcode.relativeFilePath.java": { - "type": "string", - "scope": "application" - }, - "leetcode.relativeFilePath.javascript": { - "type": "string", - "scope": "application" - }, - "leetcode.relativeFilePath.kotlin": { - "type": "string", - "scope": "application" - }, - "leetcode.relativeFilePath.mysql": { - "type": "string", - "scope": "application" - }, - "leetcode.relativeFilePath.php": { - "type": "string", - "scope": "application" - }, - "leetcode.relativeFilePath.python": { - "type": "string", - "scope": "application" - }, - "leetcode.relativeFilePath.python3": { - "type": "string", - "scope": "application" - }, - "leetcode.relativeFilePath.ruby": { - "type": "string", - "scope": "application" - }, - "leetcode.relativeFilePath.scala": { - "type": "string", - "scope": "application" - }, - "leetcode.relativeFilePath.swift": { - "type": "string", - "scope": "application" + "description": "The output path and filename to save the problem files.", + "properties": { + "default": { + "type": "object", + "properties": { + "path": { + "type": "string", + "examples": [ + "src" + ] + }, + "filename": { + "type": "string", + "examples": [ + "${camelCaseName}.${ext}", + "${PascalCaseName}.${ext}", + "${id}-${kebab-case-name}.${ext}", + "${id}_${snake_case_name}.${ext}" + ] + } + }, + "required": [ + "path", + "filename" + ] + }, + "bash": { + "type": "object", + "properties": { + "path": { + "type": "string" + }, + "filename": { + "type": "string" + } + }, + "minProperties": 1 + }, + "c": { + "type": "object", + "properties": { + "path": { + "type": "string" + }, + "filename": { + "type": "string" + } + }, + "minProperties": 1 + }, + "cpp": { + "type": "object", + "properties": { + "path": { + "type": "string" + }, + "filename": { + "type": "string" + } + }, + "minProperties": 1 + }, + "csharp": { + "type": "object", + "properties": { + "path": { + "type": "string" + }, + "filename": { + "type": "string" + } + }, + "minProperties": 1 + }, + "golang": { + "type": "object", + "properties": { + "path": { + "type": "string" + }, + "filename": { + "type": "string" + } + }, + "minProperties": 1 + }, + "java": { + "type": "object", + "properties": { + "path": { + "type": "string" + }, + "filename": { + "type": "string" + } + }, + "minProperties": 1 + }, + "javascript": { + "type": "object", + "properties": { + "path": { + "type": "string" + }, + "filename": { + "type": "string" + } + }, + "minProperties": 1 + }, + "kotlin": { + "type": "object", + "properties": { + "path": { + "type": "string" + }, + "filename": { + "type": "string" + } + }, + "minProperties": 1 + }, + "mysql": { + "type": "object", + "properties": { + "path": { + "type": "string" + }, + "filename": { + "type": "string" + } + }, + "minProperties": 1 + }, + "php": { + "type": "object", + "properties": { + "path": { + "type": "string" + }, + "filename": { + "type": "string" + } + }, + "minProperties": 1 + }, + "python": { + "type": "object", + "properties": { + "path": { + "type": "string" + }, + "filename": { + "type": "string" + } + }, + "minProperties": 1 + }, + "python3": { + "type": "object", + "properties": { + "path": { + "type": "string" + }, + "filename": { + "type": "string" + } + }, + "minProperties": 1 + }, + "ruby": { + "type": "object", + "properties": { + "path": { + "type": "string" + }, + "filename": { + "type": "string" + } + }, + "minProperties": 1 + }, + "rust": { + "type": "object", + "properties": { + "path": { + "type": "string" + }, + "filename": { + "type": "string" + } + }, + "minProperties": 1 + }, + "scala": { + "type": "object", + "properties": { + "path": { + "type": "string" + }, + "filename": { + "type": "string" + } + }, + "minProperties": 1 + }, + "swift": { + "type": "object", + "properties": { + "path": { + "type": "string" + }, + "filename": { + "type": "string" + } + }, + "minProperties": 1 + } + }, + "additionalProperties": { + "type": "object", + "properties": { + "path": { + "type": "string" + }, + "filename": { + "type": "string" + } + }, + "minProperties": 1 + }, + "default": { + "default": { + "path": "", + "filename": "${id}.${kebab-case-name}.${ext}" + } + } }, "leetcode.enableStatusBar": { "type": "boolean", diff --git a/src/commands/show.ts b/src/commands/show.ts index b1044a8f..34e63219 100644 --- a/src/commands/show.ts +++ b/src/commands/show.ts @@ -127,29 +127,35 @@ async function showProblemInternal(node: IProblem): Promise { } const leetCodeConfig: vscode.WorkspaceConfiguration = vscode.workspace.getConfiguration("leetcode"); - const outDir: string = await selectWorkspaceFolder(); - if (!outDir) { + const workspaceFolder: string = await selectWorkspaceFolder(); + if (!workspaceFolder) { return; } const outputFolder: string = leetCodeConfig.get("outputFolder", "").trim(); - const defaultRelativeFilePath: string = leetCodeConfig.get("relativeFilePath.default", path.join(outputFolder, genFileName(node, language))).trim(); - let relativeFilePath: string = leetCodeConfig.get(`relativeFilePath.${language}`, defaultRelativeFilePath).trim(); - if (relativeFilePath) { - relativeFilePath = await resolveRelativePath(relativeFilePath, node, language); - if (!relativeFilePath) { + const filePath: string = leetCodeConfig + .get(`output.${language}.path`, leetCodeConfig.get(`output.default.path`, outputFolder)) + .trim(); + const fileName: string = leetCodeConfig + .get(`output.${language}.filename`, leetCodeConfig.get(`output.default.filename`, genFileName(node, language))) + .trim(); + + let finalPath: string = path.join(workspaceFolder, filePath, fileName); + + if (finalPath) { + finalPath = await resolveRelativePath(finalPath, node, language); + if (!finalPath) { leetCodeChannel.appendLine("Showing problem canceled by user."); return; } } - const originFilePath: string = path.join(outDir, relativeFilePath); - const filePath: string = wsl.useWsl() ? await wsl.toWinPath(originFilePath) : originFilePath; + finalPath = wsl.useWsl() ? await wsl.toWinPath(finalPath) : finalPath; - await leetCodeExecutor.showProblem(node, language, originFilePath, leetCodeConfig.get("showCommentDescription")); + await leetCodeExecutor.showProblem(node, language, finalPath, leetCodeConfig.get("showCommentDescription")); await Promise.all([ - vscode.window.showTextDocument(vscode.Uri.file(filePath), { preview: false, viewColumn: vscode.ViewColumn.One }), + vscode.window.showTextDocument(vscode.Uri.file(finalPath), { preview: false, viewColumn: vscode.ViewColumn.One }), movePreviewAsideIfNeeded(node), promptHintMessage( "hint.commentDescription", From 0780a561f51d6f352f745bc0e595164db5e9c3df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=98=BF=E5=8D=A1=E7=90=B3?= Date: Tue, 6 Aug 2019 16:02:13 +0800 Subject: [PATCH 5/6] update: accept more flexible placeholder --- src/commands/show.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/commands/show.ts b/src/commands/show.ts index 34e63219..4ab7a57c 100644 --- a/src/commands/show.ts +++ b/src/commands/show.ts @@ -220,8 +220,10 @@ async function resolveRelativePath(relativePath: string, node: IProblem, selecte return _.camelCase(node.name); case "pascalcasename": return _.upperFirst(_.camelCase(node.name)); + case "kebabcasename": case "kebab-case-name": return _.kebabCase(node.name); + case "snakecasename": case "snake_case_name": return _.snakeCase(node.name); case "ext": From 0a29a305719858b2f54355e833894df6fdabea7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=98=BF=E5=8D=A1=E7=90=B3?= Date: Thu, 5 Sep 2019 15:42:08 +0800 Subject: [PATCH 6/6] update: change the config name --- package.json | 44 ++++++++++++++++++++++---------------------- src/commands/show.ts | 11 +++++++---- 2 files changed, 29 insertions(+), 26 deletions(-) diff --git a/package.json b/package.json index d506a391..0ffde67d 100644 --- a/package.json +++ b/package.json @@ -369,15 +369,15 @@ "scope": "application", "description": "[Deprecated] The output folder to save the problem files." }, - "leetcode.output": { + "leetcode.filePath": { "type": "object", "scope": "application", - "description": "The output path and filename to save the problem files.", + "description": "The output folder and filename to save the problem files.", "properties": { "default": { "type": "object", "properties": { - "path": { + "folder": { "type": "string", "examples": [ "src" @@ -394,14 +394,14 @@ } }, "required": [ - "path", + "folder", "filename" ] }, "bash": { "type": "object", "properties": { - "path": { + "folder": { "type": "string" }, "filename": { @@ -413,7 +413,7 @@ "c": { "type": "object", "properties": { - "path": { + "folder": { "type": "string" }, "filename": { @@ -425,7 +425,7 @@ "cpp": { "type": "object", "properties": { - "path": { + "folder": { "type": "string" }, "filename": { @@ -437,7 +437,7 @@ "csharp": { "type": "object", "properties": { - "path": { + "folder": { "type": "string" }, "filename": { @@ -449,7 +449,7 @@ "golang": { "type": "object", "properties": { - "path": { + "folder": { "type": "string" }, "filename": { @@ -461,7 +461,7 @@ "java": { "type": "object", "properties": { - "path": { + "folder": { "type": "string" }, "filename": { @@ -473,7 +473,7 @@ "javascript": { "type": "object", "properties": { - "path": { + "folder": { "type": "string" }, "filename": { @@ -485,7 +485,7 @@ "kotlin": { "type": "object", "properties": { - "path": { + "folder": { "type": "string" }, "filename": { @@ -497,7 +497,7 @@ "mysql": { "type": "object", "properties": { - "path": { + "folder": { "type": "string" }, "filename": { @@ -509,7 +509,7 @@ "php": { "type": "object", "properties": { - "path": { + "folder": { "type": "string" }, "filename": { @@ -521,7 +521,7 @@ "python": { "type": "object", "properties": { - "path": { + "folder": { "type": "string" }, "filename": { @@ -533,7 +533,7 @@ "python3": { "type": "object", "properties": { - "path": { + "folder": { "type": "string" }, "filename": { @@ -545,7 +545,7 @@ "ruby": { "type": "object", "properties": { - "path": { + "folder": { "type": "string" }, "filename": { @@ -557,7 +557,7 @@ "rust": { "type": "object", "properties": { - "path": { + "folder": { "type": "string" }, "filename": { @@ -569,7 +569,7 @@ "scala": { "type": "object", "properties": { - "path": { + "folder": { "type": "string" }, "filename": { @@ -581,7 +581,7 @@ "swift": { "type": "object", "properties": { - "path": { + "folder": { "type": "string" }, "filename": { @@ -594,7 +594,7 @@ "additionalProperties": { "type": "object", "properties": { - "path": { + "folder": { "type": "string" }, "filename": { @@ -605,7 +605,7 @@ }, "default": { "default": { - "path": "", + "folder": "", "filename": "${id}.${kebab-case-name}.${ext}" } } diff --git a/src/commands/show.ts b/src/commands/show.ts index e2290e1d..1906bd8e 100644 --- a/src/commands/show.ts +++ b/src/commands/show.ts @@ -144,14 +144,17 @@ async function showProblemInternal(node: IProblem): Promise { const outputFolder: string = leetCodeConfig.get("outputFolder", "").trim(); - const filePath: string = leetCodeConfig - .get(`output.${language}.path`, leetCodeConfig.get(`output.default.path`, outputFolder)) + const fileFolder: string = leetCodeConfig + .get(`filePath.${language}.folder`, leetCodeConfig.get(`filePath.default.folder`, outputFolder)) .trim(); const fileName: string = leetCodeConfig - .get(`output.${language}.filename`, leetCodeConfig.get(`output.default.filename`, genFileName(node, language))) + .get( + `filePath.${language}.filename`, + leetCodeConfig.get(`filePath.default.filename`, genFileName(node, language)), + ) .trim(); - let finalPath: string = path.join(workspaceFolder, filePath, fileName); + let finalPath: string = path.join(workspaceFolder, fileFolder, fileName); if (finalPath) { finalPath = await resolveRelativePath(finalPath, node, language); pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy