MCPcopy Create free account
hub / github.com/Acode-Foundation/Acode / getScanStart

Function getScanStart

src/cm/rainbowBrackets.ts:75–101  ·  view source on GitHub ↗
(
	view: EditorView,
	lookBehind: number,
	exactScanLimit: number,
)

Source from the content-addressed store, hash-verified

73}
74
75function getScanStart(
76 view: EditorView,
77 lookBehind: number,
78 exactScanLimit: number,
79): number {
80 const ranges = view.visibleRanges;
81 if (!ranges.length) return 0;
82
83 const firstVisibleFrom = ranges[0].from;
84 const lastVisibleTo = ranges[ranges.length - 1].to;
85 const docLength = view.state.doc.length;
86
87 if (docLength <= exactScanLimit || firstVisibleFrom <= exactScanLimit) {
88 return 0;
89 }
90
91 const visibleSpan = Math.max(1, lastVisibleTo - firstVisibleFrom);
92 const dynamicLookBehind = Math.max(
93 MIN_LOOK_BEHIND,
94 Math.min(MAX_LOOK_BEHIND, visibleSpan * 3),
95 );
96
97 return Math.max(
98 0,
99 firstVisibleFrom - Math.max(lookBehind, dynamicLookBehind),
100 );
101}
102
103function isOpeningBracket(char: string): boolean {
104 return char === "(" || char === "[" || char === "{";

Callers 1

buildDecorationsMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected