-
-
Notifications
You must be signed in to change notification settings - Fork 390
Feat: Add PHPStorm to the IDE selection and add CSS to stretch out command output block to full width for larger screens #566
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
Changes from 9 commits
afcb970
3861093
f6c9b1b
41d8bb3
387f0b9
c1b4a01
1d84967
3f18662
0732034
026ffc9
97969f4
5035fde
d372eed
742857c
363d2fa
44bae44
18b2755
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,3 @@ | ||
| use std::collections::HashMap; | ||
| use std::env; | ||
| use std::path::{Path, PathBuf}; | ||
|
|
||
|
|
@@ -7,14 +6,15 @@ use tokio::sync::Mutex; | |
| use crate::shared::process_core::tokio_command; | ||
| #[cfg(target_os = "windows")] | ||
| use crate::shared::process_core::{build_cmd_c_command, resolve_windows_executable}; | ||
| use crate::types::WorkspaceEntry; | ||
| use crate::types::{OpenAppTarget, WorkspaceEntry}; | ||
| use crate::utils::normalize_windows_namespace_path; | ||
|
|
||
| use super::helpers::resolve_workspace_root; | ||
|
|
||
| #[derive(Clone, Copy, Debug, Eq, PartialEq)] | ||
| enum LineAwareLaunchStrategy { | ||
| GotoFlag, | ||
| JetBrainsLineColumnFlags, | ||
| PathWithLineColumn, | ||
| } | ||
|
|
||
|
|
@@ -53,6 +53,9 @@ fn command_launch_strategy(command: &str) -> Option<LineAwareLaunchStrategy> { | |
| { | ||
| return Some(LineAwareLaunchStrategy::GotoFlag); | ||
| } | ||
| if identifier == "phpstorm" || identifier == "phpstorm64" { | ||
| return Some(LineAwareLaunchStrategy::JetBrainsLineColumnFlags); | ||
| } | ||
| if identifier == "zed" || identifier == "zed-preview" { | ||
| return Some(LineAwareLaunchStrategy::PathWithLineColumn); | ||
| } | ||
|
|
@@ -64,6 +67,9 @@ fn app_launch_strategy(app: &str) -> Option<LineAwareLaunchStrategy> { | |
| if normalized.contains("visual studio code") || normalized.starts_with("cursor") { | ||
| return Some(LineAwareLaunchStrategy::GotoFlag); | ||
| } | ||
| if normalized == "phpstorm" { | ||
| return Some(LineAwareLaunchStrategy::JetBrainsLineColumnFlags); | ||
|
aolin480 marked this conversation as resolved.
Outdated
|
||
| } | ||
| if normalized == "zed" || normalized.starts_with("zed ") { | ||
| return Some(LineAwareLaunchStrategy::PathWithLineColumn); | ||
| } | ||
|
|
@@ -81,28 +87,15 @@ fn app_cli_command(app: &str) -> Option<&'static str> { | |
| if normalized.starts_with("cursor") { | ||
| return Some("cursor"); | ||
| } | ||
| if normalized == "phpstorm" { | ||
| return Some("phpstorm"); | ||
|
Comment on lines
+91
to
+92
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
For macOS file links with a line/column, every recognized PhpStorm app name/path is collapsed to the global Useful? React with 👍 / 👎. |
||
| } | ||
| if normalized == "zed" || normalized.starts_with("zed ") { | ||
| return Some("zed"); | ||
| } | ||
| None | ||
| } | ||
|
|
||
| fn normalize_app_identifier(app: &str) -> String { | ||
| app.trim() | ||
| .chars() | ||
| .map(|value| { | ||
| if value.is_ascii_alphanumeric() { | ||
| value.to_ascii_lowercase() | ||
| } else { | ||
| ' ' | ||
| } | ||
| }) | ||
| .collect::<String>() | ||
| .split_whitespace() | ||
| .collect::<Vec<_>>() | ||
| .join(" ") | ||
| } | ||
|
|
||
| fn find_executable_in_path(program: &str) -> Option<PathBuf> { | ||
| let trimmed = program.trim(); | ||
| if trimmed.is_empty() { | ||
|
|
@@ -125,6 +118,22 @@ fn find_executable_in_path(program: &str) -> Option<PathBuf> { | |
| None | ||
| } | ||
|
|
||
| fn normalize_app_identifier(app: &str) -> String { | ||
| app.trim() | ||
| .chars() | ||
| .map(|value| { | ||
| if value.is_ascii_alphanumeric() { | ||
| value.to_ascii_lowercase() | ||
| } else { | ||
| ' ' | ||
| } | ||
| }) | ||
| .collect::<String>() | ||
| .split_whitespace() | ||
| .collect::<Vec<_>>() | ||
| .join(" ") | ||
| } | ||
|
|
||
| fn build_launch_args( | ||
| path: &str, | ||
| args: &[String], | ||
|
|
@@ -141,6 +150,15 @@ fn build_launch_args( | |
| launch_args.push("--goto".to_string()); | ||
| launch_args.push(located_path); | ||
| } | ||
| Some(LineAwareLaunchStrategy::JetBrainsLineColumnFlags) => { | ||
| launch_args.push("--line".to_string()); | ||
| launch_args.push(line.to_string()); | ||
| if let Some(column) = column { | ||
| launch_args.push("--column".to_string()); | ||
| launch_args.push(column.to_string()); | ||
| } | ||
| launch_args.push(path.to_string()); | ||
|
aolin480 marked this conversation as resolved.
Outdated
|
||
| } | ||
| Some(LineAwareLaunchStrategy::PathWithLineColumn) => { | ||
| let sanitized_path = normalize_windows_namespace_path(path); | ||
| let located_path = format_path_with_location(&sanitized_path, line, column); | ||
|
|
@@ -323,6 +341,10 @@ mod tests { | |
| command_launch_strategy("zed"), | ||
| Some(LineAwareLaunchStrategy::PathWithLineColumn) | ||
| ); | ||
| assert_eq!( | ||
| command_launch_strategy("phpstorm64.exe"), | ||
| Some(LineAwareLaunchStrategy::JetBrainsLineColumnFlags) | ||
| ); | ||
| assert_eq!(command_launch_strategy("vim"), None); | ||
| } | ||
|
|
||
|
|
@@ -490,6 +512,28 @@ mod tests { | |
| assert_eq!(args, vec!["/tmp/project/src/App.tsx:33".to_string()]); | ||
| } | ||
|
|
||
| #[test] | ||
| fn builds_line_and_column_flags_for_phpstorm_targets() { | ||
| let args = build_launch_args( | ||
| "/tmp/project/src/App.tsx", | ||
| &[], | ||
| Some(33), | ||
| Some(7), | ||
| Some(LineAwareLaunchStrategy::JetBrainsLineColumnFlags), | ||
| ); | ||
|
|
||
| assert_eq!( | ||
| args, | ||
| vec![ | ||
| "--line".to_string(), | ||
| "33".to_string(), | ||
| "--column".to_string(), | ||
| "7".to_string(), | ||
| "/tmp/project/src/App.tsx".to_string(), | ||
| ] | ||
| ); | ||
| } | ||
|
|
||
| #[test] | ||
| fn falls_back_to_plain_path_for_unknown_targets() { | ||
| let args = build_launch_args( | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.