Skip to content

Conversation

@marceloramires
Copy link
Contributor

The bug could be reproduced in two ways:

1) Block selection
a) Alt + select a block containing more than one line, and more than one character per line.
b) Hit backspace

Expected result: all the selected content is deleted
Actual result: only the first line of the selection is deleted

2) Multiple selection
a) Select any portion of text
b) Ctrl + select any other portion of text
c) Hit backspace

Expected result: all the selections' contents are deleted
Actual result: only the first selection is deleted

The fix

The portion of code that took care of selection deletion did not take into account multiple selections. The proposed fix simply gets the list of selections and removes them all from last to first.

closes #766

@marceloramires
Copy link
Contributor Author

I've opened an issue for this: #766

@Carreau Carreau added this to the 4.1 milestone Nov 29, 2015
@Carreau
Copy link
Member

Carreau commented Nov 29, 2015

I'm optimistically tagging that as 4.1 (as you wrote a fix ! Thanks !)

Ping @ellisonbg

minrk added a commit that referenced this pull request Dec 1, 2015
Fixing backspace on multiple selection bug
@minrk minrk merged commit b2e3382 into jupyter:master Dec 1, 2015
@benthayer
Copy link
Contributor

Are there any updates on this? I'm having the same issue, and I'm running version 6.0.0

@kevin-bates
Copy link
Member

Hi Ben. Given this has been merged for more than 3 years, I don't think any updates are expected.
I just tried this with 6.0 and could not reproduce the issue. Multi-selected items were removed via a backspace.

@benthayer
Copy link
Contributor

So actually, I think the issue is more specific than the description suggests. Maybe it is actually a different issue entirely and it makes sense to open a new and different issue.

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.

@kevin-bates
Copy link
Member

Thanks for the great response. I wasn't familiar with multiple cursors. Sounds like an unknown variation of the original and I recommend opening a new issue for this.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 26, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Backspace on multiple selections affects only one selection

5 participants