diff --git a/src/CalcViewModel/StandardCalculatorViewModel.cpp b/src/CalcViewModel/StandardCalculatorViewModel.cpp index 26c05408..48ed3a9b 100644 --- a/src/CalcViewModel/StandardCalculatorViewModel.cpp +++ b/src/CalcViewModel/StandardCalculatorViewModel.cpp @@ -355,24 +355,25 @@ void StandardCalculatorViewModel::SetTokens(_Inout_ shared_ptrSize) { 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->IsTokenEditable = isEditable; - existingItem->CommandIndex = expressionToken->CommandIndex; + existingItem->CommandIndex = 0; } else { + auto expressionToken = ref new DisplayExpressionToken(currentTokenString, i, isEditable, type); m_ExpressionTokens->InsertAt(i, expressionToken); } } else { + auto expressionToken = ref new DisplayExpressionToken(currentTokenString, i, isEditable, type); m_ExpressionTokens->Append(expressionToken); } }