Skip to content

Conversation

DanielRosenwasser
Copy link
Member

Fixes #2483.

Context

When requesting completion off of something that's not a dotted name, we need to traverse the scopes. First we need to grab a node for which we will traverse upwards to aggregate scopes. We call this the scopeNode.

The original idea was that the first node that we begin aggregating on needs to contain the position for which we are requesting completion. The original challenge was determining "containedness". Fundamentally, a node n contains a position p if n.getStart() <= p && p < n.getEnd() _or_ the n.getStart() <= p and n is not "completed". See #2396 for details.

However, when requesting completion at the end of an identifier, this is an issue because the identifier is completed. This surfaces in issues with arrow functions like in the following:

xyz => xy/*$*/

Here, the arrow function is considered completed, so we continue looking for a node that owns the position of the cursor.


Solution

In the same manner that we adjust the contextToken, we adjust the position for which we are requesting a completion if at the end of an identifier. For the previous example, we will find scopes as if the completion was requested in the following scenario:

xyz => /*$*/xy

@DanielRosenwasser DanielRosenwasser changed the title Use appropriate completion edge Use adjusted completion position when at end of identifier Mar 25, 2015
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: currentToken may also be a keyword. i.e. you wrote "of" in the process of typing 'often'. So you don't want to check for just identifier, but also for keyword. In roslyn, we just call these "Words".

DanielRosenwasser added a commit that referenced this pull request Mar 25, 2015
Use adjusted completion position when at end of identifier
@DanielRosenwasser DanielRosenwasser merged commit 8610a88 into master Mar 25, 2015
@DanielRosenwasser DanielRosenwasser deleted the useAppropriateCompletionEdge branch March 25, 2015 23:59
@microsoft microsoft locked and limited conversation to collaborators Jun 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Completion at edge of identifier in arrow function does not list items appropriately

3 participants