* Get word boundaries at a cell position
(col: number, row: number)
| 811 | * Get word boundaries at a cell position |
| 812 | */ |
| 813 | private getWordAtCell(col: number, row: number): { startCol: number; endCol: number } | null { |
| 814 | const line = this.wasmTerm.getLine(row); |
| 815 | if (!line) return null; |
| 816 | |
| 817 | // Word characters: letters, numbers, underscore, dash |
| 818 | const isWordChar = (cell: GhosttyCell) => { |
| 819 | if (!cell || cell.codepoint === 0) return false; |
| 820 | const char = String.fromCodePoint(cell.codepoint); |
| 821 | return /[\w-]/.test(char); |
| 822 | }; |
| 823 | |
| 824 | // Only return if we're actually on a word character |
| 825 | if (!isWordChar(line[col])) return null; |
| 826 | |
| 827 | // Find start of word |
| 828 | let startCol = col; |
| 829 | while (startCol > 0 && isWordChar(line[startCol - 1])) { |
| 830 | startCol--; |
| 831 | } |
| 832 | |
| 833 | // Find end of word |
| 834 | let endCol = col; |
| 835 | while (endCol < line.length - 1 && isWordChar(line[endCol + 1])) { |
| 836 | endCol++; |
| 837 | } |
| 838 | |
| 839 | return { startCol, endCol }; |
| 840 | } |
| 841 | |
| 842 | /** |
| 843 | * Copy text to clipboard |
no test coverage detected