Bug 175588

Summary: pressing "tab" with active selection on a line adds tab at the beginning of the line
Product: [Applications] kate Reporter: Ivo Anjo <ivo>
Component: partAssignee: KWrite Developers <kwrite-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: andrea.ippo, apaku, waqar.17a
Priority: NOR    
Version First Reported In: unspecified   
Target Milestone: ---   
Platform: openSUSE   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Attachments: Tab behavior inconsistent with respect to other entries

Description Ivo Anjo 2008-11-19 14:41:31 UTC
Version:            (using KDE 4.1.3)
OS:                Linux
Installed from:    SuSE RPMs

To reproduce, just create a new file, write "Hello KDE World", select the word KDE, and then press tab.

A new tab is added at the beginning of the line, while I would expect the word KDE to be replaced by a tab between Hello and World.
Comment 1 Andreas Pakulat 2008-11-19 14:56:53 UTC
Confirmed.  It seems despite the note (if no selection exists) of the "Tab key action" kate considers the selected type of tab-key-action even when a selection exists.
Comment 2 Anders Lund 2008-11-19 17:48:31 UTC
I believe this is by design, if you want tab key to indent, it also indents a selection.
Comment 3 Ivo Anjo 2008-11-19 17:52:21 UTC
But shouldn't the indentation at least start at the beginning of the selection and not at the beginning of the line?

I think the word not being deleted is not that big a problem, but the tab should appear before the word, "Hello \tKDE World" is acceptable too I think.
Comment 4 Dominik Haumann 2008-11-19 18:02:27 UTC
Well, if you select multiple lines TAB indents, no matter where the selection starts. Right now, this is also the case if (part of) a single line is selected.
I heavily disagree that the indentation should be inserted right before the selected text. I'd be fine with this:
- if multiple lines selected -> indent
- if single line / part of a line selected -> remove selected text and insert a TAB (or equivalent amount of spaces)

Maybe in block selection mode it should work as Ivo said, i.e. always insert TAB in front of each line that is selected...
Comment 5 Andreas Pakulat 2008-11-19 20:15:20 UTC
I'm with Dominik on this one, though I can't comment on the Block-Selection Mode as I don't use it.
Comment 6 Christoph Cullmann 2010-02-20 12:13:36 UTC
SVN commit 1093175 by cullmann:

make indent smarter, if you have activated, that tab key indents but only part of line is selected, it will only indent if in leading whitespace, otherwise will insert tab or what is configured
BUG: 175588

 M  +6 -3      kateviewinternal.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1093175
Comment 7 Andrea Ippolito 2022-06-02 10:01:32 UTC
Hello, I was about to report a bug on Kate for this, because while in Block selection mode, I cannot enter a tab at the same position for multiple lines in one shot, which was super handy in my use case. I could enter any other character and have it applied to all the lines affected by the block selection, AT THE position of my selection. Only tab behaves differently, and now I see why.

I think that the condition to use tab for indentation here should be made stronger: only use tab for indent if the entire line(s) (i.e. from char 0 to length-1) is/are selected. If only part of it is selected, the user probably expects tab to just insert a \t character.

I'm reopening this to further review the behavior that was implemented.

Thanks
Comment 8 Andrea Ippolito 2022-06-02 10:04:13 UTC
Created attachment 149395 [details]
Tab behavior inconsistent with respect to other entries
Comment 9 Waqar Ahmed 2022-06-02 11:26:42 UTC
Use multiple cursors instead.