You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[QUESTION] Hovering over imported dictionary variables in VSCode #673
These variables are often dictionaries. However, when hovering over them in VS Code, their contents are not resolved and displayed. We also cannot navigate to their definitions in the YAML file using F12 (Go to Definition).
What would be the preferred way to model such variable structures so that their contents can be displayed on hover in VSCode and navigation to their definitions?
Hover: From variable files (YAML, JSON and Python alike), RobotCode only shows simple values: strings, numbers, booleans and None. Dictionaries and lists can hold anything and get arbitrarily large and deeply nested, so for stability and security reasons RobotCode deliberately doesn't keep their values. That's why ${FIRST_MESSAGE_TRANSMITTED} shows 5, but ${HA} shows no value.
Completion: RobotCode doesn't complete dictionary items, or attributes and methods of objects. So far that has been too much work to implement; I work on RobotCode alone in my spare time.
The better way is to use plain variables with sensible names, using _ to group them:
HA_UNIT_ID_MASTER: 1HA_UNIT_ID_SLAVE: 2
RobotCode completes these and shows their value on hover. If you also want F12 to jump to the exact line, define them in the *** Variables *** section of a resource file instead.
Whether that fits depends on what's in your data and what you do with it. For long lists such as web locators, there may also be designs that don't need variables at all.
What do your YAML files actually contain, and what do you use the values for?
First of all, thank you very much for your quick response.
Defining the variables as plain variables seems to be the most practical solution if we want their contents to be displayed when hovering over them. However, defining them in the Variables section is not an option for us because we reuse them across many different test suites. The values may also change in the future, and our goal is to have a single source of truth so that any changes only need to be made in one place. We use these variables to improve the readability of our test cases when evaluating Python expressions as well, for example:
path/to/value/1 == ${HA}[UNIT_ID_MASTER]
Thanks to RobotCode's syntax highlighting, the variables are displayed in a very readable way, and this notation has certain advantages over plain variables, although that may ultimately come down to personal preference.
However, defining complex data structures as dictionaries is very useful, as it significantly improves readability in YAML or Python files. Combined with RobotCode's syntax highlighting, it results in a very elegant solution. If there is no way to display the contents of these variables in VS Code, we will probably have to follow your suggestion and switch to plain variables instead.
Of course, it is understandable that implementing such functionality would require a significant amount of effort, and we are aware that you maintain RobotCode on your own. By the way, you're doing a great job. I have personally been using your extension for years, and I really appreciate your work. Thank you for that!
Activity
d-biehl commentedon Oct 19, 2026
What you see are limitations of RobotCode:
None. Dictionaries and lists can hold anything and get arbitrarily large and deeply nested, so for stability and security reasons RobotCode deliberately doesn't keep their values. That's why${FIRST_MESSAGE_TRANSMITTED}shows5, but${HA}shows no value.The better way is to use plain variables with sensible names, using
_to group them:RobotCode completes these and shows their value on hover. If you also want F12 to jump to the exact line, define them in the
*** Variables ***section of a resource file instead.Whether that fits depends on what's in your data and what you do with it. For long lists such as web locators, there may also be designs that don't need variables at all.
What do your YAML files actually contain, and what do you use the values for?
ruedrot commentedon Oct 20, 2026
First of all, thank you very much for your quick response.
Defining the variables as plain variables seems to be the most practical solution if we want their contents to be displayed when hovering over them. However, defining them in the Variables section is not an option for us because we reuse them across many different test suites. The values may also change in the future, and our goal is to have a single source of truth so that any changes only need to be made in one place. We use these variables to improve the readability of our test cases when evaluating Python expressions as well, for example:
Thanks to RobotCode's syntax highlighting, the variables are displayed in a very readable way, and this notation has certain advantages over plain variables, although that may ultimately come down to personal preference.
However, defining complex data structures as dictionaries is very useful, as it significantly improves readability in YAML or Python files. Combined with RobotCode's syntax highlighting, it results in a very elegant solution. If there is no way to display the contents of these variables in VS Code, we will probably have to follow your suggestion and switch to plain variables instead.
Of course, it is understandable that implementing such functionality would require a significant amount of effort, and we are aware that you maintain RobotCode on your own. By the way, you're doing a great job. I have personally been using your extension for years, and I really appreciate your work. Thank you for that!