Repository: microsoft/TypeScript
File: src/harness/client.ts (TypeScript)

Code before:
                    return res;
                }

                return entry as { name: string; kind: ScriptElementKind; kindModifiers: string; sortText: string; }; // TODO: GH#18217
            }),
        };
    }

    getCompletionEntryDetails(fileName: string, position: number, entryName: string, _options: FormatCodeOptions | FormatCodeSettings | undefined, source: string | undefined, _preferences: UserPreferences | undefined, data: unknown): CompletionEntryDetails {
        const args: protocol.CompletionDetailsRequestArgs = { ...this.createFileLocationRequestArgs(fileName, position), entryNames: [{ name: entryName, source, data }] };

        const request = this.processRequest<protocol.CompletionDetailsRequest>(protocol.CommandTypes.CompletionDetailsFull, args);
        const response = this.processResponse<protocol.Response>(request);
        Debug.assert(response.body.length === 1, "Unexpected length of completion details response body.");
        return response.body[0];
    }

    getCompletionEntrySymbol(_fileName: string, _position: number, _entryName: string): Symbol {
        return notImplemented();
    }

    getNavigateToItems(searchValue: string, maxResultCount: number, file: string | undefined, _excludeDtsFiles: boolean | undefined, excludeLibFiles: boolean | undefined): NavigateToItem[] {
        const args: protocol.NavtoRequestArgs = {
            searchValue,
            file,
            currentFileOnly: !!file,
            maxResultCount,
        };
        const oldPreferences = this.preferences;
        if (excludeLibFiles) {
            this.configure({ excludeLibrarySymbols: true });
        }

        const request = this.processRequest<protocol.NavtoRequest>(protocol.CommandTypes.Navto, args);
        const response = this.processResponse<protocol.NavtoResponse>(request);

        if (excludeLibFiles) {
            this.configure(oldPreferences || {});
        }

        return response.body!.map(entry => ({ // TODO: GH#18217
            name: entry.name,
            containerName: entry.containerName || "",
            containerKind: entry.containerKind || ScriptElementKind.unknown,
            kind: entry.kind,
            kindModifiers: entry.kindModifiers || "",
            matchKind: entry.matchKind as keyof typeof PatternMatchKind,
            isCaseSensitive: entry.isCaseSensitive,
            fileName: entry.file,
            textSpan: this.decodeSpan(entry),
        }));

Review comment (suggestion):
One thought: if I have `excludeLibrarySymbols` enabled, but then I manually open `node_modules/typescript/lib/lib.dom.d.ts` and use ⌘⇧O (symbol search in current file), I still want to see results from the current file.

Code after:
                    return res;
                }

                return entry as { name: string; kind: ScriptElementKind; kindModifiers: string; sortText: string; }; // TODO: GH#18217
            }),
        };
    }

    getCompletionEntryDetails(fileName: string, position: number, entryName: string, _options: FormatCodeOptions | FormatCodeSettings | undefined, source: string | undefined, _preferences: UserPreferences | undefined, data: unknown): CompletionEntryDetails {
        const args: protocol.CompletionDetailsRequestArgs = { ...this.createFileLocationRequestArgs(fileName, position), entryNames: [{ name: entryName, source, data }] };

        const request = this.processRequest<protocol.CompletionDetailsRequest>(protocol.CommandTypes.CompletionDetailsFull, args);
        const response = this.processResponse<protocol.Response>(request);
        Debug.assert(response.body.length === 1, "Unexpected length of completion details response body.");
        return response.body[0];
    }

    getCompletionEntrySymbol(_fileName: string, _position: number, _entryName: string): Symbol {
        return notImplemented();
    }

    getNavigateToItems(searchValue: string, maxResultCount: number, file: string | undefined, _excludeDtsFiles: boolean | undefined, excludeLibFiles: boolean | undefined): NavigateToItem[] {
        const args: protocol.NavtoRequestArgs = {
            searchValue,
            file,
            currentFileOnly: !!file,
            maxResultCount,
        };
        const oldPreferences = this.preferences;
        if (excludeLibFiles) {
            this.configure({ excludeLibrarySymbolsInNavTo: true });
        }

        const request = this.processRequest<protocol.NavtoRequest>(protocol.CommandTypes.Navto, args);
        const response = this.processResponse<protocol.NavtoResponse>(request);

        if (excludeLibFiles) {
            this.configure(oldPreferences || {});
        }

        return response.body!.map(entry => ({ // TODO: GH#18217
            name: entry.name,
            containerName: entry.containerName || "",
            containerKind: entry.containerKind || ScriptElementKind.unknown,
            kind: entry.kind,
            kindModifiers: entry.kindModifiers || "",
            matchKind: entry.matchKind as keyof typeof PatternMatchKind,
            isCaseSensitive: entry.isCaseSensitive,
            fileName: entry.file,
            textSpan: this.decodeSpan(entry),
        }));