MCPcopy Index your code
hub / github.com/LeetCode-OpenSource/vscode-leetcode / showProblemInternal

Function showProblemInternal

src/commands/show.ts:135–191  ·  view source on GitHub ↗
(node: IProblem)

Source from the content-addressed store, hash-verified

133}
134
135async function showProblemInternal(node: IProblem): Promise<void> {
136 try {
137 const language: string | undefined = await fetchProblemLanguage();
138 if (!language) {
139 return;
140 }
141
142 const leetCodeConfig: vscode.WorkspaceConfiguration = vscode.workspace.getConfiguration("leetcode");
143 const workspaceFolder: string = await selectWorkspaceFolder();
144 if (!workspaceFolder) {
145 return;
146 }
147
148 const fileFolder: string = leetCodeConfig
149 .get<string>(`filePath.${language}.folder`, leetCodeConfig.get<string>(`filePath.default.folder`, ""))
150 .trim();
151 const fileName: string = leetCodeConfig
152 .get<string>(
153 `filePath.${language}.filename`,
154 leetCodeConfig.get<string>(`filePath.default.filename`) || genFileName(node, language),
155 )
156 .trim();
157
158 let finalPath: string = path.join(workspaceFolder, fileFolder, fileName);
159
160 if (finalPath) {
161 finalPath = await resolveRelativePath(finalPath, node, language);
162 if (!finalPath) {
163 leetCodeChannel.appendLine("Showing problem canceled by user.");
164 return;
165 }
166 }
167
168 finalPath = wsl.useWsl() ? await wsl.toWinPath(finalPath) : finalPath;
169
170 const descriptionConfig: IDescriptionConfiguration = settingUtils.getDescriptionConfiguration();
171 const needTranslation: boolean = settingUtils.shouldUseEndpointTranslation();
172
173 await leetCodeExecutor.showProblem(node, language, finalPath, descriptionConfig.showInComment, needTranslation);
174 const promises: any[] = [
175 vscode.window.showTextDocument(vscode.Uri.file(finalPath), { preview: false, viewColumn: vscode.ViewColumn.One }),
176 promptHintMessage(
177 "hint.commentDescription",
178 'You can config how to show the problem description through "leetcode.showDescription".',
179 "Open settings",
180 (): Promise<any> => openSettingsEditor("leetcode.showDescription"),
181 ),
182 ];
183 if (descriptionConfig.showInWebview) {
184 promises.push(showDescriptionView(node));
185 }
186
187 await Promise.all(promises);
188 } catch (error) {
189 await promptForOpenOutputChannel(`${error} Please open the output channel for details.`, DialogType.error);
190 }
191}
192

Callers 3

pickOneFunction · 0.85
showProblemFunction · 0.85
searchProblemFunction · 0.85

Calls 10

selectWorkspaceFolderFunction · 0.90
genFileNameFunction · 0.90
promptHintMessageFunction · 0.90
openSettingsEditorFunction · 0.90
fetchProblemLanguageFunction · 0.85
resolveRelativePathFunction · 0.85
showDescriptionViewFunction · 0.85
appendLineMethod · 0.80
showProblemMethod · 0.80

Tested by

no test coverage detected