Rewrap icon indicating copy to clipboard operation
Rewrap copied to clipboard

Zig doc comments `///` are mangled

Open MadLittleMods opened this issue 1 year ago • 0 comments

Zig doc comments start with three/triple slashes (///). When using the Rewrap extension on them, they end up getting mangled where the subsequent lines start with a double slash and the extra slash from the original comments get mixed in with the rest of the text.

Before: foo.zig

const std = @import("std");

/// This is an long example doc comment describing foo. We expect the Rewrap extension to wrap it
/// with three slashes. But it ends up breaking up the entire comment and counting the extra slash
///  as part of the comment and intermingling it with the rest of the text.
pub fn foo() void {
    std.log.debug("foo", .{});
}

After Rewrap: foo.zig

const std = @import("std");

/// This is an long example doc comment describing foo. We expect the Rewrap extension
//to wrap it / with three slashes. But it ends up breaking up the entire comment and
//counting the extra slash /  as part of the comment and intermingling it with the rest
//of the text.
pub fn foo() void {
    std.log.debug("foo", .{});
}

Demonstration in VSCode:

Versions:

  • Rewrap 1.16.3
  • VSCode 1.83.1

Related issues:

  • https://github.com/stkb/Rewrap/issues/370

Potential solutions

Probably just need to define some specific rules for Zig in core/Parsing.Documents.fs.

MadLittleMods avatar Nov 02 '23 22:11 MadLittleMods