Skip to content

Commit

Permalink
[CORRECTIVE] Fix expression editor messing up expression when overwri…
Browse files Browse the repository at this point in the history
…ting pre-existing value or a section of the value. Should fix issue #108.
  • Loading branch information
hagantsa committed Jul 3, 2024
1 parent 255be9d commit 8fd2ee3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
7 changes: 4 additions & 3 deletions editors/ComponentEditor/common/MasterExpressionEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ void MasterExpressionEditor::finishEditingCurrentWord()
if (shouldChangeTerm)
{
expression_ = replaceNthWordWith(currentWordIndex(), expression_, finishedWord);

if (currentWordIsUniqueParameterName())
{
complete(nameCompleter_->currentIndex());
Expand Down Expand Up @@ -118,7 +118,7 @@ void MasterExpressionEditor::handleKeyPressEvent(QKeyEvent* keyEvent)
{
if (hasSelection())
{
removeSelectionInExpression();
replaceSelectionInExpression(keyEvent);
}
else if (removesOperatorBeforeWord(keyEvent))
{
Expand Down Expand Up @@ -479,7 +479,7 @@ bool MasterExpressionEditor::keyMovesCursor(QKeyEvent* keyEvent) const
//-----------------------------------------------------------------------------
// Function: ExpressionLineEditor::removeSelectionInExpression()
//-----------------------------------------------------------------------------
void MasterExpressionEditor::removeSelectionInExpression()
void MasterExpressionEditor::replaceSelectionInExpression(QKeyEvent* keyEvent)
{
QString selectedText = getSelectedText();

Expand All @@ -490,6 +490,7 @@ void MasterExpressionEditor::removeSelectionInExpression()

int firstTermPos = indexOfNthWord(firstWord, expression_);
expression_.remove(expression_.indexOf(selectedText, firstTermPos), selectedText.length());
expression_.insert(firstTermPos, keyEvent->text()); // Don't just remove selection, also insert whatever was typed.
}

//-----------------------------------------------------------------------------
Expand Down
6 changes: 4 additions & 2 deletions editors/ComponentEditor/common/MasterExpressionEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -418,9 +418,11 @@ class MasterExpressionEditor
bool keyMovesCursor(QKeyEvent* keyEvent) const;

/*!
* Removes the current selection in the underlying expression.
* Replaces the current selection in the underlying expression with whatever was typed.
*
* @param [in] keyEvent The event to check.
*/
void removeSelectionInExpression();
void replaceSelectionInExpression(QKeyEvent* keyEvent);

/*!
* Replaces the references in the underlying expression with the referenced names.
Expand Down
14 changes: 7 additions & 7 deletions version.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@
#ifndef VERSIONNO__H
#define VERSIONNO__H

#define VERSION_FULL 3.13.449.0
#define VERSION_FULL 3.13.474.0

#define VERSION_BASEYEAR 0
#define VERSION_DATE "2024-07-03"
#define VERSION_TIME "09:59:59"
#define VERSION_TIME "16:41:00"

#define VERSION_MAJOR 3
#define VERSION_MINOR 13
#define VERSION_BUILDNO 449
#define VERSION_BUILDNO 474
#define VERSION_EXTEND 0

#define VERSION_FILE 3,13,449,0
#define VERSION_PRODUCT 3,13,449,0
#define VERSION_FILESTR "3,13,449,0"
#define VERSION_PRODUCTSTR "3,13,449,0"
#define VERSION_FILE 3,13,474,0
#define VERSION_PRODUCT 3,13,474,0
#define VERSION_FILESTR "3,13,474,0"
#define VERSION_PRODUCTSTR "3,13,474,0"

#endif

0 comments on commit 8fd2ee3

Please sign in to comment.