Author: vrubezhny
Date: 2012-04-13 10:23:41 -0400 (Fri, 13 Apr 2012)
New Revision: 40179
Modified:
trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/ca/ELProposalProcessor.java
Log:
JBIDE-11492
When inserting methods with parameters, CA sets cursor incorrectly
Issue is fixed.
Modified:
trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/ca/ELProposalProcessor.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/ca/ELProposalProcessor.java 2012-04-13
14:04:18 UTC (rev 40178)
+++
trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/ca/ELProposalProcessor.java 2012-04-13
14:23:41 UTC (rev 40179)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007-2011 Red Hat, Inc.
+ * Copyright (c) 2007-2012 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
@@ -146,7 +146,7 @@
* @see
org.eclipse.jface.text.contentassist.ICompletionProposal#getSelection(IDocument)
*/
public Point getSelection(IDocument document) {
- return new Point(fNewPosition, 0);
+ return new Point(getCursorPosition(), 0);
}
/*
@@ -447,7 +447,22 @@
* Return cursor position of proposal replacement string.
*/
public int getCursorPosition() {
- return fNewPosition;
+ int cursorPosition = -1;
+
+ int openingQuoteInReplacement = fString.lastIndexOf('(');
+ int closingQuoteInReplacement = fString.lastIndexOf(')');
+ int openingQuoteInDisplay = fDisplayString.lastIndexOf('(');
+ int closingQuoteInDisplay = fDisplayString.lastIndexOf(')');
+
+ if (openingQuoteInReplacement != -1
+ && closingQuoteInReplacement != -1
+ && openingQuoteInDisplay != -1
+ && closingQuoteInDisplay != -1
+ && (closingQuoteInReplacement - openingQuoteInReplacement) !=
(closingQuoteInDisplay - openingQuoteInDisplay)) {
+ cursorPosition = openingQuoteInReplacement + 1;
+ }
+
+ return cursorPosition > -1 ? fOffset + cursorPosition : fNewPosition;
}
/**
Show replies by date