Skip to content

Commit

Permalink
Merge pull request #434 from thetarnav/inlay-hints-comma
Browse files Browse the repository at this point in the history
Remove comma from first param default value inlay hint
  • Loading branch information
DanielGavin authored Jul 17, 2024
2 parents ff04a9b + 0d166ec commit ec979a8
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions src/server/inlay_hints.odin
Original file line number Diff line number Diff line change
Expand Up @@ -128,29 +128,28 @@ get_inlay_hints :: proc(
position = call_range.end
position.character -= 1

has_trailing_comma: bool;{
if !has_added_default {
till_end := string(
document.text[:call.close.offset],
)
trailing_loop: #reverse for ch in till_end {
switch ch {
case ' ', '\t', '\n':
case ',':
has_trailing_comma = true
break trailing_loop
case:
break trailing_loop
}
needs_leading_comma := i > 0

if !has_added_default && needs_leading_comma {
till_end := string(
document.text[:call.close.offset],
)
#reverse for ch in till_end {
switch ch {
case ' ', '\t', '\n':
continue
case ',':
needs_leading_comma = false
}
break
}
}

hint := InlayHint {
kind = .Parameter,
label = fmt.tprintf(
"%s %v := %v",
has_trailing_comma ? "" : ",",
needs_leading_comma ? "," : "",
label,
value,
),
Expand Down

0 comments on commit ec979a8

Please sign in to comment.