pr nits from miniksa
This commit is contained in:
parent
a3ac32ab25
commit
abb847b4c7
|
@ -182,7 +182,6 @@ Pane::BuildStartupState Pane::BuildStartupActions(uint32_t currentId, uint32_t n
|
|||
if (_firstChild->_IsLeaf() && _secondChild->_IsLeaf())
|
||||
{
|
||||
auto actionAndArgs = buildSplitPane(_secondChild);
|
||||
|
||||
std::optional<uint32_t> focusedPaneId = std::nullopt;
|
||||
if (_firstChild->_lastActive)
|
||||
{
|
||||
|
@ -2721,35 +2720,38 @@ Pane::SnapSizeResult Pane::_CalcSnappedDimension(const bool widthOrHeight, const
|
|||
void Pane::_AdvanceSnappedDimension(const bool widthOrHeight, LayoutSizeNode& sizeNode) const
|
||||
{
|
||||
const auto& termControl{ _control.try_as<TermControl>() };
|
||||
if (_IsLeaf() && termControl)
|
||||
if (_IsLeaf())
|
||||
{
|
||||
// We're a leaf pane, so just add one more row or column (unless isMinimumSize
|
||||
// is true, see below).
|
||||
|
||||
if (sizeNode.isMinimumSize)
|
||||
if (termControl)
|
||||
{
|
||||
// If the node is of its minimum size, this size might not be snapped (it might
|
||||
// be, say, half a character, or fixed 10 pixels), so snap it upward. It might
|
||||
// however be already snapped, so add 1 to make sure it really increases
|
||||
// (not strictly necessary but to avoid surprises).
|
||||
sizeNode.size = _CalcSnappedDimension(widthOrHeight, sizeNode.size + 1).higher;
|
||||
// We're a leaf pane, so just add one more row or column (unless isMinimumSize
|
||||
// is true, see below).
|
||||
|
||||
if (sizeNode.isMinimumSize)
|
||||
{
|
||||
// If the node is of its minimum size, this size might not be snapped (it might
|
||||
// be, say, half a character, or fixed 10 pixels), so snap it upward. It might
|
||||
// however be already snapped, so add 1 to make sure it really increases
|
||||
// (not strictly necessary but to avoid surprises).
|
||||
sizeNode.size = _CalcSnappedDimension(widthOrHeight, sizeNode.size + 1).higher;
|
||||
}
|
||||
else
|
||||
{
|
||||
const auto cellSize = termControl.CharacterDimensions();
|
||||
sizeNode.size += widthOrHeight ? cellSize.Width : cellSize.Height;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
const auto cellSize = termControl.CharacterDimensions();
|
||||
sizeNode.size += widthOrHeight ? cellSize.Width : cellSize.Height;
|
||||
// If we're a leaf that didn't have a TermControl, then just increment
|
||||
// by one. We have to increment by _some_ value, because this is used in
|
||||
// a while() loop to find the next bigger size we can snap to. But since
|
||||
// a non-terminal control doesn't really care what size it's snapped to,
|
||||
// we can just say "one pixel larger is the next snap point"
|
||||
sizeNode.size += 1;
|
||||
}
|
||||
}
|
||||
else if (_IsLeaf())
|
||||
{
|
||||
// If we're a leaf that didn't have a TermControl, then just increment
|
||||
// by one. We have to increment by _some_ value, because this is used in
|
||||
// a while() loop to find the next bigger size we can snap to. But since
|
||||
// a non-terminal control doesn't really care what size it's snapped to,
|
||||
// we can just say "one pixel larger is the next snap point"
|
||||
sizeNode.size += 1;
|
||||
}
|
||||
else if (!_IsLeaf())
|
||||
else // !_IsLeaf()
|
||||
{
|
||||
// We're a parent pane, so we have to advance dimension of our children panes. In
|
||||
// fact, we advance only one child (chosen later) to keep the growth fine-grained.
|
||||
|
|
|
@ -1484,6 +1484,10 @@ namespace winrt::TerminalApp::implementation
|
|||
// - Returns true if this commandline is precisely an executable in
|
||||
// system32. We can use this to bypass the elevated state check, because
|
||||
// we're confident that executables in that path won't have been hijacked.
|
||||
// - TECHNICALLY a user can take ownership of a file in system32 and
|
||||
// replace it as the system administrator. You could say it's OK though
|
||||
// because you'd already have to have had admin rights to mess that
|
||||
// folder up or something.
|
||||
// - Will attempt to resolve environment strings.
|
||||
// - Will also manually allow commandlines as generated for the default WSL
|
||||
// distros.
|
||||
|
@ -1494,7 +1498,7 @@ namespace winrt::TerminalApp::implementation
|
|||
// - cmd.exe -> returns false
|
||||
// - C:\windows\system32\cmd.exe /k echo sneaky sneak -> returns false
|
||||
// - %SystemRoot%\System32\cmd.exe -> returns true
|
||||
// - %SystemRoot%\System32\wsl.exe -d <distroname> -> returns true
|
||||
// - %SystemRoot%\System32\wsl.exe -d <distro name> -> returns true
|
||||
static bool _isInSystem32(std::wstring_view commandLine)
|
||||
{
|
||||
// use C++11 magic statics to make sure we only do this once.
|
||||
|
@ -1523,6 +1527,9 @@ namespace winrt::TerminalApp::implementation
|
|||
{
|
||||
// Get the first part of the executable path
|
||||
const auto start = fullCommandlinePath.wstring().substr(0, systemDirectory.size());
|
||||
// Doing this as an ASCII only check might be wrong, but I'm
|
||||
// guessing if system32 isn't at X:\windows\system32... this isn't
|
||||
// the only thing that is going to be sad in Windows.
|
||||
const auto pathEquals = til::equals_insensitive_ascii(start, systemDirectory);
|
||||
if (pathEquals && std::filesystem::exists(fullCommandlinePath))
|
||||
{
|
||||
|
@ -1531,10 +1538,10 @@ namespace winrt::TerminalApp::implementation
|
|||
}
|
||||
|
||||
// Also, if the path is literally
|
||||
// %SystemRoot%\System32\wsl.exe -d <distroname>
|
||||
// %SystemRoot%\System32\wsl.exe -d <distro name>
|
||||
// then allow it.
|
||||
|
||||
// Stolen from _tryMangleStartingDirectoryForWSL
|
||||
// Largely stolen from _tryMangleStartingDirectoryForWSL in ConptyConnection.
|
||||
// Find the first space, quote or the end of the string -- we'll look
|
||||
// for wsl before that.
|
||||
const auto terminator{ commandLine.find_first_of(LR"(" )", 1) }; // look past the first character in case it starts with "
|
||||
|
@ -1559,7 +1566,9 @@ namespace winrt::TerminalApp::implementation
|
|||
}
|
||||
|
||||
// Get everything after the wsl.exe
|
||||
const auto arguments{ terminator == std::wstring_view::npos ? std::wstring_view{} : commandLine.substr(terminator + 1) };
|
||||
const auto arguments{ terminator == std::wstring_view::npos ?
|
||||
std::wstring_view{} :
|
||||
commandLine.substr(terminator + 1) };
|
||||
const auto dashD{ arguments.find(L"-d ") };
|
||||
|
||||
// If we found a "-d " IMMEDIATELY AFTER wsl.exe. If it wasn't
|
||||
|
@ -1661,6 +1670,7 @@ namespace winrt::TerminalApp::implementation
|
|||
tabImpl->UpdateTitle();
|
||||
}
|
||||
}
|
||||
// return false so we make sure to iterate on every leaf.
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
|
|
@ -109,11 +109,6 @@
|
|||
</TextBlock>
|
||||
</ContentDialog>
|
||||
|
||||
<!-- <ContentDialog x:Name="ApproveCommandlineWarning"
|
||||
x:Uid="ApproveCommandlineWarning"
|
||||
x:Load="False"
|
||||
DefaultButton="Primary" />-->
|
||||
|
||||
<local:CommandPalette x:Name="CommandPalette"
|
||||
Grid.Row="1"
|
||||
VerticalAlignment="Stretch"
|
||||
|
|
|
@ -522,6 +522,8 @@ namespace winrt::TerminalApp::implementation
|
|||
// Add a event handlers to the new panes' GotFocus event. When the pane
|
||||
// gains focus, we'll mark it as the new active pane.
|
||||
const auto& termControl{ control.try_as<TermControl>() };
|
||||
// _AttachEventHandlersToControl will immediately bail if the provided
|
||||
// control is null (READ: if the pane didn't have a TermControl)
|
||||
_AttachEventHandlersToControl(newPane->Id().value(), termControl);
|
||||
_AttachEventHandlersToPane(original);
|
||||
_AttachEventHandlersToPane(newPane);
|
||||
|
|
Loading…
Reference in a new issue