trypear / pearai-app

The Open Source AI-Powered Code Editor. A fork of VSCode and Continue.
https://trypear.ai
Other
2.24k stars 407 forks source link

Bug: cmd+shift+R does not copy entire error log #133

Closed nang-dev closed 3 months ago

nang-dev commented 3 months ago

Describe the bug

Should be:

Screenshot 2024-06-11 at 7 10 50 AM

but is:

Screenshot 2024-06-11 at 7 12 48 AM

How to reproduce

Run python3 extensions/vscode/pearai_tutorial.py and then do cmd+shift+R on continue, then using pear

Expected behavior

Pear should copy the entire error message into the chat log

Clear and concise description of what you expected to happen.

Screenshots

If applicable, add screenshots to help explain your problem.

Additional information

🧙‍ Add any other context about the problem here.

nang-dev commented 3 months ago

Relevant code block

`async getTerminalContents(commands: number = -1): Promise { const tempCopyBuffer = await vscode.env.clipboard.readText(); if (commands < 0) { await vscode.commands.executeCommand( "workbench.action.terminal.selectAll", ); } else { for (let i = 0; i < commands; i++) { await vscode.commands.executeCommand( "workbench.action.terminal.selectToPreviousCommand", ); } } await vscode.commands.executeCommand( "workbench.action.terminal.copySelection", ); await vscode.commands.executeCommand( "workbench.action.terminal.clearSelection", ); let terminalContents = (await vscode.env.clipboard.readText()).trim(); await vscode.env.clipboard.writeText(tempCopyBuffer);

if (tempCopyBuffer === terminalContents) {
  // This means there is no terminal open to select text from
  return "";
}

// Sometimes the above won't successfully separate by command, so we attempt manually
const lines = terminalContents.split("\n");
const lastLine = lines.pop()?.trim();
if (lastLine) {
  let i = lines.length - 1;
  while (i >= 0 && !lines[i].trim().startsWith(lastLine)) i--;
  terminalContents = lines.slice(i).join("\n");
}

return terminalContents;

}`

nang-dev commented 3 months ago

https://github.com/trypear/pearai-submodule/pull/47

nang-dev commented 3 months ago

I fixed :D