mirror of
https://github.com/Iheuzio/gpt-contextfiles.git
synced 2025-07-18 22:10:49 +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('');
|
.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
|
||||||
|
Loading…
Reference in New Issue
Block a user