diff --git a/clients/tabby-agent/src/AgentConfig.ts b/clients/tabby-agent/src/AgentConfig.ts index b227b75e90a0..d92f7015a9a7 100644 --- a/clients/tabby-agent/src/AgentConfig.ts +++ b/clients/tabby-agent/src/AgentConfig.ts @@ -8,6 +8,7 @@ export type AgentConfig = { }; completion: { prompt: { + stripAutoClosingCharacters: boolean; maxPrefixLines: number; maxSuffixLines: number; }; @@ -46,6 +47,7 @@ export const defaultAgentConfig: AgentConfig = { }, completion: { prompt: { + stripAutoClosingCharacters: false, maxPrefixLines: 20, maxSuffixLines: 20, }, diff --git a/clients/tabby-agent/src/TabbyAgent.ts b/clients/tabby-agent/src/TabbyAgent.ts index 081a7847cfd3..6bb96e872928 100644 --- a/clients/tabby-agent/src/TabbyAgent.ts +++ b/clients/tabby-agent/src/TabbyAgent.ts @@ -264,10 +264,14 @@ export class TabbyAgent extends EventEmitter implements Agent { const maxPrefixLines = this.config.completion.prompt.maxPrefixLines; const maxSuffixLines = this.config.completion.prompt.maxSuffixLines; const { prefixLines, suffixLines } = context; - return { - prefix: prefixLines.slice(Math.max(prefixLines.length - maxPrefixLines, 0)).join(""), - suffix: suffixLines.slice(0, maxSuffixLines).join(""), - }; + const prefix = prefixLines.slice(Math.max(prefixLines.length - maxPrefixLines, 0)).join(""); + let suffix; + if (this.config.completion.prompt.stripAutoClosingCharacters && context.mode !== "fill-in-line") { + suffix = "\n" + suffixLines.slice(1, maxSuffixLines).join(""); + } else { + suffix = suffixLines.slice(0, maxSuffixLines).join(""); + } + return { prefix, suffix }; } private calculateReplaceRange(response: CompletionResponse, context: CompletionContext): CompletionResponse {