Skip to content

Commit db41ea3

Browse files
authored
Merge pull request #316 from ryantam626/rt.go-to-cell
Add go to cell option in failure dialog
2 parents 0dd110d + aca4fa3 commit db41ea3

File tree

4 files changed

+30
-7
lines changed

4 files changed

+30
-7
lines changed

CHANGELOG.md

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

3+
## Unreleased
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**

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,10 @@ To configure which/how formatters are invoked, see [configuration](https://jupyt
4747
I could really use your support in giving me a star on GitHub, recommending features, fixing bugs or maybe even providing monetary support!
4848

4949
- [Recommending features via GitHub Issues](https://github.com/ryantam626/jupyterlab_code_formatter/issues)
50-
- [Sumitting your PR on GitHub](https://github.com/ryantam626/jupyterlab_code_formatter/pulls)
50+
- [Submitting your PR on GitHub](https://github.com/ryantam626/jupyterlab_code_formatter/pulls)
5151
- [Buy me a coffee](https://www.buymeacoffee.com/ryantam626)
52-
- [Donating Via Solana](https://solana.com/): 6K7aK5RpskJkhEkwZi1ZQr68LhaVdfnTfWjZEQV3VbbD
52+
53+
Also shout-out to my employer [Huq Industires](https://huq.io/) for allowing me to work on this some of the time during work.
5354

5455
----
5556

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+
## Unreleased
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)