Skip to content

Multicursor sometimes only deletes on one line when there's spaces #4796

@benthayer

Description

@benthayer

Something similar was already addressed in #765 and #766, but this seems to be a different issue.

I'm pasting my comment from #765 here:

When using multi-cursor, either when using alt+drag or ctrl+click, deleting a space using backspace only deletes on one line, but only sometimes, specifically when there's tablike spaces involved.

For an example, consider the text below.

searches = [
    ('Richmond, VA'
    ('Virginia Beach, VA'
    ('San Jose, CA'
]

Press alt and drag the cursor from before the parentheses on the line that contains Richmond down to the line with San Jose. All lines have a cursor displayed before the parentheses. I indicate this below with a bar

searches = [
    |('Richmond, VA'
    |('Virginia Beach, VA'
    |('San Jose, CA'
]

If I press backspace, then the text changes to

searches = [
|('Richmond, VA'
   |('Virginia Beach, VA'
   |('San Jose, CA'
]

The first tab (which is 4 spaces) is removed, and the rest of them stay the same.

If instead, I were to press the right arrow key, press space four times, then press backspace, I end up with this output

searches = [
   (   |'Richmond, VA'
   (    |'Virginia Beach, VA'
   (    |'San Jose, CA'
]

The Richmond line has three spaces. It seems whatever is processing the delete sees the spaces but recognizes that it's not a tab, so it deletes it like a space, but still only affects the one line. If you keep hitting backspace, it will function normally and it's possible to get to the state below by hitting backspace three times:

searches = [
   (|'Richmond, VA'
   ( |'Virginia Beach, VA'
   ( |'San Jose, CA'
]

The line that gets deleted is the one with the last mousedown event, so if I alt+drag, it's where I start dragging, but if I ctrl+click, it's the last spot I clicked.

When the "selected" cursor is in the middle of text, deleting occurs normally. The selection below will delete normally if the cursor within the San Jose text is the "selected" cursor, but not if the "selected" cursor is on the Richmond or Virginia Beach line.

For example, hitting backspace in the situation below causes no issues.

# Before backspace:
searches = [
   |('Richmond, VA' # ctrl-clicked first
   |('Virginia Beach, VA' # ctrl-clicked second
   ('San Jos|e, CA' # ctrl-clicked third
]
# After backspace:
searches = [
  |('Richmond, VA' # ctrl-clicked first
  |('Virginia Beach, VA' # ctrl-clicked second
   ('San Jo|e, CA' # ctrl-clicked third
]

But here does cause issues

# Before backspace:
searches = [
   |('Richmond, VA' # ctrl-clicked third
   |('Virginia Beach, VA' # ctrl-clicked second
   ('San Jos|e, CA' # ctrl-clicked first
]
# After backspace:
searches = [
|('Richmond, VA' # ctrl-clicked third
   |('Virginia Beach, VA' # ctrl-clicked second
   ('San Jos|e, CA' # ctrl-clicked first
]

When typing and when the "selected" cursor is deleting non-space characters, everything works as expected.
It seems to be specifically tied with the functionality that recognizes which combinations of spaces are tabs.

I tested this in 3 configurations on two machines, and every one produced the issue in the same way.
Machine 1:

OS Name: Microsoft Windows 10 Pro
OS Version: 10.0.17134 N/A Build 17134

Chrome Version 75.0.3770.142 (Official Build) (64-bit)

Configuration 1:

>jupyter --version
jupyter core     : 4.5.0
jupyter-notebook : 5.7.8
qtconsole        : 4.5.1
ipython          : 7.5.0
ipykernel        : 5.1.1
jupyter client   : 5.2.4
jupyter lab      : not installed
nbconvert        : 5.5.0
ipywidgets       : 7.4.2
nbformat         : 4.4.0
traitlets        : 4.3.2
>python --version
Python 3.7.3

Machine 2:

OS Name: Microsoft Windows 10 Education
OS Version: 10.0.17134 N/A Build 17134

Firefox 68.0.1

Configuration 1:

>jupyter --version
4.4.0
>jupyter notebook --version
5.5.0
>python --version
Python 3.6.6

Configuration 2:

>jupyter --version
jupyter core     : 4.5.0
jupyter-notebook : 6.0.0
qtconsole        : 4.5.1
ipython          : 7.6.1
ipykernel        : 5.1.1
jupyter client   : 5.3.1
jupyter lab      : not installed
nbconvert        : 5.5.0
ipywidgets       : 7.5.0
nbformat         : 4.4.0
traitlets        : 4.3.2
>python --version
Python 3.6.5 :: Anaconda, Inc.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions