|
3800 | 3800 | // split the chunk in 2
|
3801 | 3801 | const left = { content: chunk.content.substring(0, chunk.content.indexOf(fillPlaceholder)), type: "user" };
|
3802 | 3802 | const right = { content: chunk.content.substring(chunk.content.indexOf(fillPlaceholder) + fillPlaceholder.length), type: "user" };
|
3803 |
| - fillIdx = i + 1; |
3804 | 3803 | leftPromptChunks = [
|
3805 |
| - ...promptChunks.slice(0, Math.max(0, i - 1)), |
3806 |
| - ...[left] |
| 3804 | + ...promptChunks.slice(0, i), |
| 3805 | + left |
3807 | 3806 | ];
|
3808 | 3807 | rightPromptChunks = [
|
3809 |
| - ...[right], |
| 3808 | + right, |
3810 | 3809 | ...promptChunks.slice(i + 1, promptChunks.length - 1),
|
3811 | 3810 | ];
|
| 3811 | + fillIdx = i + 1; |
3812 | 3812 | break;
|
3813 | 3813 | }
|
3814 | 3814 | }
|
|
3822 | 3822 | const finalPrompt = assembleFinalPrompt(additionalContextPrompt);
|
3823 | 3823 |
|
3824 | 3824 | predict(finalPrompt, leftPromptChunks.length, (chunk) => {
|
3825 |
| - console.log(chunk); |
3826 | 3825 | if (rightPromptChunks[0]) {
|
3827 |
| - if (chunk.content.trim().startsWith(rightPromptChunks[0].content[0])) { |
| 3826 | + const trimmedChunk = chunk.content.replace(/^ +| +$/gm, "") |
| 3827 | + if (trimmedChunk.startsWith(rightPromptChunks[0].content[0])) { |
3828 | 3828 | if (chunk.content[0] == ' ' && rightPromptChunks[0].content[0] != ' ') {
|
3829 | 3829 | rightPromptChunks[0].content = ' ' + rightPromptChunks[0].content;
|
3830 | 3830 | setPromptChunks(p => [
|
|
3902 | 3902 | while (undoStack.current.at(-1) >= chunkCount)
|
3903 | 3903 | undoStack.current.pop();
|
3904 | 3904 | undoStack.current.push(chunkCount);
|
3905 |
| - redoStack.current = []; |
| 3905 | + } else { |
| 3906 | + undoStack.current = []; |
3906 | 3907 | }
|
| 3908 | + redoStack.current = []; |
3907 | 3909 | setUndoHovered(false);
|
3908 | 3910 | setRejectedAPIKey(false);
|
3909 | 3911 | promptArea.current.scrollTarget = undefined;
|
|
0 commit comments