Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Geany 2.0: indendation ignored #3721

Closed
patham9 opened this issue Dec 16, 2023 · 8 comments
Closed

Geany 2.0: indendation ignored #3721

patham9 opened this issue Dec 16, 2023 · 8 comments

Comments

@patham9
Copy link

patham9 commented Dec 16, 2023

When working with Python files Geany ignores indentation settings and sometimes inserts tabs even when configured with the saner spaces choice (which should be the default actually anyway) particularly after pressing enter after any ":" like after if and while constructs in Python.
This makes it essentially not very useful for such programming tasks as the indentation will constantly be messed up.
I recall this setting was always a bit of a pain in Geany and needed program restarts to be applied, but previously at least it worked after restart, now its behavior is inconsistent.

Version used: geany-2.0_osx_arm64.dmg

@patham9
Copy link
Author

patham9 commented Dec 16, 2023

It seems one can avoid having it insert tabs by setting auto-indent mode to None, but then when pressing tabs it will still insert tabs instead of spaces despite "Tab key indents". Maybe automated testcases could ensure the most basic functionality won't break again in the future?

@elextr
Copy link
Member

elextr commented Dec 16, 2023

What is inserted for indentation is set in Document->Indent Type->Spaces and number by Document->Indent Width->4 (or whatever).

The values for those two settings are set on loading a file to the value in preferences or project properties which overrides the preferences if a project is open.

Both of those have a Detect from file option which you may prefer if your files are consistent (which Python files should be)

@patham9
Copy link
Author

patham9 commented Dec 16, 2023

I see, this makes sense, thank you for clarifying! I wasn't aware this can be set on a per-file basis and that this can contradict what is specified in the settings and lead to inconsistent behavior of sometimes spaces and sometimes tabs being inserted by Geany. This was indeed the cause of the issue.

@elextr elextr closed this as completed Dec 16, 2023
@willbprog127
Copy link

When using 2.0 on Windows the indentation I have set in Preferences->Editor->Indentation->Width is completely ignored in all open documents. I have indeed clicked Project->Apply default indentation and no change. I have even closed every document, closed Geany, reopened Geany then open each document and the editor indentation width is completely ignored. Going to Document->Indentation Width shows 4 when I have set 2 globally. Geany 1.38 works as expected, however.

@elextr
Copy link
Member

elextr commented Mar 12, 2024

@willbprog127 do you have a project open? It has indentation settings which override the default preference.

@willbprog127
Copy link

@willbprog127 do you have a project open? It has indentation settings which override the default preference.

No, no project open.

I know from the past that this setting is 'tricky' although it really shouldn't be. Geany is a great editor / IDE, it's just little things like this that make it frustrating to use when setting up on a new system.

@patham9
Copy link
Author

patham9 commented Mar 13, 2024

I guess in retrospect the real story is that file preference should not override global settings in the first place unless the user has explicitly changed it for the particular file. It is just confusing and strange behavior that the settings can have no effect when file-based defaults do not agree. And do people actually use that feature? Or is it like in Gimp that one can change toolbox layout etc. but in 99% of cases it just happens by accident to annoy the user? :)

@elextr
Copy link
Member

elextr commented Mar 14, 2024

Indentation is stupidly complex, everyone should use my standard, 4 spaces 😀

But sadly thats not the case, in languages like Python indentation sets program structure, so Python really should use spaces and it defines tab as 8 spaces for where they are mixed, Geany is C which doesn't care, but the devs do and decree tabs but 4 space width, GNU uses two spaces IIRC, other projects use other rules.

So it varies by project, by filetype, and needs a default for new files. So Geany has all three, with filetype file indentation settings (if present) overriding default in the preferences, and project overriding both filetype and default (IIRC, I didn't check).

But that doesn't handle the user opening a random file from somewhere else, so they need to be able to select the indentation setting manually, and have that override everything, and stick (at least as long as the file is open, and across Geany restarts).

But that can be quite a pain, so there is an option to try to detect the indentation from the file when its opened, but its a heuristic, and as such can be wrong, so the manual override is still needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants