internal/lsp/analysis/infertypeargs: reduce diagnostic range

When infertypeargs suggested an edit that kept at least one argument the
diagnostic sent to the editor included comma and whitespace(s).

In editors/IDEs that highlight the range it looked a bit odd. This
change reduce the diagnostic range to start at the first unnecessary
argument.

Change-Id: Ib091f8ff150c66d1d8ee4f82bda8b1b37202eeba
Reviewed-on: https://go-review.googlesource.com/c/tools/+/356989
Trust: Pontus Leitzler <leitzler@gmail.com>
Run-TryBot: Pontus Leitzler <leitzler@gmail.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
diff --git a/internal/lsp/analysis/infertypeargs/run_go118.go b/internal/lsp/analysis/infertypeargs/run_go118.go
index 1b767e7..aed558a 100644
--- a/internal/lsp/analysis/infertypeargs/run_go118.go
+++ b/internal/lsp/analysis/infertypeargs/run_go118.go
@@ -74,22 +74,23 @@
 		}
 		if required < len(ix.Indices) {
 			var start, end token.Pos
+			var edit analysis.TextEdit
 			if required == 0 {
 				start, end = ix.Lbrack, ix.Rbrack+1 // erase the entire index
+				edit = analysis.TextEdit{Pos: start, End: end}
 			} else {
-				start = ix.Indices[required-1].End()
+				start = ix.Indices[required].Pos()
 				end = ix.Rbrack
+				//  erase from end of last arg to include last comma & white-spaces
+				edit = analysis.TextEdit{Pos: ix.Indices[required-1].End(), End: end}
 			}
 			pass.Report(analysis.Diagnostic{
 				Pos:     start,
 				End:     end,
 				Message: "unnecessary type arguments",
 				SuggestedFixes: []analysis.SuggestedFix{{
-					Message: "simplify type arguments",
-					TextEdits: []analysis.TextEdit{{
-						Pos: start,
-						End: end,
-					}},
+					Message:   "simplify type arguments",
+					TextEdits: []analysis.TextEdit{edit},
 				}},
 			})
 		}