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

Indenting at the first position in file fails/crashes #2614

Closed
Beta-Alf opened this issue Aug 13, 2015 · 1 comment
Closed

Indenting at the first position in file fails/crashes #2614

Beta-Alf opened this issue Aug 13, 2015 · 1 comment

Comments

@Beta-Alf
Copy link

This happens under Spyder 3.0.0-dev (from winpython) as well as Spyder 2.3.5.2 (from Arch Repos).
Under windows it simply crashes the application, under Linux I get a nice traceback:

Traceback (most recent call last):
  File "/usr/lib/python3.4/site-packages/spyderlib/widgets/sourcecode/codeeditor.py", line 2466, in keyPressEvent
    self.intelligent_tab()
  File "/usr/lib/python3.4/site-packages/spyderlib/widgets/sourcecode/codeeditor.py", line 758, in intelligent_tab
    self.indent_or_replace()
  File "/usr/lib/python3.4/site-packages/spyderlib/widgets/sourcecode/codeeditor.py", line 1930, in indent_or_replace
    self.indent()
  File "/usr/lib/python3.4/site-packages/spyderlib/widgets/sourcecode/codeeditor.py", line 1916, in indent
    if not self.fix_indent(forward=True):
  File "/usr/lib/python3.4/site-packages/spyderlib/widgets/sourcecode/codeeditor.py", line 1822, in fix_indent
    correct_indent = self.get_block_indentation(prevline)
UnboundLocalError: local variable 'prevline' referenced before assignment

The problem is clear: there is no previous line

@Beta-Alf
Copy link
Author

I am trying to fix this, but I am unsure whether to do this in intelligent_tab (checking for cursor position) or in fix_indent (making sure that no codepath ever hits this problem again). It should probably be the latter.

Beta-Alf pushed a commit to Beta-Alf/spyder that referenced this issue Aug 13, 2015
Beta-Alf pushed a commit to Beta-Alf/spyder that referenced this issue Aug 13, 2015
@ccordoba12 ccordoba12 added this to the v3.0 milestone Aug 13, 2015
@ccordoba12 ccordoba12 modified the milestones: v2.3.6, v3.0 Aug 15, 2015
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

2 participants