-
Notifications
You must be signed in to change notification settings - Fork 4.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ctrl+Alt+click does not create additional text carets #15242
Comments
I think the existing behavior (only one column/block selection allowed) is by-design...and by that I mean by-design of Scintilla. I don't know the reasoning, but it could be one of complexity--it might just be too difficult to manage (in a user's mind) what could go on with multiples. Sure, you can come up with some "simple" cases where it makes perfect sense, though. I suppose that Notepad++ could "take over" from Scintilla in this regard, and allow it...but I'd think Notepad++ would be wise to let Scintilla do what it does best -- we've all seen what has happened in 8.6 and later where Notepad++ "took over" multiselection behavior, and the dust hasn't settled yet on all of the problems and corner cases with that.
Note that this is only true if you have virtual space turned on. |
Thank you @alankilborn - It's unfortunate the issue is more on the Scintilla side. Do you know if there is a word or phrase that best describes a text cursor or caret that is positioned beyond the end of a line? You mentioned "virtual space" but than added the bit about Alt+click. For example, I wanted to created a second github issue but also want to use the right word if it's not "virtual space". This issue came about from when I was playing around with Notepad++ to better understand https://community.notepad-plus-plus.org/topic/25848/pasting-alt-drag-blocks-doesn-t-work-anymore that someone started on the forums. In that case someone created a thin or zero width column selection in the "virtual space." Had they started typing characters or pasted a stream selection then the editor (I'm not sure if it's Notepad++ or Scintilla) will pad the lines with spaces so that the resulting text appears exactly where the text cursors or or carets had been out in virtual space. Instead of typing text or pasting a stream selection the person pasted a column selection (which I think is a multi selection). When the person did that, space padding was not inserted and the resulting text is appended directly onto the ends of the lines. I was also able to replicate that behavior using what I call a multi selection. I double click on a word which selects it. I Ctrl+double click on another word which selects it while leaving the previous selection selected. I Ctrl+double click on a third word which selects that and I have three words selected. Now I do Ctrl+C which loads all selected three words into the copy/paste buffer as a multi-selection. If I paste into a normal single text cursor or caret I get three lines with the three words I had selected. If I paste into a zero-width column selection that is all within text lines (not virtual space) then it's a neat column paste and I have three carets, one at the end of the three words. If I instead paste into a zero-width column selection where one or more of the carets lines are in virtual space then the words for those lines are appended to the lines without space-padding them to position the word at the location of the caret. While the behavior is the same I don't know if both column selections and Ctrl+double-click of words both are loading exactly the same "multi-selection" format of the data into the copy/paste buffer. Both of them are loading |
I don't know why you say that's "unfortunate"... Scintilla's whole reason-for-being is to handle text editing (which includes selection handling). It's best for N++ when Scintilla DOES handle this stuff; N++ developers can concentrate on other things and just let Scintilla "do its stuff".
"In virtual space" is the best I can do for describing that situation. The Alt+LClick part is important; it's actually creating a rectangular/column block selection (of zero height by zero width) -- because these types of blocks are allowed to span some virtual space even when the N++ setting to enable virtual space is not enabled. |
The Stack Overflow thread you linked is twelve years old. Whatever else might have changed since then, Scintilla made a big change between the version used in Notepad++ 8.5.8 and the one used in 8.6. I still haven’t found time and energy to track down all the details, but a few things I’ve figured out:
Despite that fallout, I suspect it was an intentional decision to make rectangular selections and multiple selections behave the same wherever possible. I’m not sure this has much to do with the subject of your issue, though. |
Check with SciTE as still does copy multiple selections to the clipboard back-to-back, Notepad++ inserts CRLF between multiple selections and adds
SciTE does not select into virtual space by default You can check the integer returned with
The Ctrl click is Scintilla that upset the Ctrl drag though the rest pretty much is Notepad++ v8.6+ changes.
If there is a strategy, I have not figured it out yet. I am just observing what will unfold.
|
I just downloaded SciTE 5.5.0 64-bit from this page and I can verify your observation. Making a multiple selection in SciTE, copying to the clipboard, and pasting into Windows Notepad produces a single line of text with all the pieces run together. Making a multiple selection in Notepad++, copying to the clipboard, and pasting into Windows Notepad yields one line for each component of the multiple selection. And this commit provides the answer. It never occurred to me before that Notepad++ might use a modified version of Scintilla. So... I suppose all bets are off as for expecting Scintilla within Notepad++ to conform to Scintilla vanilla (or its documentation).
notepad-plus-plus/scintilla/src/Editor.cxx Line 4319 in e7e88a3
MSDEVColumnSelect to the copy-to-clipboard routine whenever there are multiple selections. The only difference for rectangular selections is that it sorts them first. |
Well, the “complaint” amounts to: If Alt lets you click to place the cursor in virtual space (even when virtual space is not enabled for unmodified clicks) and Ctrl lets you make multiple selections, why doesn’t Ctrl+Alt let you make multiple selections in virtual space? Since both the Ctrl and the Alt behavior are implemented in Scintilla code, it seems to me that attempting to implement Ctrl+Alt in Notepad++ as a combination of the two would risk fragility. Whether Scintilla has a reason for not implementing it (perhaps it leads to some inconsistency we haven’t yet recognized), or whether it was just an oversight (or something no one ever requested), I don’t know. I can guess that part of it might be that Alt+drag creates a rectangular selection (even when it’s all on one line), and multiple rectangular selections are not supported. Perhaps the semantics of Ctrl+Alt+click/drag were deemed too confusing. |
Nice find. I am curious if that direct modification of the Scintilla library code was intentional and mainly - what will happen after the next possible Scintilla update... (FYI @donho) |
Quick answer, not implemented it seems. Longer answer read on. Alt is for rectangular selections and Ctrl is for multiple selections. Alt+Ctrl seems a strange combination the more I consider it as though rectangular and multiple selections are somehow the same, which does not seem to be the case. I am curious as why Ctrl+Alt should have this ability with the question asked. I consider that Scintilla might be able to make something happen rather than here though Neil may agree there and ask for a patch. But that could be pure speculation :) notepad-plus-plus/scintilla/src/Editor.cxx Line 4660 in 8beda66
See |
Is it time to ask the man himself ( @nyamatongwe ) if he's interesting in commenting on this discussion? |
If use Shift key with Ctrl key then it does go into virtual space. So the Ctrl+Alt might be unneeded to achieve the solution asked for in the OP. If not use Shift, then this code might capture the event and so selection does not happen. notepad-plus-plus/scintilla/src/Editor.cxx Lines 4791 to 4794 in 8beda66
Agh, forget it. I had virtual space checkbox checked. :( |
All the modifications of Scintilla are intentional, though it's not encouraged (for the sake of upgrading Scintilla).
Please see the file: |
Both Alan and Michael have made note of this, but I just wanted to condense it in one place so the point isn’t missed: This is a kind of side-effect. Mouse down with the Alt key pressed begins a rectangular selection. In Notepad++ (as a result of the settings it makes in Scintilla), rectangular selections are allowed to have the anchor and/or caret in virtual space even when virtual space is not enabled in the settings, so mouse down with the Alt key in virtual space doesn’t snap back to the end of a line, like an unmodified mouse down would. (Observe that the text caret is positioned on mouse down.) If you then drag (even if you let the Alt key up — but not the mouse button!), you’ll get a rectangular selection. If you mouse up without moving, then (I’m fairly sure, though I’d have to test it in code to be 100% certain) the selection reverts to an ordinary empty stream selection. However, the caret doesn’t snap back to the end of the line after the fact; it stays in virtual space. So you can use this to put the caret for an empty selection in virtual space, but that’s not its purpose; it just happens to work as a result of the way rectangular selections work. |
Nope. You can prove it by running
And this is because you're in rectangular selection mode. |
With The current behaviour of The reason that there is a separate The original poster seems to want virtual space so should enable that in the editing preferences. Temporarily allowing virtual space with |
I have long-exploited the "feature" in Notepad++ where I can Alt+Lclick past the end of line to place a caret "far out to the right" so that I can then paste some rectangular text there (giving me a nice "space gap" between there and existing text). I'm not sure what else might be proposed in this discussion, but I hope it doesn't become the elimination of this capability. Note that I don't normally want "virtual space" enabled, so that isn't an answer for me on this. |
Is there an existing issue for this?
Description of the Issue
Notepad++ v8.6 on through v8.6.8 support multi-caret by using
click
to position the first text cursor or caret and thenCtrl+click
to create and position additional text cursors or carets. If you click in the area past the end of a line then the resulting caret is positioned at the end of the line. Notepad++, including prior to v8.6, also supportsAlt+click
which works like a regular click and it also allows for positioning the text cursor or caret in the empty area past the end of a line. However, Notepad++ seems to ignore the Ctrl key whenCtrl+Alt+click
is used. It acts like a normalAlt+click
meaning that it will position the text cursor or caret in the empty area past the end of a line but you can't then create additional text cursors or carets the way you can withCtrl+click
Describe the solution you'd like.
That
Ctrl+Alt+click
will work just likeCtrl+click
with the additional ability that the text cursors or carets created can be positioned past the ends of the lines.Debug Information
Anything else?
No response
The text was updated successfully, but these errors were encountered: