Sublime Forum

Unexpected behaviour when select and unselect region


Version: Stable Channel, Build 4113

As described in the title, I noticed this phenomenon in ST4 (even in Plain Text mode), and it happens frequently in my iMac and Macbook Pro.

Not sure whether it’s a feature or bug, my expected behaviour is: After selecting some text region (using mouse left-click and drag), when i click on random spot, it should unselect it.

However, sometimes I click once and nothing happens so I need to click again to cancel the selection.



Does it happen in safe mode?



Yes, it happens in safe mode. @bschaaf

I do think I found where the problem is!

In ST4, the unexpected behaviour is because it doesn’t implement the event of holding the left-key of mouse and move a little when some text region is selected.

I tested the same behaviour in Emacs and VS Code and they works fine. And I believe ST3 works fine too.

  1. left click + drag mouse to select some text
  2. click on random spot and then hold the mouse to move a little bit without releasing left-key
  3. Emacs and VS Code cancel the selection immediately after the click (even I’m still holding the left-key)


sounds like you want to set "drag_text": false, in your user preferences

1 Like


oh great. Thanks! it works!

I found the reason behind this counter-intuition is that it only highlights the selected text instead of all the draggable region (if you move the mouse over it, ST4 detects it’s draggble, mouse cursor is arrow instead of edittable I )

still compared with VS Code (only the selected text is draggable and cursor of mouse become arrow)

but anyway, perhaps it’s just my personal flavor, I’m satisfied with disabling drag_text option.



Just wanted to chime in and say this has always been my biggest gripe with ST i.e. select stuff, maybe do a copy or something else, and then battle with trying to deselect the darn selected stuff. I’ve never found the magic trick to make this work the same as any other standard Mac application. It usually takes 1-3 clicks before deselection occurs, and I just quietly grizzle each time. The standard way to do a click and drag on the Mac is something like click down, hold for a bit (ideally the cursor would change to something indicating a drag is now in force), drag to the final location, then release the click. From memory, the stuff remains selected after the drag. The standard way to deselect selected text is just click somewhere. If ST could do this, or have a preference to do this, I’d be delighted!



Comparing Sublime Text to Safari: Neither require you to hold whatsoever - simply dragging will drag the text. Both also will deselect the text if you click either outside or inside the selected text. They also both select the dragged text after you’ve finished dragging. So I’m not sure what you’re seeing that’s different; perhaps try safe mode to see if any configuration/plugin is interfering?



Just clarifying here - ST will only reliably deselect the text with just one click if “drag_text”: false is in your user preferences. I like the idea of drag selecting so I have that set to true, in which case the original UI complaint holds. juniorxxue already confirmed this behavior still occurs in safe mode so I don’t see the point repeating that. I think what us pesky Mac users are looking for is a similar experience in deselecting text combined with with the capability of dragging text around. I believe this also happened in ST3. I totally get that most ST users are likely not on the Mac and far more detached from their mice than Mac users. I’m not looking for a battle, I’m just saying out of the box the deselection behavior of ST is awkward for us Mac users and I wish it wasn’t that way. I’ll still use ST either way, it just randomly takes 1 to 3 clicks to deselect text so I’ll live.



Indeed, before trying to figure out what’s the mechanism (it triggers text_drag) behind unselecting text, I originally thought it maybe somehow slow response and had to bear with it. Until someday I can’t stand it anymore, and tested it by myself for half an hour and then come to this website asking for help :slight_smile:

I’m also one of long-term Mac users (more than 6 years), so I believe a certain amount of people feel the same unintuition too.



"drag_text" is for drag and drop, not for dragging to select. Sublime Text should be matching the standard system behavior - but from what I can tell (other than the draggable area) it is matching. This is using macOS with a trackpad…



OK - I was about to draft up dry response to bschaaf’s claim that juniorxxue and I don’t know what we’re talking about, but it turns out the behavior we’re reporting is indeed much less noticeable when using a trackpad on a MacBook Pro (although the issue it is still there) instead of, in my case, when using a magic mouse connected via BlueTooth. Using the trackpad a single click to deselect selected text mostly works, although sometimes it does take 2 clicks. When using the magic mouse it’s typically 2-4 clicks before the text deselects. Hopefully this is a good enough clue to inspire somebody to fix this. Just as an FYI - I use the magic mouse vs the trackpad because I’m also using the BlueTooth magic keyboard (or whatever Apple call it) that has the numeric pad. The keyboard sits in front of the MacBook Pro and that makes the trackpad inconvenient to reach, so I use the BlueTooth magic mouse as well.



Thanks for clarifying that, I was able to discern the difference using a mouse. macOS seems to have a delay before text is dragged at about 150ms, before that it does a text selection instead. We’ve got a fix for this in the pipeline.



Yay - a happy ending :-). Regarding that delay, on the Mac it’s always been my experience that if you quickly click in a selected text region (i.e. mouse down/up quickly) then the text is always deselected, but if you click (i.e. only mouse down) and wait a smidge (without moving the mouse) then your intention to perform a drag is registered and then you can proceed with the drag.

I kind of like the way Microsoft Word indicates an acknowledgement that a drag and drop operation has been initiated. After the slight pause when clicking down, the highlight color for the selected text becomes a little translucent. Note that I’m using an older version 16 of Microsoft Word (because I refuse to pay rent to Microsoft!). Alternatively, you could change the mouse pointer to something else to indicate the drag acknowledgement. Most Mac applications also go the extra mile and animate the actual dragging of the selected text - something ST doesn’t do. At the very least, I do think Sublime text should adopt a visual feedback cue to indicate the initiation of drag and drop - It would be a really nice touch. I’d understand if nobody wanted to proceed with an animation of the actual dragging operation though.



The fix will be shipping in the next build, ≥4119



Thanks! Very happy to confirm the issue is fixed :-).