Skip to content

Commit c1021bd

Browse files
committed
Implement "Go to cell" option when formatting fails
Related #191
1 parent 06befb4 commit c1021bd

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

docs/changelog.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## 2.2.2 2023-06-10
4+
5+
**Jupyterlab extension**
6+
7+
- Add "Go to cell" option in dialog when formatting fails;
8+
39
## 2.2.1 2023-05-21
410

511
**General**

src/formatter.ts

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { INotebookTracker, Notebook } from '@jupyterlab/notebook';
33
import JupyterlabCodeFormatterClient from './client';
44
import { IEditorTracker } from '@jupyterlab/fileeditor';
55
import { Widget } from '@lumino/widgets';
6-
import { showErrorMessage } from '@jupyterlab/apputils';
6+
import { showErrorMessage, Dialog, showDialog } from '@jupyterlab/apputils';
77

88
class JupyterlabCodeFormatter {
99
working = false;
@@ -166,10 +166,20 @@ export class JupyterlabNotebookCodeFormatter extends JupyterlabCodeFormatter {
166166
if (cellValueHasNotChanged) {
167167
if (formattedText.error) {
168168
if (showErrors) {
169-
await showErrorMessage(
170-
'Jupyterlab Code Formatter Error',
171-
formattedText.error
172-
);
169+
const result = await showDialog(
170+
{
171+
title: 'Jupyterlab Code Formatter Error',
172+
body: formattedText.error,
173+
buttons: [
174+
Dialog.createButton({label: 'Go to cell', actions: ['revealError']}),
175+
Dialog.okButton({ label: 'Dismiss' }),
176+
]
177+
}
178+
)
179+
if (result.button.actions.indexOf('revealError') !== -1) {
180+
this.notebookTracker.currentWidget!.content.scrollToCell(cell)
181+
break
182+
}
173183
}
174184
} else {
175185
cell.model.sharedModel.source = formattedText.code;

0 commit comments

Comments
 (0)