PistonDevelopers / VisualRust

Visual Studio extension for Rust
MIT License
702 stars 72 forks source link

Util.GetTokensAtPosition edge cases #293

Closed MaulingMonkey closed 7 years ago

MaulingMonkey commented 7 years ago

currentToken is often null mid-line in my testing. As i understand it, a single character token will have StartIndex == StopIndex which means it can never be a current token. Whenever this happens, leftToken ends up being the last token, even if the cursor is at the start of the line, messing with when RustCompletionCommandHandler triggers intellisense.

I'm inclined to do the following refactorings:

MaulingMonkey commented 7 years ago

My GetIdentTokenAtPosition suggestion is a bad idea - RustF1HelpCommandHandler wants to handle more than ident tokens, best to leave the filtering of what tokens the caller wants up to the caller.

That said, I am changing/replacing the behavior of GetTokensAtPosition (possibly with a rename) such that ide|nt returns the same token for both left/right (whereas foo |ident will return the whitespace and ident tokens)

MaulingMonkey commented 7 years ago

My take on fixing: https://github.com/MaulingMonkey/VisualRust/commit/7b9f314a6db4d54a2afff6942cdb3d758fb5a552

MaulingMonkey commented 7 years ago

Closing this as it's part of my pull request.