Repository navigation
Do not trigger completion on operators - #4054
Conversation
| let! sourceText = context.Document.GetTextAsync(context.CancellationToken) | ||
| let defines = projectInfoManager.GetCompilationDefinesForEditingDocument(document) | ||
| do! Option.guard (CompletionUtils.shouldProvideCompletion(document.Id, document.FilePath, defines, sourceText, context.Position)) | ||
| //let defines = projectInfoManager.GetCompilationDefinesForEditingDocument(document) |
There was a problem hiding this comment.
Derp, I need to just delete this line; provided my change to calling ShouldTriggerCompletion be the right thing
| module internal CompletionUtils = | ||
|
|
||
| let private isPotentialOperatorChar (ch: char) = | ||
| match ch with |
There was a problem hiding this comment.
There may be more characters to use here; I'll look at it again
| && | ||
| (triggerChar = '.' || (Settings.IntelliSense.ShowAfterCharIsTyped && isStartingNewWord(sourceText, triggerPosition))) | ||
| && | ||
| not (isPotentialOperatorChar prevChar) No newline at end of file |
There was a problem hiding this comment.
Is this going to break completion in these contexts:
[<|Attribute // within attribute
&|foo // byref of variable foo
1.0/| // after divisionetc?
There was a problem hiding this comment.
It did, and I now realized that this whole original idea is just silly. The classification data can tell if we're in the middle of an operator already.
| | ClassificationTypeNames.Comment | ||
| | ClassificationTypeNames.StringLiteral | ||
| | ClassificationTypeNames.ExcludedCode | ||
| | ClassificationTypeNames.Operator |
There was a problem hiding this comment.
This line is what fixes the issue.
| let! sourceText = context.Document.GetTextAsync(context.CancellationToken) | ||
| let defines = projectInfoManager.GetCompilationDefinesForEditingDocument(document) | ||
| do! Option.guard (CompletionUtils.shouldProvideCompletion(document.Id, document.FilePath, defines, sourceText, context.Position)) | ||
| do! Option.guard (this.ShouldTriggerCompletion(sourceText, context.Position, context.Trigger, null)) |
There was a problem hiding this comment.
ShouldTriggerCompletion will fire once you type a character; however, you can ctrl+space to bring up completions and this will not fire ShouldTriggerCompletion. Instead, it will go right to ProvideCompletionsAsync.
ProvideCompletionsAsync should not be checking for a dot to get completions. That's the responsibility of ShouldTriggerCompletion.
I recommend making this go back to what it was.
| )) No newline at end of file | ||
| )) | ||
| && | ||
| (triggerChar = '.' || (Settings.IntelliSense.ShowAfterCharIsTyped && isStartingNewWord(sourceText, triggerPosition))) No newline at end of file |
There was a problem hiding this comment.
I understand the logic of putting this here. But, considering the comment I made on ShouldTriggerCompletion and ProvideCompletionsAsync, this bit that's checking does not belong in the flow of ProvideCompletionsAsync. I recommend putting this back to the way it was.
There was a problem hiding this comment.
Ah, I see. Hmmm. This logic is really just strewn about. I'd like to clean it up in this PR.
There was a problem hiding this comment.
If you want to clean things up, just create some more functions that contain these kind of checks. :)
There was a problem hiding this comment.
Yeah, I'll just do that separately. I'm thinking of a winter project of porting the old completion tests over to CompletionProvider so I might as well try to clean a few things up at this time too
TIHan
left a comment
There was a problem hiding this comment.
With the current changes, consider this code:
let f x y = x + y
let x = 1
f ^With the cursor right at f. If I ctrl+space, I get nothing. This is due to ProvideCompletionsAsync checking for the dot.
|
Considering the problem mentioned in the review, I am very surprised the tests passed. Perhaps we should provide a test for that case. |
|
@TIHan BTW, there are no tests for |
|
@vasily-kirichenko I made an issue regarding that then: #4069 Will be good to have tests against it. :) |
|
@dotnet-bot test Ubuntu14.04 Release_fcs Build please |
|
I'm catching up old notifications - but just to say "great job!" on this :) |
* No triggered completion on operators * Check with classification data instead of stupid custom stuff * Fix silly tests * Feedback
* do not simplify open statements (dotnet#4068) * Do not trigger completion on operators (dotnet#4054) * No triggered completion on operators * Check with classification data instead of stupid custom stuff * Fix silly tests * Feedback
* No triggered completion on operators * Check with classification data instead of stupid custom stuff * Fix silly tests * Feedback
I noticed this when I mistyped
|.the other day. I threw this together quickly and must now leave for the office on the ferry, so I likely won't be able to address feedback until tomorrow. I installed it into my VS and things seemed to work.