(str)
| 246 | |
| 247 | // Insert plain text at caret, replacing any selection; used by paste/drop after normalisation. Enforces `MAX_LINES`. |
| 248 | const insertAtCaret = (str) => { |
| 249 | const pos = jar.save(); |
| 250 | const text = jar.toString(); |
| 251 | let next = text.slice(0, pos.start) + str + text.slice(pos.end); |
| 252 | const all = next.split('\n'); |
| 253 | if (all.length > MAX_LINES) next = all.slice(0, MAX_LINES).join('\n'); |
| 254 | writeAndRestore(next, Math.min(pos.start + str.length, next.length)); |
| 255 | }; |
| 256 | |
| 257 | // Paste/drop pipeline: strip ```python fence, normalise CRLF+tabs, smart-dedent common indent, enforce `MAX_LINES`. |
| 258 | const insertNormalized = (raw) => { |
no test coverage detected