-
-
Notifications
You must be signed in to change notification settings - Fork 368
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 positionMapping in stale data #3920
Fix positionMapping in stale data #3920
Conversation
I have absolutely no idea how this stuff works. Maybe @wz1000 does? |
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.
the problem lays in updatePositionMapping
.
mapAccumRWithKey
accumulate (key,val) decending keys, the delta should be the old ones, instead of new
Since it contains version mapping between old versions and current version |
47ec09e
to
8af6f0f
Compare
8af6f0f
to
b1f1feb
Compare
In order to add tests on this, I have refactored the involved code into
I will explain how this is going on, The reason is that application of the mappings is reversed. The last insertion at (0,5), won't sent char at (0,4) to (0,5). It could be easily reproduced by swtich
|
hi @michaelpj , I have added a test case, it should be easy to spot the bug now. |
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.
Thanks, great catch. All this is quite subtle!
* Fix positionMapping in stale data * add test for updatePositionMapping * add comment to demonstrate addOldDelta
Thanks so much for doing the work to add a test! |
…tDocument/semanticTokens/full) (#3892) * Implement semantic tokens lsp plugin draft * SemanticTokens: combine information extracted from HieAst * clean up * map to default token types in lsp * use lsp makeSemanticTokens to convert to lsp SemanticTokens type * add test and cleanup * refine semantic type to default one in lsp * Use tokens from hieAst instead of renamedSource and add test * use customize RefMap to get semantic type * use refMap from useAsts * Also compute imported names * Also compute semantic type from TyThing * Fix dependencies version * fix version * Retrieve nameSet from renamedSource to prevent names not visible(Such as by instance deriving) being handled * add hlint config to ignore test data * cean up test data * revert flake.nix * Rename query.hs to Query.hs * Build: add semantic tokens to lts21 * Refactor and add README * Semantic token, filter names in Ast * CI: add consistancy check for wether semantic tokens computations is stable across different ghc versions * Update documentation, cleanup test, remove default modifiers * Fix: IO now classfied to TTypcon, add test for GADT and data family, Update documentation * Restore stack.yaml * fix stack build * Refactor, move out ActualToken to Mappings and use ide logger * Refactor: toLspTokenType should return Maybe type * Stop use stale hieAst * add getImportedNameSemanticRule rule to semantic tokens plugin * do not retrieve hie in getImportedNameSemanticRule * fix: add description for semantic tokens * remove TValBind and TPaternBind and Use TFunction and TVariable instead * cleanup * Refactor useWithStaleMT and took care of the token range using position map * fix build for 9.4 * refactor, use golden test * refactor, use ExceptT for computeSemanticTokens * Fix 9.2 * add persistentSemanticMapRule to prevent semantic tokens block on startup * Fix, use hieKind instead of cast the type directly * add options to turn semantic tokens on and off * Disable stan plugin by default (#3917) * Fix positionMapping in stale data (#3920) * Fix positionMapping in stale data * add test for updatePositionMapping * add comment to demonstrate addOldDelta * cleanup * fix: for local variable, extract type from contextInfo instead of bind site, thus function in pattern binds can also be indentified * clean up * Update plugins/hls-semantic-tokens-plugin/src/Ide/Plugin/SemanticTokens/Query.hs Co-authored-by: Michael Peyton Jones <me@michaelpj.com> * refactor: remove TNothing and compact the test output * refactor: rename SemanticTokenType to HsSemanticTokenType to avoid confusion with lsp' SemanticTokenTypes * refactor: push the computation of semantic token type to getSemanticTokensRule * update documentation * cleanup hieAstSpanNames * remove renamed source from getSemanticTokensRule and optimize query function for semantic token type * try to exclude names that is not visible in hie and cleanup * add HieFunMaskKind, it is to differ wether a type at type index is a function or non-function * expose function flag to expose (=>, ->, -=>, ==>) * 1. Relax GetDocMap kindMap to get TyThing for more than type variables. 2. Backport isVisibleFunArg * use customize logger, add test for unicode * fix: handle unicode in semantic tokens * update KindMap to TyThingMap * cleanup * add realSrcSpanToCodePointRange, realSrcLocToCodePointPosition to Development.IDE.GHC.Error * add Note [Semantic information from Multiple Sources] * move recoverFunMaskArray to Mappings.hs * fix test, data.Set might not appear * fix: handle semantic tokens with more than one ast * fix: instance PluginMethod Request Method_TextDocumentSemanticTokensFull * clean up * turn semantic tokens off by default * fix doc * clean up doc --------- Co-authored-by: fendor <fendor@users.noreply.github.com> Co-authored-by: Michael Peyton Jones <me@michaelpj.com>
Fix #3919 (comment)