-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Fixes to session's handling of empty results #17728
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -624,7 +624,7 @@ namespace ts.server { | |
|
|
||
| const definitions = project.getLanguageService().getTypeDefinitionAtPosition(file, position); | ||
| if (!definitions) { | ||
| return undefined; | ||
| return emptyArray; | ||
| } | ||
|
|
||
| return definitions.map(def => { | ||
|
|
@@ -714,7 +714,7 @@ namespace ts.server { | |
| const documentHighlights = project.getLanguageService().getDocumentHighlights(file, position, args.filesToSearch); | ||
|
|
||
| if (!documentHighlights) { | ||
| return undefined; | ||
| return emptyArray; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
| } | ||
|
|
||
| if (simplifiedResult) { | ||
|
|
@@ -809,7 +809,7 @@ namespace ts.server { | |
| // The rename info should be the same for every project | ||
| const renameInfo = defaultProject.getLanguageService().getRenameInfo(file, position); | ||
| if (!renameInfo) { | ||
| return undefined; | ||
| return emptyArray; | ||
|
||
| } | ||
|
|
||
| if (!renameInfo.canRename) { | ||
|
|
@@ -901,7 +901,7 @@ namespace ts.server { | |
| } | ||
| } | ||
|
|
||
| private getReferences(args: protocol.FileLocationRequestArgs, simplifiedResult: boolean): protocol.ReferencesResponseBody | ReadonlyArray<ReferencedSymbol> { | ||
| private getReferences(args: protocol.FileLocationRequestArgs, simplifiedResult: boolean): protocol.ReferencesResponseBody | undefined | ReadonlyArray<ReferencedSymbol> { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So we are okay with returning
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't really have a way to return a |
||
| const file = toNormalizedPath(args.file); | ||
| const projects = this.getProjects(args); | ||
|
|
||
|
|
@@ -911,7 +911,7 @@ namespace ts.server { | |
| if (simplifiedResult) { | ||
| const nameInfo = defaultProject.getLanguageService().getQuickInfoAtPosition(file, position); | ||
| if (!nameInfo) { | ||
| return emptyArray; | ||
| return undefined; | ||
| } | ||
|
|
||
| const displayString = displayPartsToString(nameInfo.displayParts); | ||
|
|
@@ -1165,19 +1165,16 @@ namespace ts.server { | |
| }); | ||
| } | ||
|
|
||
| private getCompletions(args: protocol.CompletionsRequestArgs, simplifiedResult: boolean): ReadonlyArray<protocol.CompletionEntry> | CompletionInfo { | ||
| private getCompletions(args: protocol.CompletionsRequestArgs, simplifiedResult: boolean): ReadonlyArray<protocol.CompletionEntry> | CompletionInfo | undefined { | ||
| const prefix = args.prefix || ""; | ||
| const { file, project } = this.getFileAndProject(args); | ||
|
|
||
| const scriptInfo = project.getScriptInfoForNormalizedPath(file); | ||
| const position = this.getPosition(args, scriptInfo); | ||
|
|
||
| const completions = project.getLanguageService().getCompletionsAtPosition(file, position); | ||
| if (!completions) { | ||
| return emptyArray; | ||
| } | ||
| if (simplifiedResult) { | ||
| return mapDefined(completions.entries, entry => { | ||
| return mapDefined(completions && completions.entries, entry => { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would have thought we'd want to return
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| if (completions.isMemberCompletion || (entry.name.toLowerCase().indexOf(prefix.toLowerCase()) === 0)) { | ||
| const { name, kind, kindModifiers, sortText, replacementSpan } = entry; | ||
| const convertedSpan = replacementSpan ? this.decorateSpan(replacementSpan, scriptInfo) : undefined; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍