Gedit auto indent inserts spaces instead of tabs

Bug #214649 reported by Ronald Schouten
4
Affects Status Importance Assigned to Milestone
GtkSourceView
Invalid
Low
gtksourceview2 (Ubuntu)
Invalid
Undecided
Unassigned

Bug Description

Binary package hint: gedit

When enabling Gedits auto-indentation feature it would be nice if it used the user's preference of tabs or spaces and not just spaces. As it is now, if the user prefers tab indentation and auto-indentation, you end up with a mix of tabs and spaces which breaks Python code.

This was found in Ubuntu 7.10 / Gedit 2.20.3-0ubuntu1

Revision history for this message
Marcel Stimberg (marcelstimberg) wrote :

This bug is still present in the latest gedit in Hardy:
gedit:
  Installed: 2.22.1-0ubuntu1
  Candidate: 2.22.1-0ubuntu1
  Version table:
 *** 2.22.1-0ubuntu1 0
        500 http://archive.ubuntu.com hardy/main Packages
        100 /var/lib/dpkg/status

Changed in gedit:
status: New → Confirmed
Revision history for this message
Marcel Stimberg (marcelstimberg) wrote :

I just realized that the problem only occurs until a manual tab is inserted. That means that the problem only occurs if
1) you change the setting "insert spaces instead of tabs" within a session and
2) automatic indentation is used before you do a manual indentation

Revision history for this message
Ronald Schouten (atomicron) wrote :

Gedit also seems to inherit the previous lines indent style. This means that if I set indent to tabs, but manually indent using spaces (i.e. copy and past code from the internent), auto-indent will use spaces too. Perhaps this is not a bug?

Revision history for this message
Marcel Stimberg (marcelstimberg) wrote :

This seems to be a bug in gtksourceview. A test with anjuta using gtksourceview showed the same behaviour. I filed a bug upstream.

Revision history for this message
Marcel Stimberg (marcelstimberg) wrote :

Sorry, didn't read your previous comment... You might be right, it seems as if the auto-indent feature ignores the tab/spaces setting and just uses the same as in the previous line. This actually makes kind of sense...
Should we close this bug, then?

Revision history for this message
Ronald Schouten (atomicron) wrote :

Even if this is working as designed I think it is confusing. My expectation was that Gedit auto-indent as indicated in my preferences, not according to the previously entered line. I'm not aware of any good reasons to do otherwise so I think keeping this bug open is appropriate.

Revision history for this message
Ronald Schouten (atomicron) wrote :

Marcel, what do you think? This is only a serious problem with Python development since indentation matters. I have not used any other editors for writing Python so I'm not sure what the norm is.

Revision history for this message
Marcel Stimberg (marcelstimberg) wrote :

Hi Ronald,
I see that the indentation is important for Python development - but I do not see a case where the issue mentioned in this bug has any negative effect. If the behaviour would be changed (ignore previous line, just use the setting) it would also be confusing to some developers ("why does it indent the line using a different convention?")...
Do you have a use case where the bug is really a problem? Because if tab/space convention does not match between your settings and the file you're editing, you'll run into problems anyhow - either during automatic or during manual indentation (given that gedit does not do any complex automatic indentation, like indenting after "def foo(bar):".

Revision history for this message
Ronald Schouten (atomicron) wrote :

I would be fine with just closing this bug. Like you said, it won't solve compilation problems in Python as the code being pasted in uses different spacing than my own code anyways so we are still left with a mix.

Revision history for this message
Marcel Stimberg (marcelstimberg) wrote :

Ok, according to the discussion above, this is not a bug but rather working as intended...

Changed in gtksourceview2:
status: Confirmed → Invalid
Changed in gtksourceview:
status: Unknown → Invalid
Changed in gtksourceview:
importance: Unknown → Low
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.