rust-lang / rust-lang/rust-analyzer

[bug] Split/merge operations on module-level comments (`//!`) don't work as expected

Open
#5,850 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Rust-Analyzer doesn't seem to correctly operate on //! comments, which makes it hard to write module-level documentation and examples. I'm not sure if this is specifically an interaction between vscode.vim and RA, or general to the way RA works. But this did seem to work correctly when I still used RLS + vim.

Issues

The two main issues I encounter regularly are:

  1. Splitting a long line into multiple lines using Vgq. This inserts a // comment instead of a //! comment.
  2. Merging two shorter lines into a single line using Vjgq. This merges the lines, but leaves in a stray ! character.

Example

Both issues we've mentioned can be seen here. First we split a long line into multiple lines, which doesn't correctly insert a //! comment. And then we merge two shorter lines into a single line, which leaves a stray ! in the merged line.

final

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 two reported cases in a Rust module containing //! comments, using Vgq to split a long line and Vjgq to merge lines with the vscode.vim setup. Compare the results with the expected //! comments: splitting should preserve the prefix, and merging should not leave a stray !.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust, vscode
Domain
developer-experience, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 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.