stkb / Rewrap

Rewrap extension for VSCode and Visual Studio
https://marketplace.visualstudio.com/items/stkb.rewrap
Other
499 stars 58 forks source link

Zig doc comments `///` are mangled #388

Open MadLittleMods opened 8 months ago

MadLittleMods commented 8 months ago

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:

Related issues:

Potential solutions

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