Closed nepsilon closed 4 years ago
Code used:
package main import ( "fmt" "github.com/sergi/go-diff/diffmatchpatch" ) func main() { var oldtext string = `foo bar ` var patchtxt string = `@@ -1,2 +1,2 @@ -foo +foobaz bar ` dmp := diffmatchpatch.New() patch, _ := dmp.PatchFromText(patchtxt) newtext, _ := dmp.PatchApply(patch, oldtext) fmt.Println("new text:", newtext) }
Output:
new text: foobazbar
Expected Output:
new text: foobaz bar
Is there a way to apply the patch to conserve the new line \n characters?
\n
@sergi I tried to look at test cases and finding ways to avoid the \n deletions but I couldn't figure it out. Do you know why this is happening? Thank you!
Code used:
Output:
Expected Output:
Is there a way to apply the patch to conserve the new line
\n
characters?