Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 264168

Summary: [block selection] problems with bracket inserter and Tab
Product: [Eclipse Project] JDT Reporter: Anton Leherbauer <aleherb+eclipse>
Component: TextAssignee: JDT-Text-Inbox <jdt-text-inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: daniel_megert, davidb.arbete+bugs+eclipse.org, denis.antonov, eclipse, kamil.kolaczynski, kaser, remy.suen, sergey.grinko, timo.rumland
Version: 3.5Keywords: helpwanted
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard: stalebug
Bug Depends on:    
Bug Blocks: 264147    

Description Anton Leherbauer CLA 2009-02-09 08:50:13 EST
+++ This bug was initially created as a clone of Bug #264147 +++

The issues reported below against CDT affect also the Java Editor.
1. Bracket inserter does not consider block selection mode.
2. Tab key should not indent line but insert a TAB character in multi-line block selection.

----
Eclipse 3.5.0M5 + CDT 6.0M5 Candidate

Hurray, we got an column edit mode in Eclipse now.

Hmm, but somehow, it's not working for all circumstances:
1. Open a C file.
2. Hit <Alt>+<Shift>+A to go into Column Edit Mode
3. Use the <Shift>+<Down> to mark several lines.
4. Enter e.g. #define FOO(  
Note: The opening parenthesis does not have to be at FOO, 
like
  #define FOO(x) foo_##x 
it could also be a macro like
  #define FOO    (1 << 0)
  #define BAR    (1 << 1)

As you can see, opening the parenthesis removes all lines but the first one, and marks the () for input completion or whatever this is now called. You know, the one where on finishing the input by hitting <Enter> and it moves behind the closing parenthesis.
But, it only happens if the line is empty, e.g. do the following:
1.) In the file, still in Column Edit Mode, mark two line by <Shift>+<Down>.
2.) Enter e.g. #define FOO  1 << 0
3.) Mark the two lines again before the 1, and enter (.

Nothing is deleted now.


Next problem is, under this edit mode, like:
#define FOO  (1 << 0)
#define BAR  (1 << 1)
Now, go to the opening parenthesis mark both line by Shift+cursor-down. Hit <TAB> and see how the lines are indented from column 0, but not from the position on marked by the cursor.
Comment 1 Tom Hofmann CLA 2009-03-05 19:13:21 EST
Affects both BracketInserter and normal content assist. Both should disable the magic when in block selection mode and multiple lines are selected... perhaps they should be disabled anyway if the selection spans multiple lines.
Comment 2 Tom Hofmann CLA 2009-04-26 10:20:35 EDT
I fixed the most annoying problem, i.e. BracketInserter deleting the extent of the selection when typing an opening bracket. Fixed > 20090426

Not so sure about content assist and tab. 

Content assist already behaves strangely when the selection spans multiple lines; perhaps this should be revisted as a whole, considering block selection and other multi-line scenarios.

Tab is different again - I completely understand the common use case of wanting to insert a tab character on each selected line. However, should we really take away a common and expected shortcut for "Shift Right" - why should this not work in block selection mode?

Dani, what's your view of this? I think the OP is right and we should only map "Tab" to "Shift/Indent" when the real operation of inserting a tab does not make much sense. Since in block selection, inserting a tab does make sense, we should do exactly that. The user can still choose the shifting and indenting actions from the source menu.
Comment 3 Dani Megert CLA 2009-04-27 09:20:32 EDT
Re content assist: agree.
re Tab, I think what Anton meant was that he likes to add a tab to the block selection. I suggest we do this in case the width of the selection is 0 but indent/left shift in all other cases.
Comment 4 Anton Leherbauer CLA 2009-04-28 04:04:21 EDT
(In reply to comment #3)
> Re content assist: agree.
> re Tab, I think what Anton meant was that he likes to add a tab to the block
> selection. I suggest we do this in case the width of the selection is 0 but
> indent/left shift in all other cases.

I think in block selection mode the tab should always be inserted literally. The reason is that block selection behaves as multiple individual selections. It is not observed as multi-line selection in the usual sense.
It's also hard to explain why one can insert a space, but not a tab, when the selection width happens to be >0.
Comment 5 Dani Megert CLA 2009-04-28 04:08:15 EDT
>I think in block selection mode the tab should always be inserted literally.
Well, I disagree. Either we leave it as is or we allow to insert a Tab with length 0. Tom to make the final call between the two as he's the block selection man.
Comment 6 Tom Hofmann CLA 2009-04-28 04:30:36 EDT
(In reply to comment #4)
> It's also hard to explain why one can insert a space, but not a tab, when the
> selection width happens to be >0.

The same could be said from the tab behavior in linear selection mode: inserting a tab would perfectly make sense - it's just not something that one typically does, that's why tab is mapped to a frequently used command.

The rationale for this decision should be that we only map tab to the indent/shift command where literally replacing the selection with a tab character would be a "very unusual" thing to do. Of course, the question is whether replacing a non-empty block selection with a tab character on each line would be very unusual... hard to say.

If we go down the way comment 3 suggests we would still be consistent with the current behavior that only a "non-empty" and "multi-line" selection triggers the indent operation.

Dani should we aim for 3.5 for this?
Comment 7 Anton Leherbauer CLA 2009-04-28 04:40:35 EDT
(In reply to comment #6)
> (In reply to comment #4)
> > It's also hard to explain why one can insert a space, but not a tab, when the
> > selection width happens to be >0.
> 
> The same could be said from the tab behavior in linear selection mode:
> inserting a tab would perfectly make sense - it's just not something that one
> typically does, that's why tab is mapped to a frequently used command.

As long as the selection is inside a line, I can insert a tab.
If I perceive a block selection as a set of linear in-line selections, I would expect I can do the same.
Comment 8 Dani Megert CLA 2009-04-28 05:17:47 EDT
>Dani should we aim for 3.5 for this?
If today's test pass goes well and once bug 267804 is off the plate we could shoot for this one but keep in mind that we go into RC-mode next week.
Comment 9 Tom Hofmann CLA 2010-02-08 12:35:32 EST
*** Bug 293548 has been marked as a duplicate of this bug. ***
Comment 10 sergey grinko CLA 2016-09-06 10:22:51 EDT
The problem with a vertical block and the TAB key and SHIFT+TAB key

TAB character is inserted always in the beginning of the text, but not to the point of separation of the vertical block. 

1. Open any file in the editor.
2. Hit <Alt>+<Shift>+A to go into Column Edit Mode
3. Use the <Shift>+<Down> to mark several lines in middle text.
4. Press key TAB

Result: All text is shifted to the right.
Expected: should fit only text that is to the right of the vertical separation.
Comment 11 Timo Rumland CLA 2016-10-22 10:59:01 EDT
Isn't the formatting of text in columns the primary use case for a block selection mode? Comparing to other editors like Notepad++, Sublime etc., I think inserting TAB in a block (or "column"-) selection mode at the vertical separation should be the default behaviour.

I for myself often format more complex Enums in columns for better readability. Currently, I copy-paste the code into one of the above editors, format the code, and paste it back into Eclipse.
Comment 12 Kamil Kolaczynski CLA 2017-03-03 05:12:38 EST
I agree, this is ultra annoying that we cannot just insert tabs in the block selection mode. It is very different than any other text editor is doing during the block selection. Is anyone (in the world :) ) satisfied with the current behavior? I can hardly imagine this.
 
Are there any plans to fix this?
Comment 13 Dani Megert CLA 2017-04-13 10:54:10 EDT
(In reply to Kamil Kolaczynski from comment #12)
> I agree, this is ultra annoying that we cannot just insert tabs in the block
> selection mode. It is very different than any other text editor is doing
> during the block selection. Is anyone (in the world :) ) satisfied with the
> current behavior? I can hardly imagine this.
>  
> Are there any plans to fix this?

High quality patches are welcome.
Comment 14 Eclipse Genie CLA 2019-10-25 19:03:03 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 15 sergey grinko CLA 2020-02-07 04:20:13 EST
My current version 
Version: 2019-09 R (4.13.0)
Build id: 20190917-1200

This problem is Active.

comment 10
Comment 16 Denis Antonov CLA 2020-05-15 06:11:58 EDT
I have the same problem.
The expected behavior,  described by Sergey in his comment posted 2016-09-06 10:22:51 EDT, is a valid one.

It works the same way in Notepad++, ABAP GUI code editor and I assume at a lot of more environments.

Please fix it, I think many people would be grateful!