Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Fix/improve manual edit #211

Open
wants to merge 48 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
72da019
extendArray utility
vidartf Nov 1, 2016
dfb4c69
Add IModel with `parent` field to all models
vidartf Oct 21, 2016
c568019
Have tests use IModel parent
vidartf Oct 27, 2016
6a68099
Allow forcing 4-way view
vidartf Dec 1, 2016
cdad268
Add unchanged models for deleted cells
vidartf Oct 27, 2016
6169cfb
Manual edits WIP
vidartf Oct 27, 2016
13dcd61
Add yellow highlighting for custom diffs
vidartf Oct 28, 2016
a53dab9
Do not highlight custom characters
vidartf Nov 1, 2016
d4f065a
Fix picker for custom diffs
vidartf Nov 1, 2016
97e88f9
Fix replaceArray bug
vidartf Oct 28, 2016
a32b4a1
Improve partial finding
vidartf Oct 28, 2016
42c8a65
Improve/fix edit/diff overlap matching
vidartf Oct 28, 2016
2fae680
Label manual edits with source
vidartf Oct 28, 2016
80ed514
Fix tests
vidartf Oct 28, 2016
6cffc25
Copy source when converting patch ops
vidartf Nov 1, 2016
bbc9139
Adjust getPartials
vidartf Nov 1, 2016
e7c136e
Ensure manual diff is labeled with source
vidartf Nov 1, 2016
071dbc1
Rename findDeletionOverlap -> findEditOverlap
vidartf Nov 1, 2016
35730e0
Add editing of unchanged models
vidartf Nov 1, 2016
c08a168
Add level to manual edit tests
vidartf Nov 2, 2016
f980c97
Remove unneeded casting
vidartf Nov 2, 2016
472353f
Fix convertPatchOps
vidartf Nov 2, 2016
7a7c491
Allow findEditOverlap to also accept patch ops
vidartf Nov 2, 2016
99739fd
combineDecisions also combines local/remote diff
vidartf Nov 2, 2016
0889421
Add ability to edit patched cells
vidartf Nov 2, 2016
96c2a30
Invalidate edited model
vidartf Nov 2, 2016
15bde1e
Enable tests for unchanged model
vidartf Nov 2, 2016
ecead75
Adjustments to edit of patched cells
vidartf Nov 2, 2016
c6543ef
MergeView code for editing by hand
vidartf Nov 2, 2016
2f1e246
Mark origin of syncModel editor text replacements
vidartf Dec 12, 2016
0af12a4
Outline decisions with mixed sources
vidartf Dec 12, 2016
d063f38
Consider line no. changes in syncModel updating
vidartf Dec 12, 2016
77bc591
Web: Improve manual edit decision overlap detection
vidartf Dec 13, 2016
5f12315
Mergeview: Adjust syncing
vidartf Dec 13, 2016
718f13a
Fix manual edit tests for deleted cells
vidartf Dec 13, 2016
e99c846
Fix replaceArrayContent bug
vidartf Dec 14, 2016
ba24353
Add getMatchinBaseLine clipping
vidartf Dec 14, 2016
331dd41
Adjust merge styles
vidartf Dec 14, 2016
315b08d
Avoid race condition in manual edit
vidartf Dec 14, 2016
981c1d3
Web: Don't combine diffs in flattenStringDiffs
vidartf Dec 15, 2016
770ba83
Lint
vidartf Dec 15, 2016
b540e55
Manual edit: Affected diffs use offset of preceding
vidartf Dec 16, 2016
2f061ac
Manual edit: Fix paths + decision combining
vidartf Dec 16, 2016
8d2ec89
Fix bug in forceFourWayViews
vidartf Dec 16, 2016
7b0ceb6
Manual edit: Simplify add/remove of full lines
vidartf Dec 16, 2016
fee8b66
Remove unused imports
vidartf Dec 21, 2016
c49c68a
ManualEdit: Fix bug when syncing last range
vidartf Dec 21, 2016
0d97fc9
Remove decision + picker when picking base on edit
vidartf Dec 21, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
887 changes: 887 additions & 0 deletions nbdime-web/src/merge/manualedit.ts

Large diffs are not rendered by default.

72 changes: 72 additions & 0 deletions nbdime-web/src/merge/util.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.
'use strict';


import {
IModel, CellDiffModel
} from '../diff/model';

import {
DecisionPath
} from './decisions';

import {
NotebookMergeModel, CellMergeModel
} from './model';


export
function getRootModel(model: IModel): IModel {
while (model.parent !== null){
model = model.parent;
}
return model;
}


export
function getPathForNewDecision(model: IModel): [DecisionPath, DecisionPath | null] {
let parent = model.parent;
if (parent === null) {
// We are a root level model
return [[], null];
}
if (parent instanceof NotebookMergeModel) {
if (model === parent.metadata) {
return [['metadata'], null];
}
let cm = model as CellMergeModel;
if (cm.base === null) {
// Inserted cell
return [['cells'], []];
} else {
let idx = parent.base.cells.indexOf(cm.base);
if (idx === -1) {
throw new Error('Invalid model');
}
return [['cells', idx], null];
}
}
let parentPath = getPathForNewDecision(parent);
// If parent is inserted cell, this will pick subpath:
let subpath = parentPath[1] || parentPath[0];
if (parent instanceof CellDiffModel) {
if (model === parent.source) {
subpath.push('source');
} else if (model === parent.metadata) {
subpath.push('metadata');
}
return parentPath;
// Do not support editing on outputs, so excluded
} else if (parent instanceof CellMergeModel) {
if (model === parent.merged.source) {
subpath.push('source');
} else if (model === parent.merged.metadata) {
subpath.push('metadata');
}
return parentPath;
// Do not support editing on outputs, so excluded
}
throw new Error('Could not find path for model');
}