-
Notifications
You must be signed in to change notification settings - Fork 8.6k
Enable Copy As Path/Paste with Path Translation in *nix profiles #19037
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
base: main
Are you sure you want to change the base?
Enable Copy As Path/Paste with Path Translation in *nix profiles #19037
Conversation
@@ -1441,6 +1443,24 @@ namespace winrt::Microsoft::Terminal::Control::implementation | |||
using namespace ::Microsoft::Console::Utils; | |||
|
|||
auto filtered = FilterStringForPaste(hstr, CarriageReturnNewline | ControlCodes); | |||
std::filesystem::path path{ filtered }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why wrap it in a path
first?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess I didn't want to blindly send all text to the translation routine. If we don't have a path, it doesnt make sense to even try to translate it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I'm reading your code correctly, if you replace all mentions of the path
variable with filtered
, the code will do the exact same it does now. But it would avoid making a redundant copy of the string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can remove the path piece
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the translation routine does do some checks that it is looking at a path
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was being over cautious I suppose.
@@ -90,7 +90,7 @@ static Microsoft::Console::TSF::Handle& GetTSFHandle() | |||
|
|||
namespace winrt::Microsoft::Terminal::Control::implementation | |||
{ | |||
static void _translatePathInPlace(std::wstring& fullPath, PathTranslationStyle translationStyle) | |||
void TermControl::_translatePathInPlace(std::wstring& fullPath, PathTranslationStyle translationStyle) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regarding your question in the issue, you can put helpers here:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you want me to move this or is what I did here ok?
…ks if its looking at a path
Summary of the Pull Request
Copy as Path / Paste with PathTranslation for *nix profiles in Terminal.
References and Relevant Issues
#18544
Detailed Description of the Pull Request / Additional comments
Path translation for drag and drop is already a thing. This pull request takes it one step further and enables Copy As Path on a file/directory and then pasting in terminal. If the profile has a PathTranslationStyle configured the path will be translated before paste.
Validation Steps Performed
This was validated to work on my machine.
PR Checklist