MCPcopy Create free account
hub / github.com/continuedev/continue / renderEditText

Function renderEditText

extensions/cli/src/ui/EditMessageSelector.tsx:179–233  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

177 }
178
179 const renderEditText = () => {
180 if (editText.length === 0) {
181 return (
182 <Text italic color="gray">
183 ▋(empty message)
184 </Text>
185 );
186 }
187
188 // Handle multi-line text with cursor
189 const lines = editText.split("\n");
190 let charCount = 0;
191 let cursorLine = 0;
192 let cursorCol = 0;
193
194 // Find which line and column the cursor is on
195 for (let i = 0; i < lines.length; i++) {
196 if (cursorPosition <= charCount + lines[i].length) {
197 cursorLine = i;
198 cursorCol = cursorPosition - charCount;
199 break;
200 }
201 charCount += lines[i].length + 1; // +1 for the newline character
202 }
203
204 // Handle cursor at the very end
205 if (cursorPosition >= editText.length) {
206 cursorLine = lines.length - 1;
207 cursorCol = lines[cursorLine].length;
208 }
209
210 return (
211 <Box flexDirection="column">
212 {lines.map((line, lineIndex) => {
213 if (lineIndex === cursorLine) {
214 // Line with cursor
215 const beforeCursor = line.slice(0, cursorCol);
216 const atCursor = line.slice(cursorCol, cursorCol + 1);
217 const afterCursor = line.slice(cursorCol + 1);
218
219 return (
220 <Text key={lineIndex}>
221 {beforeCursor}
222 <Text inverse>{atCursor || " "}</Text>
223 {afterCursor}
224 </Text>
225 );
226 } else {
227 // Regular line - ensure empty lines still render
228 return <Text key={lineIndex}>{line || " "}</Text>;
229 }
230 })}
231 </Box>
232 );
233 };
234
235 return (
236 <Box {...defaultBoxStyles("yellow")}>

Callers 1

EditMessageSelectorFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected