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

[Enhancement] Inline variable value hints #33

Open
Antyos opened this issue Jul 9, 2022 · 0 comments
Open

[Enhancement] Inline variable value hints #33

Antyos opened this issue Jul 9, 2022 · 0 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@Antyos
Copy link
Owner

Antyos commented Jul 9, 2022

This is a dedicated thread to discuss the enhancement proposed by @Dorro101 in #32.

Proposal

It would be convenient to have a toggleable feature that displays the evaluated value of variables inline. For example,

// Variables and arrays
width = 32;  // width = 32
height = 8;  // height = 8
clearance = 0.2;  // clearance = 0.2
size = [width, height + clearance];  // size = [32, 8.2]
name = "foo";  // name = "foo"

Note that what are displayed as "comments" are visual only and do not reflect the actual content of the file.

There are two parts to this:

  1. The overlays themselves should be relatively straight forward to implement. The VSCode Decorator API can be used for this. See: vscode.rocks/decorations and microsoft/vscode-extension-samples@main/decorator-sample/USAGE.md
  2. Evaluating the actual variables. This is the hard part because it requires a parser/interpreter. It is possible this will be easier with the implementation of a language server in Add language server #31, but I am not too familiar with all of that.

Other questions that still need to be answers:

  • How should for loops be treated?
    for (i = [0:5]) {  // i = [0, 1, 2, 3, 4]
        // Stuff
    }
  • Or let() statements?
  • Nesting is probably going to be an issue.
    for (i = [0:10]) {
        for (j = [0:i]) {
            for (k = [i:j]) {
                // Stuff
            }
        }
    }
  • What about named parameters in function calls?
    cylinder(h = height, r1 = 10, r2 = r+10, center = true);  // h = 10, r1 = 10, r2 = 20, center = true
  • How should long arrays or lots of parameters be handled?

Plans

As of right now, I have no immediate plans to implement this feature. However, I think it would be a cool feature to have in the extension. If anyone wants to take a go at this and submit a PR, please be my guest.

And an important question, does the nesting issue make this completely infeasible?

@Antyos Antyos added enhancement New feature or request help wanted Extra attention is needed labels Jul 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant