Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fix "Expand Function" code action removing comments and whitespace
  • Loading branch information
jwortmann committed Dec 19, 2022
commit 0cbc887b5663907a30d3c2d23d21712fd467457b
6 changes: 3 additions & 3 deletions src/requests/actions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ function expand_inline_func(x, server, conn)
if headof(body) == :block && length(body) == 1
file, offset = get_file_loc(func)
tde = TextDocumentEdit(VersionedTextDocumentIdentifier(get_uri(file), get_version(file)), TextEdit[
TextEdit(Range(file, offset .+ (0:func.fullspan)), string("function ", get_text(file)[offset .+ (1:sig.span)], "\n ", get_text(file)[offset + sig.fullspan + op.fullspan .+ (1:body.span)], "\nend\n"))
TextEdit(Range(file, offset .+ (0:func.span)), string("function ", get_text(file)[offset .+ (1:sig.span)], "\n ", get_text(file)[offset + sig.fullspan + op.fullspan .+ (1:body.span)], "\nend"))
])
JSONRPC.send(conn, workspace_applyEdit_request_type, ApplyWorkspaceEditParams(missing, WorkspaceEdit(missing, TextDocumentEdit[tde])))
elseif (headof(body) === :begin || CSTParser.isbracketed(body)) &&
Expand All @@ -175,8 +175,8 @@ function expand_inline_func(x, server, conn)
newtext = string(newtext, "\n ", get_text(file)[blockoffset .+ (1:body.args[1].args[i].span)])
blockoffset += body.args[1].args[i].fullspan
end
newtext = string(newtext, "\nend\n")
tde = TextDocumentEdit(VersionedTextDocumentIdentifier(get_uri(file), get_version(file)), TextEdit[TextEdit(Range(file, offset .+ (0:func.fullspan)), newtext)])
newtext = string(newtext, "\nend")
tde = TextDocumentEdit(VersionedTextDocumentIdentifier(get_uri(file), get_version(file)), TextEdit[TextEdit(Range(file, offset .+ (0:func.span)), newtext)])
JSONRPC.send(conn, workspace_applyEdit_request_type, ApplyWorkspaceEditParams(missing, WorkspaceEdit(missing, TextDocumentEdit[tde])))
end
end
Expand Down