segmentio / golines

A golang formatter that fixes long lines
MIT License
903 stars 56 forks source link

shorten comments not workring correctly #125

Open amandeepgautam opened 5 months ago

amandeepgautam commented 5 months ago

For the following:

╰─ cat /tmp/minimal.go
package main

type A interface {
    // This is a small example with 79 char but is formatted when limit is 80 chars.
    Create(uniqueIdWithPaddingToRe int, nameWithPaddingToRe string) (*int, error)

    // AcquireWithMin method is used to acquire desired and minimum number of
    // units. This may block if at least the minimum number of resources are not
    // available. It returns the number of units allocated which can be between
    // desired or minimum units. Additionally it returns the percent of capacity
    // used including the current allocation. If a request tries to allocate more
    // than the capacity, it will receive units equal to the capcity when available.
}

func main() {}

The format response is creating new incomplete lines

╰─ ~/.vim-go/golines -m 79 --shorten-comments /tmp/minimal.go
package main

type A interface {
    // This is a small example with 79 char but is formatted when limit is 80
    // chars.
    Create(
        uniqueIdWithPaddingToRe int,
        nameWithPaddingToRe string,
    ) (*int, error)

    // AcquireWithMin method is used to acquire desired and minimum number of
    // units. This may block if at least the minimum number of resources are
    // not    <<<<<<<< This is not expected.
    // available. It returns the number of units allocated which can be between
    // desired or minimum units. Additionally it returns the percent of
    // capacity used including the current allocation. If a request tries to
    // allocate more than the capacity, it will receive units equal to the
    // capcity when available.
}

func main() {}