mirror of
https://github.com/EthanMarti/infio-copilot.git
synced 2026-05-16 12:41:38 +00:00
init
This commit is contained in:
24
src/core/autocomplete/post-processors/remove-whitespace.ts
Normal file
24
src/core/autocomplete/post-processors/remove-whitespace.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
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;
|
||||
Reference in New Issue
Block a user