Skip to content
Open
Show file tree
Hide file tree
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
37 changes: 18 additions & 19 deletions PhpStorm Protocol (Win)/run_editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,29 +78,13 @@ function configureToolboxSettings(settings) {
var fileCollection = folder.SubFolders;


var maxMajor = 0,
maxMinor = 0,
maxPatch = 0,
maxVersionFolder = "";
var maxVersionFolder = "0";
// Traverse through the fileCollection using the FOR loop
// read the maximum version from toolbox filesystem
for (var objEnum = new Enumerator(fileCollection); !objEnum.atEnd(); objEnum.moveNext()) {
var folderObject = ( objEnum.item() );
if (folderObject.Name.lastIndexOf('plugins') === -1) {
var versionMatch = /(\d+)\.(\d+)\.(\d+)/.exec(folderObject.Name),
major = parseInt(versionMatch[ 1 ]),
minor = parseInt(versionMatch[ 2 ]),
patch = parseInt(versionMatch[ 3 ]);
if (maxMajor === 0 || maxMajor <= major) {
maxMajor = major;
if (maxMinor === 0 || maxMinor <= minor) {
maxMinor = minor;
if (maxPatch === 0 || maxPatch <= patch) {
maxPatch = patch;
maxVersionFolder = folderObject.Name;
}
}
}
if (folderObject.Name.lastIndexOf('plugins') === -1 && compareVersion(folderObject.Name, maxVersionFolder) > 0 ){
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please pay attention to code style.

maxVersionFolder = folderObject.Name;
}
}

Expand All @@ -113,4 +97,19 @@ function configureToolboxSettings(settings) {
eval('var productVersion = ' + content + ';');
settings.window_title = 'PhpStorm ' + productVersion.version;
editor = '"' + toolboxDirectory + settings.folder_name + '\\' + productVersion.launch[ 0 ].launcherPath.replace(/\//g, '\\') + '"';
}

function compareVersion(v1, v2) {
if (typeof v1 !== 'string') return false;
if (typeof v2 !== 'string') return false;
v1 = v1.split('.');
v2 = v2.split('.');
const k = Math.min(v1.length, v2.length);
for (let i = 0; i < k; ++ i) {
v1[i] = parseInt(v1[i], 10);
v2[i] = parseInt(v2[i], 10);
if (v1[i] > v2[i]) return 1;
if (v1[i] < v2[i]) return -1;
}
return v1.length == v2.length ? 0: (v1.length < v2.length ? -1 : 1);
}
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,7 @@ Installing on Windows
7. delete cloned folder

#### Working under another path?
You can make use of the [project alias settings](/PhpStorm Protocol (Win)/run_editor.js#L11-L14) in case you are working under a network share or Vagrant.
* You can make use of the [project alias settings](PhpStorm%20Protocol%20(Win)/run_editor.js#L14-L17) in case you are working under a network share or Vagrant.

* If you're using the JetBrains Toolbox, you're only need to set the [toolBoxActive](PhpStorm%20Protocol%20(Win)/run_editor.js#L2-L3) flag to ```true``` and no other settings needs to be configured, because all settings will read automatically