Skip to content

editor: Don't merge adjacent selections#44811

Merged
Veykril merged 7 commits intozed-industries:mainfrom
marcocondrache:fix/adjacent-selections
Dec 15, 2025
Merged

editor: Don't merge adjacent selections#44811
Veykril merged 7 commits intozed-industries:mainfrom
marcocondrache:fix/adjacent-selections

Conversation

@marcocondrache
Copy link
Contributor

@marcocondrache marcocondrache commented Dec 14, 2025

Closes #24748

Release Notes:

  • Adjacent selections are not merged anymore

Signed-off-by: Marco Mihai Condrache <52580954+marcocondrache@users.noreply.github.com>
@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Dec 14, 2025
@github-actions github-actions bot added the community champion Issues filed by our amazing community champions! 🫶 label Dec 14, 2025
@github-project-automation github-project-automation bot moved this to Community Champion PRs in Quality Week – December 2025 Dec 14, 2025
Signed-off-by: Marco Mihai Condrache <52580954+marcocondrache@users.noreply.github.com>
Signed-off-by: Marco Mihai Condrache <52580954+marcocondrache@users.noreply.github.com>
Signed-off-by: Marco Mihai Condrache <52580954+marcocondrache@users.noreply.github.com>
@marcocondrache marcocondrache marked this pull request as ready for review December 14, 2025 13:59
@marcocondrache
Copy link
Contributor Author

marcocondrache commented Dec 14, 2025

I'm having issues with the test editor_tests::test_toggle_comment. I'm struggling with whitespace handling, and the assertion keeps failing. It's driving me crazy, and I think I need the team's support on this one

image

Signed-off-by: Marco Mihai Condrache <52580954+marcocondrache@users.noreply.github.com>
@Veykril Veykril self-assigned this Dec 14, 2025
@Veykril
Copy link
Member

Veykril commented Dec 15, 2025

The test now fails because it seems we have differing behavior here.

    cx.assert_editor_state(indoc! {"
        fn a() {
            // «b();
-            // c();
-            ˇ»//  d();
+            ˇ»// «c();
+            ˇ» // d();
        }
    "});

Note how we now end up with two selections after invoking ToggleComments where as before we only had one. Which makes sense, looking at the editor state before that assertion, we have two selections touching each other which now no longer merge. And the whitespace change also comes from that, because we remain with two selections here and thus consider different columns for each

Signed-off-by: Marco Mihai Condrache <52580954+marcocondrache@users.noreply.github.com>
Signed-off-by: Marco Mihai Condrache
<52580954+marcocondrache@users.noreply.github.com>
@marcocondrache
Copy link
Contributor Author

@Veykril Thanks so much for this - that helped it click for me. I was counting the markers as columns, but they disappear in the final marked text. Rookie mistake 😄

Copy link
Member

@Veykril Veykril left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@Veykril Veykril merged commit 34122ae into zed-industries:main Dec 15, 2025
23 checks passed
@github-project-automation github-project-automation bot moved this from Community Champion PRs to Done in Quality Week – December 2025 Dec 15, 2025
CherryWorm pushed a commit to CherryWorm/zed that referenced this pull request Dec 16, 2025
Closes zed-industries#24748

Release Notes:

- Adjacent selections are not merged anymore

---------

Signed-off-by: Marco Mihai Condrache <52580954+marcocondrache@users.noreply.github.com>
Signed-off-by: Marco Mihai Condrache
@JosephTLyons
Copy link
Collaborator

@marcocondrache, I'll make an issue for this later, but figured I'd bring it up here first. I'm assuming a separate issue, but once you start typing, things gets merged.

Screen.Recording.2025-12-16.at.2.07.52.PM.mov

@marcocondrache marcocondrache deleted the fix/adjacent-selections branch December 16, 2025 19:43
@marcocondrache
Copy link
Contributor Author

@JosephTLyons wow, thank you for discovering this. Could you assign the issue to me? I will provide a fix immediately

@JosephTLyons
Copy link
Collaborator

JosephTLyons commented Dec 16, 2025

@JosephTLyons wow, thank you for discovering this. Could you assign the issue to me? I will provide a fix immediately

Thank you so much! Here's the issue. I'm weirdly not able to assign it currently, I think we might have some permission issues going on since we migrated over to an GH organization. Maybe if you comment on the issue, I can assign.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement community champion Issues filed by our amazing community champions! 🫶

Projects

Development

Successfully merging this pull request may close these issues.

Zed merges adjacent non-overlapping selections

3 participants