Skip to content

Commit

Permalink
only show return type for fns if one exists
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshuaBatty committed Nov 27, 2024
1 parent 3b611b6 commit aecc32c
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions sway-lsp/src/capabilities/document_symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,8 +380,14 @@ fn fn_decl_detail(parameters: &[TyFunctionParameter], return_type: &TypeArgument
.map(|p| format!("{}: {}", p.name, p.type_argument.span.as_str()))
.collect::<Vec<_>>()
.join(", ");
let return_type = return_type.span.as_str();
format!("fn({}) -> {}", params, return_type)

// Check for the presence of a CallPathTree, and if it exists, add it to the return type.
let return_type = return_type
.call_path_tree
.as_ref()
.map(|_| format!(" -> {}", return_type.span.as_str()))
.unwrap_or_default();
format!("fn({}){}", params, return_type)
}

/// Extracts the header of a sway construct such as an `impl` block or `abi` declaration,
Expand Down

0 comments on commit aecc32c

Please sign in to comment.