fix(syntax)

This commit is contained in:
Christopher 2023-06-18 17:39:01 -04:00
parent 14471be6d8
commit 6d99c75447

View File

@ -142,25 +142,40 @@ function getWebviewContent(fileContents, question) {
) )
.join(''); .join('');
const formattedContents = selectedFiles
.map(file => {
const document = vscode.workspace.textDocuments.find(doc => doc.uri.fsPath === file.uri.fsPath);
if (document) {
const lines = document.getText().split('\n');
const formattedLines = lines.map(line => `\t${line}`).join('\n');
return `${file.uri.fsPath}:\n\`\`\`\n${formattedLines}\n\`\`\``;
}
return '';
})
.join('\n\n');
return ` return `
<html> <html>
<body> <body>
<h1>GPT Context</h1> <h1>GPT Context</h1>
<form id="questionForm"> <form id="questionForm">
<div>
<label for="question">Enter your question:</label> <label for="question">Enter your question:</label>
<input type="text" id="question" name="question" required> <input type="text" id="question" name="question" required>
<button type="submit">Submit</button> <button type="submit">Submit</button>
<button type="button" onclick="clearSelectedFiles()">Clear</button> <button type="button" onclick="clearSelectedFiles()">Clear</button>
<button type="button" onclick="refreshSelectedFiles()">Refresh</button> <button type="button" onclick="refreshSelectedFiles()">Refresh</button>
</form> </div>
<div>
<div><pre>${question ? question : ''}</pre></div>
${ ${
fileContents ? `<div><pre>${fileContents}</pre></div>` : '' fileContents ? `<div><pre>${formattedContents}</pre></div>` : ''
} }
</div>
<div> <div>
<h2>Selected Files:</h2> <h2>Selected Files:</h2>
${fileList} ${fileList}
</div> </div>
<div><pre>${question ? question : ''}</pre></div>
<script> <script>
const vscode = acquireVsCodeApi(); const vscode = acquireVsCodeApi();
@ -198,6 +213,7 @@ function getWebviewContent(fileContents, question) {
`; `;
} }
// Activates the extension // Activates the extension
function activate(context) { function activate(context) {
// Register the file data provider // Register the file data provider