microsoft / microsoft/TypeScript

Give 'this' keyword suggestion the same `sortText` as class properties if inside a class

Open
#30,012 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Experience Enhancement Suggestion
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
2d 4h
Merged PRs (30d)
132

Description

From https://github.com/Microsoft/vscode/issues/66868

TypeScript Version: 3.4.0-dev.20190220

Search Terms:

  • suggestions
  • completions
  • sortText

Code
For the javascript:

class Foo {
    constructor() {
        this.prop = 1;
    }

    render() {
        th
    }
}
  • Trigger intellisense after th in render

Expected behavior:
this should be the first suggestion in VS Code

Actual behavior:
render and then prop are the first suggestions

The root cause of this is that the suggestion for this has a sortText of "0" while the one for prop and render have a sortText of "1". This causes VS Code to sort prop and render before this

@amcasey @minestarks I'm not sure if the current sorting issue would also effect VS

Playground Link:

Related Issues:

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the completion ordering in the TypeScript language service using the class example and inspect the completion entries for this, prop, and render. Update the relevant completion behavior so this uses the same sortText as class properties, then add or update a regression test covering the example and verify the resulting ordering.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
compilers, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.