Skip to content

fix: Correct icons for clipboards files#845

Merged
lazysegtree merged 1 commit into
yorukot:mainfrom
Frost-Phoenix:clipboard-icons-fix
May 23, 2025
Merged

fix: Correct icons for clipboards files#845
lazysegtree merged 1 commit into
yorukot:mainfrom
Frost-Phoenix:clipboard-icons-fix

Conversation

@Frost-Phoenix

@Frost-Phoenix Frost-Phoenix commented May 23, 2025

Copy link
Copy Markdown
Contributor

This PR closes #832

The issue is that ClipboardPrettierName(name string, width int, isDir bool, isSelected bool) string, which is called when rendering the clipboard panel, is called with the file full path (e.g. /home/name/Documents/file.txt) . But GetElementIcon(file string, isDir bool, nerdFont bool) icon.Style, witch is used to retrived the file icon, expect only the file base name (e.g. file.txt). So for files like go.mod that relies on the full base name to get the icon, the full path of the file will be given and not just the base name.

After the changes:
image

Summary by CodeRabbit

  • Bug Fixes
    • Improved icon selection for clipboard items by basing it on the filename instead of the full file path, resulting in more accurate icons.

@coderabbitai

coderabbitai Bot commented May 23, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

The change updates the ClipboardPrettierName function to use only the base filename when determining the icon style by extracting the base from the path using filepath.Base. This adjustment ensures that icon selection is based on the filename rather than the full path. No other logic or exported interfaces are modified.

Changes

File(s) Change Summary
src/internal/common/string_function.go Imports "path/filepath" and modifies ClipboardPrettierName to use filepath.Base(name) for icon selection instead of the full path.

Assessment against linked issues

Objective Addressed Explanation
Correct icons for clipboard files based on their filenames (#832)

Poem

From path to base, the icons now gleam,
Clipboard’s delight, a coder’s dream.
No more confusion, the files now show,
The prettiest icons, in a tidy row.
🐇✨

— A rabbit, hopping through your code!

Note

⚡️ AI Code Reviews for VS Code, Cursor, Windsurf

CodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback.
Learn more here.


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 6752c87 and f98a0fd.

📒 Files selected for processing (1)
  • src/internal/common/string_function.go (2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/internal/common/string_function.go (1)
src/internal/common/icon_utils.go (1)
  • GetElementIcon (10-63)
🔇 Additional comments (2)
src/internal/common/string_function.go (2)

10-10: Import addition looks good.

The addition of "path/filepath" import is necessary for the filepath.Base() function used in line 85.


85-85: Excellent fix for the icon display issue.

The change from name to filepath.Base(name) correctly addresses the core issue described in the PR. The GetElementIcon function expects a base filename (e.g., go.mod) rather than a full path (e.g., /home/user/project/go.mod) to properly match file-specific icons.

Looking at the GetElementIcon implementation, it performs icon lookups based on:

  1. File extensions via filepath.Ext(file)
  2. Full filenames for special files (like go.mod, package.json, etc.)

Both of these require the base filename to work correctly, making this fix essential for proper icon display in the clipboard panel.

✨ Finishing Touches
  • 📝 Generate Docstrings

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 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.

@lazysegtree lazysegtree merged commit 9b1bd84 into yorukot:main May 23, 2025
3 checks passed
@Frost-Phoenix Frost-Phoenix deleted the clipboard-icons-fix branch May 23, 2025 10:18
tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request May 26, 2025
This MR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [yorukot/superfile](https://github.com/yorukot/superfile) | patch | `v1.3.0` -> `v1.3.1` |

MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot).

**Proposed changes to behavior should be submitted there as MRs.**

---

### Release Notes

<details>
<summary>yorukot/superfile (yorukot/superfile)</summary>

### [`v1.3.1`](https://github.com/yorukot/superfile/releases/tag/v1.3.1)

[Compare Source](yorukot/superfile@v1.3.0...v1.3.1)

Hey folks. Releasing v1.3.1, providing some recent bug fixes for v1.3.0 , and a new feature.

#### Install:

[**Click me to know how to install**](https://github.com/yorukot/superfile?tab=readme-ov-file#installation)

#### Highlights

-   Bug fix for String Width check causing startup failure on RUNEWIDTH_EASTASIAN=1 . Thanks [@&#8203;YHYJBPXR](https://github.com/YHYJBPXR) for creating the issue, and [@&#8203;mnixry](https://github.com/mnixry) for finding the root cause.
-   Bug fix for correcting icons for clipboard panel. Thanks [@&#8203;Frost-Phoenix](https://github.com/Frost-Phoenix) for this quick bug fix.
-   Added a new sort type - you can now sort files by their Type (file extension) - Thanks [@&#8203;trejdof](https://github.com/trejdof) for the idea and implementation.
-   Code improvements and refactoring . Thanks [@&#8203;JassonCordones](https://github.com/JassonCordones) for your code improvements.

Discussion for any questions/clarifications :

-   yorukot/superfile#855 (comment)

#### Detailed Change Summary

<details><summary>Details</summary>
<p>

-   Correct icons for clipboard files [`#845`](yorukot/superfile#845) by [@&#8203;Frost-Phoenix](https://github.com/Frost-Phoenix)
-   Update main.go [`#839`](yorukot/superfile#839) by [@&#8203;JassonCordones](https://github.com/JassonCordones)
-   Purego package update [`#837`](yorukot/superfile#837) by [@&#8203;daeho-ro](https://github.com/daeho-ro)
-   Replace custom giscus implementation with official starlight-giscus plugin [`#843`](yorukot/superfile#843) by [@&#8203;yorukot](https://github.com/yorukot)
-   Add 'Type' option for sorting by file extension with fallback [`#829`](yorukot/superfile#829) by [@&#8203;trejdof](https://github.com/trejdof)
-   Replace mattn/rundwidth with ansi package for more robust StringWidth [`#848`](yorukot/superfile#848) by [@&#8203;lazysegtree](https://github.com/lazysegtree)

</p>
</details> 

#### New Contributors
* @&#8203;daeho-ro made their first contribution in yorukot/superfile#837
* @&#8203;trejdof made their first contribution in yorukot/superfile#829

**Full Changelog**: yorukot/superfile@v1.3.0...v1.3.1

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever MR is behind base branch, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this MR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0MC4yNi4xIiwidXBkYXRlZEluVmVyIjoiNDAuMjYuMSIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiUmVub3ZhdGUgQm90Il19-->
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.

Clipboard files dont have correct icons

2 participants