Skip to content

Code completion does not show cross-file new identifiers (unless a significant portion of the new identifier is typed) #2122

Open
@DimaKozhinov

Description

@DimaKozhinov

Swift version

Swift version 6.1 (swift-6.1-RELEASE)

Platform

Windows 11

Editor

Visual Studio Code 1.99.3 with Swift plugin 2.2.0, other editors

Description

When a new identifier is added (a let constant, a func, etc.) in a different source file within a module, it is not listed in results of textDocument/completion request, unless a significant portion of the new identifier is typed by user.

Expected behavior: When a new identifier is added in a different source file, it should appear in code completion when a user types just the first character of the new identifier (and not a significant portion of it), like it is already working now if the new identifier is added in the same file.

Steps to Reproduce

  1. Create a Swift package:
mkdir test
cd test
swift package init --type executable
  1. Add a new Swift file in the Sources folder of the package, e.g. helpers.swift in addition to the default main.swift .
  2. Open the test package folder in Visual Studio Code.
  3. Edit the helpers.swift in VS Code: add for example let zzzConst = 42 .
  4. Switch to main.swift file in VS Code and type something that would use the new constant from helpers.swift, e.g. "let aaa = z"
  5. Code completion does not show zzzConst (shows only two suggestions starting with "zip")
  6. Add more text, now "let aaa = zz"
  7. Code completion does not show any suggestions at all.
  8. Add more text, now "let aaa = zzz"
  9. At last zzzConst appears in code suggestions.

Logging

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions