Skip to content

Commit

Permalink
[CORRECTIVE] Fix overwriting selection in expressions. Follow up to 8…
Browse files Browse the repository at this point in the history
  • Loading branch information
hagantsa committed Jul 29, 2024
1 parent 581c6e9 commit 5a09e82
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 9 deletions.
8 changes: 8 additions & 0 deletions editors/ComponentEditor/common/ExpressionEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,3 +309,11 @@ int ExpressionEditor::getSelectionLastWord() const
{
return toPlainText().left(textCursor().selectionEnd()).count(WORD_DELIMITER);
}

//-----------------------------------------------------------------------------
// Function: ExpressionEditor::getSelectionStartIndex()
//-----------------------------------------------------------------------------
int ExpressionEditor::getSelectionStartIndex() const
{
return textCursor().selectionStart();
}
7 changes: 7 additions & 0 deletions editors/ComponentEditor/common/ExpressionEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,13 @@ private slots:
* @return Length of the last word in the selection.
*/
int getSelectionLastWord() const final;

/*!
* Get the start index of the selection.
*
* @return The start index of the current selection.
*/
int getSelectionStartIndex() const final;
};

#endif // EXPRESSIONEDITOR_H
8 changes: 8 additions & 0 deletions editors/ComponentEditor/common/ExpressionLineEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,3 +240,11 @@ int ExpressionLineEditor::getSelectionLastWord() const
{
return text().left(selectionEnd()).count(WORD_DELIMITER);
}

//-----------------------------------------------------------------------------
// Function: ExpressionLineEditor::getSelectionStartIndex()
//-----------------------------------------------------------------------------
int ExpressionLineEditor::getSelectionStartIndex() const
{
return selectionStart();
}
7 changes: 7 additions & 0 deletions editors/ComponentEditor/common/ExpressionLineEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,13 @@ private slots:
* @return Length of the last word in the selection.
*/
int getSelectionLastWord() const final;

/*!
* Get the start index of the selection.
*
* @return The start index of the current selection.
*/
int getSelectionStartIndex() const final;
};

#endif // EXPRESSIONLINEEDITOR_H
2 changes: 1 addition & 1 deletion editors/ComponentEditor/common/MasterExpressionEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ void MasterExpressionEditor::replaceSelectionInExpression(QKeyEvent* keyEvent)

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.
expression_.insert(getSelectionStartIndex(), keyEvent->text()); // Don't just remove selection, also insert whatever was typed.
}

//-----------------------------------------------------------------------------
Expand Down
7 changes: 7 additions & 0 deletions editors/ComponentEditor/common/MasterExpressionEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,13 @@ class MasterExpressionEditor
*/
virtual int getSelectionLastWord() const = 0;

/*!
* Get the start index of the selection.
*
* @return The start index of the current selection.
*/
virtual int getSelectionStartIndex() const = 0;

/*!
* Checks if the editing would change text in the middle of a referencing term.
*
Expand Down
16 changes: 8 additions & 8 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.519.0
#define VERSION_FULL 3.13.534.0

#define VERSION_BASEYEAR 0
#define VERSION_DATE "2024-07-15"
#define VERSION_TIME "17:24:58"
#define VERSION_DATE "2024-07-29"
#define VERSION_TIME "13:53:28"

#define VERSION_MAJOR 3
#define VERSION_MINOR 13
#define VERSION_BUILDNO 519
#define VERSION_BUILDNO 534
#define VERSION_EXTEND 0

#define VERSION_FILE 3,13,519,0
#define VERSION_PRODUCT 3,13,519,0
#define VERSION_FILESTR "3,13,519,0"
#define VERSION_PRODUCTSTR "3,13,519,0"
#define VERSION_FILE 3,13,534,0
#define VERSION_PRODUCT 3,13,534,0
#define VERSION_FILESTR "3,13,534,0"
#define VERSION_PRODUCTSTR "3,13,534,0"

#endif

0 comments on commit 5a09e82

Please sign in to comment.