Skip to content

fixed use wsl feature (issue#509) #510

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

Merged
merged 7 commits into from
Feb 22, 2020
Merged

fixed use wsl feature (issue#509) #510

merged 7 commits into from
Feb 22, 2020

Conversation

LNKLEO
Copy link
Contributor

@LNKLEO LNKLEO commented Feb 13, 2020

convert path wsl after full path constructed
resolve problem cased by wslpath conversion

leetCodeRootPathInWsl no longer used
getLeetCodeRootPath function removed since it has only one reference after the bug fixed

#509

convert path wsl after full path constructed
leetCodeRootPathInWsl no longer used
getLeetCodeRootPath function removed since it has only one reference after the bug fixed
add missing signature
@lgtm-com
Copy link

lgtm-com bot commented Feb 13, 2020

This pull request introduces 1 alert when merging f3ad33f into 1c4a39e - view on LGTM.com

new alerts:

  • 1 for Yield in non-generator function

this.leetCodeRootPathInWsl = `${await wsl.toWslPath(this.leetCodeRootPath)}`;
}
return `${this.leetCodeRootPathInWsl}`;
return `${yield wsl.toWslPath(`"${path.join(yield`"${this.leetCodeRootPath}"`, "bin", "leetcode")}"`)}`;
Copy link
Member

Choose a reason for hiding this comment

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

No need to have yield here


public async getLeetCodeBinaryPath(): Promise<string> { // wrapped by ""
return `"${path.join(await this.getLeetCodeRootPath(), "bin", "leetcode")}"`;
return `"${path.join(yield`"${this.leetCodeRootPath}"`, "bin", "leetcode")}"`;
Copy link
Member

Choose a reason for hiding this comment

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

No need to have yield here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Orz
i'm not too much familiar with ts, maybe you should take over this fix if i keep failed the build

patch to solve wslpath fail when path not exists
@LNKLEO
Copy link
Contributor Author

LNKLEO commented Feb 13, 2020

when open new problem, wslpath conversion to windows fails as the target path under wsl doesn't exists yet, I tried fixed this and append to this same PR

@jdneo
Copy link
Member

jdneo commented Feb 14, 2020

Thank you @LinkeyLeo,

Sorry I have no Windows machine right now (it's in my office, and given the current situation, It's not easy to get it).

Could you please help me to understand the change? You have mentioned:

when open new problem, wslpath conversion to windows fails as the target path under wsl doesn't exists yet

What's the path you mentioned here?

@LNKLEO
Copy link
Contributor Author

LNKLEO commented Feb 14, 2020

Thank you @LinkeyLeo,

Sorry I have no Windows machine right now (it's in my office, and given the current situation, It's not easy to get it).

Could you please help me to understand the change? You have mentioned:

when open new problem, wslpath conversion to windows fails as the target path under wsl doesn't exists yet

What's the path you mentioned here?

the workflow for open problem for coding is looks like following:
1.fetchting problem
2.parsing problem title etc.
3.create new file with default codes
4.open code file and problem description in vscode

in step 3, we need to create a new source file for writing default codes, due to using node under wsl, the target file path reported by node is a wsl path, but the extension host is running under windows and need a windows path for creating and open the file, thus we need wslpath to convert the path, then the problem appeared.

wslpath will finish the path conversion only if the path is valid and the path is exists, or it rise a path doesn't exist error and won't do the path conversion.

considering other path may need to be conversion and have the same problem in the future, I fixed this problem by modified toWinPath function, making it only process the prefix of whole path and manually reconstruct the complete path

Copy link
Member

@jdneo jdneo left a comment

Choose a reason for hiding this comment

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

@LinkeyLeo My apologize for the late reply, sorry!

The PR looks good to me overall. Just one question, when will the path does not start with "\\mnt\\". we have this: return (await executeCommand("wsl", ["wslpath", "-w", "/"])).trim() + path;

Could you explain more about this?

Thanks.

@LNKLEO
Copy link
Contributor Author

LNKLEO commented Feb 21, 2020

@jdneo

i divide wsl paths into two parts, mounted drive root from windows which located in /mnt/ and other path located in / except /mnt/

for the after ones, we need to map /{WSL PATH} to \wsl${distor name}{WSL PATH}
actually, simply use "wsl wslpath -w {WSL PATH}" would work too, but that need to replace \ with / in path manually first.

Copy link
Member

@jdneo jdneo left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@jdneo jdneo added this to the 0.16.1 milestone Feb 22, 2020
@jdneo jdneo merged commit d7e4c10 into LeetCode-OpenSource:master Feb 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants