@@ -1774,5 +1774,290 @@ define(function (require, exports, module) {
17741774 expect ( getTabCount ( ) ) . toBe ( 0 ) ;
17751775 } ) ;
17761776 } ) ;
1777+
1778+ describe ( "Split Panes" , function ( ) {
1779+ beforeEach ( async function ( ) {
1780+ // Enable the tab bar feature
1781+ PreferencesManager . set ( "tabBar.options" , { showTabBar : true , numberOfTabs : - 1 } ) ;
1782+
1783+ // Close all files to start with a clean state
1784+ await testWindow . closeAllFiles ( ) ;
1785+
1786+ // Set up a horizontal split view (two columns)
1787+ MainViewManager . setLayoutScheme ( 1 , 2 ) ;
1788+ } ) ;
1789+
1790+ afterEach ( async function ( ) {
1791+ // Reset to single pane layout
1792+ MainViewManager . setLayoutScheme ( 1 , 1 ) ;
1793+ } ) ;
1794+
1795+ /**
1796+ * Helper function to check if the tab bar for a specific pane is visible
1797+ * @param {string } paneId - The pane ID ("first-pane" or "second-pane")
1798+ * @returns {boolean } - True if the tab bar is visible, false otherwise
1799+ */
1800+ function isTabBarVisible ( paneId ) {
1801+ const tabBarId = paneId === "first-pane" ? "#phoenix-tab-bar" : "#phoenix-tab-bar-2" ;
1802+ return $ ( tabBarId ) . is ( ":visible" ) ;
1803+ }
1804+
1805+ /**
1806+ * Helper function to get the tab count for a specific pane
1807+ * @param {string } paneId - The pane ID ("first-pane" or "second-pane")
1808+ * @returns {number } - The number of tabs in the pane
1809+ */
1810+ function getPaneTabCount ( paneId ) {
1811+ const tabBarId = paneId === "first-pane" ? "#phoenix-tab-bar" : "#phoenix-tab-bar-2" ;
1812+ return $ ( tabBarId ) . find ( ".tab" ) . length ;
1813+ }
1814+
1815+ /**
1816+ * Helper function to check if a tab for a specific file exists in a specific pane
1817+ * @param {string } filePath - The path of the file to check
1818+ * @param {string } paneId - The pane ID ("first-pane" or "second-pane")
1819+ * @returns {boolean } - True if the tab exists in the pane, false otherwise
1820+ */
1821+ function tabExistsInPane ( filePath , paneId ) {
1822+ const tabBarId = paneId === "first-pane" ? "#phoenix-tab-bar" : "#phoenix-tab-bar-2" ;
1823+ return $ ( tabBarId ) . find ( `.tab[data-path="${ filePath } "]` ) . length > 0 ;
1824+ }
1825+
1826+ it ( "should show tab bars in both panes when files are open in both" , async function ( ) {
1827+ // Open a file in the first pane
1828+ await awaitsForDone (
1829+ CommandManager . execute ( Commands . FILE_OPEN , { fullPath : testFilePath , paneId : "first-pane" } ) ,
1830+ "Open file in first pane"
1831+ ) ;
1832+
1833+ // Open a different file in the second pane
1834+ await awaitsForDone (
1835+ CommandManager . execute ( Commands . FILE_OPEN , { fullPath : testFilePath2 , paneId : "second-pane" } ) ,
1836+ "Open file in second pane"
1837+ ) ;
1838+
1839+ // Wait for both tab bars to appear
1840+ await awaitsFor (
1841+ function ( ) {
1842+ return isTabBarVisible ( "first-pane" ) && isTabBarVisible ( "second-pane" ) ;
1843+ } ,
1844+ "Both tab bars to appear" ,
1845+ 1000
1846+ ) ;
1847+
1848+ // Verify both tab bars are visible
1849+ expect ( isTabBarVisible ( "first-pane" ) ) . toBe ( true ) ;
1850+ expect ( isTabBarVisible ( "second-pane" ) ) . toBe ( true ) ;
1851+
1852+ // Verify each pane has the correct tab
1853+ expect ( tabExistsInPane ( testFilePath , "first-pane" ) ) . toBe ( true ) ;
1854+ expect ( tabExistsInPane ( testFilePath2 , "second-pane" ) ) . toBe ( true ) ;
1855+ expect ( getPaneTabCount ( "first-pane" ) ) . toBe ( 1 ) ;
1856+ expect ( getPaneTabCount ( "second-pane" ) ) . toBe ( 1 ) ;
1857+ } ) ;
1858+
1859+ it ( "should hide tab bar in a pane with no files" , async function ( ) {
1860+ // Open a file in the first pane only
1861+ await awaitsForDone (
1862+ CommandManager . execute ( Commands . FILE_OPEN , { fullPath : testFilePath , paneId : "first-pane" } ) ,
1863+ "Open file in first pane"
1864+ ) ;
1865+
1866+ // Wait for the first tab bar to appear
1867+ await awaitsFor (
1868+ function ( ) {
1869+ return isTabBarVisible ( "first-pane" ) ;
1870+ } ,
1871+ "First tab bar to appear" ,
1872+ 1000
1873+ ) ;
1874+
1875+ // Verify first tab bar is visible and second is not
1876+ expect ( isTabBarVisible ( "first-pane" ) ) . toBe ( true ) ;
1877+ expect ( isTabBarVisible ( "second-pane" ) ) . toBe ( false ) ;
1878+
1879+ // Verify the first pane has the correct tab
1880+ expect ( tabExistsInPane ( testFilePath , "first-pane" ) ) . toBe ( true ) ;
1881+ expect ( getPaneTabCount ( "first-pane" ) ) . toBe ( 1 ) ;
1882+ } ) ;
1883+
1884+ it ( "should update tab bars when moving files between panes" , async function ( ) {
1885+ // Open a file in the first pane
1886+ await awaitsForDone (
1887+ CommandManager . execute ( Commands . FILE_OPEN , { fullPath : testFilePath , paneId : "first-pane" } ) ,
1888+ "Open file in first pane"
1889+ ) ;
1890+
1891+ // Wait for the first tab bar to appear
1892+ await awaitsFor (
1893+ function ( ) {
1894+ return isTabBarVisible ( "first-pane" ) ;
1895+ } ,
1896+ "First tab bar to appear" ,
1897+ 1000
1898+ ) ;
1899+
1900+ // Verify first tab bar is visible and second is not
1901+ expect ( isTabBarVisible ( "first-pane" ) ) . toBe ( true ) ;
1902+ expect ( isTabBarVisible ( "second-pane" ) ) . toBe ( false ) ;
1903+
1904+ // Move the file to the second pane
1905+ const fileObj = FileSystem . getFileForPath ( testFilePath ) ;
1906+ MainViewManager . addToWorkingSet ( "second-pane" , fileObj ) ;
1907+
1908+ // Remove from first pane
1909+ await awaitsForDone (
1910+ CommandManager . execute ( Commands . FILE_CLOSE , { file : fileObj , paneId : "first-pane" } ) ,
1911+ "Close file in first pane"
1912+ ) ;
1913+
1914+ // Wait for the tab to appear in the second pane and disappear from the first
1915+ await awaitsFor (
1916+ function ( ) {
1917+ return (
1918+ ! tabExistsInPane ( testFilePath , "first-pane" ) && tabExistsInPane ( testFilePath , "second-pane" )
1919+ ) ;
1920+ } ,
1921+ "Tab to move to second pane" ,
1922+ 1000
1923+ ) ;
1924+
1925+ // Verify the tab bars visibility has updated
1926+ expect ( isTabBarVisible ( "first-pane" ) ) . toBe ( false ) ;
1927+ expect ( isTabBarVisible ( "second-pane" ) ) . toBe ( true ) ;
1928+
1929+ // Verify the tab is now in the second pane
1930+ expect ( tabExistsInPane ( testFilePath , "first-pane" ) ) . toBe ( false ) ;
1931+ expect ( tabExistsInPane ( testFilePath , "second-pane" ) ) . toBe ( true ) ;
1932+ expect ( getPaneTabCount ( "first-pane" ) ) . toBe ( 0 ) ;
1933+ expect ( getPaneTabCount ( "second-pane" ) ) . toBe ( 1 ) ;
1934+ } ) ;
1935+
1936+ it ( "should hide tab bar when closing all files in a pane" , async function ( ) {
1937+ // Open files in both panes
1938+ await awaitsForDone (
1939+ CommandManager . execute ( Commands . FILE_OPEN , { fullPath : testFilePath , paneId : "first-pane" } ) ,
1940+ "Open file in first pane"
1941+ ) ;
1942+ await awaitsForDone (
1943+ CommandManager . execute ( Commands . FILE_OPEN , { fullPath : testFilePath2 , paneId : "second-pane" } ) ,
1944+ "Open file in second pane"
1945+ ) ;
1946+
1947+ // Wait for both tab bars to appear
1948+ await awaitsFor (
1949+ function ( ) {
1950+ return isTabBarVisible ( "first-pane" ) && isTabBarVisible ( "second-pane" ) ;
1951+ } ,
1952+ "Both tab bars to appear" ,
1953+ 1000
1954+ ) ;
1955+
1956+ // Verify both tab bars are visible
1957+ expect ( isTabBarVisible ( "first-pane" ) ) . toBe ( true ) ;
1958+ expect ( isTabBarVisible ( "second-pane" ) ) . toBe ( true ) ;
1959+
1960+ // Close the file in the second pane
1961+ const fileToClose = FileSystem . getFileForPath ( testFilePath2 ) ;
1962+ const promise = CommandManager . execute ( Commands . FILE_CLOSE , {
1963+ file : fileToClose ,
1964+ paneId : "second-pane"
1965+ } ) ;
1966+
1967+ // Cancel the save dialog if it appears
1968+ testWindow . brackets . test . Dialogs . cancelModalDialogIfOpen (
1969+ testWindow . brackets . test . DefaultDialogs . DIALOG_ID_SAVE_CLOSE ,
1970+ testWindow . brackets . test . DefaultDialogs . DIALOG_BTN_DONTSAVE
1971+ ) ;
1972+
1973+ await awaitsForDone ( promise , "Close file in second pane" ) ;
1974+
1975+ // Wait for the second tab bar to disappear
1976+ await awaitsFor (
1977+ function ( ) {
1978+ return ! isTabBarVisible ( "second-pane" ) ;
1979+ } ,
1980+ "Second tab bar to disappear" ,
1981+ 1000
1982+ ) ;
1983+
1984+ // Verify first tab bar is still visible but second is not
1985+ expect ( isTabBarVisible ( "first-pane" ) ) . toBe ( true ) ;
1986+ expect ( isTabBarVisible ( "second-pane" ) ) . toBe ( false ) ;
1987+
1988+ // Verify the tabs are in the correct panes
1989+ expect ( tabExistsInPane ( testFilePath , "first-pane" ) ) . toBe ( true ) ;
1990+ expect ( tabExistsInPane ( testFilePath2 , "second-pane" ) ) . toBe ( false ) ;
1991+ expect ( getPaneTabCount ( "first-pane" ) ) . toBe ( 1 ) ;
1992+ expect ( getPaneTabCount ( "second-pane" ) ) . toBe ( 0 ) ;
1993+ } ) ;
1994+
1995+ it ( "should work correctly with vertical split layout" , async function ( ) {
1996+ // Change to vertical split layout (2 rows, 1 column)
1997+ MainViewManager . setLayoutScheme ( 2 , 1 ) ;
1998+
1999+ // Open a file in the first pane
2000+ await awaitsForDone (
2001+ CommandManager . execute ( Commands . FILE_OPEN , { fullPath : testFilePath , paneId : "first-pane" } ) ,
2002+ "Open file in first pane"
2003+ ) ;
2004+
2005+ // Open a different file in the second pane
2006+ await awaitsForDone (
2007+ CommandManager . execute ( Commands . FILE_OPEN , { fullPath : testFilePath2 , paneId : "second-pane" } ) ,
2008+ "Open file in second pane"
2009+ ) ;
2010+
2011+ // Wait for both tab bars to appear
2012+ await awaitsFor (
2013+ function ( ) {
2014+ return isTabBarVisible ( "first-pane" ) && isTabBarVisible ( "second-pane" ) ;
2015+ } ,
2016+ "Both tab bars to appear" ,
2017+ 1000
2018+ ) ;
2019+
2020+ // Verify both tab bars are visible
2021+ expect ( isTabBarVisible ( "first-pane" ) ) . toBe ( true ) ;
2022+ expect ( isTabBarVisible ( "second-pane" ) ) . toBe ( true ) ;
2023+
2024+ // Verify each pane has the correct tab
2025+ expect ( tabExistsInPane ( testFilePath , "first-pane" ) ) . toBe ( true ) ;
2026+ expect ( tabExistsInPane ( testFilePath2 , "second-pane" ) ) . toBe ( true ) ;
2027+ expect ( getPaneTabCount ( "first-pane" ) ) . toBe ( 1 ) ;
2028+ expect ( getPaneTabCount ( "second-pane" ) ) . toBe ( 1 ) ;
2029+
2030+ // Close the file in the second pane
2031+ const fileToClose = FileSystem . getFileForPath ( testFilePath2 ) ;
2032+ const promise = CommandManager . execute ( Commands . FILE_CLOSE , {
2033+ file : fileToClose ,
2034+ paneId : "second-pane"
2035+ } ) ;
2036+
2037+ // Cancel the save dialog if it appears
2038+ testWindow . brackets . test . Dialogs . cancelModalDialogIfOpen (
2039+ testWindow . brackets . test . DefaultDialogs . DIALOG_ID_SAVE_CLOSE ,
2040+ testWindow . brackets . test . DefaultDialogs . DIALOG_BTN_DONTSAVE
2041+ ) ;
2042+
2043+ await awaitsForDone ( promise , "Close file in second pane" ) ;
2044+
2045+ // Wait for the second tab bar to disappear
2046+ await awaitsFor (
2047+ function ( ) {
2048+ return ! isTabBarVisible ( "second-pane" ) ;
2049+ } ,
2050+ "Second tab bar to disappear" ,
2051+ 1000
2052+ ) ;
2053+
2054+ // Verify first tab bar is still visible but second is not
2055+ expect ( isTabBarVisible ( "first-pane" ) ) . toBe ( true ) ;
2056+ expect ( isTabBarVisible ( "second-pane" ) ) . toBe ( false ) ;
2057+
2058+ // Reset to horizontal split for other tests
2059+ MainViewManager . setLayoutScheme ( 1 , 2 ) ;
2060+ } ) ;
2061+ } ) ;
17772062 } ) ;
17782063} ) ;
0 commit comments