mirror of
https://github.com/EthanMarti/infio-copilot.git
synced 2026-01-16 08:21:55 +00:00
25 lines
684 B
TypeScript
25 lines
684 B
TypeScript
import Context from "../context-detection";
|
|
import { PostProcessor } from "../types";
|
|
|
|
class RemoveWhitespace implements PostProcessor {
|
|
process(
|
|
prefix: string,
|
|
suffix: string,
|
|
completion: string,
|
|
context: Context
|
|
): string {
|
|
if (context === Context.Text || context === Context.Heading || context === Context.MathBlock || context === Context.TaskList || context === Context.NumberedList || context === Context.UnorderedList) {
|
|
if (prefix.endsWith(" ") || suffix.endsWith("\n")) {
|
|
completion = completion.trimStart();
|
|
}
|
|
if (suffix.startsWith(" ")) {
|
|
completion = completion.trimEnd();
|
|
}
|
|
}
|
|
|
|
return completion;
|
|
}
|
|
}
|
|
|
|
export default RemoveWhitespace;
|