Skip to content

Add paths to duplicate browser names in Settings#5210

Open
mven wants to merge 1 commit intoRanchero-Software:mainfrom
mven:feat/dupe-browsers-path
Open

Add paths to duplicate browser names in Settings#5210
mven wants to merge 1 commit intoRanchero-Software:mainfrom
mven:feat/dupe-browsers-path

Conversation

@mven
Copy link
Copy Markdown

@mven mven commented Mar 24, 2026

This change adds an informative path name if duplicate browsers are present in Settings > Browser

Notable changes:

  • visible path name for duplicate browsers, middle truncation if path is long
  • add bundlePath computed property
  • use bundlePath over bundleIdentifierin representedObject to make menu items more unique

swiftlint was performed on these specific files.

Screenshot 2026-03-24 at 10 43 04

closes #4747

menu.addItem(item)
menu.addItem(NSMenuItem.separator())

let baseFont = NSFont.menuFont(ofSize: 0)
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Not sure if this is the best place for these constants.


let item = NSMenuItem(title: name, action: nil, keyEquivalent: "")
item.representedObject = browser.bundleIdentifier
item.representedObject = browser.bundlePath
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I used the path instead of bundleIdentifier, because bundleIdentifier wasn't unique when duplicate browsers exist.

if let leftName = $0.name, let rightName = $1.name {
return leftName < rightName
if let leftName = $0.name, let leftPath = $0.bundlePath, let rightName = $1.name, let rightPath = $1.bundlePath {
return (leftName, leftPath) < (rightName, rightPath)
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Make sure browsers are sorted by name AND path

let pathThreshold = 4

// index 0 is `/` with absolute path
let pathStart = "\(pathComponents[0])\(pathComponents[1])"
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I'm not too crazy about the way this looks, since it looks a little messy. I'm open to suggestions or any best practices I'm unaware of.

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.

Duplicate browser listed in settings

2 participants