texstudio-org / texstudio

TeXstudio is a fully featured LaTeX editor. Our goal is to make writing LaTeX documents as easy and comfortable as possible.
http://www.texstudio.org/
GNU General Public License v3.0
2.82k stars 345 forks source link

Consider changing TeXStudio cursor behavior #599

Open kendonB opened 5 years ago

kendonB commented 5 years ago

TexStudio's cursor behavior is nonstandard following a text selection and an arrow press in the opposite direction. Usually, when one highlights left then presses right arrow the cursor will move to the right end of the selection. In TexStudio, the cursor stays on the left of the selection.

Environment

Expected behavior

This is a string|.

Say the cursor is at the "|", press Ctrl-Shift-Left -> Right

This is a string|.

The cursor should end up at the "|".

Actual behavior

This is a s|tring.

The cursor actually ends up at this "|".

aubreyz commented 5 years ago

I'm not following this. I tried your instructions and it seems completely standard and intuitive to me.

Ctrl-Shift-Left hightlights the word to the left of the cursor

Then pressing right (not with Ctrl-Shift) undoes the selection and moves one character to the right (or the second character of what was the selected word). Every other text editor I have does the same. Maybe you need to provide screenshots of what you mean. The cursor should not end up at the | (although if you keep the Ctrl-Shift pressed it does)

kendonB commented 5 years ago

You are able to replicate the behavior I'm seeing (I had one small error in my comment above that is now fixed). We just disagree on what we think is "correct".

What editors are you using and what is your system? I am seeing the behavior I like in RStudio, Google Chrome, Notepad++, Notepad, Microsoft Word, a Jupyter Notebook, and Spyder. TexStudio is the only exception with different behavior. A colleague with a Mac sees the behavior I like on TextEdit and RStudio.

sunderme commented 5 years ago

I don't see the described behaviour. Please recheck with the newest version of txs.

aubreyz commented 5 years ago

I agree that Notepad++ does behave differently (but Notepad does not), I am on Win10.

I find the Notepad++ behaviour a little counterintitive - it actually shows the blinking cursor at the right end of the selection -- and I don't think it is expected for the cursor to jump a full length on a single right press when it usually shifts one space (I would use Control shift to get there - the same as I used to get there in the first place).

But I do see that the very editor I am using now in Github does display your desired behaviour (in Chrome).

aubreyz commented 5 years ago

If you right selected a word as you described and then pressed the down-arrow where would you expect the cursor to go? I would expect it to undo the selection and go down ONE line (as the down arrow would normally do). It is therefore not at all intuitive to me that a left or right arrow would do something different from the usual (albeit I now accept that at least two one text-editor I use -of several) do in fact do this).

Codebrowser - behaves as I like Notepad++ - behaves as you would like Chrome - behaves as you would like Notepad - behaves as I would like Word (Yuk) - does as you like -- but interestingly the editor within an Excel cell does not and so on

manueldeprada commented 5 years ago

Codebrowser - behaves as I like Notepad++ - behaves as you would like Chrome - behaves as you would like Notepad - behaves as I would like Word (Yuk) - does as you like -- but interestingly the editor within an Excel cell does not and so on

So TexStudio's behavior is not nonstandard in any way...

kendonB commented 5 years ago

To summarize, labelling TexStudio's current behavior as "existing" and the behavior I'm proposing as "alternative", here's all the programs I've tested with ticks meaning "alternative":

I didn't count vim as I couldn't figure out a similar set of actions one would take in that program. But I believe all the big modern text editors are in there (Atom, Eclipse, Sublime) and they all have the alternative behavior. Emacs is the biggest program that has the "existing" behavior.

benibela commented 5 years ago

and

(I never knew github has clickable ticks)

timhoffm commented 5 years ago
dbitouze commented 5 years ago

With Emacs, pressing on:

This is a string|.

the equivalent of Ctr-Shift- then , results in:

This is a s|tring.

but with tring highlighted.

kendonB commented 5 years ago

Codebrowser - behaves as I like Notepad++ - behaves as you would like Chrome - behaves as you would like Notepad - behaves as I would like Word (Yuk) - does as you like -- but interestingly the editor within an Excel cell does not and so on

So TexStudio's behavior is not nonstandard in any way...

I think that looking to Atom, Eclipse, and Sublime for standard behavior is appropriate.

manueldeprada commented 5 years ago

May be a good idea. Looks like that change would need to be done in src/qcodeedit/lib, if anyone wants to give it a try and start searching...

sunderme commented 5 years ago

I find the suggested cursor behaviour largely illogical. Why don't you press ctrl+right if you want to jump to the end of word. And what do you do if you want to move the cursor one right.

Hence, I am strongly opposed to changing txs behaviour.

kendonB commented 5 years ago

@sunderme The alternative cursor behavior moves to the end of the current selection, not necessarily a single word.

If one wants to move the cursor 1 to the right of the left end of the selection you would do Left then Right.

sunderme commented 5 years ago

sounds not really intuitive ...

alexboche commented 5 years ago

Here's what I see as a problem with texstudios' cursor behavior. Let's say you have a line of text: "my name is Alex" and you select starting from "name" to "Alex" by first placing the cursor before the "n" in "name" and then pressing shift-end. As far as I can tell, there is no way in texstudio to then get the cursor to go back to right before the "n" in "name". Pressing left will take you to the right side of the selection and pressing right will take you one space to the right of the right side of the selection. I would like a way to get the cursor to go back to the left side of the selection i.e. to right before the "n" in "name". In most applications, you could accomplish this simply by pressing left but not in texstudio. Thank you very much.

aubreyz commented 5 years ago

But you are selecting text BY moving the cursor (as indicated, apart from anything else, by the flashing cursor!). You move the cursor through the text while doing something else to act as a selection trigger (whether that is holding down the mouse button or the shift key). So it is logical (to me) for usual cursor navigation to be respected instead of respected in some respects and not respected in others almost at random (and to be respected totally differently while the trigger is "on" and the selection point is moving).

I guess it is what one is used to -- but I grew up coding in notepad (the gold standard?). Notepad, despite some curious assertions to the contrary here, does not do odd cursor jumps when undoing a selection via right or left cursor (on Windows 10 here, or on Win 7, XP, or any other version I have used). The editor I am using here on Github/Chrome demonstrates an odd bodge of ideas -- if one presses left to undo a selection the cursor moves to the start of the selection - but if one presses up to undo the selection it moves up one line. Go figure...

kendonB commented 5 years ago

FYI, I am currently sitting on three different Windows 10 computers and the behavior of Notepad is different between them. Only my Dell Laptop has the "alternative"/"popular"/"hip" behavior.

aubreyz commented 5 years ago

That's interesting....

AdamJel commented 5 years ago

Some are for the change of the behaviour, some are against it. It is clear that is should be made an object of settings, so that one may choose. But it is a good idea to enable a behaviour, which is found in some other IDE.

schtandard commented 2 years ago

Just wanted to mention that there are other ways to select a portion of text than "by moving the cursor", for example by double-clicking, triple-clicking, using a keyboard shortcut like Ctrl+A or with the search function. (There are probably possibilities I'm forgetting.) TeXstudio chooses to put the cursor at the end of the selection in each of these cases (which is fairly standard, as far as I can tell).

I agree that the current behavior has a consistent logic, but I also see the use of being able to select an arbitrary end of the current selection when deselecting. The requested behavior (left or right arrow key just moves the cursor to that edge of the selection and undoes the selection) provides this otherwise unavailable functionality, which is probably why so many popular editors provide it.

octaeder commented 2 years ago

You may give Macro "Transpose Cursor and Anchor Positions" a try (s. menu "Macros/Edit Macros...", button "Browse", group "addedFeature"). It interchanges both positions without deselecting. By this you are even able to change the ends of the selection as you want. Shortcut Alt+Y by default. In addition I use a macro that deselects without moving the cursor. If you like I can upload this, too.