@@ -1382,7 +1382,7 @@ describe('server', () => {
1382
1382
} )
1383
1383
1384
1384
it ( 'returns range when a renamable symbol is found' , async ( ) => {
1385
- // echo builtin command
1385
+ // echo builtin
1386
1386
expect ( await getPrepareRenameResult ( 3 , 2 ) ) . toMatchInlineSnapshot ( `
1387
1387
{
1388
1388
"end": {
@@ -1395,7 +1395,7 @@ describe('server', () => {
1395
1395
},
1396
1396
}
1397
1397
` )
1398
- // ls executable command
1398
+ // ls executable
1399
1399
expect ( await getPrepareRenameResult ( 12 , 12 ) ) . toMatchInlineSnapshot ( `
1400
1400
{
1401
1401
"end": {
@@ -1502,7 +1502,7 @@ describe('server', () => {
1502
1502
} )
1503
1503
1504
1504
it ( 'returns all instances within file when no declaration is found' , async ( ) => {
1505
- // $HOME variable
1505
+ // $HOME
1506
1506
expect ( await getRenameRequestResult ( 29 , 9 ) ) . toMatchInlineSnapshot ( `
1507
1507
{
1508
1508
"changes": {
@@ -1537,7 +1537,7 @@ describe('server', () => {
1537
1537
},
1538
1538
}
1539
1539
` )
1540
- // ls command
1540
+ // ls
1541
1541
expect ( await getRenameRequestResult ( 30 , 0 ) ) . toMatchInlineSnapshot ( `
1542
1542
{
1543
1543
"changes": {
@@ -1574,7 +1574,99 @@ describe('server', () => {
1574
1574
` )
1575
1575
} )
1576
1576
1577
- it . todo ( 'returns all instances within file when declaration is local to file' )
1577
+ it ( 'returns all instances within file when declaration is local to file' , async ( ) => {
1578
+ // $somevar
1579
+ expect ( await getRenameRequestResult ( 12 , 0 ) ) . toMatchInlineSnapshot ( `
1580
+ {
1581
+ "changes": {
1582
+ "file://__REPO_ROOT_FOLDER__/testing/fixtures/renaming.sh": [
1583
+ {
1584
+ "newText": "newName",
1585
+ "range": {
1586
+ "end": {
1587
+ "character": 7,
1588
+ "line": 12,
1589
+ },
1590
+ "start": {
1591
+ "character": 0,
1592
+ "line": 12,
1593
+ },
1594
+ },
1595
+ },
1596
+ {
1597
+ "newText": "newName",
1598
+ "range": {
1599
+ "end": {
1600
+ "character": 15,
1601
+ "line": 18,
1602
+ },
1603
+ "start": {
1604
+ "character": 8,
1605
+ "line": 18,
1606
+ },
1607
+ },
1608
+ },
1609
+ ],
1610
+ },
1611
+ }
1612
+ ` )
1613
+ // somecommand
1614
+ expect ( await getRenameRequestResult ( 17 , 13 ) ) . toMatchInlineSnapshot ( `
1615
+ {
1616
+ "changes": {
1617
+ "file://__REPO_ROOT_FOLDER__/testing/fixtures/renaming.sh": [
1618
+ {
1619
+ "newText": "newName",
1620
+ "range": {
1621
+ "end": {
1622
+ "character": 11,
1623
+ "line": 13,
1624
+ },
1625
+ "start": {
1626
+ "character": 0,
1627
+ "line": 13,
1628
+ },
1629
+ },
1630
+ },
1631
+ {
1632
+ "newText": "newName",
1633
+ "range": {
1634
+ "end": {
1635
+ "character": 19,
1636
+ "line": 17,
1637
+ },
1638
+ "start": {
1639
+ "character": 8,
1640
+ "line": 17,
1641
+ },
1642
+ },
1643
+ },
1644
+ ],
1645
+ },
1646
+ }
1647
+ ` )
1648
+ } )
1649
+
1650
+ it ( 'differentiates between variables and functions with same name' , async ( ) => {
1651
+ const getChangeRanges = async ( line : LSP . uinteger , character : LSP . uinteger ) =>
1652
+ Object . values (
1653
+ ( ( await getRenameRequestResult ( line , character ) ) as LSP . WorkspaceEdit )
1654
+ . changes as {
1655
+ [ uri : LSP . DocumentUri ] : LSP . TextEdit [ ]
1656
+ } ,
1657
+ ) [ 0 ] . map ( ( c ) => c . range )
1658
+
1659
+ // $variable_or_function
1660
+ const varRanges = await getChangeRanges ( 32 , 9 )
1661
+ // variable_or_function
1662
+ const funcRanges = await getChangeRanges ( 33 , 21 )
1663
+
1664
+ expect ( varRanges ) . toHaveLength ( 4 )
1665
+ expect ( funcRanges ) . toHaveLength ( 2 )
1666
+ expect ( varRanges ) . not . toContainEqual ( funcRanges [ 0 ] )
1667
+ expect ( varRanges ) . not . toContainEqual ( funcRanges [ 1 ] )
1668
+ } )
1669
+
1578
1670
it . todo ( 'returns all instances within scope when declaration is local to scope' )
1579
1671
it . todo ( 'returns all instances across linked files' )
1580
1672
} )
0 commit comments