Skip to content
This repository was archived by the owner on Nov 24, 2025. It is now read-only.
This repository was archived by the owner on Nov 24, 2025. It is now read-only.

[BUG] Twinny formatter misidentifies split lines as duplicates in tightly wrapped code #471

Description

@ton-An

Describe the bug
When using a formatter with a short line length, single logical lines of code are often split across multiple physical lines. For example:

when(
  () => mockAuthenticationRepository.getCurrentUserId(),
).thenAnswer((_) async => const Right(tUserId));

when(
  () => mockLocationDataRepository.getLocationsByDate(
    start: any(named: 'start'),
    end: any(named: 'end'),
  ),
).thenAnswer((_) async => Right(tLocations));

In this case, if the FIM model generates a completion that begins with when(, the Twinny formatter at

protected preventDuplicateLine(): this {

incorrectly identifies it as a duplicate line and removes it. This results in an empty formatted completion:

[INFO] *** Twinny completion triggered for file: file:///Users/anton/Desktop/Projects/Location-History/location_history/app/test/features/location_tracking/domain/usecases/get_locations_by_date_test.dart ***
      Original completion: when(
      Formatted completion: 
      Max Lines: 20
      Use file context: true
      Completed lines count 1
      Using custom FIM template fim.bhs?: false

To Reproduce
1. Open a test file where logical lines are split due to short formatter line limits.
2. Trigger a completion that starts with the beginning of a multi-line expression (e.g., when().
3. Observe that the completion is removed as a “duplicate” despite being valid.

Here is a file with just that

Expected behavior
The Twinny formatter should treat logically connected lines of code—those split across multiple physical lines due to formatting constraints—as a single unit. This would prevent it from mistakenly identifying individual fragments (like when() as duplicates and ensure valid completions are preserved.

API Provider
LMStudio

Chat or Auto Complete?
FIM

Model Name
deepseek-coder-v2-lite-base-mlx

Desktop:

  • OS: MacOS 15.3.2
  • VSCode Version: 1.100.0-insider

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions