-
Notifications
You must be signed in to change notification settings - Fork 39
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
fix(suggest): file level cmds don't leak internal syms #944
fix(suggest): file level cmds don't leak internal syms #944
Conversation
The more elaborate PR message helps with understanding your reasoning better, which thus makes review easier, nice. |
I aware of that, just it take times, as it's much different from making PR in nim repo. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Testing whether the cursor column is -1
relies too much on details decided far away from here, which introduces hidden dependencies making the code harder to reason about and change.
It's more robust to check whether a cursor is attached at all (whole project or whole file operations don't attach a cursor).
@bung87 the PR message is really helpful, thank you! |
Co-authored-by: zerbina <[email protected]>
Co-authored-by: zerbina <[email protected]>
semIdeForTemplateOrGenericCheck
not validate trackPos.col
semIdeForTemplateOrGenericCheck
unnecessarily invoke semIdeForTemplateOrGeneric
semIdeForTemplateOrGenericCheck
unnecessarily invoke semIdeForTemplateOrGeneric
semIdeForTemplateOrGenericCheck
not validate ideCmd unnecessarily invoke semIdeForTemplateOrGeneric
semIdeForTemplateOrGenericCheck
not validate ideCmd unnecessarily invoke semIdeForTemplateOrGeneric
semIdeForTemplateOrGenericCheck
not validate ideCmd
The changes are good, but the PR message needs to be adjusted a bit:
I can help with phrasing and grammar, but the basic structure and information needs to be there. |
semIdeForTemplateOrGenericCheck
not validate ideCmd
updated, thank you! |
While updating the PR message, I thought about whether this would a regression for However, the workings of the three commands are a bit shaky with regards to templates/generics, so maybe the regression is okay. What are your thought's on this, @saem and @bung87? |
I still have no knowledge why this need a seperate sem step |
Honestly, I'm a bit confused, and it could be that the other changes are elsewhere. My mental model:
Example commands (non-exhaustive):
Thoughts/Questions:
|
well, if this intent to work for two kinds of commands then can't guard on cursor outside, the suggest tool run single command one time. |
Thank you for the overview. My mental model matches yours.
Yep, I think so too, and that's what I was trying to raise with my initial question.
Personally, I'd say so, yeah. |
Just to make sure I understand, the reason we can't have early avoidance of running the command is not so much the avoidance part not working, but suggest runs once and unless something is marked dirty it won't run again, it'll simply use cached results. The changing of the cursor position doesn't invalidate cache. So if we had the following module: template a(thing: untyped) =
thing.#[1]#
proc b[T](thing: T) =
thing.#[2]# And we ran two |
no, the dirty file thing you described only apply to #946 that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple of minor phrasing items.
Once you've updated the PR body to the latest ping me, thanks.
Co-authored-by: Saem Ghani <[email protected]>
Co-authored-by: Saem Ghani <[email protected]>
@saem updated. |
It's no where close to done, but I made a single change of moving the second bullet point from the Summary to the Details. The Summary should be short, focusing on the user facing impact. Also it seems like you wrote the Summary first, instead write the Details first, then summarize it. |
/merge |
Merge requested by: @saem Contents after the first section break of the PR description has been removed and preserved below:
|
/cancel |
/merge |
Summary
Suggest commands related to the whole file (i.e. outline), and not
cursor positions, no longer include symbols from inside template and
generic routines.
Details
semIdeForTemplateOrGenericCheck
is used to detect whether the cursoris within a generic routine or template body, before this change it
didn't validate which suggest command was invoked (
ideCmd
). Thisresulted in
safeSemExpr
being run and potentially reporting symbolsfrom inside such routines. This led to commands such as
outline
containing symbols from the routine bodies polluting module level
results.
semIdeForTemplateOrGenericCheck
has now been updated to check thecommand against the newly added
ideLocCmds
constant, which includescommands that require cursor position tracking (
ideSug
,ideCon
,ideDef
,ideUse
,ideDus
), preventing the unexpected analysisand pollution of module level results.
A regression test was added to ensure that accidentally providing cursor
tracking information to module level commands doesn't change the
results.