|
3850 | 3850 | // split the chunk in 2
|
3851 | 3851 | const left = { content: chunk.content.substring(0, chunk.content.indexOf(fillPlaceholder)), type: "user" };
|
3852 | 3852 | const right = { content: chunk.content.substring(chunk.content.indexOf(fillPlaceholder) + fillPlaceholder.length), type: "user" };
|
3853 |
| - fillIdx = i + 1; |
3854 | 3853 | leftPromptChunks = [
|
3855 |
| - ...promptChunks.slice(0, Math.max(0, i - 1)), |
3856 |
| - ...[left] |
| 3854 | + ...promptChunks.slice(0, i), |
| 3855 | + left |
3857 | 3856 | ];
|
3858 | 3857 | rightPromptChunks = [
|
3859 |
| - ...[right], |
| 3858 | + right, |
3860 | 3859 | ...promptChunks.slice(i + 1, promptChunks.length - 1),
|
3861 | 3860 | ];
|
| 3861 | + fillIdx = i + 1; |
3862 | 3862 | break;
|
3863 | 3863 | }
|
3864 | 3864 | }
|
|
3872 | 3872 | const finalPrompt = assembleFinalPrompt(additionalContextPrompt);
|
3873 | 3873 |
|
3874 | 3874 | predict(finalPrompt, leftPromptChunks.length, (chunk) => {
|
3875 |
| - console.log(chunk); |
3876 | 3875 | if (rightPromptChunks[0]) {
|
3877 |
| - if (chunk.content.trim().startsWith(rightPromptChunks[0].content[0])) { |
| 3876 | + const trimmedChunk = chunk.content.replace(/^ +| +$/gm, "") |
| 3877 | + if (trimmedChunk.startsWith(rightPromptChunks[0].content[0])) { |
3878 | 3878 | if (chunk.content[0] == ' ' && rightPromptChunks[0].content[0] != ' ') {
|
3879 | 3879 | rightPromptChunks[0].content = ' ' + rightPromptChunks[0].content;
|
3880 | 3880 | setPromptChunks(p => [
|
|
3956 | 3956 | while (undoStack.current.at(-1) >= chunkCount)
|
3957 | 3957 | undoStack.current.pop();
|
3958 | 3958 | undoStack.current.push(chunkCount);
|
3959 |
| - redoStack.current = []; |
| 3959 | + } else { |
| 3960 | + undoStack.current = []; |
3960 | 3961 | }
|
| 3962 | + redoStack.current = []; |
3961 | 3963 | setUndoHovered(false);
|
3962 | 3964 | setRejectedAPIKey(false);
|
3963 | 3965 | promptArea.current.scrollTarget = undefined;
|
|
0 commit comments