MCPcopy Create free account
hub / github.com/massCodeIO/massCode / getContiguousSelection

Function getContiguousSelection

src/renderer/utils/index.ts:17–42  ·  view source on GitHub ↗
(
  orderedIds: number[],
  anchorId: number | undefined,
  targetId: number,
)

Source from the content-addressed store, hash-verified

15}
16
17export function getContiguousSelection(
18 orderedIds: number[],
19 anchorId: number | undefined,
20 targetId: number,
21): number[] {
22 if (!orderedIds.length) {
23 return []
24 }
25
26 const anchorIndex
27 = anchorId !== undefined ? orderedIds.indexOf(anchorId) : -1
28 const targetIndex = orderedIds.indexOf(targetId)
29
30 if (targetIndex === -1) {
31 return []
32 }
33
34 if (anchorIndex === -1) {
35 return [targetId]
36 }
37
38 const startIndex = Math.min(anchorIndex, targetIndex)
39 const endIndex = Math.max(anchorIndex, targetIndex)
40
41 return orderedIds.slice(startIndex, endIndex + 1)
42}
43
44export * from './entryNameValidationMessage'

Callers 6

selectSnippetFunction · 0.90
selectHttpRequestFunction · 0.90
selectNoteFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected