Skip to content

Commit 08d803f

Browse files
committed
Add test for issue #2556
1 parent 45fb958 commit 08d803f

File tree

1 file changed

+92
-0
lines changed

1 file changed

+92
-0
lines changed

src/core/diff/strategies/__tests__/multi-search-replace.test.ts

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1765,6 +1765,98 @@ console.log("test");
17651765
const result = await strategy.applyDiff(originalContent, diffContent)
17661766
expect(result.success).toBe(false)
17671767
})
1768+
1769+
it("should work correctly with line numbers", async () => {
1770+
const originalContent = `.game-container {
1771+
display: flex;
1772+
flex-direction: column;
1773+
gap: 1rem;
1774+
}
1775+
1776+
.chess-board-container {
1777+
display: flex;
1778+
gap: 1rem;
1779+
align-items: center;
1780+
}
1781+
1782+
.overlay {
1783+
position: absolute;
1784+
top: 0;
1785+
left: 0;
1786+
width: 100%;
1787+
height: 100%;
1788+
background-color: rgba(0, 0, 0, 0.5);
1789+
z-index: 999; /* Ensure it's above the board but below the promotion dialog */
1790+
}
1791+
1792+
.game-container.promotion-active .chess-board,
1793+
.game-container.promotion-active .game-toolbar,
1794+
.game-container.promotion-active .game-info-container {
1795+
filter: blur(2px);
1796+
pointer-events: none; /* Disable clicks on these elements */
1797+
}
1798+
1799+
.game-container.promotion-active .promotion-dialog {
1800+
z-index: 1000; /* Ensure it's above the overlay */
1801+
pointer-events: auto; /* Enable clicks on the promotion dialog */
1802+
}`
1803+
const diffContent = `test.ts
1804+
<<<<<<< SEARCH
1805+
:start_line:12
1806+
:end_line:13
1807+
-------
1808+
.overlay {
1809+
=======
1810+
.piece {
1811+
will-change: transform;
1812+
}
1813+
1814+
.overlay {
1815+
>>>>>>> REPLACE
1816+
`
1817+
1818+
const result = await strategy.applyDiff(originalContent, diffContent)
1819+
expect(result.success).toBe(true)
1820+
if (result.success) {
1821+
expect(result.content).toBe(`.game-container {
1822+
display: flex;
1823+
flex-direction: column;
1824+
gap: 1rem;
1825+
}
1826+
1827+
.chess-board-container {
1828+
display: flex;
1829+
gap: 1rem;
1830+
align-items: center;
1831+
}
1832+
1833+
.piece {
1834+
will-change: transform;
1835+
}
1836+
1837+
.overlay {
1838+
position: absolute;
1839+
top: 0;
1840+
left: 0;
1841+
width: 100%;
1842+
height: 100%;
1843+
background-color: rgba(0, 0, 0, 0.5);
1844+
z-index: 999; /* Ensure it's above the board but below the promotion dialog */
1845+
}
1846+
1847+
.game-container.promotion-active .chess-board,
1848+
.game-container.promotion-active .game-toolbar,
1849+
.game-container.promotion-active .game-info-container {
1850+
filter: blur(2px);
1851+
pointer-events: none; /* Disable clicks on these elements */
1852+
}
1853+
1854+
.game-container.promotion-active .promotion-dialog {
1855+
z-index: 1000; /* Ensure it's above the overlay */
1856+
pointer-events: auto; /* Enable clicks on the promotion dialog */
1857+
}`)
1858+
}
1859+
})
17681860
})
17691861
})
17701862

0 commit comments

Comments
 (0)