Skip to content

feat/making plugin padding customizable #352

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Theoreticallyhugo
Copy link
Collaborator

replace the space that would be added to the left and right of a plugin by customizable variables.
both the left and right pad variables are one space per default in order not to change the status quo and break user configs.

this enables tighter packing of plugins, by using a zero width space for padding.

set -g @dracula-left-pad ''  # THERE IS A ZERO WIDTH SPACE HERE
set -g @dracula-right-pad ''  # USING '' WITHOUT A PADDING CHARACTER WON'T WORK
set -g @dracula-show-right-sep ""
set -g @dracula-show-powerline true
image

or fancy wide configs

set -g @dracula-show-edge-icons true
set -g @dracula-left-pad ''
set -g @dracula-right-pad ''
set -g @dracula-show-left-sep ""
set -g @dracula-show-right-sep ""
set -g @dracula-inverse-divider 
image

Copy link

coderabbitai bot commented Jul 16, 2025

📝 Walkthrough

Walkthrough

A new configuration option for plugin padding in the tmux Dracula theme is introduced. Documentation is updated with instructions and examples for customizing or removing padding around plugins. The main script is modified to support left and right padding options, applying them consistently to plugin outputs in all display modes.

Changes

Cohort / File(s) Change Summary
Documentation Update
docs/CONFIG.md
Added a section describing new options for customizing or removing plugin padding, with examples.
Script Logic Update
scripts/dracula.sh
Introduced @dracula-left-pad and @dracula-right-pad options; updated plugin output handling to apply configurable padding in all modes.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/padding

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@Theoreticallyhugo
Copy link
Collaborator Author

hi @druxorey, may i ask you to review this pr? i feel like this is something you probably know well and may like

@druxorey
Copy link
Contributor

druxorey commented Aug 1, 2025

Hello, sorry for the delay. I've already checked and tested the PR, and it's a great addition. I haven't found any problems, so I think you can merge it into main.

@ethancedwards8 ethancedwards8 marked this pull request as ready for review August 1, 2025 23:54
Copy link
Member

@ethancedwards8 ethancedwards8 left a comment

Choose a reason for hiding this comment

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

diff lgtm as well

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (3)
scripts/dracula.sh (1)

370-381: Empty-plugin hiding ignores padding – revisit logic (optional).

show_empty_plugins=false relies on #{==:$script,} – i.e. before padding is added.
If a plugin outputs an empty string but left_pad/right_pad are non-empty, the pads are
still generated yet subsequently discarded by the ? conditional.
That works, but it also means every evaluation executes (and discards) the pads,
which is unnecessary processing and can be confusing when custom pads include colour
formatting.
Consider basing the test on pad_script (after quoting fix) or wrapping the padding
inside the false-branch so it is only produced when actually rendered.

docs/CONFIG.md (2)

91-94: Minor grammar & clarity nit – tighten the new paragraph.

Current sentence is hard to parse.

-Whilst the padding is one space per default, can be whatever you want it to be, whether that's whitespace or other characters.
+Padding defaults to a single space but can be *any* string – additional whitespace, symbols, even colour codes.

Also consider explicitly noting that the zero-width space shown below is invisible; many readers
won’t realise the character is present.


95-101: Invisible zero-width spaces – add a comment for copy-pasting users.

Because the zero-width space is… well, invisible, many users end up pasting an empty string
instead and complain that padding remains.
A quick inline comment helps:

-set -g @dracula-left-pad '​'
-set -g @dracula-right-pad '​'
+# zero-width space between the quotes ↓
+set -g @dracula-left-pad '​'
+set -g @dracula-right-pad '​'
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a2ddf12 and dca498c.

📒 Files selected for processing (2)
  • docs/CONFIG.md (1 hunks)
  • scripts/dracula.sh (2 hunks)
🔇 Additional comments (1)
scripts/dracula.sh (1)

366-368: pad_script duplicates quoting bug & can break with spaces in padding.

Even after fixing the previous comment, $left_pad$script$right_pad is unquoted.
If either pad contains a space, word-splitting will again trim or split the string, potentially mangling
the status-line fragment.

- pad_script="$left_pad$script$right_pad"
+pad_script="${left_pad}${script}${right_pad}"

Enclosing the components fixes both word-splitting and glob-expansion edge-cases.

Likely an incorrect or invalid review comment.

Comment on lines +41 to 43
left_pad=$(get_tmux_option "@dracula-left-pad" " ")
right_pad=$(get_tmux_option "@dracula-right-pad" " ")

Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

⚠️ Potential issue

Leading / trailing-space padding is silently stripped – quote command substitutions.

get_tmux_option may legitimately return strings that start or end with spaces (e.g. ' ° ' in the docs).
Because the result of a command-substitution is subject to word-splitting, the assignment

left_pad=$(get_tmux_option "@dracula-left-pad" " ")

drops those leading / trailing blanks – they never make it into left_pad / right_pad.

- left_pad=$(get_tmux_option "@dracula-left-pad" " ")
- right_pad=$(get_tmux_option "@dracula-right-pad" " ")
+ left_pad="$(get_tmux_option "@dracula-left-pad" " ")"
+ right_pad="$(get_tmux_option "@dracula-right-pad" " ")"

Quoting preserves the exact byte sequence the user configured (including zero-width spaces).
Same issue exists anywhere we later read the option back; fixing it here is sufficient.

🤖 Prompt for AI Agents
In scripts/dracula.sh around lines 41 to 43, the command substitutions assigning
left_pad and right_pad are unquoted, causing leading and trailing spaces to be
stripped due to word splitting. To fix this, wrap the command substitutions in
double quotes like left_pad="$(get_tmux_option "@dracula-left-pad" " ")" and
right_pad="$(get_tmux_option "@dracula-right-pad" " ")" to preserve all
whitespace exactly as returned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants