notebook icon indicating copy to clipboard operation
notebook copied to clipboard

Block indent always inserts spaces for indentation, even when configured to use tabs.

Open fake-name opened this issue 10 months ago • 4 comments

Description

When in a jupyter notebook, with indentation set to tab, if you select a block of code and hit tab to indent it, it inserts spaces. If you're using python, this is obviously a problem, particularly on python3.

Reproduce

In jupyter notebook (codemirror? Jupyter has too many poorly delineated components):

  1. Set the indentation to tabs:
    image
  2. Select a block of code.
  3. Hit Tab
  4. You get spaces: image

Expected behavior

If you have the editor set to tab mode (the correct way to indent things), I'd expect the block indentation operation to insert tabs.

Additionally, Notebook 7 seems to no longer have visible tab characters, whereas they are shown in 6 and/or "nbclassic". I'd call that a regression.

Context

  • Operating System and version: Server: Ubuntu 22.04. Client: Windows 10
  • Browser and version: Vivaldi 6.1.3035.302 (Stable channel) (64-bit)
  • Jupyter Notebook version: 7.0.3

I don't think the rest of the template is relevant, since this seems to be a logic error rather then a bug in the sense of the code doing something it's not intended to do.

fake-name avatar Sep 01 '23 06:09 fake-name

Thanks @fake-name for reporting :+1:

Would you be able to check if this is an issue in JupyterLab as well? (since Notebook 7 is based on JupyterLab)

jtpio avatar Sep 04 '23 11:09 jtpio

It works well in text editor in JupyterLab. I think the problem here is that this menu should not be shown when Notebook (rather than a Text Editor) is active. The underlying problem is the same as issues:

  • https://github.com/jupyterlab/jupyterlab/issues/8332
  • https://github.com/jupyterlab/jupyterlab/issues/13382
  • https://github.com/jupyterlab/jupyterlab/issues/14372 where users assume "Text Editor" also means "Code editor in notebook" (but it does not)

In this sense it is a bug in Notebook because in JupyterLab there is no such an entry in the view menu when using a notebook.

krassowski avatar Sep 05 '23 17:09 krassowski

Oh, sorry it is there in JupyterLab too. I think that a good solutions would be to add a new "Cell Editor Indentation" which would toggle indentation for all types of cell (this is what Auto Close Brackets does if I remember correctly), and only show it notebook view, while hiding the "Text Editor Indentation".

@fake-name for now you should be able to adjust the indentation in "Settings Editor", under "CodeMirror" (to adjust them globally) or under "Notebook" to adjust it on per-cell-type basis.

krassowski avatar Sep 05 '23 18:09 krassowski

so, how to change indentation settings in jupyter notebook?

I try to change Settings->Text Editr Indentation, but it affects only the editor but not the notebook. This does not depend on whether I open the notebook in a separate browser tab or in Jupiterlab.

Where is notebook settings?

FeelUsM avatar Feb 01 '24 08:02 FeelUsM