diff --git a/src/goFormat.ts b/src/goFormat.ts index 0e7347d3c..18f6c9478 100644 --- a/src/goFormat.ts +++ b/src/goFormat.ts @@ -29,7 +29,7 @@ export class Formatter { let formatCommandBinPath = getBinPath(this.formatCommand); let formatFlags = vscode.workspace.getConfiguration('go')['formatFlags'] || []; let canFormatToolUseDiff = vscode.workspace.getConfiguration('go')['useDiffForFormatting'] && isDiffToolAvailable(); - if (canFormatToolUseDiff) { + if (canFormatToolUseDiff && formatFlags.indexOf('-d') === -1) { formatFlags.push('-d'); } // We ignore the -w flag that updates file on disk because that would break undo feature @@ -80,4 +80,4 @@ export class GoDocumentFormattingEditProvider implements vscode.DocumentFormatti // package main; import \"fmt\"; func main() {fmt.Print(\"Hello\")} // package main; import \"fmt\"; import \"math\"; func main() {fmt.Print(\"Hello\")} -// package main; import \"fmt\"; import \"gopkg.in/Shopify/sarama.v1\"; func main() {fmt.Print(sarama.V0_10_0_0)} \ No newline at end of file +// package main; import \"fmt\"; import \"gopkg.in/Shopify/sarama.v1\"; func main() {fmt.Print(sarama.V0_10_0_0)}