View Issue Details

IDProjectCategoryView StatusLast Update
0007011LazarusIDEpublic2013-09-03 12:07
ReporterGraeme Geldenhuys Assigned ToMartin Friebe  
PrioritynormalSeveritymajorReproducibilityalways
Status closedResolutionfixed 
Platformi386OSUbuntu Linux 
Product Version0.9.17 (SVN) 
Target Version1.0.0Fixed in Version0.9.27 (SVN) 
Summary0007011: Editor doesn't insert TAB characters
DescriptionIf I edit a .pas file with gedit (Gnome Editor which supports tab
charaters for indentation) and use tabs instead of spaces for
indentation, Lazarus displays it correctly. Lets say I used a tab
width of 8 in both gedit and Lazarus.

<t> = tab
<s> = space

-------------- sample pas file --------------------
begin
<t>if (getGnome = null &
<t><s><s><s><s>getKDE = null)
<t>{
<t><t>// do something
<t><t>{ it has 2 tabs ahead }
<t>}
end.
------------------ end --------------------------------

Now I edit this file in Lazarus, and add a third comment line and also
used 2 tabs infront of the comment. Everything looks fine in Lazarus,
so I save.

Now I change gedits tab with to 4 and open that source file. The
newly added line didn't line up with the other comments, because
spaces were inserted instead of tabs.

Another way of testing this is viewing that same file in Lazarus. Go
to the editor options and change the Tab Width to 4. All the lines
move, except the last line added using Lazarus.

Using the arrow keys, and pressing left or right, shows it is jumping
tabs, but again for that third comment line, it jumps single spaces.

Now in the editor options, I don't have the "Tabs to Spaces" ticked
and I don't have "Smart Tabs" ticked.

In synedit.pp at line 9625
 Spaces := StringOfChar(' ', i);
overwrites what the previous line stored in the variable Spaces???
I commented it out and then noticed that the Tabs now get saved, but
there is still some problems.

------------- synedit.pp.patch --------------------
Index: synedit.pp
===================================================================
--- synedit.pp (revision 9377)
+++ synedit.pp (working copy)
@@ -9622,7 +9622,7 @@
  // i now contains the needed spaces
  Spaces := CreateTabsAndSpaces(CaretX,i,TabWidth,
                                not (eoTabsToSpaces in Options))+'|';
- Spaces := StringOfChar(' ', i);
+// Spaces := StringOfChar(' ', i);
  //debugln('TCustomSynEdit.DoTabKey Spaces="',DbgStr(Spaces),'"
TabChar=',DbgStr(TabChar));

  BeginUndoBlock;

----------------- end ---------------------------------
Steps To ReproduceSee description...
Additional InformationResponse from Flávio Etrusco in the mailing list
Date: May 31, 2006 7:35 PM
Subject: Re: Lazarus doesn't insert TAB charaters

Disabling "Trim Trailing Spaces" should help you here.
But, a big WARNING: undo/redo has several bugs when dealing with tabs.

-Flávio

Now the long answer ;-)

First, "hard" tabs support is incomplete in SynEdit, even in the
latest official version (of SynEdit, and the component in Lazarus is
based on a quite old version).

The major problem here is "eoTrimTrailingSpaces" in Options, because
text is trimmed after every key press. So, disabling "Trim Trailing
Spaces" should at least preserve the tabs you explicitly typed/wrote.

The current official version of SynEdit has fixed most of the bugs
with tabs and remaining ones (that are known) only happen with
"TrimTrailingSpaces", but since we couldn't agree on the best fix for
"trim", for now we introduced a "end key jumps to nearest end" option.
TrimTrailing is disabled and SmartEndKey is enabled by default, btw.

Also, I've come to respect that people have different tastes for
indentation size (and thus at my workplace we standardized on using
tabs), so yes, I plan to fix the remaing tab bugs, and have an option
to "display" tabs and trailing empty chars. It would be simply a
subset of "show special chars" (which already exists) anyway.
Oh, and non-tabulated tabs :-/

Cheers,
Flávio
TagsNo tags attached.
Fixed in Revision18241
LazTarget1.4
Widgetset
Attached Files

Activities

Martin Friebe

2009-01-02 03:01

manager   ~0024101

The comments from the mail-list is outdated. Trim-trailing spaces does keep tabs now (SVN / 0.9.27)

Assuming you have *not* selected the options "tabs to spaces" and "smart tabs", SynEdit inserts real tabs (with and without trim trailing spaces).

From the original description I am not clear if the
 "a third comment line and also used 2 tabs infront"
 got it tabs (or spaces) by
A) positioning the caret at column 1, and press the tab key twice
B) pressing Return at the end of the previous line and have the option "Auto Indent" on

- In case A you should now get 2 real tabs, which will work with any editor, and resize in SynEdit too.
- With option B spaces are inserted ("Auto Intend" does not yet support real tabs)

Please confirm or correct the following:

1) My reading of the bug is that it was initially about intending by pressing the tab key? (I do not have 0.9.17 to reproduce)
2) Since the above should be fixed, the bug could now be described as:
Auto-indent should copy real-tabs from the line above, if the line above was indented with real tabs?

Additional please confirm that the desired behaviour applies to both "tabs to spaces" and "smart tabs" turned *off*
(smart-tabs actually uses a mixture off spaces and tabs)

Martin Friebe

2009-01-10 22:16

manager   ~0024351

The original issue (as understood by me) has been fixed longer ago.
Tabs are inserted even with trim-trailing-spaces=on.

The only other tab related issue (missing feature) seems to have been auto-intend. This has been done too.

Please close if ok

Issue History

Date Modified Username Field Change
2006-06-02 09:41 Graeme Geldenhuys New Issue
2006-06-02 09:41 Graeme Geldenhuys Widgetset => GTK, Win32
2006-06-02 22:46 Vincent Snijders Target => 1.0
2006-06-02 22:46 Vincent Snijders Status new => acknowledged
2008-04-09 11:30 Vincent Snijders LazTarget 1.0 => post 1.2
2008-11-04 18:10 Martin Friebe Status acknowledged => assigned
2008-11-04 18:10 Martin Friebe Assigned To => Martin Friebe
2009-01-02 03:01 Martin Friebe Note Added: 0024101
2009-01-02 03:01 Martin Friebe Status assigned => feedback
2009-01-10 22:16 Martin Friebe Fixed in Revision => 18241
2009-01-10 22:16 Martin Friebe Widgetset GTK, Win32 =>
2009-01-10 22:16 Martin Friebe Status feedback => resolved
2009-01-10 22:16 Martin Friebe Fixed in Version => 0.9.27 (SVN)
2009-01-10 22:16 Martin Friebe Resolution open => fixed
2009-01-10 22:16 Martin Friebe Note Added: 0024351
2009-01-10 22:16 Martin Friebe Target Version => 1.0.0
2009-06-13 12:08 Marc Weustink Status resolved => closed
2013-09-03 12:07 Martin Friebe LazTarget post 1.2 => 1.4