mirror of
https://github.com/Iheuzio/gpt-contextfiles.git
synced 2025-07-18 14:00:48 +00:00
Merge pull request #2 from Iheuzio/fix/format-queries
fix(queries): Fixes the queries formatting
This commit is contained in:
commit
43e3b9781e
22
extension.js
22
extension.js
@ -142,25 +142,40 @@ function getWebviewContent(fileContents, question) {
|
||||
)
|
||||
.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 `
|
||||
<html>
|
||||
<body>
|
||||
<h1>GPT Context</h1>
|
||||
<form id="questionForm">
|
||||
<div>
|
||||
<label for="question">Enter your question:</label>
|
||||
<input type="text" id="question" name="question" required>
|
||||
<button type="submit">Submit</button>
|
||||
<button type="button" onclick="clearSelectedFiles()">Clear</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>
|
||||
<h2>Selected Files:</h2>
|
||||
${fileList}
|
||||
</div>
|
||||
<div><pre>${question ? question : ''}</pre></div>
|
||||
<script>
|
||||
const vscode = acquireVsCodeApi();
|
||||
|
||||
@ -198,6 +213,7 @@ function getWebviewContent(fileContents, question) {
|
||||
`;
|
||||
}
|
||||
|
||||
|
||||
// Activates the extension
|
||||
function activate(context) {
|
||||
// Register the file data provider
|
||||
|
Loading…
Reference in New Issue
Block a user