Skip to content
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

Custom operations are at the top of completion list & remove active pattern values from the list #4831

Conversation

vasily-kirichenko
Copy link
Contributor

This fixes #4829

image

@vasily-kirichenko
Copy link
Contributor Author

It also fixes #4832

image

(VS NUnit 3 Test Adapter is unable to discover any test, so I cannot run the new tests locally, chances are they will fail on CI).

@forki
Copy link
Contributor

forki commented May 5, 2018 via email

@vasily-kirichenko
Copy link
Contributor Author

vasily-kirichenko commented May 5, 2018

@forki To move custom operations to the top of completion list in Ionide, it must sort items by kind itself (in FSAC, I think). This PR expose CustomOperation kind for items, but the sorting is done in FSharp.Editor, which is not a part of FCS and works in VS only.

@forki
Copy link
Contributor

forki commented May 5, 2018 via email

@cartermp
Copy link
Contributor

cartermp commented May 9, 2018

VS NUnit 3 Test Adapter is unable to discover any test, so I cannot run the new tests locally, chances are they will fail on CI

Nope 😄

@cartermp
Copy link
Contributor

cartermp commented May 9, 2018

Testing this out right now. I have two thoughts, neither of which are related to the PR:

  1. Interesting that CompletionItemKind doesn't have a notion of a local, which you may want at the top of the completion list under some circumstances. But the placement of the priority makes sense to me given what exists.
  2. WOOF, while we're here can we just make bestAlmostIncludedSoFar a mutable value instead of the ref cell? Pretty sure @dsyme wouldn't mind that change even if it's not related to this PR directly...

@cartermp
Copy link
Contributor

cartermp commented May 9, 2018

Hmmm, building this PR against master on 15.7 results in #4832 and #4829 are still there. Maybe I just screwed up installing the VSIX into VS because I'm tired, but the version is 42.42.42.42 and your commits are in the log on the branch I built off of...

@vasily-kirichenko
Copy link
Contributor Author

@cartermp I confirm the sorting does not work on Saturn's application CE, however it does work on query CE.

@vasily-kirichenko
Copy link
Contributor Author

image

Kind is wrong for custom operations:

[F#][INFO 12:21:42 PM] First 10 completion items:
[|("abs", Field); ("acceptHtml", Field); ("acceptJson", Field);
  ("acceptMultipart", Field); ("acceptXml", Field); ("acos", Field);
  ("application", Field); ("array2D", Field); ("asin", Field); ("async", Field)|]

… corresponds to a computation expression"

This reverts commit 4548ca2.
@vasily-kirichenko
Copy link
Contributor Author

The fix for #4832 was wrong. It turns out for the following code

let _ = 
  query {
    for i in 1..10 do
    <* cursor *>
  }

at the cursor position there is no name resolution environment for the entire CE, and the "smart" algorithm of GetBestEnvForPos picks the first lhs one, which spreads from { to do and has eIsComputationExpression set to true. My fix was to not pick such nenvs specifically, to avoid polluting completion list with custom operations outside of the last CE. It results with no custom operations at cursor position above. So, I've reverted the fix and left only the sorting stuff.

Vasily Kirichenko and others added 3 commits June 6, 2018 11:07
@vasily-kirichenko
Copy link
Contributor Author

It's ready.

@vasily-kirichenko
Copy link
Contributor Author

I also remove active patterns (as values) from completion list altogether.

Before

image

After

image

@vasily-kirichenko vasily-kirichenko changed the title Custom operations are at the top of completion list Custom operations are at the top of completion list & remove active pattern values from the list Jun 11, 2018
@cartermp
Copy link
Contributor

@TIHan / @KevinRansom / @brettfo / @Pilchie we should consider this for 15.8 P4

@cartermp cartermp requested review from TIHan and dsyme July 21, 2018 18:19
Copy link
Member

@TIHan TIHan left a comment

Choose a reason for hiding this comment

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

This is a very reasonable change. Looks good to me.

@KevinRansom
Copy link
Member

@dotnet-bot test this please

@KevinRansom
Copy link
Member

@dotnet-bot no longer works :-( so closing and reopen is the way until we get a new way.

@KevinRansom KevinRansom closed this Aug 6, 2018
@KevinRansom KevinRansom reopened this Aug 6, 2018
@KevinRansom
Copy link
Member

@vasily-kirichenko thanks for this mate. Nice work.

Kevin

@KevinRansom KevinRansom merged commit 3c7f59e into dotnet:master Aug 7, 2018
@Krzysztof-Cieslak
Copy link
Contributor

❤️

nosami pushed a commit to xamarin/visualfsharp that referenced this pull request Jan 26, 2022
…attern values from the list (dotnet#4831)

* custom operations are at the top of completion list

* do not pick rhs NameResolutionEnvironment in completion if it corresponds to a computation expression

* Revert "do not pick rhs NameResolutionEnvironment in completion if it corresponds to a computation expression"

This reverts commit 4548ca2.

* fix after merge

* put active patterns (as functions) to the very end of completion list

* filter out active patterns-as-value from completion list

* Revert "put active patterns (as functions) to the very end of completion list"

This reverts commit c26b24c.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Put computation expression custom operations at the top of completion list
6 participants