MCPcopy Create free account
hub / github.com/cursorless-dev/cursorless / getSelectionInfo

Function getSelectionInfo

src/core/updateSelections/updateSelections.ts:27–57  ·  view source on GitHub ↗
(
  document: TextDocument,
  selection: Selection,
  rangeBehavior: DecorationRangeBehavior
)

Source from the content-addressed store, hash-verified

25 * @returns An object that can be used for selection tracking
26 */
27export function getSelectionInfo(
28 document: TextDocument,
29 selection: Selection,
30 rangeBehavior: DecorationRangeBehavior
31): FullSelectionInfo {
32 return {
33 range: new Range(selection.start, selection.end),
34 isForward: isForward(selection),
35 expansionBehavior: {
36 start: {
37 type:
38 rangeBehavior === DecorationRangeBehavior.ClosedClosed ||
39 rangeBehavior === DecorationRangeBehavior.ClosedOpen
40 ? "closed"
41 : "open",
42 },
43 end: {
44 type:
45 rangeBehavior === DecorationRangeBehavior.ClosedClosed ||
46 rangeBehavior === DecorationRangeBehavior.OpenClosed
47 ? "closed"
48 : "open",
49 },
50 },
51 offsets: {
52 start: document.offsetAt(selection.start),
53 end: document.offsetAt(selection.end),
54 },
55 text: document.getText(selection),
56 };
57}
58
59/**
60 * Creates SelectionInfo objects for all selections in a list of lists.

Callers 3

runMethod · 0.90

Calls 1

isForwardFunction · 0.90

Tested by

no test coverage detected