Skip to content

[Rust] Making new comment lines sometimes gives weird results. #12539

Closed
@Scripter17

Description

@Scripter17

Summary

With 25.01, adding a new line after a comment/doc comment prepend the relevant comment prefix to the new line. This seems to give weird results in some cases

Reproduction Steps

I began with the following code in Rust

/// Details of an IPv4 address.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct Ipv4Details {}

/// Details of an IPv6 address.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct Ipv6Details {}

I wanted to add a line in the doc comments of both that they're currently unused and only exist for completeness. So I put my only cursor after the period on the IPv4 comment, then alt-clicked to place a new cursor after the period on the IPv6 comment.

image

After this, I pressed enter twice, and had the following code:

/// Details of an IPv4 address.
///
/// 
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct Ipv4Details {}

/// Details of an IPv6 address.
///
/// 
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct Ipv6Details {}

While the text is as expected and the cursor for the IPv4 comment was at the end of the doc comment's third line as expected, the cursor for the IPv6 comment was over the # of the derive invocation.

image

Reversing the order of cursors gives the exact same result, with the IPv6 comment giving the weird result

image

Helix log

~/.cache/helix/helix.log

The log doesn't contain any lines past 2025-01-04, so I assume it's not relevant. Also I doubt any of the code involved has any reason to print to the log.

Platform

Linux, Kubuntu 24.10, KDE Plasma 6.1.5

Terminal Emulator

Konsole 24.08.1

Installation Method

Snap

Helix Version

25.1 (dabfb6c)

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions