Skip to content

Commit

Permalink
Merge pull request #7 from fuji8/fix/issue-3
Browse files Browse the repository at this point in the history
fix edit range
  • Loading branch information
fuji8 authored Sep 11, 2022
2 parents 0ba20fa + 8d36b10 commit a9910bd
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
2 changes: 1 addition & 1 deletion gotypeconverter-langserver/gotypeconverter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
6 changes: 1 addition & 5 deletions gotypeconverter-langserver/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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,
},
},
Expand All @@ -62,7 +59,6 @@ func main() {
},
},
}
log.Info("soushin")
return []interface{}{res}, nil
}
return nil, nil
Expand Down

0 comments on commit a9910bd

Please sign in to comment.