dst icon indicating copy to clipboard operation
dst copied to clipboard

Support for line directives

Open growler opened this issue 6 years ago • 2 comments

Would be nice to have support for go's line directives.

The simplest way I believe would be to avoid indenting line comments Decorations starting with //line

Thank you!

growler avatar May 16 '19 10:05 growler

go/printer checks for line directive and skips indentation if comment pos is either invalid or points to column 1:

        const linePrefix = "//line "
        if strings.HasPrefix(text, linePrefix) && (!pos.IsValid() || pos.Column == 1) {
                // Possibly a //-style line directive.
                // Suspend indentation temporarily to keep line directive valid.
                defer func(indent int) { p.indent = indent }(p.indent)
                p.indent = 0
        }

... but I failed to realise how to force r.cursor point to first column at applyDecorations ¯_(ツ)_/¯

growler avatar May 16 '19 11:05 growler

Hi Alexey! I’m taking a break from open source and trekking across Nepal for five months... today is the first internet I’ve had in over a month. I won’t have my laptop until September but I’ll take a look at this when I can.

However from looking at your issue it looks like something I want to fix.

p.s. if you want to know more about the trek, check out my blog wildernessprime.com :)

dave avatar May 27 '19 03:05 dave