MCPcopy Create free account
hub / github.com/Zoo-Code-Org/Zoo-Code / removeMention

Function removeMention

webview-ui/src/utils/context-mentions.ts:78–97  ·  view source on GitHub ↗
(text: string, position: number)

Source from the content-addressed store, hash-verified

76}
77
78export function removeMention(text: string, position: number): { newText: string; newPosition: number } {
79 const beforeCursor = text.slice(0, position)
80 const afterCursor = text.slice(position)
81
82 // Check if we're at the end of a mention
83 const matchEnd = beforeCursor.match(new RegExp(mentionRegex.source + "$"))
84
85 if (matchEnd) {
86 // If we're at the end of a mention, remove it
87 // Remove the mention and the first space that follows it
88 const mentionLength = matchEnd[0].length
89 // Remove the mention and one space after it if it exists
90 const newText = text.slice(0, position - mentionLength) + afterCursor.replace(/^\s/, "")
91 const newPosition = position - mentionLength
92 return { newText, newPosition }
93 }
94
95 // If we're not at the end of a mention, just return the original text and position
96 return { newText: text, newPosition: position }
97}
98
99export enum ContextMenuOptionType {
100 OpenedFile = "openedFile",

Callers 2

ChatTextArea.tsxFile · 0.90

Calls 1

replaceMethod · 0.65

Tested by

no test coverage detected