diff --git a/core/edit/lazy/deterministic.test.ts b/core/edit/lazy/deterministic.test.ts index 7e050055d..13a4da0bf 100644 --- a/core/edit/lazy/deterministic.test.ts +++ b/core/edit/lazy/deterministic.test.ts @@ -119,7 +119,7 @@ describe("deterministicApplyLazyEdit(", () => { await expectDiff("fastapi.py"); }); - // Whitespace + // TODO: Whitespace test("calculator exp", async () => { await expectDiff("calculator-exp.js"); }); @@ -128,7 +128,11 @@ describe("deterministicApplyLazyEdit(", () => { await expectDiff("calculator-exp2.js"); }); - test.only("calculator comments", async () => { + test("calculator comments", async () => { await expectDiff("calculator-comments.js"); }); + + test("calculator docstrings", async () => { + await expectDiff("calculator-docstrings.js"); + }); }); diff --git a/core/edit/lazy/test-examples/calculator-docstrings.js.diff b/core/edit/lazy/test-examples/calculator-docstrings.js.diff new file mode 100644 index 000000000..a7702238a --- /dev/null +++ b/core/edit/lazy/test-examples/calculator-docstrings.js.diff @@ -0,0 +1,189 @@ +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; + } +} + +--- + +/** + * Calculator class for performing basic arithmetic operations. + */ +class Calculator { + /** + * Creates a new Calculator instance. + * Initializes the result to 0. + */ + constructor() { + this.result = 0; + } + + /** + * Adds a number to the current result. + * @param {number} number - The number to add. + * @returns {Calculator} The Calculator instance for method chaining. + */ + add(number) { + this.result += number; + return this; + } + + /** + * Subtracts a number from the current result. + * @param {number} number - The number to subtract. + * @returns {Calculator} The Calculator instance for method chaining. + */ + subtract(number) { + this.result -= number; + return this; + } + + /** + * Multiplies the current result by a number. + * @param {number} number - The number to multiply by. + * @returns {Calculator} The Calculator instance for method chaining. + */ + multiply(number) { + this.result *= number; + return this; + } + + /** + * Divides the current result by a number. + * @param {number} number - The number to divide by. + * @returns {Calculator} The Calculator instance for method chaining. + * @throws {Error} If attempting to divide by zero. + */ + divide(number) { + if (number === 0) { + throw new Error("Cannot divide by zero"); + } + this.result /= number; + return this; + } + + /** + * Returns the current result. + * @returns {number} The current result. + */ + getResult() { + return this.result; + } + + /** + * Resets the calculator's result to 0. + * @returns {Calculator} The Calculator instance for method chaining. + */ + reset() { + this.result = 0; + return this; + } +} + +--- + ++ /** ++ * Calculator class for performing basic arithmetic operations. ++ */ +class Calculator { ++ /** ++ * Creates a new Calculator instance. ++ * Initializes the result to 0. ++ */ + constructor() { + this.result = 0; + } + ++ /** ++ * Adds a number to the current result. ++ * @param {number} number - The number to add. ++ * @returns {Calculator} The Calculator instance for method chaining. ++ */ + add(number) { + this.result += number; + return this; + } + ++ /** ++ * Subtracts a number from the current result. ++ * @param {number} number - The number to subtract. ++ * @returns {Calculator} The Calculator instance for method chaining. ++ */ + subtract(number) { + this.result -= number; + return this; + } + ++ /** ++ * Multiplies the current result by a number. ++ * @param {number} number - The number to multiply by. ++ * @returns {Calculator} The Calculator instance for method chaining. ++ */ + multiply(number) { + this.result *= number; + return this; + } + ++ /** ++ * Divides the current result by a number. ++ * @param {number} number - The number to divide by. ++ * @returns {Calculator} The Calculator instance for method chaining. ++ * @throws {Error} If attempting to divide by zero. ++ */ + divide(number) { + if (number === 0) { + throw new Error("Cannot divide by zero"); + } + this.result /= number; + return this; + } + ++ /** ++ * Returns the current result. ++ * @returns {number} The current result. ++ */ + getResult() { + return this.result; + } + ++ /** ++ * Resets the calculator's result to 0. ++ * @returns {Calculator} The Calculator instance for method chaining. ++ */ + reset() { + this.result = 0; + return this; + } +} \ No newline at end of file diff --git a/gui/src/components/markdown/PreWithToolbar.tsx b/gui/src/components/markdown/PreWithToolbar.tsx index 30c34a91d..02c055a92 100644 --- a/gui/src/components/markdown/PreWithToolbar.tsx +++ b/gui/src/components/markdown/PreWithToolbar.tsx @@ -10,6 +10,7 @@ import CodeBlockToolBar from "./CodeBlockToolbar"; const TopDiv = styled.div` border: 0.5px solid ${lightGray}80; border-radius: ${defaultBorderRadius}; + margin-bottom: 8px; `; function childToText(child: any) {