Windows 10 - No error but file is not open
Snowbaha opened this issue · 23 comments
Hello,
I am running the script with Windows 10 (FR) 64 bits and PHPstorm 2017.
I adapt the reg with :
[HKEY_CLASSES_ROOT\phpstorm\shell\open\command] @="wscript \"C:\\Program Files (x86)\\PhpStorm Protocol (Win)\\run_editor.js\" \"%1\""
and the JS with :
var settings = {
// Set to 'true' (without quotes) if run on Windows 64bit. Set to 'false' (without quotes) otherwise.
x64: false,
// Set to folder name, where PhpStorm was installed to (e.g. 'PhpStorm')
folder_name: 'PhpStorm 2016.3',
// Set to window title (only text after dash sign), that you see, when switching to running PhpStorm instance
window_title: 'PhpStorm 2017.1.3',
// In case your file is mapped via a network share and paths do not match.
// eg. /var/www will can replaced with Y:/
projects_basepath: '',
projects_path_alias: ''
};
// dont change anything below this line, unless you know what youre doing
var url = WScript.Arguments(0),
match = /^phpstorm:\/\/open\?(url=file:\/\/|file=)(.+)&line=(\d+)$/.exec(url),
project = '',
editor = '"C:\\' + (settings.x64 ? 'Program Files (x86)' : 'Program Files') + '\\JetBrains\\' + settings.folder_name + '\\bin\\
>phpstorm.exe
"';
But It does not work and I have no errors :
Image demo : I clicked on the Controller file : https://vgy.me/OiVhlQ.png
Open with the script : https://vgy.me/jBi1Hk.png
...And nothing happen :(
Edit :
On my config.yml I wrote : ide: 'phpstorm://open?url=file://%%f&line=%%l'
Are you using the latest codebase (from master
branch) of this project? I'm asking because there were Windows 10 related fixes recently.
To be sure, I copied all the code there :
https://github.com/aik099/PhpStormProtocol/blob/master/PhpStorm%20Protocol%20(Win)/run_editor.js
So yes, it is the latest
I added my config.yml
Then I have no idea unfortunately. I know it worked in Windows 7, where I originally tested it upon and some fixes were applied to work on Windows 8 as well.
If you find out what causing it to malfunction, then PR would be welcome.
Ok, do you know how I can have a log or something to help me to know that is wrong?
No idea. Probably there are some methods on WScript.
object that can be used. The Google/MSDN would know better.
Same issue here, I had to align the url a bit:
phpstorm://open/?file={file}&line={line}
note the additional /
after open
@buddh4 , so if you change phpstorm://open?file={file}&line={line}
with phpstorm://open/?file={file}&line={line}
in code, that is building links for you (not this protocol listener project), then it works for you?
Yes, otherwise the regex does not match and the scripts exits without any errors
/^phpstorm:\/\/open\/\?(url=file:\/\/|file=)(.+)&line=(\d+)$/
@buddh4 , please post actual link you click on Windows (working and non-working ones). I want to see how the path with all slashes looks like in there.
Ha, it looks like change made in #25 replaced regex by making /
after open
a requirement. Before it wasn't needed at all. And now URL in README.md doesn't actually work :(
What if you use phpstorm://
link as in README.md (no /
after open
) and change regular expression in run_editor.js
file from /^phpstorm:\/\/open\/\?(url=file:\/\/|file=)(.+)&line=(\d+)$/
to /^phpstorm:\/\/open\/?\?(url=file:\/\/|file=)(.+)&line=(\d+)$/
(replaced open\/
with open\/?
)?
Will it work then as well?
for me the #25 is working on win 10 without doing any others edit
the only edit I made was about the exe path, because I'm using Jetbrains Toolbox
Sorry for the confusion, had to do some debugging before it worked and thought it was the regex, but there probably was another issue regarding my url, now it works also without the slash.
My actual problem was, that if I set the x64: true
it searches in Program Files (x86)
, but I have a 64 bit installation in Program Files
. I also had to change from phpstorm.exe
to phpstorm64.exe
So in my case the following path is valid:
"C:\\Program Files\\JetBrains\\' + settings.folder_name + '\\bin\\phpstorm64.exe"'
Nice to know. Then I'm closing this because changing binary path in config solves the problem.
Hello,
I did the change with
(replaced open\/ with open\/?)
match = /^phpstorm:\/\/open\/?\?(url=file:\/\/|file=)(.+)&line=(\d+)$/.exec(url),
in the run_editor.js
And I adapt the config.yml of Symfony 3 :
ide: 'phpstorm://open/?url=file://%%f&line=%%l'
Error : File is not found
Is it the same issue or another one?
I don't know, I can't easily translate French text on the images 😉
Oups sorry :
"Line : 55"
Char (not sure what it is?) : 2
Error : File is not found
But May I have to create new issue?
Here the full JS :
var settings = {
// Set to 'true' (without quotes) if run on Windows 64bit. Set to 'false' (without quotes) otherwise.
x64: false,
// Set to folder name, where PhpStorm was installed to (e.g. 'PhpStorm')
folder_name: 'PhpStorm 2016.3',
// Set to window title (only text after dash sign), that you see, when switching to running PhpStorm instance
window_title: 'PhpStorm 2017.2.1',
// In case your file is mapped via a network share and paths do not match.
// eg. /var/www will can replaced with Y:/
projects_basepath: '',
projects_path_alias: ''
};
// don't change anything below this line, unless you know what you're doing
var url = WScript.Arguments(0),
match = /^phpstorm:\/\/open\/?\?(url=file:\/\/|file=)(.+)&line=(\d+)$/.exec(url),
project = '',
editor = '"C:\\' + (settings.x64 ? 'Program Files (x86)' : 'Program Files') + '\\JetBrains\\' + settings.folder_name + '\\bin\\phpstorm.exe"';
if (match) {
var shell = new ActiveXObject('WScript.Shell'),
file_system = new ActiveXObject('Scripting.FileSystemObject'),
file = decodeURIComponent(match[2]).replace(/\+/g, ' '),
search_path = file.replace(/\//g, '\\');
if (settings.projects_basepath != '' && settings.projects_path_alias != '') {
file = file.replace(new RegExp('^' + settings.projects_basepath), settings.projects_path_alias);
}
while (search_path.lastIndexOf('\\') != -1) {
search_path = search_path.substring(0, search_path.lastIndexOf('\\'));
if(file_system.FileExists(search_path+'\\.idea\\.name')) {
project = search_path;
break;
}
}
if (project != '') {
editor += ' "%project%"';
}
editor += ' --line %line% "%file%"';
var command = editor.replace(/%line%/g, match[3])
.replace(/%file%/g, file)
.replace(/%project%/g, project)
.replace(/\//g, '\\');
shell.Exec(command);
shell.AppActivate(settings.window_title);
}
I have no idea. Probably something in regexp needs to be escaped differently.
Ok not easy to find indeed :(
Perhaps you have to align the editor
path. Try setting the path directly
editor = "<path to my phpstorm.exe>";
instead of
editor = '"C:\\' + (settings.x64 ? 'Program Files (x86)' : 'Program Files') + '\\JetBrains\\' + settings.folder_name + '\\bin\\phpstorm.exe"';
Ohhh nice ! It is working ^^
Thanks !
editor = '"C:\\Program Files (x86)\\JetBrains\\' + settings.folder_name + '\\bin\\phpstorm.exe"';
Ok i will Try, I found the right editor path ^^ the x64 was inversed