Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions phpstorm-url-handler
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,23 @@ file=$(echo "${arg}" | sed -r "s/${pattern}/\2/")
# Get the line number.
line=$(echo "${arg}" | sed -r "s/${pattern}/\4/")

# Since PhpStorm 2026.2, --line is only accepted when a project directory
# is passed as the first argument. Resolve it from the target file's git root.
project=$(cd "$(dirname "${file}")" 2>/dev/null && git rev-parse --show-toplevel 2>/dev/null)

# Check if phpstorm|pstorm command exist.
if type phpstorm > /dev/null; then
/usr/bin/env phpstorm --line "${line}" "${file}"
if [ -n "${project}" ]; then
/usr/bin/env phpstorm "${project}" --line "${line}" "${file}"
else
/usr/bin/env phpstorm --line "${line}" "${file}"
fi
elif type pstorm > /dev/null; then
/usr/bin/env pstorm --line "${line}" "${file}"
if [ -n "${project}" ]; then
/usr/bin/env pstorm "${project}" --line "${line}" "${file}"
else
/usr/bin/env pstorm --line "${line}" "${file}"
fi
fi

if type wmctrl > /dev/null; then
Expand Down