Skip to content

Autocomplete duplicates suggestions (double insertion) instead of replacing prefix #3562

@NamanGoyalK

Description

@NamanGoyalK

Relevant console output or errors

None. The Analysis Server returns the correct completion list, but the editor fails to apply the replacement range correctly.

How did this error happen?

How did this error happen?*

Description: When selecting a suggestion from the autocomplete popup, DartPad appends the full suggestion string to the existing prefix rather than replacing it.

Reproduction Steps:

Open [dartpad.dev](https://dartpad.dev/).

Start typing a widget or class (e.g., Text.ri).

When the autocomplete popup appears, select rich() by:

    Clicking the item in the popup.

    Pressing Tab.

    Pressing Enter.

Observe that the result is Text.richri instead of the expected Text.rich().

Relevant Dart code

import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      debugShowCheckedModeBanner: false,
      home: Scaffold(body: Center(child: Text.ri)), // Trigger autocomplete on 'ri'
    );
  }
}

What OS did this error occur on?

Linux

What browser(s) did you experience this issue on?

Chromium based (Chrome, Edge)

Do you have any additional information?

Also occurred on Zen Browser (Firefox-based).

Version: Dart 3.10.7 • Flutter 3.38.7 (Stable channel)

Testing: Confirmed that Shift + Enter and Shift + Tab do not change the behavior.

Consistency: This is a persistent issue across different widgets and methods, not limited to the Text class.

Screenshots:

Image Image Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugIncorrect behavior (everything from a crash to more subtle misbehavior)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions