Skip to content

Commit f9435b7

Browse files
joshwilhelmiclaude
andcommitted
[gobby-cli-#74] Fix bogus 100% savings on empty outline/symbol results
Skip savings reporting when actual bytes is zero — empty results from unindexed files are not savings. Also bumps gcode to v0.4.4. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 2f87d10 commit f9435b7

4 files changed

Lines changed: 13 additions & 5 deletions

File tree

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ All notable changes to gobby-cli are documented in this file.
77
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
88
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
99

10+
## [0.4.4]
11+
12+
### Fixed
13+
14+
#### gcode
15+
16+
- Fix bogus "saved 100%" output when outline/symbol returns empty results — skip savings reporting when actual bytes is zero (#74)
17+
1018
## [0.4.3]
1119

1220
### Changed

crates/gcode/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "gobby-code"
3-
version = "0.4.3"
3+
version = "0.4.4"
44
edition = "2024"
55
rust-version = "1.85"
66
authors = ["Josh Wilhelmi <hello@gobby.ai>"]

crates/gcode/src/commands/symbols.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub fn outline(ctx: &Context, file: &str, format: Format, verbose: bool) -> anyh
2828
+ 20 // line numbers, separators
2929
})
3030
.sum();
31-
if file_bytes > outline_bytes {
31+
if outline_bytes > 0 && file_bytes > outline_bytes {
3232
savings::print_savings(&format!("outline {file}"), file_bytes, outline_bytes);
3333
if let Some(url) = savings::resolve_daemon_url(None) {
3434
savings::report_savings(&url, file_bytes, outline_bytes);
@@ -84,7 +84,7 @@ pub fn symbol(ctx: &Context, id: &str, format: Format) -> anyhow::Result<()> {
8484
let snippet = String::from_utf8_lossy(&source[start..end]);
8585

8686
// Record savings: symbol bytes vs full file bytes
87-
if file_bytes > symbol_bytes {
87+
if symbol_bytes > 0 && file_bytes > symbol_bytes {
8888
savings::print_savings(
8989
&format!("symbol {}", s.qualified_name),
9090
file_bytes,
@@ -147,7 +147,7 @@ pub fn symbols(ctx: &Context, ids: &[String], format: Format) -> anyhow::Result<
147147
total_symbol_bytes += s.byte_end - s.byte_start;
148148
}
149149
}
150-
if total_file_bytes > total_symbol_bytes {
150+
if total_symbol_bytes > 0 && total_file_bytes > total_symbol_bytes {
151151
savings::print_savings(
152152
&format!("symbols ({})", results.len()),
153153
total_file_bytes,

crates/gcode/src/savings.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ pub fn resolve_daemon_url(config_url: Option<&str>) -> Option<String> {
5757

5858
/// Print savings info to stderr in gsqz-style format.
5959
pub fn print_savings(label: &str, original_chars: usize, actual_chars: usize) {
60-
if original_chars <= actual_chars || original_chars == 0 {
60+
if actual_chars == 0 || original_chars <= actual_chars {
6161
return;
6262
}
6363
let pct = savings_pct(original_chars, actual_chars);

0 commit comments

Comments
 (0)