stuff
This commit is contained in:
parent
396ca3e704
commit
a0e503fde0
4 changed files with 125 additions and 7 deletions
|
|
@ -120,7 +120,11 @@ describe("deterministicApplyLazyEdit(", () => {
|
|||
expect(myersDiffs).toEqual([]);
|
||||
});
|
||||
|
||||
test.only("tabs vs. spaces differences are ignored", async () => {
|
||||
test.only("fastapi", async () => {
|
||||
await expectDiff("fastapi.py");
|
||||
});
|
||||
|
||||
test.only("calculator exp", async () => {
|
||||
await expectDiff("fastapi.py");
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ export async function* streamLazyApply(
|
|||
filename: string,
|
||||
newCode: string,
|
||||
llm: ILLM,
|
||||
fastLlm: ILLM,
|
||||
): AsyncGenerator<DiffLine> {
|
||||
const promptFactory = lazyApplyPromptForModel(llm.model, llm.providerName);
|
||||
if (!promptFactory) {
|
||||
|
|
@ -33,19 +34,21 @@ export async function* streamLazyApply(
|
|||
oldCode,
|
||||
linesBefore,
|
||||
linesAfter,
|
||||
llm,
|
||||
fastLlm,
|
||||
)) {
|
||||
yield line;
|
||||
}
|
||||
|
||||
// let r = getReplacementByMatching(oldCode, linesBefore, linesAfter);
|
||||
// if (r) {
|
||||
// return r;
|
||||
// }
|
||||
// r = await getReplacementWithLlm(oldCode, linesBefore, linesAfter, llm);
|
||||
// if (r) {
|
||||
// return r;
|
||||
// for (let line of r.split("\n")) {
|
||||
// yield line;
|
||||
// }
|
||||
// }
|
||||
// // r = await getReplacementWithLlm(oldCode, linesBefore, linesAfter, llm);
|
||||
// // if (r) {
|
||||
// // return r;
|
||||
// // }
|
||||
// return "// NO REPLACEMENT FOUND";
|
||||
}
|
||||
|
||||
|
|
|
|||
99
core/edit/lazy/test-examples/calculator-exp.js.diff
Normal file
99
core/edit/lazy/test-examples/calculator-exp.js.diff
Normal file
|
|
@ -0,0 +1,99 @@
|
|||
class Calculator {
|
||||
constructor() {
|
||||
this.result = 0;
|
||||
}
|
||||
|
||||
add(number) {
|
||||
this.result += number;
|
||||
return this;
|
||||
}
|
||||
|
||||
subtract(number) {
|
||||
this.result -= number;
|
||||
return this;
|
||||
}
|
||||
|
||||
multiply(number) {
|
||||
this.result *= number;
|
||||
return this;
|
||||
}
|
||||
|
||||
divide(number) {
|
||||
if (number === 0) {
|
||||
throw new Error("Cannot divide by zero");
|
||||
}
|
||||
this.result /= number;
|
||||
return this;
|
||||
}
|
||||
|
||||
getResult() {
|
||||
return this.result;
|
||||
}
|
||||
|
||||
reset() {
|
||||
this.result = 0;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
---
|
||||
|
||||
class Calculator {
|
||||
constructor() {
|
||||
this.result = 0;
|
||||
}
|
||||
|
||||
// ... same ...
|
||||
|
||||
exp(a) {
|
||||
this.result = Math.pow(this.result, a);
|
||||
return this;
|
||||
}
|
||||
|
||||
// ... same ...
|
||||
}
|
||||
|
||||
---
|
||||
|
||||
class Calculator {
|
||||
constructor() {
|
||||
this.result = 0;
|
||||
}
|
||||
|
||||
add(number) {
|
||||
this.result += number;
|
||||
return this;
|
||||
}
|
||||
|
||||
subtract(number) {
|
||||
this.result -= number;
|
||||
return this;
|
||||
}
|
||||
|
||||
multiply(number) {
|
||||
this.result *= number;
|
||||
return this;
|
||||
}
|
||||
|
||||
divide(number) {
|
||||
if (number === 0) {
|
||||
throw new Error("Cannot divide by zero");
|
||||
}
|
||||
this.result /= number;
|
||||
return this;
|
||||
}
|
||||
+
|
||||
+ exp(a) {
|
||||
+ this.result = Math.pow(this.result, a);
|
||||
+ return this;
|
||||
+ }
|
||||
|
||||
getResult() {
|
||||
return this.result;
|
||||
}
|
||||
|
||||
reset() {
|
||||
this.result = 0;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
import { ILLM } from "core";
|
||||
import { ConfigHandler } from "core/config/ConfigHandler";
|
||||
import { streamLazyApply } from "core/edit/lazy/streamLazyApply";
|
||||
import {
|
||||
|
|
@ -147,12 +148,23 @@ export class VsCodeMessenger {
|
|||
return;
|
||||
}
|
||||
|
||||
let fastLlm: ILLM | undefined;
|
||||
if (config.experimental?.modelRoles?.repoMapFileSelection) {
|
||||
fastLlm = config.models.find(
|
||||
(model) =>
|
||||
model.title ===
|
||||
config.experimental?.modelRoles?.repoMapFileSelection,
|
||||
);
|
||||
}
|
||||
fastLlm ??= llm;
|
||||
|
||||
// Generate the diff and pass through diff manager
|
||||
const diffLines = streamLazyApply(
|
||||
editor.document.getText(),
|
||||
getBasename(editor.document.fileName),
|
||||
msg.data.text,
|
||||
llm,
|
||||
fastLlm,
|
||||
);
|
||||
const verticalDiffManager = await this.verticalDiffManagerPromise;
|
||||
verticalDiffManager.streamDiffLines(diffLines);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue