Skip to content
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

fix(segment) Check folders is not empty #6268

Merged
merged 1 commit into from
Mar 15, 2025

Conversation

d3v2a
Copy link
Contributor

@d3v2a d3v2a commented Mar 13, 2025

Prerequisites

  • I have read and understood the contributing guide.
  • The commit message follows the conventional commits guidelines.
  • Tests for the changes have been added (for bug fixes / features).
  • Docs have been added/updated (for bug fixes / features).

Description

Fix panic in getAgnosterLeftPath when in a root directory

This PR fixes a runtime panic caused by an out-of-range index error in getAgnosterLeftPath.

Problem

The issue occurs when the current working directory is a root directory (e.g., /data), leading to an empty path segment list and triggering an out-of-bounds access:

panic: runtime error: index out of range [0] with length 0

goroutine 11 [running]:
github.com/jandedobbeleer/oh-my-posh/src/segments.(*Path).getAgnosterLeftPath(0xc000596000)
        D:/a/oh-my-posh/oh-my-posh/src/segments/path.go:356 +0x318

Solution

The fix ensures that the function properly handles cases where the path segment list is empty, preventing the panic.

@d3v2a d3v2a force-pushed the fix_root_path branch 2 times, most recently from 80bf4ec to 4c71755 Compare March 14, 2025 01:51
@JanDeDobbeleer JanDeDobbeleer changed the base branch from main to next March 15, 2025 08:55
@JanDeDobbeleer JanDeDobbeleer merged commit 6e6eeeb into JanDeDobbeleer:next Mar 15, 2025
7 checks passed
@JanDeDobbeleer
Copy link
Owner

@all-contributors please add @d3v2a for code

This is pure magic 🪄! @holopin-bot @d3v2a wizard

Copy link

holopin-bot bot commented Mar 15, 2025

Congratulations @d3v2a, the maintainer of this repository has issued you a badge! Here it is: https://holopin.io/claim/cm89zmsff37760cjvlbdscv15

This badge can only be claimed by you, so make sure that your GitHub account is linked to your Holopin account. You can manage those preferences here: https://holopin.io/account.
Or if you're new to Holopin, you can simply sign up with GitHub, which will do the trick!

Copy link
Contributor

@JanDeDobbeleer

I've put up a pull request to add @d3v2a! 🎉

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.

2 participants