Bug 533379 - Only add space when appropriate
Only strings starting with "operator" should be subject to the space addition.
Change-Id: I690695e7c3385e0d4e64ddd4cbe470a20cf788d6
Signed-off-by: Torbjörn Svensson <torbjorn.svensson@st.com>
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchUtil.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchUtil.java
index 43e5bd8..218d8a6 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchUtil.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchUtil.java
@@ -7,6 +7,7 @@
*
* Contributors:
* Andrew Niefer (Rational Software) - initial implementation
+ * Torbjörn Svensson (STMicroelectronics) - bug #533379
*******************************************************************************/
package org.eclipse.cdt.internal.ui.search;
@@ -92,9 +93,11 @@
*/
public static String adjustSearchStringForOperators(String searchStr) {
int operatorIndex = searchStr.indexOf("operator"); //$NON-NLS-1$
- int operatorCharIndex = operatorIndex + 8; // "operator" is 8 characters
- if (operatorCharIndex < searchStr.length() && isOperatorChar(searchStr.charAt(operatorCharIndex))) {
- searchStr = searchStr.substring(0, operatorCharIndex) + ' ' + searchStr.substring(operatorCharIndex);
+ if (operatorIndex >= 0) { // Only do this if string actually contains "operator"
+ int operatorCharIndex = operatorIndex + 8; // "operator" is 8 characters
+ if (operatorCharIndex < searchStr.length() && isOperatorChar(searchStr.charAt(operatorCharIndex))) {
+ searchStr = searchStr.substring(0, operatorCharIndex) + ' ' + searchStr.substring(operatorCharIndex);
+ }
}
return searchStr;
}