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

Evaluating a non-list top level form from inside a form evaluates the wrong form when in a rich comment #2290

Closed
bpringe opened this issue Aug 18, 2023 · 3 comments

Comments

@bpringe
Copy link
Member

bpringe commented Aug 18, 2023

Repro:

(comment
  {:hello "w|orld"})

With the cursor at | within the form above, run the command the evaluate the top level form, and see that "world" is returned. I expect {:hello "world"} to be returned.

If you move that map outside the comment form and perform the same steps, the whole map is returned instead of just the string, as is expected.

@PEZ PEZ changed the title Evaluate top level form evaluates only string within top level form when cursor inside string within comment form Evaluate a non-list top level form evaluates only string within top level form when cursor inside string within comment form Aug 19, 2023
@PEZ
Copy link
Collaborator

PEZ commented Aug 19, 2023

I updated the title to reflect that this seems to be specific to when the top level form evaluated is not a function call. This is correctly handled:

(comment
  (str "w|orld") => "world"
  :rcf) 

@PEZ PEZ changed the title Evaluate a non-list top level form evaluates only string within top level form when cursor inside string within comment form Evaluate a non-list top level form from inside a form evaluates the wrong form when in a rich comment Aug 19, 2023
PEZ added a commit that referenced this issue Aug 19, 2023
@PEZ
Copy link
Collaborator

PEZ commented Aug 19, 2023

I updated the title again, because it is not only from inside strings it goes wrong. It's from inside a form that's is inside a “non-list”, when in a rich comment:

(comment
  {:hello "w|orld"} => "world"
  {:hello ['w|orld]} => [world]
  :rcf)

I added some unit tests that expose this:

@PEZ PEZ mentioned this issue Aug 20, 2023
13 tasks
@bpringe bpringe changed the title Evaluate a non-list top level form from inside a form evaluates the wrong form when in a rich comment Evaluating a non-list top level form from inside a form evaluates the wrong form when in a rich comment Aug 20, 2023
@bpringe
Copy link
Member Author

bpringe commented Aug 20, 2023

I updated the title to reflect that this seems to be specific to when the top level form evaluated is not a function call. This is correctly handled:

Assuming you ran the command to evaluate the top level form in that code you showed, from where you showed the cursor to be, that example doesn't show for sure that the evaluation is correctly handled. Evaluating both (str "world") and "world" will both result in "world", and I don't know from the example which was evaluated.

Anyway, good investigation and nice work on the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants