(text: string, position: number)
| 74 | // Helper to check if a position is inside string delimiters (double quotes or backticks only) |
| 75 | // Single quotes are excluded because they're commonly used as apostrophes (don't, it's, etc.) |
| 76 | export const isInsideStringDelimiters = (text: string, position: number): boolean => { |
| 77 | let inDoubleQuote = false |
| 78 | let inBacktick = false |
| 79 | |
| 80 | for (let i = 0; i < position; i++) { |
| 81 | const char = text[i] |
| 82 | |
| 83 | // Check if this character is escaped by counting preceding backslashes |
| 84 | let numBackslashes = 0 |
| 85 | let j = i - 1 |
| 86 | while (j >= 0 && text[j] === '\\') { |
| 87 | numBackslashes++ |
| 88 | j-- |
| 89 | } |
| 90 | |
| 91 | // If there's an odd number of backslashes, the character is escaped |
| 92 | const isEscaped = numBackslashes % 2 === 1 |
| 93 | |
| 94 | if (!isEscaped) { |
| 95 | if (char === '"' && !inBacktick) { |
| 96 | inDoubleQuote = !inDoubleQuote |
| 97 | } else if (char === '`' && !inDoubleQuote) { |
| 98 | inBacktick = !inBacktick |
| 99 | } |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | return inDoubleQuote || inBacktick |
| 104 | } |
| 105 | |
| 106 | export const parseAtInLine = (line: string): MentionParseResult => { |
| 107 | const atIndex = line.lastIndexOf('@') |
no outgoing calls
no test coverage detected