aboutsummaryrefslogtreecommitdiff
path: root/src/server
diff options
context:
space:
mode:
authorDanielGavin <danielgavin5@hotmail.com>2024-07-18 01:45:15 +0200
committerGitHub <noreply@github.com>2024-07-18 01:45:15 +0200
commitec979a82fd9e7ec104242223d7d73cda21147670 (patch)
treef83beb2a8c95f957da31622e4b99fcedc3cb5485 /src/server
parentff04a9b285cb72b18d7556905e3d9001c430ed3c (diff)
parent0d166ec2c79ccfb97f8606c7435b2d42e04e28b6 (diff)
Merge pull request #434 from thetarnav/inlay-hints-comma
Remove comma from first param default value inlay hint
Diffstat (limited to 'src/server')
-rw-r--r--src/server/inlay_hints.odin29
1 files changed, 14 insertions, 15 deletions
diff --git a/src/server/inlay_hints.odin b/src/server/inlay_hints.odin
index 55cd486..3f8d181 100644
--- a/src/server/inlay_hints.odin
+++ b/src/server/inlay_hints.odin
@@ -128,21 +128,20 @@ 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
}
}
@@ -150,7 +149,7 @@ get_inlay_hints :: proc(
kind = .Parameter,
label = fmt.tprintf(
"%s %v := %v",
- has_trailing_comma ? "" : ",",
+ needs_leading_comma ? "," : "",
label,
value,
),