rust-lang / rust-lang/rust-analyzer

Extend selection behaves differently between single- and multi-line statements

Open
#7,452 11 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-vscode C-bug S-unactionable
Dominant language
Rust
Stars
16.9k
Forks
2.2k
Avg merge
1d 12h
Merged PRs (30d)
72

Description

Say I have code like this:

mod gl {}

fn main() {
    let gl = ();
    
    gl.GetIntegerv(gl::DRAW_FRAMEBUFFER_BINDING, &mut previous_framebuffer);
    gl.BindFramebuffer(gl::DRAW_FRAMEBUFFER, self.framebuffer);
    gl.FramebufferTexture2D(
        gl::DRAW_FRAMEBUFFER,
        gl::COLOR_ATTACHMENT0,
        gl::TEXTURE_2D,
        self.texture,
        0,
    );
}

I'd like to wrap all calls in some other call. I set up multiple cursors like so:

image

Then I hit extend selection:

image

Note how single-line statements got fully selected up to ;, but the multi-line one didn't. In fact, it requires one more extend selection:

image

But now the single-line statements have ; selected, too. All this means I have to first deal with single-line statements, and then, separately, with multi-line statements. It would be nice if the behavior was unified.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the Rust example using multiple cursors and Extend Selection, then trace the editor action that computes successive selections. The issue names no source file or test; done means single-line and multi-line statements expand to consistent boundaries without requiring separate handling.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
devtools
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.