Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Path is converted to windows style when opening with external editor in win #15096

Merged
merged 3 commits into from
Mar 19, 2020
Merged
Changes from 1 commit
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
Next Next commit
On Wiindows Path is converted to windows style when opening with exte…
…rnal editor
  • Loading branch information
Nitesh Kumar committed Mar 19, 2020
commit f9f584eeb5150a28dc69d5b58a627ee68596c20d
9 changes: 8 additions & 1 deletion src/extensions/default/OpenWithExternalApplication/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,16 @@ define(function (require, exports, module) {

var extensionToExtApplicationMap = {};

function convertUnixPathToWindowsPath(path) {
if (brackets.platform === "win") {
path = path.split("/").join("\\");
Copy link
Contributor

@g-217 g-217 Mar 19, 2020

Choose a reason for hiding this comment

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

I think we should write

path = path.replace(/\//g, '\\');

Also since we are converting path to Windows, should we ensure first char is a drive letter?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

path = path.replace(///g, '\'); this don't work , tried it.

Other suggestion to check first char is a drive done,

Copy link
Contributor

Choose a reason for hiding this comment

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

Check this:
FileSystem.isAbsolutePath = function (fullPath) {
return (fullPath[0] === "/" || (fullPath[1] === ":" && fullPath[2] === "/"));
};

Copy link
Contributor

@g-217 g-217 Mar 19, 2020

Choose a reason for hiding this comment

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

Also checked, and this is working:

'C:/Users/gjha/Desktop/test.js'.replace(/\//g, '\\')
"C:\Users\gjha\Desktop\test.js"
'C:/Users/gjha/Desktop/test.js'.replace(RegExp('/','g'), '\\')
"C:\Users\gjha\Desktop\test.js"

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@jha-G made changes as above info.

}
return path;
}

function _openWithExternalApplication(event, path) {
_nodeDomain.exec("open", {
path: path,
path: convertUnixPathToWindowsPath(path),
app: extensionToExtApplicationMap[FileUtils.getFileExtension(path).toLowerCase()]
});
}
Expand Down