Skip to content

EditorBehaviorFeature keeps a flag computed while the file's language server starts across that language server's later changes #2261

Done

Description

@lagergren

Cause

EditorBehaviorFeature.compute reads the modification counts after LanguageServiceAccessor.getModificationTrackers(file) has looked up the started language servers of the file. That includes the project-level count, which changes whenever a language server changes status.

Take a language server that is created after that lookup and started before the counts are read:

  • its own tracker isn't kept;
  • the project-level count already includes its start.

hasAny still computes the flag from it. Its later changes, counted by its own tracker (LanguageServerWrapper.incrementModificationCount()), are missed, and the flag stays cached until a language server of the project changes status or definition.

EditorBehaviorFeatureTest.testAFlagThatChangesWhileItIsComputedIsComputedAgain failed once in 5 runs of its class, headless, on IU 2026.3, with "The flag must be computed again once it has changed while it was computed". In the test, the semantic tokens file view provider of test.ts (a TextMate file, since the JavaScript plugin is disabled in tests) can compute the flag that way while the test starts the language server.

How to reproduce

  • On its own it is rare: 0 failures in 20 runs of the class on IU 2026.3, 10 on IC 2024.2 and 10 on 2025.3, on one Mac.
  • To make it fail every time: hold a computation of the flag on another thread between the lookup of the servers and the read of the counts, for example with a latch in hashCode() of another started definition, which getModificationTrackers asks right after the lookup. While it is held, start the file's language server, then release it. If the language server's first answer changes its flag and calls incrementModificationCount(), the next calls of EditorBehaviorFeature.enableSemanticTokensFileViewProvider(file) keep the first answer.

Activity

  1. added this to the 0.30.2 milestone on Nov 25, 2026
  2. added
    bug
    on Nov 25, 2026
  3. added a commit that references this issue on Nov 25, 2026
    a713d6d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions