diff --git a/nbdime/webapp/templates/compare.html b/nbdime/webapp/templates/compare.html index d22bf65e..a6fcef0f 100644 --- a/nbdime/webapp/templates/compare.html +++ b/nbdime/webapp/templates/compare.html @@ -9,18 +9,18 @@

Notebook Diff/Merge

Please input filenames of notebooks to compare: - - - - - - + + +
- + diff --git a/nbdime/webapp/templates/diff.html b/nbdime/webapp/templates/diff.html index 7d16c40b..447675eb 100644 --- a/nbdime/webapp/templates/diff.html +++ b/nbdime/webapp/templates/diff.html @@ -9,15 +9,15 @@

Notebook Diff

Please input filenames/URLs of notebooks to diff: - - - - + +
- + diff --git a/nbdime/webapp/templates/difftool.html b/nbdime/webapp/templates/difftool.html index ff7a5f11..5c86959d 100644 --- a/nbdime/webapp/templates/difftool.html +++ b/nbdime/webapp/templates/difftool.html @@ -5,7 +5,7 @@

Notebook Diff

- + diff --git a/nbdime/webapp/templates/merge.html b/nbdime/webapp/templates/merge.html index 9de50977..a8e7ce00 100644 --- a/nbdime/webapp/templates/merge.html +++ b/nbdime/webapp/templates/merge.html @@ -9,18 +9,18 @@

Notebook Merge

Please input filenames/URLs of notebooks to merge: - - - - - - + + +
- + diff --git a/nbdime/webapp/templates/mergetool.html b/nbdime/webapp/templates/mergetool.html index 7820add4..bfe62d76 100644 --- a/nbdime/webapp/templates/mergetool.html +++ b/nbdime/webapp/templates/mergetool.html @@ -5,7 +5,7 @@

Notebook Merge

- + diff --git a/packages/nbdime/src/common/mergeview.ts b/packages/nbdime/src/common/mergeview.ts index 808f3309..e2f83144 100644 --- a/packages/nbdime/src/common/mergeview.ts +++ b/packages/nbdime/src/common/mergeview.ts @@ -1196,7 +1196,7 @@ function getMatchingEditLineLC(toMatch: Chunk, chunks: Chunk[]): number { } } // toMatch is not in chunks list, add lines delta from the last chunk - return toMatch.baseTo + (previous ? (previous.remoteTo - previous.baseTo) : 0); + return toMatch.baseTo + (previous ? previous.remoteTo - previous.baseTo : 0); } /** @@ -1444,7 +1444,13 @@ export class MergeView extends Panel { const additionalExtensions = inMergeView ? [listener, mergeControlGutter, getCommonEditorExtensions(inMergeView)] : getCommonEditorExtensions(inMergeView); - if (this._collapseIdentical >= 0) { + const singlePane = !merged && (remote?.unchanged || remote?.added || remote?.deleted) + if ( + // no collapse + this._collapseIdentical >= 0 && + // not displaying a single editor + !singlePane + ) { additionalExtensions.push(CollapsedRangesField); } @@ -1686,7 +1692,7 @@ export class MergeView extends Panel { Decoration.widget({ widget: new PaddingWidget(delta * lineHeight), block: true, - side: -1, + side: -1, }), ); } diff --git a/ui-tests/data/merge_test6/center.ipynb b/ui-tests/data/merge_test6/center.ipynb new file mode 100644 index 00000000..7a13ad78 --- /dev/null +++ b/ui-tests/data/merge_test6/center.ipynb @@ -0,0 +1,78 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "b84ee5a1", + "metadata": {}, + "source": [ + "# Initial notebook" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "id": "a29ef27d", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'hello the world'" + ] + }, + "execution_count": 1, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# This is the first cell in the initial commit\n", + "a = \"hello the world\"\n", + "a" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "0b24d979", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'hello Tony Stark'" + ] + }, + "execution_count": 2, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# This is the last cell in the initial commit\n", + "a.replace(\"the world\", \"Tony Stark\")" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.9.5" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} \ No newline at end of file diff --git a/ui-tests/data/merge_test6/left.ipynb b/ui-tests/data/merge_test6/left.ipynb new file mode 100644 index 00000000..49d99454 --- /dev/null +++ b/ui-tests/data/merge_test6/left.ipynb @@ -0,0 +1,101 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "b84ee5a1", + "metadata": {}, + "source": [ + "# a-branch notebook" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "id": "a29ef27d", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'hello the world'" + ] + }, + "execution_count": 1, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# This is the first cell in the initial commit\n", + "a = \"hello the world\"\n", + "a" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "a29bf27d", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'The answer is 42'" + ] + }, + "execution_count": 2, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# This is a new cell in a-branch\n", + "b = \"The answer is 42\"\n", + "b" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "0b24d979", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'hello a-branch'" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# This is the last cell in the initial commit\n", + "a.replace(\"the world\", \"a-branch\")" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.9.5" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} \ No newline at end of file diff --git a/ui-tests/data/merge_test6/right.ipynb b/ui-tests/data/merge_test6/right.ipynb new file mode 100644 index 00000000..905dcc0b --- /dev/null +++ b/ui-tests/data/merge_test6/right.ipynb @@ -0,0 +1,100 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "b84ee5a1", + "metadata": {}, + "source": [ + "# Enhanced notebook" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "id": "a29ef27d", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'hello the world'" + ] + }, + "execution_count": 1, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# This is the first cell in the initial commit\n", + "a = \"hello the world\"\n", + "a" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "0b24d979", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'hello Superman'" + ] + }, + "execution_count": 2, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# This is the last cell in the initial commit\n", + "a.replace(\"the world\", \"Superman\")" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "0b74d979", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'What about Batman?'" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# This the new last cell on master\n", + "print(\"What about Batman?\")" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.9.5" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} \ No newline at end of file diff --git a/ui-tests/package-lock.json b/ui-tests/package-lock.json index 9d389c9b..827e33f3 100644 --- a/ui-tests/package-lock.json +++ b/ui-tests/package-lock.json @@ -40,6 +40,7 @@ "version": "2.3.2", "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "dev": true, "hasInstallScript": true, "optional": true, "os": [ @@ -49,23 +50,6 @@ "node": "^8.16.0 || ^10.6.0 || >=11.0.0" } }, - "node_modules/playwright": { - "version": "1.38.1", - "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.38.1.tgz", - "integrity": "sha512-oRMSJmZrOu1FP5iu3UrCx8JEFRIMxLDM0c/3o4bpzU5Tz97BypefWf7TuTNPWeCe279TPal5RtPPZ+9lW/Qkow==", - "dependencies": { - "playwright-core": "1.38.1" - }, - "bin": { - "playwright": "cli.js" - }, - "engines": { - "node": ">=16" - }, - "optionalDependencies": { - "fsevents": "2.3.2" - } - }, "node_modules/playwright-core": { "version": "1.36.2", "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.36.2.tgz", @@ -77,17 +61,6 @@ "engines": { "node": ">=16" } - }, - "node_modules/playwright/node_modules/playwright-core": { - "version": "1.38.1", - "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.38.1.tgz", - "integrity": "sha512-tQqNFUKa3OfMf4b2jQ7aGLB8o9bS3bOY0yMEtldtC2+spf8QXG9zvXLTXUeRsoNuxEYMgLYR+NXfAa1rjKRcrg==", - "bin": { - "playwright-core": "cli.js" - }, - "engines": { - "node": ">=16" - } } } } diff --git a/ui-tests/tests/nbdime-merge-test6.spec.ts b/ui-tests/tests/nbdime-merge-test6.spec.ts new file mode 100644 index 00000000..28a41bfe --- /dev/null +++ b/ui-tests/tests/nbdime-merge-test6.spec.ts @@ -0,0 +1,18 @@ +import { expect, test } from '@playwright/test'; + +test.describe('merge test6', () => { + test.beforeEach(async ({ page }) => { + await page.goto('http://localhost:41000/merge'); + await page.locator('#merge-local').fill('data/merge_test6/left.ipynb'); + await page.locator('#merge-base').fill('data/merge_test6/center.ipynb'); + await page.locator('#merge-remote').fill('data/merge_test6/right.ipynb'); + await page.getByRole('button', { name: 'Merge files' }).click(); + }); + + test('take a snapshot at opening', async ({ page }) => { + await page.getByText('Hide unchanged cells').click() + await page.getByText('a = "hello the world"').waitFor(); + // Check that single editor are not collapsed; added cell and unchanged cell + expect.soft(await page.locator('#main').screenshot()).toMatchSnapshot(); + }); +}); diff --git a/ui-tests/tests/nbdime-merge-test6.spec.ts-snapshots/merge-test6-take-a-snapshot-at-opening-1-linux.png b/ui-tests/tests/nbdime-merge-test6.spec.ts-snapshots/merge-test6-take-a-snapshot-at-opening-1-linux.png new file mode 100644 index 00000000..2f3bcd34 Binary files /dev/null and b/ui-tests/tests/nbdime-merge-test6.spec.ts-snapshots/merge-test6-take-a-snapshot-at-opening-1-linux.png differ diff --git a/ui-tests/tests/nbdime-merge-test6.spec.ts-snapshots/merge-test6-take-a-snapshot-at-opening-1-win32.png b/ui-tests/tests/nbdime-merge-test6.spec.ts-snapshots/merge-test6-take-a-snapshot-at-opening-1-win32.png new file mode 100644 index 00000000..f780199e Binary files /dev/null and b/ui-tests/tests/nbdime-merge-test6.spec.ts-snapshots/merge-test6-take-a-snapshot-at-opening-1-win32.png differ