From 748223cf5818bba87421cbd68bb98cc75ebcf48e Mon Sep 17 00:00:00 2001 From: Varun Sahni <74827870+varunsahni18@users.noreply.github.com> Date: Sun, 13 Apr 2025 15:47:19 +0530 Subject: [PATCH] Update show.ts Adding cpp headers for easy debugging --- src/commands/show.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/commands/show.ts b/src/commands/show.ts index eccf557..974c9af 100644 --- a/src/commands/show.ts +++ b/src/commands/show.ts @@ -191,6 +191,13 @@ async function showProblemInternal(node: IProblem): Promise { const needTranslation: boolean = settingUtils.shouldUseEndpointTranslation(); await leetCodeExecutor.showProblem(node, language, finalPath, descriptionConfig.showInComment, needTranslation); + // Add C++ headers and main function if the language is C++ + if (language === "cpp") { + const cppHeaders = `#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\n`; + const mainFunction = `int main() {\n Solution sol;\n // Add your test cases here\n cout << "Test cases go here" << endl;\n return 0;\n}\n`; + const fileContent = yield vscode.workspace.fs.readFile(vscode.Uri.file(finalPath)); + yield vscode.workspace.fs.writeFile(vscode.Uri.file(finalPath), Buffer.from(cppHeaders + fileContent.toString() + "\n" + mainFunction)); + } const promises: any[] = [ vscode.window.showTextDocument(vscode.Uri.file(finalPath), { preview: false, 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