Skip to content

Deleting a test results in the next test marker moving to the wrong line #5831

Closed

Description

@DanTup

When I delete this test, the next test getter icon moves to the wrong line.

test.mp4

Activity

  1. added this to the v3.126.0 milestone on Dec 3, 2025
  2. added
    in testingRelates to test execution of Dart/Flutter tests for end users
    on Dec 3, 2025
  3. FMorschel commented on Dec 4, 2025

    @FMorschel
    Contributor

    Typo (title): marker*

  4. changed the title [-]Deleting a test results in the next test market moving to the wrong line[/-] [+]Deleting a test results in the next test marker moving to the wrong line[/+] on Dec 4, 2025
  5. FMorschel commented on Dec 4, 2025

    @FMorschel
    Contributor

    Run the following test file and run Dart: Sort Members. See a similar behaviour. Is this the exact same?

    import 'package:test/test.dart';
    import 'package:test_reflective_loader/test_reflective_loader.dart';
    
    void main() {
      defineReflectiveSuite(() {
        defineReflectiveTests(ATEst);
      });
    }
    
    @reflectiveTest
    class ATEst {
      void test_example() {
        // Example test
        expect(1 + 1, 2);
      }
    
      void test_anotherExample() {
        // Another example test
        // this
        // one
        // is
        // longer
        expect('hello'.toUpperCase(), 'HELLO');
      }
    
      void test_yetAnotherExample() {
        // Yet another example test
        expect([1, 2, 3].length, 3);
      }
    }

    Note that it doesn't happen if all tests are the same line length.

  6. DanTup commented on Dec 4, 2025

    @DanTup
    MemberAuthor

    With my fix, I end up with this:

    Image

    The top two get swapped around, and their positions removed.

    The bug was that when a tracked range (which is a start and end position) was deleted, we first deleted the start position (internally, range tracker is just two position trackers), which caused the first range tracker to dispose itself. This reduced the number of position trackers, but it was done in a callback during the processing, so the code looping over the position trackers skipped one (because the collection was modified).

    This resulted in only the end position of the second range being changed (resulting in a range where the start was before the end!) which caused weird things to happen.

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

    in testingRelates to test execution of Dart/Flutter tests for end usersis bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions