Skip to content

Commit

Permalink
fix(vscode): fix vscode notebook context, add newline before suffix c…
Browse files Browse the repository at this point in the history
…ells. (TabbyML#1317)
  • Loading branch information
icycodes authored Jan 29, 2024
1 parent bbbd51f commit 5c3d9de
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions clients/vscode/src/TabbyCompletionProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,12 +208,10 @@ export class TabbyCompletionProvider extends EventEmitter implements InlineCompl
// Add all the cells in the notebook as context
const notebook = window.activeNotebookEditor.notebook;
const current = window.activeNotebookEditor.selection.start;
const prefix = this.buildNotebookContext(notebook, new NotebookRange(0, current), document.languageId);
const suffix = this.buildNotebookContext(
notebook,
new NotebookRange(current + 1, notebook.cellCount),
document.languageId,
);
const prefix = this.buildNotebookContext(notebook, new NotebookRange(0, current), document.languageId) + "\n\n";
const suffix =
"\n\n" +
this.buildNotebookContext(notebook, new NotebookRange(current + 1, notebook.cellCount), document.languageId);
return { prefix, suffix };
}
return { prefix: "", suffix: "" };
Expand All @@ -233,13 +231,13 @@ export class TabbyCompletionProvider extends EventEmitter implements InlineCompl
.getCells(range)
.map((cell) => {
if (cell.document.languageId === languageId) {
return cell.document.getText() + "\n\n";
return cell.document.getText();
} else if (Object.keys(this.notebookLanguageComments).includes(languageId)) {
return this.notebookLanguageComments[languageId]!(cell.document.getText()) + "\n\n";
return this.notebookLanguageComments[languageId]!(cell.document.getText());
} else {
return "";
}
})
.join("");
.join("\n\n");
}
}

0 comments on commit 5c3d9de

Please sign in to comment.