Sublime Forum

[bug] ctrl-backspace deletes extra space

#1

Summary:

In beta 20091002, ctrl+backspace deletes a character and the preceding whitespace. In previous versions, and in most other text editors, ctrl+backspace deletes only the word adjascent to the cursor.

Steps to reproduce:

write the sentence "I made a spelling misakte’. Hit Hit ctrl-backspace to delete the badly-spelled word. Type the correct word ‘mistake’.

Expected behaviour:

The text on screen reads ‘I made a spelling mistake’.

Actual behaviour:

The text reads ‘I made a spellingmistake’.

Version Seen in:

beta 20091002

Steve.

0 Likes

#2

This was introduced in 20090620, when the macro for ctrl+backspace was changed from:

move words -1 extend
leftDeleteCharacters

to

move wordends -1 extend
leftDeleteCharacters

both of these don’t work in different ways… I’ll replace the macro with a bit of python, unless someone has already written a proper implementation of ctrl+backspace?

0 Likes

#3

This is fixed in 20091004

0 Likes

#4

Genius. Cheers.

0 Likes

#5

This bug reappeared in ST2. The cause is this block of code from lines 62-67 of delete_word.py:

# If there's a single space after the word, eat that too if setting says to if not did_eat_extra_space and len(txt) > count and at_boundary: is_single_trailing_space = ((classify(txt[count], classes) == 0) and (count + 1 == len(txt) or classify(txt[count + 1], classes) != 0)) if is_single_trailing_space: count += 1

If that block is removed/disabled, the bug disappears. If some people like the current behavior, then perhaps a “delete_space_with_word” setting could be checked in the first if condition.

0 Likes

#6

This is by design

0 Likes

#7

Fine, but it most definitely is not what some people want. For example, I have this code:

if (foo === bar)

The cursor is at the end of “bar”. I trigger delete word. I don’t want the space before “bar” to be deleted, I just want to replace the word “bar”. For me at least, 90% of the time I do not want the space deleted along with the word because I am replacing the word. That’s why I suggest the following:

# If there's a single space after the word, eat that too if setting says to if not did_eat_extra_space and len(txt) > count and at_boundary and view.settings().get("delete_space_with_word", True):

This way we at least have the option to change the default behavior without copying and tweaking the command ourselves.

0 Likes