Sublime Forum

[FIXED] Dbl Click text selections + drag selects newline too

#1

This (bug?) has been happening for several nightly release cycles now, but it’s driving me a little nuts at this point.

Say I have the following Ruby on Rails code:

  def inbox_action?
    params:action] == 'inbox'
  end
  1. I want to quickly select the text “inbox_action?” for copy + paste elsewhere, so
  2. I double click on inbox_action to quickly select that word, and then
  3. I drag to the right to get the ‘?’ as well, but
  4. Sadly, the newline character is now selected as well and I can’t shake it off with the mouse, no matter what I do. So to fix,
  5. I let go of the mouse button and I use shift + left arrow to unselect the newline character.
    Note: This behavior is the same if in (1) I had double clicked “def” and dragged to the right just the same as in (3).

This behavior only presents when I start my selection with a double click (which almost always do because it’s quicker and requires less precision) and only if the line ends in a question mark or a period or a quote mark or close-paren (so far as I have found, there may be other terminators for which this happens. I know that it does not happen for greater-than signs or regular words for example).

Side question: Is there anyway to make question marks be part of my initial selection in the first place? Lots of my method names include question marks at the end.

Thanks!

Paul

0 Likes

#2

I realized that the newline is not required. Doing the same double-click + drag does the same thing in this situation:

inbox_action? || sentbox_action?

Here, if I double click on “inbox_action” because i want to quickly select “inbox_action?” and then drag to the right, the selection becomes "inbox_action? ". But that whitespace there is not wanted!

The same is true for this:

(is_inbox = inbox_action?) ? ...

In this case the selection becomes “inbox_action?)” and the “)” is not wanted.

0 Likes

#3

As a workaround, have you tried changing your word_separators to not include the question mark?

0 Likes

#4

Thanks for the idea adzenith! I didn’t realize how easy it was to set the word_separators like that. Now my double clicks include the question mark in the initial text selection and that helps a lot in general for my purposes :smile:.

0 Likes

#5

The latest build 2213 fixes this. Thanks!

Also, a note to other rubyists: I highly recommend removing ? and ! from your list of word_separators. This allows not only quick selection of methods that end in ? or ! but also allows auto_complete to include the ? and ! in your method name auto-completes. If you remove @ from the list as well you get the same for instance variables. And if you want to make the change just for Ruby code use Syntax-specific settings for that. :smiling_imp:

0 Likes

#6

Thanks, but still there is a little behaviour I don’t think is correct.

When you double click only white-space at the beginning of a line. If there is white-paces at the end of the previous line, that white-space is selected too. please fix too.

Put your mouse near the “line number” and double click the white-space in a view. The white-pace of the previous line will be selected!

0 Likes

#7

Really happy to know about word_separators. Thanks!

0 Likes