fixed PY-9466 Wrong current parameter highlighting for the very first parameter in finction

regression, added test
This commit is contained in:
Ekaterina Tuzova
2013-04-11 15:07:39 +04:00
parent 528f673f1c
commit 82303ad2b5
3 changed files with 13 additions and 4 deletions
@@ -178,7 +178,10 @@ public class PyParameterInfoHandler implements ParameterInfoHandler<PyArgumentLi
// highlight the next parameter to be filled
if (canOfferNext) {
int highlightIndex = Integer.MAX_VALUE; // initially beyond reason = no highlight
if (lastParamIndex < parameterList.size() - 1) { // lastParamIndex not at end, or no args
if (isArgsEmpty) {
highlightIndex = marked.getImplicitOffset(); // no args, highlight first (PY-3690)
}
else if (lastParamIndex < parameterList.size() - 1) { // lastParamIndex not at end, or no args
if (namedParameters.get(lastParamIndex).isPositionalContainer()) {
highlightIndex = lastParamIndex; // stick to *arg
}
@@ -186,9 +189,6 @@ public class PyParameterInfoHandler implements ParameterInfoHandler<PyArgumentLi
highlightIndex = lastParamIndex + 1; // highlight next
}
}
else if (isArgsEmpty) {
highlightIndex = marked.getImplicitOffset(); // no args, highlight first (PY-3690)
}
else if (lastParamIndex == parameterList.size() - 1) { // we're right after the end of param list
if (namedParameters.get(lastParamIndex).isPositionalContainer() || namedParameters.get(lastParamIndex).isKeywordContainer()) {
highlightIndex = lastParamIndex; // stick to *arg
+4
View File
@@ -0,0 +1,4 @@
def foo(a, b, c):
pass
foo(<arg1>)
@@ -375,6 +375,11 @@ public class PyParameterInfoTest extends LightMarkedTestCase {
feignCtrlP(marks.get("<arg4>").getTextOffset()).check("*arg, a=1, b=2", new String[]{"a=1, "});
}
public void testNoArgs() {
Map<String, PsiElement> marks = loadTest(1);
feignCtrlP(marks.get("<arg1>").getTextOffset()).check("a, b, c", new String[]{"a, "});
}
/**
* Imitates pressing of Ctrl+P; fails if results are not as expected.
* @param offset offset of 'cursor' where ^P is pressed.