Skip to content

[BUG] Rename Symbol resulting in invalid python code. #244

Open
@gohierf

Description

@gohierf

Describe the bug
"Rename Symbol" (Right click on variable name, or F2) is a great feature, but it does not rename properly in Python evaluations: it removes underscores that are necessary to have valid python variables.

To Reproduce
Steps to reproduce the behavior:

  1. Right click on a variable which is also used in a inline python statement elsewhere.
  2. Click on "Rename Symbol".
  3. Add a space in the new variable name.
  4. The python code variable is not found because python does not support space in variable names.

If possible add some example source code like:

*** Variables ***
${MY VARIABLE}      foo

*** Test Cases ***
A Test Case
    Log    ${MY VARIABLE}
    IF    len($MY_VARIABLE)>=3    No Operation

Expected behavior
The spaces in the variable could be automatically converted to underscores in the resulting inline python code.

Screenshots/ Videos
BEFORE
image

AFTER
image

DESIRABLE
image

Desktop (please complete the following information):
VS Code Version 1.87.2
RobotCode Version 0.78.4
OS: Windows
Python Version 3.11.8
RobotFramework Version 7.0

Additional context
As a side note, it might be useful to deny multiple space in these symbol renaming because it will result in RobotFramework considering it as multiple symbols rather than a single variable or keyword. It is then not possible to use rename symbol again to perform the rollback operation. Which could be fixed by a Ctrl+Z, except that the renaming is done on multiple files, while Ctrl+Z only works on the current file.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions