Skip to content

Python running selection within function causes indentation error #4101

Closed

Description

Environment data

  • VS Code version: 1.30.1
  • OS and version: Linux Ubuntu 18.04 bionic
  • Python version (& distribution if applicable, e.g. Anaconda): 2.7.15

Expected behaviour

After selecting indented lines (i.e.) inside a function/method/class and hitting Shift+Enter, code should execute in terminal without raising IndentationError.

Actual behaviour

For code:

def square(i):
    s = i*i
    s2 = s+1
    return s2

selecting two lines with variable manipulation causes error.
cselect

Steps to reproduce:

  1. Create python source file.
  2. Create function inside it
  3. Select lines inside the function
  4. Press Shift+Enter to run the selection

Output

Python 2.7.15rc1 (default, Nov 12 2018, 14:31:15)
[GCC 7.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>     s = i*i
  File "<stdin>", line 1
    s = i*i
    ^
IndentationError: unexpected indent
>>>     s2 = s+1
  File "<stdin>", line 1
    s2 = s+1
    ^
IndentationError: unexpected indent
>>>

Activity

  1. ghost added
    triage-neededNeeds assignment to the proper sub-team
    on Jan 23, 2019
  2. ghost removed
    triage-neededNeeds assignment to the proper sub-team
    on Jan 23, 2019
  3. ericsnowcurrently commented on Feb 4, 2019

    @ericsnowcurrently

    Thanks for bringing this up, Michał Kaczanowicz (@vicrac). I've verified (on linux) with the latest release of the extension that this is failing as described. We'll working on fixing it.

  4. ericsnowcurrently commented on Feb 4, 2019

    @ericsnowcurrently

    FWIW, this reminds me of something we fixed a while back. Don Jayamanne (@DonJayamanne), do you remember that? I'm pretty sure you worked on it.

  5. DougPlumley commented on Jun 25, 2019

    @DougPlumley
  6. locked as resolved and limited conversation to collaborators on Jul 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-terminalbugIssue identified by VS Code Team member as probable bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions