(textarea: HTMLTextAreaElement)
| 1 | import {isMacOS} from '@primer/behaviors/utils' |
| 2 | |
| 3 | export const getSelectedLineRange = (textarea: HTMLTextAreaElement): [number, number] => { |
| 4 | // Subtract one from the caret position so the newline found is not the one _at_ the caret position |
| 5 | // then add one because we don't want to include the found newline. Also changes -1 (not found) result to 0 |
| 6 | const start = textarea.value.lastIndexOf('\n', textarea.selectionStart - 1) + 1 |
| 7 | |
| 8 | // activeLineEnd will be the index of the next newline inclusive, which works because slice is last-index exclusive |
| 9 | let end = textarea.value.indexOf('\n', textarea.selectionEnd) |
| 10 | if (end === -1) end = textarea.value.length |
| 11 | |
| 12 | return [start, end] |
| 13 | } |
| 14 | |
| 15 | export const markdownComment = (text: string) => `<!-- ${text.replaceAll('--', '\\-\\-')} -->` |
| 16 |
no outgoing calls
no test coverage detected