Text selection with mouse - how to disable "snap to text"?


#1

Trying to select only a part of the line, but since I start text selection with a double-click, it “snaps” to “as many as possible” characters.
This is counter-productive.
How can I tell atom.io to not behave that way?
I mean, double-clicking should apply “snapping” only on text. Leave the second (third, fourth etc’) brackets out.

Notice it happens only on the second an on.
The first one doesn’t do that. I guess it’s some code compares the previous char and decides if it should auto-select the next one.

Code (JS) in the video:

const capitalize = (text) => text.capitalize();

const printMyName = (options) => {
// 1. Double-click on capitalize
// 2. Drap the mouse to the right, trying to select everything
// inside of console.log(…)
console.log(capitalize(options[‘user’][‘firstName’]))
// No success, because there’s a “snap-to-text” to the last bracket

// Trying with SHIFT clicking… But it snaps!

#%@(#&(*&#(%*#!!!)))
Thanks :slight_smile:
}

printMyName({
user: {
firstName: ‘Dan’
}
});

I’ve made a nice GIF showing what I mean:

Peek%202018-05-15%2017-27


#2

Here’s your problem. Don’t double-click. One click will start the text selection.


#3

Not a problem. I don’t need to try and point the cursor exactly between two characters. Double-clicking solves that.


#4

You can double-click and then press shift-right to achieve what you want. Otherwise, I think you’re fighting a fundamental behavior and there’s no way to tweak it without changing Atom’s code.


#5

I wish it was that simple. The thing is, sometimes there are a few brackets, i.e something like “)])))”.

I think I have an idea for Atom though:

Look, when I double click a words and then mark text/code, there’s some “snap” flag turning on.
How do I know about this flag?
Simple: I release the mouse button, leaving the code selected. Then I Shift+click on the rest of the code I wish to include in the selection, but, it behaves as above - selecting blocks of “similar text”, i.e selecting blocks of brackets (like the above mentioned “)])))”) etc’.

Solution:
Check if the Ctrl key is pressed, when utilizing that “snap” flag in order to decide on the required behavior (either select per character or per block of “similar text”).
If Ctrl key is pressed, flip the behavior.

This proposed solution doesn’t affect any user and solves it to ones like myself which I’m sure exist but are just too busy debugging :slight_smile:


#6

When I think about it, Ctrl might conflict with the excellent multi-cursor feature.
Maybe the Alt key?
Maybe check if CAP LOCK is on?
You get the idea.

Thanks.

By the way - excellent work on Atom in general! Much appreciated! :slight_smile:


#7

I’m sure it could be implemented just fine. However, the best place to make a proposal is the GitHub repo, not here. Not all of the developers look at the forum, and those who do don’t do it every day. If you post on the repo, your post will definitely be seen, at least.