Skip to content

Commit 43d0c99

Browse files
committed
improved logic for code execution
1 parent 5370f63 commit 43d0c99

File tree

7 files changed

+19
-47
lines changed

7 files changed

+19
-47
lines changed

dist/extension.js

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -297709,11 +297709,10 @@ var CommandTreeDataProvider = class {
297709297709
// Mapping of command IDs to their display names, icons, and colors
297710297710
this.extensionCommands = {
297711297711
"leetcode-cph-helper-by-ashish.fetchLeetCodeTestCases": { label: "Fetch Test Cases(CTRL+1)", icon: "cloud-download", color: "charts.green" },
297712-
"leetcode-cph-helper-by-ashish.runTestCases": { label: "Run Test Cases(CTRL+5)", icon: "play-circle", color: "charts.blue" },
297713-
"leetcode-cph-helper-by-ashish.writeSolutionFile": { label: "Write Solution File(CTRL+4)", icon: "file-code", color: "charts.yellow" },
297714-
"leetcode-test-case-manager.getSolutionFileDirectory": { label: "Get Solution File Directory(CTRL+3)", icon: "folder", color: "charts.orange" },
297715-
"leetcode-cph-helper-by-ashish.getIOFileDirectory": { label: "Get I/O File Directory(CTRL+2)", icon: "folder", color: "charts.red" },
297716-
"leetcode-cph-helper-by-ashish.showLeetCodeProblemLinks": { label: "Show LeetCode Problem Links(CTRL+6)", icon: "link", color: "charts.purple" }
297712+
"leetcode-cph-helper-by-ashish.runTestCases": { label: "Run Test Cases(CTRL+4)", icon: "play-circle", color: "charts.blue" },
297713+
"leetcode-cph-helper-by-ashish.writeSolutionFile": { label: "Write Solution File(CTRL3)", icon: "file-code", color: "charts.yellow" },
297714+
"leetcode-cph-helper-by-ashish.getIOFileDirectory": { label: "Get I/O & Soluton File Directory(CTRL+2)", icon: "folder", color: "charts.red" },
297715+
"leetcode-cph-helper-by-ashish.showLeetCodeProblemLinks": { label: "Show LeetCode Problem Links(CTRL+5)", icon: "link", color: "charts.purple" }
297717297716
};
297718297717
}
297719297718
// Returns a TreeItem representation of the given element
@@ -297799,24 +297798,12 @@ function activate(context2) {
297799297798
async () => {
297800297799
try {
297801297800
await vscode4.env.clipboard.writeText(baseDirectory);
297802-
vscode4.window.showInformationMessage(`I/O text file directory path copied to clipboard: ${baseDirectory}`);
297801+
vscode4.window.showInformationMessage(`I/O & Solution file directory path copied to clipboard: ${baseDirectory}`);
297803297802
} catch (error) {
297804297803
vscode4.window.showErrorMessage(`Error: ${error}`);
297805297804
}
297806297805
}
297807297806
);
297808-
const getSolutionFileDirectoryCommand = vscode4.commands.registerCommand(
297809-
"leetcode-test-case-manager.getSolutionFileDirectory",
297810-
async () => {
297811-
try {
297812-
const solutionDir = path12.join(baseDirectory, "dist", "test_cases");
297813-
await vscode4.env.clipboard.writeText(solutionDir);
297814-
vscode4.window.showInformationMessage(`Solution directory path copied to clipboard: ${solutionDir}`);
297815-
} catch (error) {
297816-
vscode4.window.showErrorMessage(`Error copying solution directory path: ${error}`);
297817-
}
297818-
}
297819-
);
297820297807
const writeSolutionFileCommand = vscode4.commands.registerCommand(
297821297808
"leetcode-cph-helper-by-ashish.writeSolutionFile",
297822297809
async () => {
@@ -297987,7 +297974,7 @@ ${results.join("\n\n")}`, { modal: true });
297987297974
await vscode4.window.showTextDocument(document2);
297988297975
}
297989297976
);
297990-
context2.subscriptions.push(fetchCommand, showLeetCodeProblemLinksCommand, getIOFileDirectoryCommand, getSolutionFileDirectoryCommand, writeSolutionFileCommand, runCommand);
297977+
context2.subscriptions.push(fetchCommand, showLeetCodeProblemLinksCommand, getIOFileDirectoryCommand, writeSolutionFileCommand, runCommand);
297991297978
const commandTreeDataProvider = new CommandTreeDataProvider();
297992297979
vscode4.window.registerTreeDataProvider("leetcodeHelperCommands", commandTreeDataProvider);
297993297980
vscode4.commands.executeCommand("workbench.view.extension.leetcodeHelper");

dist/extension.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/test_cases/solution.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ def reverse_words(s: str) -> str:
1010
# Example usage
1111
# Provide the test case number and function name
1212

13-
run_test_case(3, reverse_words)
13+
run_test_case(5, reverse_words)

package.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,14 @@
2121
"command": "leetcode-cph-helper-by-ashish.runTestCases",
2222
"title": "Run Test Cases"
2323
},
24-
{
25-
"command": "leetcode-cph-helper-by-ashish.writeSolutionFile",
26-
"title": "Write Solution File"
27-
},
24+
2825
{
2926
"command": "leetcode-test-case-manager.getSolutionFileDirectory",
3027
"title": "Get Solution File Directory"
3128
},
3229
{
3330
"command": "leetcode-cph-helper-by-ashish.getIOFileDirectory",
34-
"title": "Get I/O File Directory"
31+
"title": "Get I/O & Solution File Directory"
3532
},
3633
{
3734
"command": "leetcode-cph-helper-by-ashish.showLeetCodeProblemLinks",

src/commandTreeDataProvider.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,10 @@ export class CommandTreeDataProvider implements vscode.TreeDataProvider<vscode.T
88
// Mapping of command IDs to their display names, icons, and colors
99
private extensionCommands: { [key: string]: { label: string, icon: string, color: string } } = {
1010
'leetcode-cph-helper-by-ashish.fetchLeetCodeTestCases': { label: 'Fetch Test Cases(CTRL+1)', icon: 'cloud-download', color: 'charts.green' },
11-
'leetcode-cph-helper-by-ashish.runTestCases': { label: 'Run Test Cases(CTRL+5)', icon: 'play-circle', color: 'charts.blue' },
12-
'leetcode-cph-helper-by-ashish.writeSolutionFile': { label: 'Write Solution File(CTRL+4)', icon: 'file-code', color: 'charts.yellow' },
13-
'leetcode-test-case-manager.getSolutionFileDirectory': { label: 'Get Solution File Directory(CTRL+3)', icon: 'folder', color: 'charts.orange' },
14-
'leetcode-cph-helper-by-ashish.getIOFileDirectory': { label: 'Get I/O File Directory(CTRL+2)', icon: 'folder', color: 'charts.red' },
15-
'leetcode-cph-helper-by-ashish.showLeetCodeProblemLinks': { label: 'Show LeetCode Problem Links(CTRL+6)', icon: 'link', color: 'charts.purple' }
11+
'leetcode-cph-helper-by-ashish.runTestCases': { label: 'Run Test Cases(CTRL+4)', icon: 'play-circle', color: 'charts.blue' },
12+
'leetcode-cph-helper-by-ashish.writeSolutionFile': { label: 'Write Solution File(CTRL3)', icon: 'file-code', color: 'charts.yellow' },
13+
'leetcode-cph-helper-by-ashish.getIOFileDirectory': { label: 'Get I/O & Soluton File Directory(CTRL+2)', icon: 'folder', color: 'charts.red' },
14+
'leetcode-cph-helper-by-ashish.showLeetCodeProblemLinks': { label: 'Show LeetCode Problem Links(CTRL+5)', icon: 'link', color: 'charts.purple' }
1615
};
1716

1817
// Returns a TreeItem representation of the given element

src/extension.ts

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -57,26 +57,15 @@ export function activate(context: vscode.ExtensionContext) {
5757
try {
5858
// Copy the directory path to the clipboard
5959
await vscode.env.clipboard.writeText(baseDirectory);
60-
vscode.window.showInformationMessage(`I/O text file directory path copied to clipboard: ${baseDirectory}`);
60+
vscode.window.showInformationMessage(`I/O & Solution file directory path copied to clipboard: ${baseDirectory}`);
6161
} catch (error) {
6262
vscode.window.showErrorMessage(`Error: ${error}`);
6363
}
6464
}
6565
);
6666

6767
// Command: Get Solution File Directory
68-
const getSolutionFileDirectoryCommand = vscode.commands.registerCommand(
69-
'leetcode-test-case-manager.getSolutionFileDirectory',
70-
async () => {
71-
try {
72-
const solutionDir = path.join(baseDirectory, 'dist', 'test_cases');
73-
await vscode.env.clipboard.writeText(solutionDir);
74-
vscode.window.showInformationMessage(`Solution directory path copied to clipboard: ${solutionDir}`);
75-
} catch (error) {
76-
vscode.window.showErrorMessage(`Error copying solution directory path: ${error}`);
77-
}
78-
}
79-
);
68+
8069

8170
// Command: Write Solution File
8271
const writeSolutionFileCommand = vscode.commands.registerCommand(
@@ -288,7 +277,7 @@ int main() {
288277
);
289278

290279
// Register commands in context so that commandTreeDataProvider can access them
291-
context.subscriptions.push(fetchCommand,showLeetCodeProblemLinksCommand, getIOFileDirectoryCommand, getSolutionFileDirectoryCommand, writeSolutionFileCommand, runCommand);
280+
context.subscriptions.push(fetchCommand,showLeetCodeProblemLinksCommand, getIOFileDirectoryCommand, writeSolutionFileCommand, runCommand);
292281
const commandTreeDataProvider = new CommandTreeDataProvider();
293282
vscode.window.registerTreeDataProvider('leetcodeHelperCommands', commandTreeDataProvider);
294283

src/fetchTestCases.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as puppeteer from 'puppeteer';
1+
import * as puppeteer from 'puppeteer'; // web scrapper
22
import * as fs from 'fs';
33
import * as path from 'path';
44
import * as vscode from 'vscode';
@@ -12,7 +12,7 @@ const RETRY_DELAY = 3000; // 0.1 seconds
1212
const MAX_RETRIES = 5; // Maximum retry attempts
1313

1414
export async function fetchTestCases(url: string): Promise<void> {
15-
const browser = await puppeteer.launch({ headless: false }); // Run in visible mode for debugging
15+
const browser = await puppeteer.launch({ headless: false }); //browser page is visible
1616
const page = await browser.newPage();
1717

1818
let attempts = 0;

0 commit comments

Comments
 (0)