fix: code interpreter code editor issue
Some checks failed
Deploy to HuggingFace Spaces / check-secret (push) Has been cancelled
Create and publish Docker images with specific build args / build-main-image (linux/amd64, ubuntu-latest) (push) Has been cancelled
Create and publish Docker images with specific build args / build-main-image (linux/arm64, ubuntu-24.04-arm) (push) Has been cancelled
Create and publish Docker images with specific build args / build-cuda-image (linux/amd64, ubuntu-latest) (push) Has been cancelled
Create and publish Docker images with specific build args / build-cuda-image (linux/arm64, ubuntu-24.04-arm) (push) Has been cancelled
Create and publish Docker images with specific build args / build-cuda126-image (linux/amd64, ubuntu-latest) (push) Has been cancelled
Create and publish Docker images with specific build args / build-cuda126-image (linux/arm64, ubuntu-24.04-arm) (push) Has been cancelled
Create and publish Docker images with specific build args / build-ollama-image (linux/amd64, ubuntu-latest) (push) Has been cancelled
Create and publish Docker images with specific build args / build-ollama-image (linux/arm64, ubuntu-24.04-arm) (push) Has been cancelled
Frontend Build / Format & Build Frontend (push) Has been cancelled
Frontend Build / Frontend Unit Tests (push) Has been cancelled
Deploy to HuggingFace Spaces / deploy (push) Has been cancelled
Create and publish Docker images with specific build args / merge-main-images (push) Has been cancelled
Create and publish Docker images with specific build args / merge-cuda-images (push) Has been cancelled
Create and publish Docker images with specific build args / merge-cuda126-images (push) Has been cancelled
Create and publish Docker images with specific build args / merge-ollama-images (push) Has been cancelled

This commit is contained in:
Timothy Jaeryang Baek 2025-06-26 11:05:17 +04:00
parent b6e2b2e514
commit 21d616f8ed

View File

@ -48,35 +48,28 @@
/**
* Finds multiple diffs in two strings and generates minimal change edits.
*/
function findChanges(oldStr, newStr) {
let changes = [];
let oldIndex = 0,
newIndex = 0;
while (oldIndex < oldStr.length || newIndex < newStr.length) {
if (oldStr[oldIndex] !== newStr[newIndex]) {
let start = oldIndex;
// Identify the changed portion
while (oldIndex < oldStr.length && oldStr[oldIndex] !== newStr[newIndex]) {
oldIndex++;
}
while (newIndex < newStr.length && newStr[newIndex] !== oldStr[start]) {
newIndex++;
}
changes.push({
from: start,
to: oldIndex, // Replace the differing part
insert: newStr.substring(start, newIndex)
});
} else {
oldIndex++;
newIndex++;
}
function findChanges(oldStr: string, newStr: string) {
// Find the start of the difference
let start = 0;
while (start < oldStr.length && start < newStr.length && oldStr[start] === newStr[start]) {
start++;
}
return changes;
// If equal, nothing to change
if (oldStr === newStr) return [];
// Find the end of the difference by comparing backwards
let endOld = oldStr.length,
endNew = newStr.length;
while (endOld > start && endNew > start && oldStr[endOld - 1] === newStr[endNew - 1]) {
endOld--;
endNew--;
}
return [
{
from: start,
to: endOld,
insert: newStr.slice(start, endNew)
}
];
}
export let id = '';