Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
126 changes: 2 additions & 124 deletions dist/extension.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/extension.js.map

Large diffs are not rendered by default.

11 changes: 0 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
],
"activationEvents": [
"onCommand:doc-detective-vsc.helloWorld",
"onCommand:doc-detective-vsc.simpleView",
"onView:docDetectiveView"
],
"main": "./dist/extension.js",
Expand All @@ -25,11 +24,6 @@
{
"command": "doc-detective.helloWorld",
"title": "Hello World"
},
{
"command": "doc-detective.simpleView",
"title": "Use Simple View",
"icon": "$(list-flat)"
}
],
"configuration": {
Expand All @@ -44,11 +38,6 @@
},
"menus": {
"view/title": [
{
"command": "doc-detective.simpleView",
"when": "view == docDetectiveView",
"group": "navigation"
}
]
},
"viewsContainers": {
Expand Down
132 changes: 4 additions & 128 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,14 +254,8 @@ class DocDetectiveWebviewViewProvider implements vscode.WebviewViewProvider {
this._view.webview.html = this.getHtmlForWebview(results);
log('Webview updated successfully with full view');
} catch (renderError) {
log(`Error with full view rendering, falling back to simplified view: ${renderError}`);
try {
this._view.webview.html = this.getSimplifiedHtmlForWebview(results);
log('Webview updated with simplified view');
} catch (fallbackError) {
log(`Error with simplified view too: ${fallbackError}`);
this._view.webview.html = this.getErrorHtml(`Failed to render results: ${renderError}. Fallback also failed: ${fallbackError}`);
}
log(`Error with view rendering: ${renderError}`);
this._view.webview.html = this.getErrorHtml(`Failed to render results: ${renderError}`);
}
} catch (error) {
log(`Error updating webview: ${error}`);
Expand Down Expand Up @@ -697,79 +691,9 @@ class DocDetectiveWebviewViewProvider implements vscode.WebviewViewProvider {
}
}

private getSimplifiedHtmlForWebview(jsonObj: any): string {
try {
// Create a simpler representation without all the complex HTML
return `<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; style-src 'unsafe-inline' https:; script-src 'unsafe-inline'; connect-src vscode-webview:;">
<title>Doc Detective Results (Simple View)</title>
<style>
body {
font-family: var(--vscode-editor-font-family, monospace);
margin: 0;
padding: 1em;
background: var(--vscode-editor-background);
color: var(--vscode-editor-foreground);
}
pre {
white-space: pre-wrap;
word-wrap: break-word;
padding: 1em;
background: var(--vscode-editor-background);
border: 1px solid var(--vscode-dropdown-border);
border-radius: 3px;
}
h3 {
margin-top: 0;
}
.file-path {
font-weight: bold;
margin-top: 1em;
padding: 0.5em;
background: var(--vscode-sideBar-background);
border-bottom: 1px solid var(--vscode-sideBarSectionHeader-border);
}
</style>
</head>
<body>
<h3>Doc Detective Results</h3>
<p>Showing simplified view due to rendering issues with the full view.</p>
<div id="content">
${Object.keys(jsonObj).map(filePath => `
<div class="file-path">${filePath}</div>
<pre>${JSON.stringify(jsonObj[filePath], null, 2)}</pre>
`).join('')}
</div>
</body>
</html>`;
} catch (error) {
log(`Error generating simplified HTML: ${error}`);
return this.getErrorHtml(`Failed to generate simplified HTML view: ${error}`);
}
}

// Method to show a simplified view of the results
public getSimpleView(results: Record<string, any>): void {
try {
if (!this._view) {
log('No view available for simple view');
return;
}

log('Setting simplified view for results');
this._view.webview.html = this.getSimplifiedHtmlForWebview(results);
log('Simple view set successfully');
} catch (error) {
log(`Error setting simple view: ${error}`);
if (this._view) {
this._view.webview.html = this.getErrorHtml(`Failed to show simplified view: ${error}`);
}
}
}


}

// This method is called when your extension is activated
Expand Down Expand Up @@ -842,54 +766,6 @@ export function activate(context: vscode.ExtensionContext) {
})
);


// Add a command to use simplified view
const simpleViewCommand = vscode.commands.registerCommand('doc-detective.simpleView', async () => {
log('Simple view requested');
if (provider.hasView()) {
try {
const editors = vscode.window.visibleTextEditors;
const filePaths = editors
.filter(e => e.document.uri.scheme === 'file')
.map(e => e.document.uri.fsPath);
const uniquePaths = Array.from(new Set(filePaths));

// Load config file if available
const configFilePath = await findConfigFile(vscode.workspace.workspaceFolders);
let baseConfig: any = null;

if (configFilePath) {
baseConfig = await loadConfigFile(configFilePath);
log(`Loaded base config from ${configFilePath} for simple view`);
}

const results: Record<string, any> = {};
for (const file of uniquePaths) {
try {
// Create a config object that either extends the loaded config or creates a new one
const config = baseConfig ? { ...baseConfig } : {};

// Always override the input with the current file
config.input = file;

const suites = await detectTests({ config });
results[file] = suites;
} catch (e) {
results[file] = { error: String(e) };
}
}

// Use the provider method to get the HTML
provider.getSimpleView(results);
vscode.window.showInformationMessage('Doc Detective panel using simplified view');
} catch (error) {
log(`Error in simple view command: ${error}`);
vscode.window.showErrorMessage(`Error switching to simple view: ${error}`);
}
}
});
context.subscriptions.push(simpleViewCommand);

context.subscriptions.push(outputChannel);
log('Doc Detective extension activated');
}
Expand Down
1 change: 0 additions & 1 deletion src/test/extension.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ suite('Extension Test Suite', () => {

// Test for the extension's commands
assert.ok(commands.includes('doc-detective.helloWorld'), 'helloWorld command should be registered');
assert.ok(commands.includes('doc-detective.simpleView'), 'simpleView command should be registered');
});

test('WebView provider should be registered', async () => {
Expand Down