From 5c3d9deb4efba09015c244c737967bb9fc9a1a15 Mon Sep 17 00:00:00 2001 From: Zhiming Ma Date: Mon, 29 Jan 2024 09:51:42 +0800 Subject: [PATCH] fix(vscode): fix vscode notebook context, add newline before suffix cells. (#1317) --- clients/vscode/src/TabbyCompletionProvider.ts | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/clients/vscode/src/TabbyCompletionProvider.ts b/clients/vscode/src/TabbyCompletionProvider.ts index 1b2f3dc23b3b..c8257d5f0c2d 100644 --- a/clients/vscode/src/TabbyCompletionProvider.ts +++ b/clients/vscode/src/TabbyCompletionProvider.ts @@ -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: "" }; @@ -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"); } }