Skip to content

Commit

Permalink
CR fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
gabritto committed Mar 30, 2022
1 parent fe5a809 commit 41db01c
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/compiler/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8753,7 +8753,7 @@ namespace ts {
readonly includeCompletionsWithInsertText?: boolean;
readonly includeCompletionsWithClassMemberSnippets?: boolean;
readonly includeCompletionsWithObjectLiteralMethodSnippets?: boolean;
readonly includeCompletionsWithLabelDetails?: boolean;
readonly useLabelDetailsInCompletionEntries?: boolean;
readonly allowIncompleteCompletions?: boolean;
readonly importModuleSpecifierPreference?: "shortest" | "project-relative" | "relative" | "non-relative";
/** Determines whether we import `foo/index.ts` as "foo", "foo/index", or "foo/index.js" */
Expand Down
3 changes: 2 additions & 1 deletion src/server/protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3434,8 +3434,9 @@ namespace ts.server.protocol {
readonly includeCompletionsWithObjectLiteralMethodSnippets?: boolean;
/**
* Indicates whether {@link CompletionEntry.labelDetails completion entry label details} are supported.
* If not, contents of `labelDetails` may be included in the {@link CompletionEntry.name} property.
*/
readonly includeCompletionsWithLabelDetails?: boolean;
readonly useLabelDetailsInCompletionEntries?: boolean;
readonly allowIncompleteCompletions?: boolean;
readonly importModuleSpecifierPreference?: "shortest" | "project-relative" | "relative" | "non-relative";
/** Determines whether we import `foo/index.ts` as "foo", "foo/index", or "foo/index.js" */
Expand Down
6 changes: 4 additions & 2 deletions src/services/completions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,7 @@ namespace ts.Completions {
if (origin && originIsObjectLiteralMethod(origin)) {
let importAdder;
({ insertText, isSnippet, importAdder, labelDetails } = origin);
if (!preferences.includeCompletionsWithLabelDetails) {
if (!preferences.useLabelDetailsInCompletionEntries) {
name = name + labelDetails.detail;
labelDetails = undefined;
}
Expand Down Expand Up @@ -1104,8 +1104,10 @@ namespace ts.Completions {
target: options.target,
omitTrailingSemicolon: true,
});
// The `labelDetails.detail` will be displayed right beside the method name,
// so we drop the name (and modifiers) from the signature.
const methodSignature = factory.createMethodSignature(
method.modifiers,
/*modifiers*/ undefined,
/*name*/ "",
method.questionToken,
method.typeParameters,
Expand Down
10 changes: 5 additions & 5 deletions tests/cases/fourslash/completionsObjectLiteralMethod1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ verify.completions({
includeCompletionsWithInsertText: true,
includeCompletionsWithSnippetText: false,
includeCompletionsWithObjectLiteralMethodSnippets: true,
includeCompletionsWithLabelDetails: true,
useLabelDetailsInCompletionEntries: true,
},
includes: [
{
Expand All @@ -64,7 +64,7 @@ verify.completions({
includeCompletionsWithInsertText: true,
includeCompletionsWithSnippetText: false,
includeCompletionsWithObjectLiteralMethodSnippets: true,
includeCompletionsWithLabelDetails: true,
useLabelDetailsInCompletionEntries: true,
},
includes: [
{
Expand Down Expand Up @@ -121,7 +121,7 @@ verify.completions({
includeCompletionsWithInsertText: true,
includeCompletionsWithSnippetText: false,
includeCompletionsWithObjectLiteralMethodSnippets: true,
includeCompletionsWithLabelDetails: true,
useLabelDetailsInCompletionEntries: true,
},
includes: [
{
Expand All @@ -147,7 +147,7 @@ verify.completions({
includeCompletionsWithInsertText: true,
includeCompletionsWithSnippetText: true,
includeCompletionsWithObjectLiteralMethodSnippets: true,
includeCompletionsWithLabelDetails: true,
useLabelDetailsInCompletionEntries: true,
},
includes: [
{
Expand All @@ -174,7 +174,7 @@ verify.completions({
includeCompletionsWithInsertText: true,
includeCompletionsWithSnippetText: true,
includeCompletionsWithObjectLiteralMethodSnippets: true,
includeCompletionsWithLabelDetails: false,
useLabelDetailsInCompletionEntries: false,
},
includes: [
{
Expand Down
4 changes: 2 additions & 2 deletions tests/cases/fourslash/completionsObjectLiteralMethod2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ verify.completions({
includeCompletionsWithInsertText: true,
includeCompletionsWithSnippetText: false,
includeCompletionsWithObjectLiteralMethodSnippets: true,
includeCompletionsWithLabelDetails: true,
useLabelDetailsInCompletionEntries: true,
},
includes: [
{
Expand All @@ -51,7 +51,7 @@ verify.applyCodeActionFromCompletion("a", {
includeCompletionsWithInsertText: true,
includeCompletionsWithSnippetText: false,
includeCompletionsWithObjectLiteralMethodSnippets: true,
includeCompletionsWithLabelDetails: true,
useLabelDetailsInCompletionEntries: true,
},
name: "foo",
source: completion.CompletionSource.ObjectLiteralMethodSnippet,
Expand Down
4 changes: 2 additions & 2 deletions tests/cases/fourslash/completionsObjectLiteralMethod3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ verify.completions({
includeCompletionsWithInsertText: true,
includeCompletionsWithSnippetText: false,
includeCompletionsWithObjectLiteralMethodSnippets: true,
includeCompletionsWithLabelDetails: true,
useLabelDetailsInCompletionEntries: true,
},
includes: [
{
Expand Down Expand Up @@ -97,7 +97,7 @@ verify.completions({
includeCompletionsWithInsertText: true,
includeCompletionsWithSnippetText: false,
includeCompletionsWithObjectLiteralMethodSnippets: true,
includeCompletionsWithLabelDetails: true,
useLabelDetailsInCompletionEntries: true,
},
includes: [
{
Expand Down
2 changes: 1 addition & 1 deletion tests/cases/fourslash/fourslash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ declare namespace FourSlashInterface {
readonly includeCompletionsWithInsertText?: boolean;
readonly includeCompletionsWithClassMemberSnippets?: boolean;
readonly includeCompletionsWithObjectLiteralMethodSnippets?: boolean;
readonly includeCompletionsWithLabelDetails?: boolean;
readonly useLabelDetailsInCompletionEntries?: boolean;
readonly allowIncompleteCompletions?: boolean;
/** @deprecated use `includeCompletionsWithInsertText` */
readonly includeInsertTextCompletions?: boolean;
Expand Down

0 comments on commit 41db01c

Please sign in to comment.