Skip to content

Commit

Permalink
Do not collapse editor lines in single editor (#719)
Browse files Browse the repository at this point in the history
* Deal with collapsed line in single editor

* Update Playwright Snapshots

* Update Playwright Snapshots

* Apply suggestions from code review

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
fcollonval and github-actions[bot] authored Oct 20, 2023
1 parent 8ebbc6e commit d39f45a
Show file tree
Hide file tree
Showing 13 changed files with 328 additions and 52 deletions.
14 changes: 7 additions & 7 deletions nbdime/webapp/templates/compare.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@ <h3>Notebook Diff/Merge</h3>
<form id="nbdime-compare-form" class="nbdime-forms">
<fieldset>
<legend>Please input filenames of notebooks to compare:</legend>
<label>Local:</label>
<input id="compare-local" type="text" name="local" value="{{ config_data['local']|e }}" />
<label>Base:</label>
<input id="compare-base" type="text" name="base" value="{{ config_data['base']|e }}" />
<label>Remote:</label>
<input id="compare-remote" type="text" name="remote" value="{{ config_data['remote']|e }}" />
<label>Local:
<input id="compare-local" type="text" name="local" value="{{ config_data['local']|e }}" /></label>
<label>Base:
<input id="compare-base" type="text" name="base" value="{{ config_data['base']|e }}" /></label>
<label>Remote:
<input id="compare-remote" type="text" name="remote" value="{{ config_data['remote']|e }}" /></label>
<input id="nbdime-run-compare" type="submit" name="auto" value="Compare files" />
<button id="nbdime-download" style="display: none" type="button">Download</button>
</fieldset>
</form> <!-- nbdime-forms -->
<div id="nbdime-header-buttonrow">
<input id="nbdime-hide-unchanged" type="checkbox"><label for="cbox1">Hide unchanged cells</label></input>
<label><input id="nbdime-hide-unchanged" type="checkbox"></input>Hide unchanged cells</label>
<button id="nbdime-save" style="display: none">Save</button>
<button id="nbdime-download" style="display: none">Download</button>
<button id="nbdime-close" style="display: none">Close tool</button>
Expand Down
10 changes: 5 additions & 5 deletions nbdime/webapp/templates/diff.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ <h3>Notebook Diff</h3>
<form id="nbdime-diff-form" class="nbdime-forms">
<fieldset>
<legend>Please input filenames/URLs of notebooks to diff:</legend>
<label>Base:</label>
<input id="diff-base" type="text" name="base" value="{{ config_data['base']|e }}" />
<label>Remote:</label>
<input id="diff-remote" type="text" name="remote" value="{{ config_data['remote']|e }}" />
<label>Base:
<input id="diff-base" type="text" name="base" value="{{ config_data['base']|e }}" /></label>
<label>Remote:
<input id="diff-remote" type="text" name="remote" value="{{ config_data['remote']|e }}" /></label>
<input id="nbdime-run-diff" type="submit" name="diff" value="Diff files" />
</fieldset>
</form> <!-- nbdime-forms -->
<div id="nbdime-header-buttonrow">
<input id="nbdime-hide-unchanged" type="checkbox"><label for="cbox1">Hide unchanged cells</label></input>
<label><input id="nbdime-hide-unchanged" type="checkbox"></input>Hide unchanged cells</label>
<button id="nbdime-trust" style="display: none">Trust outputs</button>
<button id="nbdime-close" type="checkbox" style="display: none">Close tool</button>
<button id="nbdime-export" type="checkbox" style="display: none">Export diff</button>
Expand Down
2 changes: 1 addition & 1 deletion nbdime/webapp/templates/difftool.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<div id="nbdime-header" class="nbdime-Diff">
<h3>Notebook Diff</h3>
<div id="nbdime-header-buttonrow">
<input id="nbdime-hide-unchanged" type="checkbox"><label for="cbox1">Hide unchanged cells</label></input>
<label><input id="nbdime-hide-unchanged" type="checkbox"></input>Hide unchanged cells</label>
<button id="nbdime-trust" style="display: none">Trust outputs</button>
<button id="nbdime-close" style="display: none">Close tool</button>
<button id="nbdime-export" style="display: none">Export diff</button>
Expand Down
14 changes: 7 additions & 7 deletions nbdime/webapp/templates/merge.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@ <h3>Notebook Merge</h3>
<form id="nbdime-merge-form" class="nbdime-forms">
<fieldset>
<legend>Please input filenames/URLs of notebooks to merge:</legend>
<label>Local:</label>
<input id="merge-local" type="text" name="local" value="{{ config_data['local']|e }}" />
<label>Base:</label>
<input id="merge-base" type="text" name="base" value="{{ config_data['base']|e }}" />
<label>Remote:</label>
<input id="merge-remote" type="text" name="remote" value="{{ config_data['remote']|e }}" />
<label>Local:
<input id="merge-local" type="text" name="local" value="{{ config_data['local']|e }}" /></label>
<label>Base:
<input id="merge-base" type="text" name="base" value="{{ config_data['base']|e }}" /></label>
<label>Remote:
<input id="merge-remote" type="text" name="remote" value="{{ config_data['remote']|e }}" /></label>
<input id="nbdime-run-merge" type="submit" name="merge" value="Merge files" />
<button id="nbdime-download" style="display: none" type="button">Download</button>
</fieldset>
</form> <!-- nbdime-forms -->
<div id="nbdime-header-buttonrow">
<input id="nbdime-hide-unchanged" type="checkbox"><label for="cbox1">Hide unchanged cells</label></input>
<label><input id="nbdime-hide-unchanged" type="checkbox"></input>Hide unchanged cells</label>
<button id="nbdime-save" style="display: none">Save</button>
<button id="nbdime-download" style="display: none">Download</button>
<button id="nbdime-close" style="display: none">Close tool</button>
Expand Down
2 changes: 1 addition & 1 deletion nbdime/webapp/templates/mergetool.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<div id="nbdime-header" class="nbdime-Merge">
<h3>Notebook Merge</h3>
<div id="nbdime-header-buttonrow">
<input id="nbdime-hide-unchanged" type="checkbox"><label for="cbox1">Hide unchanged cells</label></input>
<label><input id="nbdime-hide-unchanged" type="checkbox"></input>Hide unchanged cells</label>
<button id="nbdime-save" style="display: none">Save</button>
<button id="nbdime-download" style="display: none">Download</button>
<button id="nbdime-close" style="display: none">Close tool</button>
Expand Down
12 changes: 9 additions & 3 deletions packages/nbdime/src/common/mergeview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -1686,7 +1692,7 @@ export class MergeView extends Panel {
Decoration.widget({
widget: new PaddingWidget(delta * lineHeight),
block: true,
side: -1,
side: -1,
}),
);
}
Expand Down
78 changes: 78 additions & 0 deletions ui-tests/data/merge_test6/center.ipynb
Original file line number Diff line number Diff line change
@@ -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
}
101 changes: 101 additions & 0 deletions ui-tests/data/merge_test6/left.ipynb
Original file line number Diff line number Diff line change
@@ -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
}
Loading

0 comments on commit d39f45a

Please sign in to comment.