Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add second choice for unsupported default language#885

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
Ancient77 wants to merge1 commit intoLeetCode-OpenSource:master
base:master
Choose a base branch
Loading
fromAncient77:master
Open
Show file tree
Hide file tree
Changes fromall commits
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
4 changes: 2 additions & 2 deletions.vscode/launch.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,7 +7,7 @@
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": ["--extensionDevelopmentPath=${workspaceRoot}" ],
"args": ["--extensionDevelopmentPath=${workspaceRoot}", "--disable-extensions" ],
"stopOnEntry": false,
"sourceMaps": true,
"outFiles": [ "${workspaceRoot}/out/src/**/*.js" ],
Expand All@@ -25,4 +25,4 @@
"preLaunchTask": "npm"
}
]
}
}
76 changes: 46 additions & 30 deletionssrc/commands/show.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -132,45 +132,61 @@ async function fetchProblemLanguage(): Promise<string | undefined> {
return language;
}

async function showProblemInternal(node: IProblem): Promise<void> {
try {
const language: string | undefined = await fetchProblemLanguage();
if (!language) {
return;
}

const leetCodeConfig: vscode.WorkspaceConfiguration = vscode.workspace.getConfiguration("leetcode");
const workspaceFolder: string = await selectWorkspaceFolder();
if (!workspaceFolder) {
return;
}
async function createPath(language:string,node:IProblem):Promise<string>{
const leetCodeConfig: vscode.WorkspaceConfiguration = vscode.workspace.getConfiguration("leetcode");
const workspaceFolder: string = await selectWorkspaceFolder();
if (!workspaceFolder) {
Promise.reject("No workspace is opened.");
}

const fileFolder: string = leetCodeConfig
.get<string>(`filePath.${language}.folder`, leetCodeConfig.get<string>(`filePath.default.folder`, ""))
.trim();
const fileName: string = leetCodeConfig
.get<string>(
`filePath.${language}.filename`,
leetCodeConfig.get<string>(`filePath.default.filename`) || genFileName(node, language),
)
.trim();
const fileFolder: string = leetCodeConfig
.get<string>(`filePath.${language}.folder`, leetCodeConfig.get<string>(`filePath.default.folder`, ""))
.trim();
const fileName: string = leetCodeConfig
.get<string>(
`filePath.${language}.filename`,
leetCodeConfig.get<string>(`filePath.default.filename`) || genFileName(node, language),
)
.trim();

let finalPath: string = path.join(workspaceFolder, fileFolder, fileName);
let finalPath: string = path.join(workspaceFolder, fileFolder, fileName);

if (finalPath) {
finalPath = await resolveRelativePath(finalPath, node, language);
if (!finalPath) {
leetCodeChannel.appendLine("Showing problem canceled by user.");
return;
}
if (finalPath) {
finalPath = await resolveRelativePath(finalPath, node, language);
if (!finalPath) {
leetCodeChannel.appendLine("Showing problem canceled by user.");
Promise.reject("Showing problem canceled by user.");
}
}

finalPath = wsl.useWsl() ? await wsl.toWinPath(finalPath) : finalPath;
return finalPath;
}

finalPath = wsl.useWsl() ? await wsl.toWinPath(finalPath) : finalPath;
async function showProblemInternal(node: IProblem): Promise<void> {
try {
let language: string | undefined = await fetchProblemLanguage();
if (!language) {
return;
}
let finalPath: string = await createPath(language,node);

const descriptionConfig: IDescriptionConfiguration = settingUtils.getDescriptionConfiguration();
const needTranslation: boolean = settingUtils.shouldUseEndpointTranslation();
try {
await leetCodeExecutor.showProblem(node, language, finalPath, descriptionConfig.showInComment, needTranslation);
} catch (e) {
if (e instanceof Error) {
//this shows all languages, not just the ones, which are supported for this specific problem
language = await vscode.window.showQuickPick(languages, { placeHolder: "This problem is not supporting your default language, please choose another", ignoreFocusOut: true });
if (language === undefined) { throw e; }

await leetCodeExecutor.showProblem(node, language, finalPath, descriptionConfig.showInComment, needTranslation);
finalPath = await createPath(language,node);
await leetCodeExecutor.showProblem(node, language, finalPath, descriptionConfig.showInComment, needTranslation);
} else {
throw e;
}
}
const promises: any[] = [
vscode.window.showTextDocument(vscode.Uri.file(finalPath), { preview: false, viewColumn: vscode.ViewColumn.One }),
promptHintMessage(
Expand Down
6 changes: 4 additions & 2 deletionssrc/leetCodeExecutor.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -107,10 +107,12 @@ class LeetCodeExecutor implements Disposable {
if (!needTranslation) {
cmd.push("-T"); // use -T to force English version
}

const codeTemplate: string = await this.executeCommandWithProgressEx("Fetching problem data...", this.nodeExecutable, cmd)
if(codeTemplate === undefined) {
throw new Error("language not supported");
}
if (!await fse.pathExists(filePath)) {
await fse.createFile(filePath);
const codeTemplate: string = await this.executeCommandWithProgressEx("Fetching problem data...", this.nodeExecutable, cmd);
await fse.writeFile(filePath, codeTemplate);
}
}
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp