View Issue Details

IDProjectCategoryView StatusLast Update
0017603LazarusIDEpublic2011-12-01 11:24
ReporterBo Berglund Assigned ToMartin Friebe  
Status closedResolutionfixed 
Product Version0.9.28.2 
Target Version0.9.30Fixed in Version0.9.29 (SVN) 
Summary0017603: IDE block indent/unindent do not work properly
DescriptionCode that is imported from Delphi or downloaded from websites often has the wrong indentation, maybe caused by mixed use of TAB and <space> characters.
In any case when looking at this in Lazarus it gets awful, so I wanted to use my old proven Delphi7 ways to fix it:
1) Select a block which has ragged left limit (some lines in different positions)
2) Use Ctrl-Shift-u repeatedly until the block is at the left edge and all lines now start in column 1.
3) Use Ctrl-Shift-i repeatedly to move the block to the wanted position.

This does not work in Lazarus.

Only by activating the Tab to move blocks in editor configuration is it possible to move blocks of text, but only to the right of the original position.
Using Shift-TAB does nothing, except if it is entered immediately after TAB, when it backs off the indentation just done by TAB.
Notice that it seems totally impossible to move any block *left* of the original position, which totally breaks the procedure outlined above.

It has been suggested that it is caused by not using TAB as indentation, but this is very hard to prove since Lazarus does not show any whitespace difference...
In fact I would like the unindent to actually remove the configured number of columns in front of the text no matter if the text was moved right by a number of space or TAB characters.
Whitespace is whitespace and if I set my preferences to use the space character then Lazarus should change any tab to the correct number of spaces.
Especially while indenting a block of code.
TagsNo tags attached.
Fixed in Revision27906
Attached Files


Bo Berglund

2010-10-11 19:14

reporter   ~0041730

Now that I have learned how to make Lazarus display special chars I can verify that in those sections where the white space in front of the line consists of spaces unindent works. But where the white space is a number of TAB chars, unindent does not work.
Indent works in both cases and any indent created can be unindented back to the starting point but not longer if the original indent was made with TAB:s.

Martin Friebe

2010-10-27 23:55

manager   ~0042223

Please update, test and close if ok.

The new behaviour is not to convert all, but only the minimum needed tabs into spaces. This will happen independent of other "space to tab" or "tab to space" settings, since unindent can not work without

** Unindent
attempts to delete the last N spaces before the first none whitechar of the line. If those contain tabs, then this tab (or tabs) are converted.

("_" space / "-->" tab / tabstop=4 / unindent=2)
will become
In the last line, the last tab has been converted

** Indent
inserts always spaces. They are no longer inserted at the very first column, but immediately before the last none-whitechar. Therefore they will not be affected by tabs in the leading white-chars
spaces where insert behind the 2 tabs

This fixes the issue that unindent/indent did not work. There is room for adding options, such as always turning tabs to spaces, or combine spaces into tabs.
But this is not part of this issue. This can be added as separate request, if required.

If conversion of all tabs (in selection) to spaces is required, Lazarus has a special menu entry for this (Edit menu). This can be assigned to a key combo if required, and executed on it's own

Issue History

Date Modified Username Field Change
2010-10-11 13:24 Bo Berglund New Issue
2010-10-11 13:24 Bo Berglund Widgetset => Win32/Win64
2010-10-11 13:35 Martin Friebe Status new => assigned
2010-10-11 13:35 Martin Friebe Assigned To => Martin Friebe
2010-10-11 19:14 Bo Berglund Note Added: 0041730
2010-10-27 23:55 Martin Friebe Fixed in Revision => 27906
2010-10-27 23:55 Martin Friebe LazTarget => 1.0
2010-10-27 23:55 Martin Friebe Widgetset Win32/Win64 =>
2010-10-27 23:55 Martin Friebe Status assigned => resolved
2010-10-27 23:55 Martin Friebe Fixed in Version => 0.9.29 (SVN)
2010-10-27 23:55 Martin Friebe Resolution open => fixed
2010-10-27 23:55 Martin Friebe Note Added: 0042223
2010-10-27 23:56 Martin Friebe Target Version => 0.9.30
2011-12-01 11:24 Marc Weustink Status resolved => closed