From 8d36b10604b9e2364c4f3b06ff40287b31729c78 Mon Sep 17 00:00:00 2001 From: fuji8 Date: Sun, 11 Sep 2022 14:57:33 +0900 Subject: [PATCH] fix edit range --- gotypeconverter-langserver/gotypeconverter.go | 2 +- gotypeconverter-langserver/main.go | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/gotypeconverter-langserver/gotypeconverter.go b/gotypeconverter-langserver/gotypeconverter.go index 5535ca1..350b05b 100644 --- a/gotypeconverter-langserver/gotypeconverter.go +++ b/gotypeconverter-langserver/gotypeconverter.go @@ -64,7 +64,7 @@ func SuggestedFix(path string, line, character int) (string, *protocol.Range) { } fn := ana.InitFuncMaker(pkg.Types) - fn.MakeFunc(ana.InitType(dstType, "src"), ana.InitType(srcType, "")) + fn.MakeFunc(ana.InitType(dstType, ""), ana.InitType(srcType, "")) buf := &bytes.Buffer{} buf.Write(fn.WriteBytes()) diff --git a/gotypeconverter-langserver/main.go b/gotypeconverter-langserver/main.go index 5218617..25b6d44 100644 --- a/gotypeconverter-langserver/main.go +++ b/gotypeconverter-langserver/main.go @@ -31,11 +31,8 @@ func main() { SetTrace: setTrace, TextDocumentCodeAction: func(context *glsp.Context, params *protocol.CodeActionParams) (interface{}, error) { if len(params.Context.Only) >= 1 && params.Context.Only[0] == "refactor" { - log.Info("refactor") path := params.TextDocument.URI[7:] newText, rng := SuggestedFix(path, int(params.Range.Start.Line), int(params.Range.Start.Character)) - // fmt.Println(path) - // newText := "hoge" if newText == "" { return nil, nil } @@ -52,7 +49,7 @@ func main() { Line: rng.Start.Line - 1, }, End: protocol.Position{ - Line: rng.End.Line, + Line: rng.End.Line - 1, Character: 10000000, }, }, @@ -62,7 +59,6 @@ func main() { }, }, } - log.Info("soushin") return []interface{}{res}, nil } return nil, nil