diff --git a/src/main/kotlin/com/github/sblundy/elvish/psi/ElvishAssignmentBase.kt b/src/main/kotlin/com/github/sblundy/elvish/psi/ElvishAssignmentBase.kt index 0c222d5..071481f 100644 --- a/src/main/kotlin/com/github/sblundy/elvish/psi/ElvishAssignmentBase.kt +++ b/src/main/kotlin/com/github/sblundy/elvish/psi/ElvishAssignmentBase.kt @@ -5,7 +5,8 @@ import com.intellij.lang.ASTNode abstract class ElvishAssignmentBase(node: ASTNode) : ASTWrapperPsiElement(node), ElvishAssignment, ElvishVariableScope { override fun findVariables(ref: ReferenceWithNamespacePsiElement): Collection { - return variableList.filter { declaration -> declaration.nameMatches(ref) } + return variableList.filter { declaration -> declaration.nameMatches(ref) } + + ElvishPsiUtils.findVariableInParentScope(ref, this) } override fun processVariables(processor: ElvishVariableScope.VariableProcessor) { diff --git a/src/test/kotlin/com/github/sblundy/elvish/ElvishUsageProviderTest.kt b/src/test/kotlin/com/github/sblundy/elvish/ElvishUsageProviderTest.kt index ac68e09..8d6b954 100644 --- a/src/test/kotlin/com/github/sblundy/elvish/ElvishUsageProviderTest.kt +++ b/src/test/kotlin/com/github/sblundy/elvish/ElvishUsageProviderTest.kt @@ -106,6 +106,17 @@ class ElvishUsageProviderTest { Assert.assertEquals(26, usages.firstOrNull()?.navigationOffset) } } + + @Test + fun testFindUsagesMuseliGit() { + runTest { + val usages = myFixture.testFindUsages(myFullDataPath + "ElvishUsageProviderTest-museli-git.elv") + + Assert.assertNotNull(usages) + Assert.assertEquals(1, usages.size) + Assert.assertEquals(127, usages.firstOrNull()?.navigationOffset) + } + } } fun runTest(t : () -> Unit) { diff --git a/src/test/resources/com/github/sblundy/elvish/ElvishUsageProviderTest-museli-git.elv b/src/test/resources/com/github/sblundy/elvish/ElvishUsageProviderTest-museli-git.elv new file mode 100644 index 0000000..ee55b4f --- /dev/null +++ b/src/test/resources/com/github/sblundy/elvish/ElvishUsageProviderTest-museli-git.elv @@ -0,0 +1,9 @@ +use re + +fn status [&counts=$false]{ + is-ok = ?($git-status-cmd | eawk [line @f]{}) + + result = [ + &is-git-repo= (bool $is-ok) + ] +}