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

Error thrown when removing the only cell #545

Open
krassowski opened this issue Feb 23, 2021 · 0 comments
Open

Error thrown when removing the only cell #545

krassowski opened this issue Feb 23, 2021 · 0 comments
Labels
bug Something isn't working package:jupyterlab-lsp

Comments

@krassowski
Copy link
Member

krassowski commented Feb 23, 2021

Description

If there is only one cell in the notebook and it gets removed (which is a bit pathological edge case) an error is thrown:

TypeError: Cannot read property 'model' of undefined
    at Mt.activeCellChanged (237.a21e094affef50264d99.js:formatted:4176)
    at m (jlab_core.61e1fcd0f32a80614a78.js:2)
    at Object.l [as emit] (jlab_core.61e1fcd0f32a80614a78.js:2)
    at e.emit (jlab_core.61e1fcd0f32a80614a78.js:2)
    at ne.set activeCellIndex [as activeCellIndex] (jlab_core.61e1fcd0f32a80614a78.js:2)
    at ne.onCellRemoved (jlab_core.61e1fcd0f32a80614a78.js:2)
    at ne._removeCell (jlab_core.61e1fcd0f32a80614a78.js:2)
    at jlab_core.61e1fcd0f32a80614a78.js:2
    at c (jlab_core.61e1fcd0f32a80614a78.js:2)
    at ne._onCellsChanged (jlab_core.61e1fcd0f32a80614a78.js:2)

Users previously complained about uncaught errors (#543 and a few earlier) and it would be nice to handle this one too.

The important use case is when selecting all cells and removing all of them to clear notebook as the only cells gets removed too.

Importantly the removed cells is immediately re-added by the model (a notebook has to have at least one cell) but we are fast and apparently can get into this strange state of the model when cell was already removed but not yet re-added.

Reproduce

  1. Open new notebook
  2. Press esc followed by dd (d twice)
  3. See error in console

Expected behavior

Be nice, do not throw errors.

Context

  • JupyterLab version: 3.0.7
  • Lab extension 3.4.1
@krassowski krassowski added bug Something isn't working package:jupyterlab-lsp labels Mar 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working package:jupyterlab-lsp
Projects
None yet
Development

No branches or pull requests

1 participant