Editor selects text instead of moving a caret

Answered

For a while now I occasionally run into a weird behavior in the editor.

 

Instead of moving the caret on Ctrl+Left/Right it selects the text. As if I was pressing Shift+Left/Right.

I am quite sure though I press just Ctrl and Shift is not "stuck".

This usually happens when the caret is at the beginning or end of the text in the line. After pasting some code (I usually do that with Shift+Ins, btw) or pressing Home.

 

When I discover the text is being selected and cancel the selection with Esc or Home it starts to behave normally.

 

It does not happen very often. About once a week or so. And I haven't been able to reproduce it consistently.

That's why I decided to post this as a forum topic rather than a bug report.

 

Are there any particular aspects I should give closer attention to when trying to reproduce the problem?

Could I maybe enable some extra logging to obtain more information next time it happens?

0
22 comments

Did you install/enable IdeaVim plug-in?

1

No, I don't have it installed.

And I believe I never installed it in the past. (just to be sure, I checked and there is nothing mentioning "vim" in IDEA/config)

0

It seems I cannot attach files here. Should I create a ticket in YouTrack?

 

By the way, what do you plan to look at in the log? Installed plugins?
As I mentioned the problem is highly unstable. I haven't seen it for a while. So I doubt there will be any indication in the log.

 

P.S. It seems IDEA logging is not configured properly, btw:

BUILDER_PROCESS [stderr]: SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
BUILDER_PROCESS [stderr]: SLF4J: Defaulting to no-operation (NOP) logger implementation

0

Plugins, Java, OS versions, exceptions, etc.

If you can reproduce it, please file a bug at https://youtrack.jetbrains.com/issues/IDEA with all the details.

0

The problem is impossible to reproduce. Even though I've just run into it again.

There is nothing logged to idea.log in the last 50 minutes. So I doubt it's some exception or illegal state.

 

Do you want me to paste 40 KB of IDEA startup log into a comment here?

0

Please upload it at some file sharing service or the service like gist/pastie, etc.

0

Did you check if disabling the non-bundled plug-ins makes any difference?

0

No, I didn't. And frankly speaking I can't imagine how can I check if the problem is gone?

Sometimes I do not see it for several weeks. But not having it while running without external plug-ins for month still does not prove anything, does it?

Luckily, there are just a few:

GenerateSerialVersionUID which I do not use that much

iBATIS which I don't need for the projects I work on currently

JFlex support which is broken

and Lua which is incompatible with the latest EAP

I've disabled them all for now. Will see how it goes.

0

It has just happened to me again in the Commit message input.

I tried to repeat the same actions, but I couldn't reproduce the problem.

0

Could it be caused by some third-party application you may have installed that affects keyboard behavior? Some clipboard manager, keyword expansion tool, etc.

0

No. I don't use anything like that. No clipboard managers, macro / hotkey or text expansion tools.

0

Might be keyboard driver or keyboard hardware specific. I've never seen anything like that and I don't recall anyone else reporting this problem.

0

If it was driver or hardware specific it would appear in other applications too, wouldn't it?

So far I've only seen this happening in IDEA. And I've been seeing this problem for a few years now.

 

Is there any extra logging I could enable or add to try to collect more details about the issue? In the latter case I would appreciate if you could direct me to a class I could add some logging to. The one that is handling Shift+Right vs Ctrl+Right in the editor.

0

This is what happens after double Ctrl press, followed by arrows, i.e. press Ctrl, release Ctrl, press Ctrl, press arrow key. This logic exists to create carets/selections above/below current line. You can disable it in Settings->Editor->General->Smart Keys->Add multiple carets on double Ctrl with arrow keys.

2

Bingo!

Thank you Dmitry!

 

P.S. It would probably make sense not to enable by default features around such often used keys as Ctrl.
(Just like nobody uses Ctrl+Shift combination to switch keyboard languages because you occasionally press it by itself when working in an IDE)

1

Would you mind explaining how this "double-Ctrl to select" is supposed to be used?

Is it just an alternative for Alt+Shift+Ins to switch to column selection mode?

Then I could suggest to bind Alt+Shift+Down / Alt+Shift+Up to "Clone Caret Below" / "Clone Caret Above" instead. That would render the special double-Ctrl behavior redundant, as far as I can tell.

Unless I am missing some other use scenario.

1

You're right, double-Ctrl+arrows are supposed to create column-mode-like selection, without the need to switch to a 'column selection' mode. Alt+Shift+arrows shortcuts are already assigned in default keymap unfortunately (as well as other modifier+Up/Down combinations), so there didn't seem to be a better solution.

0

Alt+Shift+Up/Down is indeed mapped to 'Move Line Up / Down' by default. However there is also Ctrl+Shift+Up/Down for 'Move Statement Up / Down'.

I'd argue that the latter is more usable as it breaks the code less often. And most of the time it does move one line anyway.

Do you have any usage stats to see how often 'Move Line Up' is used compared to 'Move Statement Up'?

 

P.S. For example, in the situation like this:

    }
   |else {

pressing Ctrl+Shift+Up will only move the 'else' line up resulting in broken code.
That's not what I would expect from 'Move Statement'. Should I create a JIRA for that?

0

We don't have any related stats at the moment. But I believe it's nice to have both actions available - one is low-level one, operating on line basis, while the other is high-level one, working with language statements.

As for specific 'move statetement' behaviour you describe, it looks like a bug, you can create a ticket for it.

0

Hi guys, a bit late into this discussion, but I just now got frustrated with this issue and was ready to report this "bug" when I figured from this thread that it's actually a feature.

Just wanted to write that Dmitry is not the only one disliking it. To be honest, I was almost absolutely sure that it is a bug and I would've never guessed it can be turned off (unless I read it here), so I also wanted to say that maybe the default state of this option should be off. Users that want it can set it to on at any time, but I think that it's more often you get people using ctrl left/right arrow to navigate through text/code than you get people that want to select text/code with double ctrl click and the thing is that I, apparently, mistakenly press double ctrl often enough to make this an inconvenience.

All the best and thanks for the solution!

0

Please sign in to leave a comment.