Download apps/vscode/webview-ui/src/components/inputarea/utils.ts from SaylorTwift/kimi-code: direct link, hf CLI and curl.
- Browser
- Download file 962 Bytes
-
https://huggingface.co/SaylorTwift/kimi-code/resolve/main/apps/vscode/webview-ui/src/components/inputarea/utils.ts
- Command line
-
hf download hf://SaylorTwift/kimi-code/apps/vscode/webview-ui/src/components/inputarea/utils.ts
-
curl -L -o utils.ts https://huggingface.co/SaylorTwift/kimi-code/resolve/main/apps/vscode/webview-ui/src/components/inputarea/utils.ts
962 Bytes
| interface InsertMentionParams { | |
| text: string; | |
| cursorPos: number; | |
| filePath: string; | |
| activeToken: { start: number } | null; | |
| isAppend: boolean; | |
| } | |
| interface InsertMentionResult { | |
| newText: string; | |
| newCursorPos: number; | |
| } | |
| export function computeMentionInsert(params: InsertMentionParams): InsertMentionResult { | |
| const { text, cursorPos, filePath, activeToken, isAppend } = params; | |
| // Quote paths containing spaces, as the CLI/TUI mention completers do, so | |
| // whitespace cannot split the mention. | |
| const target = filePath.includes(" ") ? `"${filePath}"` : filePath; | |
| if (isAppend || !activeToken) { | |
| const newText = text + `@${target} `; | |
| return { newText, newCursorPos: newText.length }; | |
| } | |
| const before = text.slice(0, activeToken.start); | |
| const after = text.slice(cursorPos); | |
| const newText = `${before}@${target} ${after}`; | |
| const newCursorPos = activeToken.start + 1 + target.length + 1; | |
| return { newText, newCursorPos }; | |
| } | |