mirror of
https://github.com/EthanMarti/infio-copilot.git
synced 2026-01-16 08:21:55 +00:00
25 lines
718 B
TypeScript
25 lines
718 B
TypeScript
import Context from "../context-detection";
|
|
import { PreProcessor, PrefixAndSuffix } from "../types";
|
|
|
|
class LengthLimiter implements PreProcessor {
|
|
private readonly maxPrefixChars: number;
|
|
private readonly maxSuffixChars: number;
|
|
|
|
constructor(maxPrefixChars: number, maxSuffixChars: number) {
|
|
this.maxPrefixChars = maxPrefixChars;
|
|
this.maxSuffixChars = maxSuffixChars;
|
|
}
|
|
|
|
process(prefix: string, suffix: string, context: Context): PrefixAndSuffix {
|
|
prefix = prefix.slice(-this.maxPrefixChars);
|
|
suffix = suffix.slice(0, this.maxSuffixChars);
|
|
return { prefix, suffix };
|
|
}
|
|
|
|
removesCursor(prefix: string, suffix: string): boolean {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
export default LengthLimiter;
|