Skip to content

Commit

Permalink
Bug fix: Find variable in assignment
Browse files Browse the repository at this point in the history
  • Loading branch information
sblundy committed Nov 18, 2020
1 parent 4d2f580 commit 9e54747
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import com.intellij.lang.ASTNode

abstract class ElvishAssignmentBase(node: ASTNode) : ASTWrapperPsiElement(node), ElvishAssignment, ElvishVariableScope {
override fun findVariables(ref: ReferenceWithNamespacePsiElement): Collection<ElvishVariableDeclaration> {
return variableList.filter { declaration -> declaration.nameMatches(ref) }
return variableList.filter { declaration -> declaration.nameMatches(ref) } +
ElvishPsiUtils.findVariableInParentScope(ref, this)
}

override fun processVariables(processor: ElvishVariableScope.VariableProcessor) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
use re

fn status [&counts=$false]{
is-o<caret>k = ?($git-status-cmd | eawk [line @f]{})

result = [
&is-git-repo= (bool $is-ok)
]
}

0 comments on commit 9e54747

Please sign in to comment.