MCPcopy Create free account
hub / github.com/experdot/pointer / getSelectedTextFromInput

Function getSelectedTextFromInput

src/renderer/src/utils/searchSelection.ts:3–14  ·  view source on GitHub ↗
(activeElement: Element | null)

Source from the content-addressed store, hash-verified

1import { isMonacoFocused } from './shortcutGuards'
2
3function getSelectedTextFromInput(activeElement: Element | null): string | null {
4 if (activeElement instanceof HTMLInputElement || activeElement instanceof HTMLTextAreaElement) {
5 const selectionStart = activeElement.selectionStart
6 const selectionEnd = activeElement.selectionEnd
7
8 if (selectionStart !== null && selectionEnd !== null && selectionEnd > selectionStart) {
9 return activeElement.value.slice(selectionStart, selectionEnd)
10 }
11 }
12
13 return null
14}
15
16export function getSearchPrefillSelection(): string | null {
17 if (isMonacoFocused()) {

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected