-
Notifications
You must be signed in to change notification settings - Fork 8.5k
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
Add options to enable and disable read only mode #14995
Add options to enable and disable read only mode #14995
Conversation
@microsoft-github-policy-service agree |
@zadjii-msft Not sure why PR is failing, unrelated to my code change? |
This will be fixed #15002. You can merge with |
@lhecker Made changes on the back of your review - Has been pushed and is building now. Merged latest main into branch, but now getting an error to do with my code formatting - resolving that now. |
@lhecker @zadjii-msft Whats the next steps? Is there something I need to do to get this progressed? |
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.
Honestly, just the one question. The rest looks great to me!
void TerminalTab::SetPaneReadOnly(const bool readOnlyState) | ||
{ | ||
auto hasReadOnly = false; | ||
auto allReadOnly = true; | ||
_activePane->WalkTree([&](const auto& p) { | ||
if (const auto& control{ p->GetTerminalControl() }) | ||
{ | ||
hasReadOnly |= control.ReadOnly(); | ||
allReadOnly &= control.ReadOnly(); | ||
} | ||
}); | ||
_activePane->WalkTree([&](const auto& p) { | ||
if (const auto& control{ p->GetTerminalControl() }) | ||
{ | ||
// If all controls have the same read only state then just disable | ||
if (allReadOnly || !hasReadOnly) | ||
{ | ||
control.SetReadOnly(readOnlyState); | ||
} | ||
// otherwise set to all read only. | ||
else if (!control.ReadOnly()) | ||
{ | ||
control.SetReadOnly(readOnlyState); | ||
} | ||
} | ||
}); | ||
} | ||
|
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.
Is all of this logic necessary? Why wouldn't this just be a
WalkTree([&](const auto& p){
if (const auto& control{ p->GetTerminalControl() })
{
control.SetReadOnly(readOnlyState);
}
});
Maybe I just haven't had enough coffee yet
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.
Ill push my changes for this, I dont see any issue when ive tested it.
Co-authored-by: Mike Griese <[email protected]>
…nkid/terminal into dev/swinkid/readonly-actions
This reverts commit 1670299.
This reverts commit 69787f0.
This reverts commit 8a8590a.
@zadjii-msft If i take your changes about the tree into account it fails the tests - they must be related to something but can't figure out what. I've tested the changes but it works as it should. |
That's w a c k y but okay! Thanks for confirming |
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.
Hey, thanks so much for doing this!
You're welcome - this is why I love opensource.. helping fellow developers out! |
## Summary of the Pull Request PR adds functionality to enable or disable readOnly mode within panes. This functionality is different to toggling as if you call the same functionality twice, it will not toggle between states. ## References and Relevant Issues - Closes #14415 - Documentation MicrosoftDocs/terminal#645 ## Validation Steps Performed - Checked readOnly is enabled when command triggered - Checked readOnly is enabled when command triggered while read only already enabled - Checked readOnly is disabled when command triggered while read only is enabled - Checked readOnly stays disabled when command triggered while read only is disabled - Checked above with multiple tabs and split panes ## PR Checklist - [ ] Closes #14415 - [X] Tests added/passed - [x] Documentation updated - If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/terminal) and link it here: MicrosoftDocs/terminal#645 - [X] Schema updated (if necessary) --------- Co-authored-by: Mike Griese <[email protected]> (cherry picked from commit 2acdc9d) Service-Card-Id: 89002012 Service-Version: 1.17
Summary of the Pull Request
PR adds functionality to enable or disable readOnly mode within panes. This functionality is different to toggling as if you call the same functionality twice, it will not toggle between states.
References and Relevant Issues
Validation Steps Performed
PR Checklist