Skip to content

Fix flags_without_count option behavior for empty symbols #136

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 10, 2025

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Aug 10, 2025

The flags_without_count option was not handling empty symbols correctly. Previously, flags with empty symbols were completely hidden regardless of the option value, but according to the intended behavior, they should show counts when flags_without_count=false (default).

Fixed Behavior

Case 1: Non-empty symbol with count=1

  • flags_without_count: false → prints: "S1" (symbol + count)
  • flags_without_count: true → prints: "S" (symbol only)

Case 2: Empty symbol with count=1

  • flags_without_count: false → prints: "1" (count only)
  • flags_without_count: true → prints: "" (nothing)

Case 3: Count is 0

  • Always prints "" regardless of flags_without_count value

Changes Made

  • Updated formatFlag() function to properly handle empty symbols based on the flags_without_count option
  • Modified flags() function to call formatFlag even when symbols are empty (as long as count > 0)
  • Added comprehensive test coverage for all flag behavior cases
  • Updated README documentation to clarify the option behavior
  • Enhanced configuration file comments to explain the new behavior

Example

With a configuration where staged and modified symbols are empty:

symbols:
  staged: ""     # empty symbol  
  modified: ""   # empty symbol
  untracked: "" # non-empty symbol

Before: Empty symbols were always hidden
After with flags_without_count: false: Shows "2 1 … 3" (counts for empty symbols, symbol+count for non-empty)
After with flags_without_count: true: Shows "…" (only non-empty symbols, no counts)

This change enables users to have full control over flag display behavior, allowing all combinations of symbol presence and count visibility.

Fixes #133.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@Copilot Copilot AI changed the title [WIP] [FEATURE] fix behaviour of flags_without_count option Fix flags_without_count option behavior for empty symbols Aug 10, 2025
@Copilot Copilot AI requested a review from arl August 10, 2025 11:51
Copilot finished work on behalf of arl August 10, 2025 11:51
Copy link
Owner

@arl arl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good. See comments though
@copilot

@arl
Copy link
Owner

arl commented Aug 10, 2025

@copilot see requested changes

@Copilot Copilot AI requested a review from arl August 10, 2025 13:11
Copilot finished work on behalf of arl August 10, 2025 13:11
@arl arl marked this pull request as ready for review August 10, 2025 15:34
Copy link
Owner

@arl arl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@arl arl merged commit 6a169c6 into main Aug 10, 2025
6 checks passed
@arl arl deleted the copilot/fix-133-2 branch August 10, 2025 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE] fix behaviour of flags_without_count option
2 participants