Skip to content

"Rename Symbol" deletes some content when one of the renames is last line in file #1340

Closed
@nkinkade

Description

@nkinkade

Environment data

  • VS Code version: 1.22.1
  • Extension version: 2018.3.1
  • OS and version: Debian / Buster (testing)
  • Python version: 2.7.14
  • Type of virtual environment used: N/A
  • Relevant/affected Python packages and their versions:
    • rope 0.10.7

Actual behavior

When one of the symbols being renamed is on the last line of the file, that line disappears after renaming the symbol. Take this tiny file for example:

def testme(num):
    x = num + 2
    return x

print testme(2)

If you select testme in the function and press F2, then rename the function to, for example, testyou and press Enter. The last line in the file (print testme(2)) vanishes. I've verified that putting a newline character at the end of the last line fixes the issue. It appears to have something do with one of the symbols being renamed being on the last line of the file.

Expected behavior

I would have expected the line print testme(2) to turn into print testyou(2), instead of the line disappearing.

Steps to reproduce:

  1. Create a file with the above minimal content, making sure that there are no newline characters after the last line.
  2. Select testme in the function.
  3. Press F2.
  4. Rename the function to whatever you want.
  5. Press Enter.
  6. The last line disappears from the file.

Logs

Output for Python in the Output panel:

It is empty. Well, some git commands show up, but it seems highly unlikely they are relevant.

> git status -z -u
> git symbolic-ref --short HEAD
> git rev-parse master
> git rev-parse --symbolic-full-name master@{u}
fatal: no upstream configured for branch 'master'
> git for-each-ref --format %(refname) %(objectname) --sort -committerdate
> git remote --verbose

Output from Console under the Developer Tools panel (toggle Developer Tools on under Help)

None. There is no output at all in the Console of the Developer Tools.

Comments

While looking to see if there were any other issues filed for this problem, I did come across issue #52, in which the last comment (from puzzler10) seems to be related to this issue. They were asked to create a separate issue, but I can't find any issues opened by puzzler10, so I assume the person never did.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIssue identified by VS Code Team member as probable bug

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions