Skip to content

Commit e05ffb0

Browse files
committed
Makeing right pane editable and update source on changes
1 parent 249205b commit e05ffb0

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/diff/cell.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,16 @@ class CodeMirrorSplitDiffWidget extends BaseDiffWidget {
6060
extensions: [
6161
basicSetup,
6262
python(),
63-
EditorView.editable.of(false),
64-
jupyterTheme
63+
EditorView.editable.of(true),
64+
jupyterTheme,
65+
EditorView.updateListener.of(update => {
66+
if (update.docChanged) {
67+
const newText = update.state.doc.toString();
68+
69+
this._modifiedCode = newText;
70+
this._newSource = newText;
71+
}
72+
})
6573
]
6674
},
6775
parent: this.node

src/widget.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ export abstract class BaseDiffWidget extends Widget {
100100
*/
101101
public onAcceptClick(): void {
102102
if (this._cell) {
103-
this._cell.sharedModel.setSource(this._newSource);
103+
this._cell.sharedModel.setSource(this._newSource || this._originalSource);
104104
this._closeDiffView();
105105
}
106106
}
@@ -191,9 +191,9 @@ export abstract class BaseDiffWidget extends Widget {
191191
private _cell: ICellModel;
192192
private _cellFooterTracker: ICellFooterTracker;
193193
private _originalSource: string;
194-
private _newSource: string;
195194
private _showActionButtons: boolean;
196195
private _openDiff: boolean;
197196
private _toggleButton: ToolbarButton | null = null;
198197
private _trans: TranslationBundle;
198+
public _newSource: string;
199199
}

0 commit comments

Comments
 (0)