8000 Indentation auto-detection for python files · Issue #1008 · geany/geany · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Indentation auto-detection for python files #1008

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

Open
xuhcc opened this issue Apr 25, 2016 · 5 comments
Open

Indentation auto-detection for python files #1008

xuhcc opened this issue Apr 25, 2016 · 5 comments

Comments

@xuhcc
Copy link
xuhcc commented Apr 25, 2016

I have "Detect width from file" option checked in preferences. But geany often fails to detect indentation width for some python files, for example:

import unittest


class MyTestCase(unittest.TestCase):

    def test_test(self):
        # test
        # test
        # test
        pass

For this file indentation is set to 8 spaces (should be 4).

Geany 1.27, Arch Linux

@elextr
Copy link
Member
elextr commented Apr 25, 2016

The detection width is set by a heuristic based on a "factored most common" and is not language specific. With a heuristic there will always be situations where it will get it wrong. In particular a language like Python tends to have most indents at a multiple of the minimum, so it is likely to be most at risk.

The most accurate method would be to make it language dependent, especially for Python where indent is syntax.

But that would need support for language specific capabilities to be added via plugins since we do not want to hard code language specific features for all the number of languages we support. That plugin capability has been discussed, but does not exist at the moment.

@Spike1377
Copy link

I have this problem too.

@Spike1377
Copy link

Wait no for me its worse and just always does tab indents even when I set it to spaces.

@eht16
Copy link
Member
eht16 commented May 18, 2025

Wait no for me its worse and just always does tab indents even when I set it to spaces.

That sounds like a different issue.
Do you mind opening a new one and describing the problem in more detail with example code to reproduce?

@Spike1377
Copy link
Spike1377 commented May 18, 2025 via email

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

No branches or pull requests

4 participants
0