mirror of
https://github.com/Microsoft/calculator.git
synced 2025-08-22 06:13:14 -07:00
create DisplayExpressionToken only when necessary + fix the failed unit test
This commit is contained in:
parent
48fd72525b
commit
ff550053da
1 changed files with 4 additions and 3 deletions
|
@ -355,24 +355,25 @@ void StandardCalculatorViewModel::SetTokens(_Inout_ shared_ptr<CalculatorVector<
|
||||||
}
|
}
|
||||||
|
|
||||||
auto currentTokenString = ref new String(currentToken.first.c_str());
|
auto currentTokenString = ref new String(currentToken.first.c_str());
|
||||||
auto expressionToken = ref new DisplayExpressionToken(currentTokenString, i, isEditable, type);
|
|
||||||
if (i < m_ExpressionTokens->Size)
|
if (i < m_ExpressionTokens->Size)
|
||||||
{
|
{
|
||||||
auto existingItem = m_ExpressionTokens->GetAt(i);
|
auto existingItem = m_ExpressionTokens->GetAt(i);
|
||||||
if (type == existingItem->Type && expressionToken->Token->Equals(currentTokenString))
|
if (type == existingItem->Type && existingItem->Token->Equals(currentTokenString))
|
||||||
{
|
{
|
||||||
existingItem->TokenPosition = i;
|
existingItem->TokenPosition = i;
|
||||||
existingItem->IsTokenEditable = isEditable;
|
existingItem->IsTokenEditable = isEditable;
|
||||||
existingItem->CommandIndex = expressionToken->CommandIndex;
|
existingItem->CommandIndex = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
auto expressionToken = ref new DisplayExpressionToken(currentTokenString, i, isEditable, type);
|
||||||
m_ExpressionTokens->InsertAt(i, expressionToken);
|
m_ExpressionTokens->InsertAt(i, expressionToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
auto expressionToken = ref new DisplayExpressionToken(currentTokenString, i, isEditable, type);
|
||||||
m_ExpressionTokens->Append(expressionToken);
|
m_ExpressionTokens->Append(expressionToken);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue