Skip to content

Commit

Permalink
rename
Browse files Browse the repository at this point in the history
  • Loading branch information
Edvard Fonsell committed Dec 14, 2012
1 parent 650a102 commit a2db1c7
Showing 1 changed file with 4 additions and 4 deletions.
Expand Up @@ -52,15 +52,15 @@ public static Region calculate(ParsedString argument, int cursorOffsetInDocument
// unclosed variable at the end of the argument, replace unclosed variable
return new Region(startPosInDocument, argument.getArgEndCharPos() - startPosInDocument);
}
int nextStartPos = getNextStartPos(closePos, nextDollarPos, nextAtPos);
int endPos = getEndPos(closePos, nextDollarPos, nextAtPos);
boolean cursorAtVariableStart = cursorOffset == startPos + 1 || cursorOffset == startPos + 2;
boolean isClosedVariable = closePos == nextStartPos - 1;
boolean isClosedVariable = closePos == endPos - 1;
if (cursorAtVariableStart && !isClosedVariable) {
// "foo$<cursor is here>{bar" replace only ${ or @{
return new Region(startPosInDocument, 2);
}
// replace variable (may be followed by other variables)
return new Region(startPosInDocument, nextStartPos - startPos);
return new Region(startPosInDocument, endPos - startPos);
}

private static int getStartPos(String arg, int cursorOffset) {
Expand All @@ -69,7 +69,7 @@ private static int getStartPos(String arg, int cursorOffset) {
return Math.max(dollarPos, atPos);
}

private static int getNextStartPos(int closePos, int nextDollarPos, int nextAtPos) {
private static int getEndPos(int closePos, int nextDollarPos, int nextAtPos) {
int minPositive = minPositive(closePos, minPositive(nextDollarPos, nextAtPos));
if (closePos == minPositive) {
return closePos + 1;
Expand Down

0 comments on commit a2db1c7

Please sign in to comment.