reflow icon indicating copy to clipboard operation
reflow copied to clipboard

Dedent incorrectly removes spaces that aren't at the start of a line

Open dadgar opened this issue 1 year ago • 0 comments

When a string has lines with no indentation and lines with indentations, the dedented string will remove the first spaces within the line instead of just at the start.

package main

import (
	"fmt"

	"github.com/muesli/reflow/dedent"
)

func main() {
	input := `This is an example
	
  with no shared indent.`
	fmt.Println(dedent.String(input))
}

The output will be:

Thisisan example

with no shared indent.

https://go.dev/play/p/Q13CeRD8Tb2

dadgar avatar Jan 27 '24 00:01 dadgar