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

Function shouldRenderColor

src/cm/colorView.ts:96–118  ·  view source on GitHub ↗
(doc: Text, start: number, end: number)

Source from the content-addressed store, hash-verified

94}
95
96function shouldRenderColor(doc: Text, start: number, end: number): boolean {
97 const immediatePrev = charAt(doc, start - 1);
98 if (disallowedBoundaryBefore.has(immediatePrev)) return false;
99
100 const immediateNext = charAt(doc, end);
101 if (disallowedBoundaryAfter.has(immediateNext)) return false;
102
103 const prevNonWhitespaceIndex = findPrevNonWhitespace(doc, start);
104 if (prevNonWhitespaceIndex !== -1) {
105 const prevNonWhitespaceChar = charAt(doc, prevNonWhitespaceIndex);
106 if (disallowedBoundaryBefore.has(prevNonWhitespaceChar)) return false;
107 const prevWord = readWordBefore(doc, prevNonWhitespaceIndex);
108 if (ignoredLeadingWords.has(prevWord)) return false;
109 }
110
111 const nextNonWhitespaceIndex = findNextNonWhitespace(doc, end);
112 if (nextNonWhitespaceIndex < doc.length) {
113 const nextNonWhitespaceChar = charAt(doc, nextNonWhitespaceIndex);
114 if (disallowedBoundaryAfter.has(nextNonWhitespaceChar)) return false;
115 }
116
117 return true;
118}
119
120class ColorWidget extends WidgetType {
121 state: ColorWidgetState;

Callers 1

colorRangesFunction · 0.85

Calls 4

charAtFunction · 0.85
findPrevNonWhitespaceFunction · 0.85
readWordBeforeFunction · 0.85
findNextNonWhitespaceFunction · 0.85

Tested by

no test coverage detected