Fix issues with opening links and files using WSL
- PR Description
This PR fixes to issues with the current implementation of the OSConfig for WSL:
File explorer When using the file explorer from WSL, for instance by pressing "o" in the "Files" menu, the explorer always opens on the default landing page. This is caused by the filepath being expressed in WSL format instead of the expected Windows format. For instance:
- "/home/myuser/path/to/my/file" should be "\wsl$\MyDistroName\home\myuser\path\to\my\file"
- "/mnt/c/path/to/my/file" should be "C:\path\to\my\file"
There's a utility to do that in WSL, wslpath. We use it in the Open to format the filename before passing it to the Powershell command
Link URLs Opening links containing ampersands inside lazygit (a pull-request creation page in BitBucket Server, for instance) returns the following Powershell error:
The ampersand (&) character is not allowed. The & operator is reserved for future use; wrap an ampersand in double quotation marks ("&") to pass it as part of a string.
We fix it by enclosing the URL in single quotes.
Notes on this PR This is my first PR on this repo, please tell me if something is needed. I read the contributing guide. The OS-specific logic doesn't appear to be tested in integration and unit tests, so I didn't add tests.
- Please check if the PR fulfills these requirements
- [x] Cheatsheets are up-to-date (run
go generate ./...) - [x] Code has been formatted (see here)
- [ ] Tests have been added/updated (see here for the integration test guide)
- [ ] Text is internationalised (see here)
- [ ] If a new UserConfig entry was added, make sure it can be hot-reloaded (see here)
- [ ] Docs have been updated if necessary
- [x] You've read through your own file changes for silly mistakes etc
As an alternative, we could default to using xdg-open for all Linux systems, and refer WSL users to wsl-open.
@jesseduffield Is something wrong with the checks? They don't seem to run.
This PR will fix #3843
@jesseduffield Is something wrong with the checks? They don't seem to run.
First time contributors have to have their changes approved manually before the CI runs them.
Do I still need to do something to merge this PR?
@jesseduffield can we merge this PR? I don't think I have sufficient rights to do it myself. Many thanks!
Since Jesse approved these already, I'll just merge. Thanks for the contribution!