Skip to content

Commit

Permalink
Projects pane: Fix opening files' location in Terminal (#358)
Browse files Browse the repository at this point in the history
* Rename menu item to "Show in Terminal". It's symmetrical to "Show in Tracker".
  It's more correct, because you don't just open a Terminal somewhere, but in
  the location of the selected file/folder.

* "Show in Terminal" only worked correctly when invoked in a directory. Invoked
  on a file, it opened in the project's top folder instead. Terminal's "-w"
  parameter only accepts folders, not files.
  No we check if the invoked-on item is a directory. If it isn't use the files
  parent directory.
  • Loading branch information
humdingerb authored Apr 23, 2024
1 parent f2ddbba commit b48d685
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/ui/GenioWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3766,7 +3766,12 @@ GenioWindow::_OpenTerminalWorkingDirectory()
if (selectedProjectItem == nullptr)
return B_BAD_VALUE;

BPath itemPath(selectedProjectItem->GetSourceItem()->EntryRef());
BEntry itemEntry(selectedProjectItem->GetSourceItem()->EntryRef());
if (!itemEntry.IsDirectory())
itemEntry.GetParent(&itemEntry);

BPath itemPath(&itemEntry);

const char* argv[] = {
"-w",
itemPath.Path(),
Expand Down
2 changes: 1 addition & 1 deletion src/ui/ProjectsFolderBrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ ProjectsFolderBrowser::_ShowProjectItemPopupMenu(BPoint where)

BMenuItem* showInTrackerProjectMenuItem = new BMenuItem(B_TRANSLATE("Show in Tracker"),
new BMessage(MSG_PROJECT_MENU_SHOW_IN_TRACKER));
BMenuItem* openTerminalProjectMenuItem = new BMenuItem(B_TRANSLATE("Open Terminal"),
BMenuItem* openTerminalProjectMenuItem = new BMenuItem(B_TRANSLATE("Open in Terminal"),
new BMessage(MSG_PROJECT_MENU_OPEN_TERMINAL));
showInTrackerProjectMenuItem->SetEnabled(true);
openTerminalProjectMenuItem->SetEnabled(true);
Expand Down

0 comments on commit b48d685

Please sign in to comment.