Skip to content

Commit 979839c

Browse files
committed
Some fixes
1 parent 4690e54 commit 979839c

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

mikupad.html

+9-7
Original file line numberDiff line numberDiff line change
@@ -3800,15 +3800,15 @@
38003800
// split the chunk in 2
38013801
const left = { content: chunk.content.substring(0, chunk.content.indexOf(fillPlaceholder)), type: "user" };
38023802
const right = { content: chunk.content.substring(chunk.content.indexOf(fillPlaceholder) + fillPlaceholder.length), type: "user" };
3803-
fillIdx = i + 1;
38043803
leftPromptChunks = [
3805-
...promptChunks.slice(0, Math.max(0, i - 1)),
3806-
...[left]
3804+
...promptChunks.slice(0, i),
3805+
left
38073806
];
38083807
rightPromptChunks = [
3809-
...[right],
3808+
right,
38103809
...promptChunks.slice(i + 1, promptChunks.length - 1),
38113810
];
3811+
fillIdx = i + 1;
38123812
break;
38133813
}
38143814
}
@@ -3822,9 +3822,9 @@
38223822
const finalPrompt = assembleFinalPrompt(additionalContextPrompt);
38233823

38243824
predict(finalPrompt, leftPromptChunks.length, (chunk) => {
3825-
console.log(chunk);
38263825
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])) {
38283828
if (chunk.content[0] == ' ' && rightPromptChunks[0].content[0] != ' ') {
38293829
rightPromptChunks[0].content = ' ' + rightPromptChunks[0].content;
38303830
setPromptChunks(p => [
@@ -3902,8 +3902,10 @@
39023902
while (undoStack.current.at(-1) >= chunkCount)
39033903
undoStack.current.pop();
39043904
undoStack.current.push(chunkCount);
3905-
redoStack.current = [];
3905+
} else {
3906+
undoStack.current = [];
39063907
}
3908+
redoStack.current = [];
39073909
setUndoHovered(false);
39083910
setRejectedAPIKey(false);
39093911
promptArea.current.scrollTarget = undefined;

0 commit comments

Comments
 (0)