Skip to content

isNewIdentifierLocation is always set to true inside function call #25691

@mjbvz

Description

@mjbvz
Contributor

TypeScript Version: 3.0.0-dev.20180713

Search Terms:

  • isNewIdentifierLocation
  • completions
  • suggest

Bug
The completionInfo request seems to always return isNewIdentifierLocation when inside a function call such as:

console.log(c|)

Expected behavior:
I believe that isNewIdentifierLocation should only be returned when the user is starting to write a arrow function with a parenthesized parameter list, such as:

(c|)

or

console.log((c|)

Activity

ghost

ghost commented on Jul 16, 2018

@ghost

The problem is that c => c + 1 is also a syntactically valid arrow function. So when the user types c, we wouldn't want to automatically correct it to something that happened to start with c.
One option might be to return three results: definitely not a new identifier, probably a new identifier, and probably not a new identifier. Then the editor could avoid making leaps of corrections, but still correct obvious spelling mistakes.

mjbvz

mjbvz commented on Jul 16, 2018

@mjbvz
ContributorAuthor

@Andy-MS One case we are interested in here is whether to enable accepting completions on , or not. I think , should commit for c| when the user is going to type c => c + 1 but not for (c|) in (c) => c + 1

I think we could do this with the extra information you are proposing

added this to the TypeScript 3.1 milestone on Jul 16, 2018
ghost added
FixedA PR has been merged for this issue
on Jul 16, 2018
ghost removed this from the TypeScript 3.1 milestone on Sep 18, 2018
ghost added this to the TypeScript 3.2 milestone on Sep 18, 2018
ghost removed this from the TypeScript 3.2.1 milestone on Nov 16, 2018
ghost added this to the TypeScript 3.3 milestone on Nov 16, 2018
Repository owner unassigned on Nov 16, 2018
highco

highco commented on Jan 14, 2019

@highco

The bug is still present in TypeScript 3.2.2. It's quite annoying, because in all IDEs, the autocomplete match doesn't get inserted in situation where you would expect it to be inserted.

I think the value of isNewIdentifierLocation should depend upon whether an arrow function is valid at the current location. For example:

function demo(a:number, b:(x:number) => void)
{
}

demo(a|     // an arrow function isn't valid here, isNewIdentifierLocation should be false
demo(a, b|  // an arrow function is valid here, isNewIdentifierLocation should be true
self-assigned this
on Aug 6, 2024
removed
FixedA PR has been merged for this issue
Fix AvailableA PR has been opened for this issue
on Aug 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptDomain: Completion ListsThe issue relates to showing completion lists in an editorFix AvailableA PR has been opened for this issue

Type

No type

Projects

No projects

Relationships

None yet

    Participants

    @highco@DanielRosenwasser@RyanCavanaugh@mhegazy@mjbvz

    Issue actions

      isNewIdentifierLocation is always set to true inside function call · Issue #25691 · microsoft/TypeScript