| ... | ... | @@ -31,111 +31,138 @@ import { |
| 31 | 31 | RustRoverIcon, |
| 32 | 32 | WebStormIcon, |
| 33 | 33 | } from "../JetBrainsIcons"; |
| 34 | | import { isMacPlatform, isWindowsPlatform } from "~/lib/utils"; |
| 34 | import { cn, isMacPlatform, isWindowsPlatform } from "~/lib/utils"; |
| 35 | 35 | import { shellEnvironment } from "~/state/shell"; |
| 36 | 36 | import { useAtomCommand } from "~/state/use-atom-command"; |
| 37 | 37 | |
| 38 | type OpenInOption = { |
| 39 | label: string; |
| 40 | Icon: Icon; |
| 41 | value: EditorId; |
| 42 | kind: "brand" | "generic"; |
| 43 | }; |
| 44 | |
| 38 | 45 | const resolveOptions = (platform: string, availableEditors: ReadonlyArray<EditorId>) => { |
| 39 | | const baseOptions: ReadonlyArray<{ label: string; Icon: Icon; value: EditorId }> = [ |
| 46 | const baseOptions: ReadonlyArray<OpenInOption> = [ |
| 40 | 47 | { |
| 41 | 48 | label: "Cursor", |
| 42 | 49 | Icon: CursorIcon, |
| 43 | 50 | value: "cursor", |
| 51 | kind: "brand", |
| 44 | 52 | }, |
| 45 | 53 | { |
| 46 | 54 | label: "Trae", |
| 47 | 55 | Icon: TraeIcon, |
| 48 | 56 | value: "trae", |
| 57 | kind: "brand", |
| 49 | 58 | }, |
| 50 | 59 | { |
| 51 | 60 | label: "Kiro", |
| 52 | 61 | Icon: KiroIcon, |
| 53 | 62 | value: "kiro", |
| 63 | kind: "brand", |
| 54 | 64 | }, |
| 55 | 65 | { |
| 56 | 66 | label: "VS Code", |
| 57 | 67 | Icon: VisualStudioCode, |
| 58 | 68 | value: "vscode", |
| 69 | kind: "brand", |
| 59 | 70 | }, |
| 60 | 71 | { |
| 61 | 72 | label: "VS Code Insiders", |
| 62 | 73 | Icon: VisualStudioCodeInsiders, |
| 63 | 74 | value: "vscode-insiders", |
| 75 | kind: "brand", |
| 64 | 76 | }, |
| 65 | 77 | { |
| 66 | 78 | label: "VSCodium", |
| 67 | 79 | Icon: VSCodium, |
| 68 | 80 | value: "vscodium", |
| 81 | kind: "brand", |
| 69 | 82 | }, |
| 70 | 83 | { |
| 71 | 84 | label: "Zed", |
| 72 | 85 | Icon: Zed, |
| 73 | 86 | value: "zed", |
| 87 | kind: "brand", |
| 74 | 88 | }, |
| 75 | 89 | { |
| 76 | 90 | label: "Antigravity", |
| 77 | 91 | Icon: AntigravityIcon, |
| 78 | 92 | value: "antigravity", |
| 93 | kind: "brand", |
| 79 | 94 | }, |
| 80 | 95 | { |
| 81 | 96 | label: "IntelliJ IDEA", |
| 82 | 97 | Icon: IntelliJIdeaIcon, |
| 83 | 98 | value: "idea", |
| 99 | kind: "brand", |
| 84 | 100 | }, |
| 85 | 101 | { |
| 86 | 102 | label: "Aqua", |
| 87 | 103 | Icon: AquaIcon, |
| 88 | 104 | value: "aqua", |
| 105 | kind: "brand", |
| 89 | 106 | }, |
| 90 | 107 | { |
| 91 | 108 | label: "CLion", |
| 92 | 109 | Icon: CLionIcon, |
| 93 | 110 | value: "clion", |
| 111 | kind: "brand", |
| 94 | 112 | }, |
| 95 | 113 | { |
| 96 | 114 | label: "DataGrip", |
| 97 | 115 | Icon: DataGripIcon, |
| 98 | 116 | value: "datagrip", |
| 117 | kind: "brand", |
| 99 | 118 | }, |
| 100 | 119 | { |
| 101 | 120 | label: "DataSpell", |
| 102 | 121 | Icon: DataSpellIcon, |
| 103 | 122 | value: "dataspell", |
| 123 | kind: "brand", |
| 104 | 124 | }, |
| 105 | 125 | { |
| 106 | 126 | label: "GoLand", |
| 107 | 127 | Icon: GoLandIcon, |
| 108 | 128 | value: "goland", |
| 129 | kind: "brand", |
| 109 | 130 | }, |
| 110 | 131 | { |
| 111 | 132 | label: "PhpStorm", |
| 112 | 133 | Icon: PhpStormIcon, |
| 113 | 134 | value: "phpstorm", |
| 135 | kind: "brand", |
| 114 | 136 | }, |
| 115 | 137 | { |
| 116 | 138 | label: "PyCharm", |
| 117 | 139 | Icon: PyCharmIcon, |
| 118 | 140 | value: "pycharm", |
| 141 | kind: "brand", |
| 119 | 142 | }, |
| 120 | 143 | { |
| 121 | 144 | label: "Rider", |
| 122 | 145 | Icon: RiderIcon, |
| 123 | 146 | value: "rider", |
| 147 | kind: "brand", |
| 124 | 148 | }, |
| 125 | 149 | { |
| 126 | 150 | label: "RubyMine", |
| 127 | 151 | Icon: RubyMineIcon, |
| 128 | 152 | value: "rubymine", |
| 153 | kind: "brand", |
| 129 | 154 | }, |
| 130 | 155 | { |
| 131 | 156 | label: "RustRover", |
| 132 | 157 | Icon: RustRoverIcon, |
| 133 | 158 | value: "rustrover", |
| 159 | kind: "brand", |
| 134 | 160 | }, |
| 135 | 161 | { |
| 136 | 162 | label: "WebStorm", |
| 137 | 163 | Icon: WebStormIcon, |
| 138 | 164 | value: "webstorm", |
| 165 | kind: "brand", |
| 139 | 166 | }, |
| 140 | 167 | { |
| 141 | 168 | label: isMacPlatform(platform) |
| ... | ... | @@ -145,12 +172,17 @@ const resolveOptions = (platform: string, availableEditors: ReadonlyArray<Editor |
| 145 | 172 | : "Files", |
| 146 | 173 | Icon: FolderClosedIcon, |
| 147 | 174 | value: "file-manager", |
| 175 | kind: "generic", |
| 148 | 176 | }, |
| 149 | 177 | ]; |
| 150 | 178 | const availableEditorSet = new Set(availableEditors); |
| 151 | 179 | return baseOptions.filter((option) => availableEditorSet.has(option.value)); |
| 152 | 180 | }; |
| 153 | 181 | |
| 182 | function getOpenInIconClass(kind: OpenInOption["kind"]) { |
| 183 | return cn(kind === "brand" ? "text-foreground opacity-100" : "text-muted-foreground"); |
| 184 | } |
| 185 | |
| 154 | 186 | export const OpenInPicker = memo(function OpenInPicker({ |
| 155 | 187 | environmentId, |
| 156 | 188 | keybindings, |
| ... | ... | @@ -233,7 +265,12 @@ export const OpenInPicker = memo(function OpenInPicker({ |
| 233 | 265 | disabled={!preferredEditor || !openInCwd} |
| 234 | 266 | onClick={() => openInEditor(preferredEditor)} |
| 235 | 267 | > |
| 236 | | {primaryOption?.Icon && <primaryOption.Icon aria-hidden="true" className="size-3.5" />} |
| 268 | {primaryOption?.Icon && ( |
| 269 | <primaryOption.Icon |
| 270 | aria-hidden="true" |
| 271 | className={cn("size-3.5", getOpenInIconClass(primaryOption.kind))} |
| 272 | /> |
| 273 | )} |
| 237 | 274 | <span |
| 238 | 275 | className={ |
| 239 | 276 | compact |
| ... | ... | @@ -259,9 +296,9 @@ export const OpenInPicker = memo(function OpenInPicker({ |
| 259 | 296 | </MenuTrigger> |
| 260 | 297 | <MenuPopup align="end"> |
| 261 | 298 | {options.length === 0 && <MenuItem disabled>No installed editors found</MenuItem>} |
| 262 | | {options.map(({ label, Icon, value }) => ( |
| 299 | {options.map(({ label, Icon, value, kind }) => ( |
| 263 | 300 | <MenuItem key={value} onClick={() => openInEditor(value)}> |
| 264 | | <Icon aria-hidden="true" className="text-muted-foreground" /> |
| 301 | <Icon aria-hidden="true" className={getOpenInIconClass(kind)} /> |
| 265 | 302 | {label} |
| 266 | 303 | {value === preferredEditor && openFavoriteEditorShortcutLabel && ( |
| 267 | 304 | <MenuShortcut>{openFavoriteEditorShortcutLabel}</MenuShortcut> |