Skip to content

Commit 7f628eb

Browse files
authored
fix(lsp): inlay hints now based on lock file version (#52)
Shows ✅ only when lock file has the latest version. Shows ❌ otherwise, regardless of manifest requirement.
1 parent ac4a73e commit 7f628eb

File tree

5 files changed

+38
-24
lines changed

5 files changed

+38
-24
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [0.5.4] - 2026-01-15
11+
12+
### Fixed
13+
- **Inlay hints now based on lock file version** — Shows ✅ only when lock file has the latest version, ❌ otherwise (regardless of manifest requirement)
14+
1015
## [0.5.3] - 2026-01-15
1116

1217
### Changed

Cargo.toml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ exclude = ["crates/deps-zed"]
44
resolver = "2"
55

66
[workspace.package]
7-
version = "0.5.3"
7+
version = "0.5.4"
88
edition = "2024"
99
rust-version = "1.89"
1010
authors = ["Andrei G"]
@@ -15,12 +15,12 @@ repository = "https://github.com/bug-ops/deps-lsp"
1515
async-trait = "0.1"
1616
criterion = "0.8"
1717
dashmap = "6.1"
18-
deps-core = { version = "0.5.3", path = "crates/deps-core" }
19-
deps-cargo = { version = "0.5.3", path = "crates/deps-cargo" }
20-
deps-npm = { version = "0.5.3", path = "crates/deps-npm" }
21-
deps-pypi = { version = "0.5.3", path = "crates/deps-pypi" }
22-
deps-go = { version = "0.5.3", path = "crates/deps-go" }
23-
deps-lsp = { version = "0.5.3", path = "crates/deps-lsp" }
18+
deps-core = { version = "0.5.4", path = "crates/deps-core" }
19+
deps-cargo = { version = "0.5.4", path = "crates/deps-cargo" }
20+
deps-npm = { version = "0.5.4", path = "crates/deps-npm" }
21+
deps-pypi = { version = "0.5.4", path = "crates/deps-pypi" }
22+
deps-go = { version = "0.5.4", path = "crates/deps-go" }
23+
deps-lsp = { version = "0.5.4", path = "crates/deps-lsp" }
2424
futures = "0.3"
2525
insta = "1"
2626
mockito = "1"

crates/deps-cargo/src/ecosystem.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,9 @@ mod tests {
358358
needs_update_text: "❌ {}".to_string(),
359359
};
360360

361-
let resolved_versions = HashMap::new();
361+
// Lock file has the latest version
362+
let mut resolved_versions = HashMap::new();
363+
resolved_versions.insert("serde".to_string(), "1.0.214".to_string());
362364
let hints = tokio_test::block_on(ecosystem.generate_inlay_hints(
363365
&parse_result,
364366
&cached_versions,
@@ -369,7 +371,7 @@ mod tests {
369371

370372
assert_eq!(hints.len(), 1);
371373
match &hints[0].label {
372-
InlayHintLabel::String(s) => assert_eq!(s, "✅"),
374+
InlayHintLabel::String(s) => assert_eq!(s, "✅ 1.0.214"),
373375
_ => panic!("Expected String label"),
374376
}
375377
}
@@ -394,7 +396,9 @@ mod tests {
394396
needs_update_text: "❌ {}".to_string(),
395397
};
396398

397-
let resolved_versions = HashMap::new();
399+
// Lock file has the latest version
400+
let mut resolved_versions = HashMap::new();
401+
resolved_versions.insert("serde".to_string(), "1.0.214".to_string());
398402
let hints = tokio_test::block_on(ecosystem.generate_inlay_hints(
399403
&parse_result,
400404
&cached_versions,
@@ -405,7 +409,7 @@ mod tests {
405409

406410
assert_eq!(hints.len(), 1);
407411
match &hints[0].label {
408-
InlayHintLabel::String(s) => assert_eq!(s, "✅"),
412+
InlayHintLabel::String(s) => assert_eq!(s, "✅ 1.0.214"),
409413
_ => panic!("Expected String label"),
410414
}
411415
}
@@ -466,7 +470,9 @@ mod tests {
466470
needs_update_text: "❌ {}".to_string(),
467471
};
468472

469-
let resolved_versions = HashMap::new();
473+
// Lock file has the latest version - but show_up_to_date_hints is false
474+
let mut resolved_versions = HashMap::new();
475+
resolved_versions.insert("serde".to_string(), "1.0.214".to_string());
470476
let hints = tokio_test::block_on(ecosystem.generate_inlay_hints(
471477
&parse_result,
472478
&cached_versions,

crates/deps-core/src/lsp_helpers.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -172,11 +172,9 @@ pub fn generate_inlay_hints(
172172
continue;
173173
};
174174

175-
let version_req = dep.version_requirement().unwrap_or("");
176-
let requirement_allows_latest =
177-
formatter.version_satisfies_requirement(latest, version_req);
178-
179-
let (is_up_to_date, display_version) = (requirement_allows_latest, Some(latest.as_str()));
175+
// Up-to-date only if lock file already has the latest version
176+
let is_up_to_date =
177+
resolved_version.is_some_and(|resolved| resolved.as_str() == latest.as_str());
180178

181179
let label_text = if is_up_to_date {
182180
if config.show_up_to_date_hints {
@@ -189,8 +187,7 @@ pub fn generate_inlay_hints(
189187
continue;
190188
}
191189
} else {
192-
let version = display_version.unwrap_or("unknown");
193-
config.needs_update_text.replace("{}", version)
190+
config.needs_update_text.replace("{}", latest)
194191
};
195192

196193
hints.push(InlayHint {
@@ -1141,7 +1138,9 @@ mod tests {
11411138
let mut cached_versions = HashMap::new();
11421139
cached_versions.insert("serde".to_string(), "1.0.214".to_string());
11431140

1144-
let resolved_versions = HashMap::new();
1141+
// Lock file has the latest version
1142+
let mut resolved_versions = HashMap::new();
1143+
resolved_versions.insert("serde".to_string(), "1.0.214".to_string());
11451144

11461145
let hints = generate_inlay_hints(
11471146
&parse_result,
@@ -1156,7 +1155,7 @@ mod tests {
11561155
match &hints[0].label {
11571156
InlayHintLabel::String(text) => {
11581157
assert_eq!(
1159-
text, "✅",
1158+
text, "✅ 1.0.214",
11601159
"Expected up-to-date hint, not loading hint, got: {}",
11611160
text
11621161
);

crates/deps-go/src/ecosystem.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,9 @@ mod tests {
310310
needs_update_text: "❌ {}".to_string(),
311311
};
312312

313-
let resolved_versions = HashMap::new();
313+
// Lock file has the latest version
314+
let mut resolved_versions = HashMap::new();
315+
resolved_versions.insert("github.com/gin-gonic/gin".to_string(), "v1.9.1".to_string());
314316
let hints = tokio_test::block_on(ecosystem.generate_inlay_hints(
315317
&parse_result,
316318
&cached_versions,
@@ -321,7 +323,7 @@ mod tests {
321323

322324
assert_eq!(hints.len(), 1);
323325
match &hints[0].label {
324-
InlayHintLabel::String(s) => assert_eq!(s, "✅"),
326+
InlayHintLabel::String(s) => assert_eq!(s, "✅ v1.9.1"),
325327
_ => panic!("Expected String label"),
326328
}
327329
}
@@ -394,7 +396,9 @@ mod tests {
394396
needs_update_text: "❌ {}".to_string(),
395397
};
396398

397-
let resolved_versions = HashMap::new();
399+
// Lock file has the latest version - but show_up_to_date_hints is false
400+
let mut resolved_versions = HashMap::new();
401+
resolved_versions.insert("github.com/gin-gonic/gin".to_string(), "v1.9.1".to_string());
398402
let hints = tokio_test::block_on(ecosystem.generate_inlay_hints(
399403
&parse_result,
400404
&cached_versions,

0 commit comments

Comments
 (0)