Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/diff/cell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,16 @@ class CodeMirrorSplitDiffWidget extends BaseDiffWidget {
extensions: [
basicSetup,
python(),
EditorView.editable.of(false),
jupyterTheme
EditorView.editable.of(true),
jupyterTheme,
EditorView.updateListener.of(update => {
if (update.docChanged) {
const newText = update.state.doc.toString();

this._modifiedCode = newText;
this._newSource = newText;
}
})
]
},
parent: this.node
Expand Down
4 changes: 2 additions & 2 deletions src/widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export abstract class BaseDiffWidget extends Widget {
*/
public onAcceptClick(): void {
if (this._cell) {
this._cell.sharedModel.setSource(this._newSource);
this._cell.sharedModel.setSource(this._newSource || this._originalSource);
this._closeDiffView();
}
}
Expand Down Expand Up @@ -191,9 +191,9 @@ export abstract class BaseDiffWidget extends Widget {
private _cell: ICellModel;
private _cellFooterTracker: ICellFooterTracker;
private _originalSource: string;
private _newSource: string;
private _showActionButtons: boolean;
private _openDiff: boolean;
private _toggleButton: ToolbarButton | null = null;
private _trans: TranslationBundle;
public _newSource: string;
}
Loading