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
2 changes: 0 additions & 2 deletions src/ai/OpenAICaller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@ export class OpenAICaller implements APICaller {
}
]
}).then(response => {
console.log(response.choices[0].message.content!);

let feedback: AIFeedback = {
request: request,
problemFiles: JSON.parse(response.choices[0].message.content!).problemFiles
Expand Down
13 changes: 10 additions & 3 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,22 @@
import { InlineDiagnostic } from "./extension/InlineDiagnostic";
import { initTerminal, getTerminalOutput } from "./terminal";
import { OpenAICaller } from "./ai/OpenAICaller";
import { ProblemFile } from "./types/ProblemFile";

export function activate(context: vscode.ExtensionContext) {
initSettings();
initTerminal();

const askAI = vscode.commands.registerCommand("drDebug.askAI", async () => {
let response = (await new OpenAICaller().sendRequest({ terminalOutput: getTerminalOutput() }))
if (response !== undefined && response.text !== undefined) {
vscode.window.showInformationMessage(response.text, { modal: true });
let response = await new OpenAICaller().sendRequest({ terminalOutput: getTerminalOutput() });
if (response !== undefined && response.problemFiles && response.text !== undefined) {
const problemFile: ProblemFile = response.problemFiles[0]

Check warning on line 15 in src/extension.ts

View workflow job for this annotation

GitHub Actions / test

Missing semicolon

Check warning on line 15 in src/extension.ts

View workflow job for this annotation

GitHub Actions / test

Missing semicolon
const inline: InlineDiagnostic = new InlineDiagnostic(vscode.Uri.file(problemFile.fileName),
new vscode.Range(
new vscode.Position(problemFile.line! - 1, 0),
new vscode.Position(problemFile.line! - 1, 0)),
response.text);
inline.show();
}
});

Expand Down
17 changes: 17 additions & 0 deletions src/extension/InlineDiagnostic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ export class InlineDiagnostic implements Inline {
}

public async show(): Promise<void> {
this.cleanMessage();

// Create diagnostic
const diagnostic = new vscode.Diagnostic(this.range, this.message, vscode.DiagnosticSeverity.Error);
diagnostic.source = diagnosticName;
Expand All @@ -36,4 +38,19 @@ export class InlineDiagnostic implements Inline {
}
}

private cleanMessage(): void {
let result = "";
let lineLength = 0;
for(const word of this.message.split(" ")) {
if(lineLength + word.length <= 80) {
result += word + " ";
lineLength += word.length + 1;
} else {
result += "\n" + word + " ";
lineLength = word.length + 1;
}
}
this.message = result;
}

}