@@ -1808,22 +1808,77 @@ testCM("addLineClass", function(cm) {
18081808
18091809testCM ( "atomicMarker" , function ( cm ) {
18101810 addDoc ( cm , 10 , 10 ) ;
1811- function atom ( ll , cl , lr , cr , li , ri ) {
1812- return cm . markText ( Pos ( ll , cl ) , Pos ( lr , cr ) ,
1813- { atomic : true , inclusiveLeft : li , inclusiveRight : ri } ) ;
1811+
1812+ function atom ( ll , cl , lr , cr , li , ri , ls , rs ) {
1813+ var options = {
1814+ atomic : true ,
1815+ inclusiveLeft : li ,
1816+ inclusiveRight : ri
1817+ } ;
1818+
1819+ if ( ls === true || ls === false ) options [ "selectLeft" ] = ls ;
1820+ if ( rs === true || rs === false ) options [ "selectRight" ] = rs ;
1821+
1822+ return cm . markText ( Pos ( ll , cl ) , Pos ( lr , cr ) , options ) ;
18141823 }
1824+
1825+ // Can cursor to the left and right of a normal marker by jumping across it
18151826 var m = atom ( 0 , 1 , 0 , 5 ) ;
18161827 cm . setCursor ( Pos ( 0 , 1 ) ) ;
18171828 cm . execCommand ( "goCharRight" ) ;
18181829 eqCursorPos ( cm . getCursor ( ) , Pos ( 0 , 5 ) ) ;
18191830 cm . execCommand ( "goCharLeft" ) ;
18201831 eqCursorPos ( cm . getCursor ( ) , Pos ( 0 , 1 ) ) ;
18211832 m . clear ( ) ;
1833+
1834+ // Can't cursor to the left of a marker when inclusiveLeft=true
18221835 m = atom ( 0 , 0 , 0 , 5 , true ) ;
18231836 eqCursorPos ( cm . getCursor ( ) , Pos ( 0 , 5 ) , "pushed out" ) ;
18241837 cm . execCommand ( "goCharLeft" ) ;
18251838 eqCursorPos ( cm . getCursor ( ) , Pos ( 0 , 5 ) ) ;
18261839 m . clear ( ) ;
1840+
1841+ // Can't cursor to the left of a marker when inclusiveLeft=false and selectLeft=false
1842+ m = atom ( 0 , 0 , 0 , 5 , false , false , false ) ;
1843+ cm . setCursor ( Pos ( 0 , 5 ) ) ;
1844+ eqCursorPos ( cm . getCursor ( ) , Pos ( 0 , 5 ) , "pushed out" ) ;
1845+ cm . execCommand ( "goCharLeft" ) ;
1846+ eqCursorPos ( cm . getCursor ( ) , Pos ( 0 , 5 ) ) ;
1847+ m . clear ( ) ;
1848+
1849+ // Can cursor to the left of a marker when inclusiveLeft=false and selectLeft=True
1850+ m = atom ( 0 , 0 , 0 , 5 , false , false , true ) ;
1851+ cm . setCursor ( Pos ( 0 , 5 ) ) ;
1852+ eqCursorPos ( cm . getCursor ( ) , Pos ( 0 , 5 ) , "pushed out" ) ;
1853+ cm . execCommand ( "goCharLeft" ) ;
1854+ eqCursorPos ( cm . getCursor ( ) , Pos ( 0 , 0 ) ) ;
1855+ m . clear ( ) ;
1856+
1857+ // Can't cursor to the right of a marker when inclusiveRight=true
1858+ m = atom ( 0 , 0 , 0 , 5 , false , true ) ;
1859+ cm . setCursor ( Pos ( 0 , 0 ) ) ;
1860+ eqCursorPos ( cm . getCursor ( ) , Pos ( 0 , 0 ) ) ;
1861+ cm . execCommand ( "goCharRight" ) ;
1862+ eqCursorPos ( cm . getCursor ( ) , Pos ( 0 , 6 ) ) ;
1863+ m . clear ( ) ;
1864+
1865+ // Can't cursor to the right of a marker when inclusiveRight=false and selectRight=false
1866+ m = atom ( 0 , 0 , 0 , 5 , false , false , true , false ) ;
1867+ cm . setCursor ( Pos ( 0 , 0 ) ) ;
1868+ eqCursorPos ( cm . getCursor ( ) , Pos ( 0 , 0 ) ) ;
1869+ cm . execCommand ( "goCharRight" ) ;
1870+ eqCursorPos ( cm . getCursor ( ) , Pos ( 0 , 6 ) ) ;
1871+ m . clear ( ) ;
1872+
1873+ // Can cursor to the right of a marker when inclusiveRight=false and selectRight=True
1874+ m = atom ( 0 , 0 , 0 , 5 , false , false , true , true ) ;
1875+ cm . setCursor ( Pos ( 0 , 0 ) ) ;
1876+ eqCursorPos ( cm . getCursor ( ) , Pos ( 0 , 0 ) ) ;
1877+ cm . execCommand ( "goCharRight" ) ;
1878+ eqCursorPos ( cm . getCursor ( ) , Pos ( 0 , 5 ) ) ;
1879+ m . clear ( ) ;
1880+
1881+ // Can't cursor to the right of a multiline marker when inclusiveRight=true
18271882 m = atom ( 8 , 4 , 9 , 10 , false , true ) ;
18281883 cm . setCursor ( Pos ( 9 , 8 ) ) ;
18291884 eqCursorPos ( cm . getCursor ( ) , Pos ( 8 , 4 ) , "set" ) ;
@@ -1834,6 +1889,9 @@ testCM("atomicMarker", function(cm) {
18341889 cm . execCommand ( "goCharLeft" ) ;
18351890 eqCursorPos ( cm . getCursor ( ) , Pos ( 8 , 3 , "after" ) ) ;
18361891 m . clear ( ) ;
1892+
1893+ // Cursor jumps across a multiline atomic marker,
1894+ // and backspace deletes the entire marker
18371895 m = atom ( 1 , 1 , 3 , 8 ) ;
18381896 cm . setCursor ( Pos ( 0 , 0 ) ) ;
18391897 cm . setCursor ( Pos ( 2 , 0 ) ) ;
@@ -1848,10 +1906,16 @@ testCM("atomicMarker", function(cm) {
18481906 eqCursorPos ( cm . getCursor ( ) , Pos ( 3 , 8 ) ) ;
18491907 cm . execCommand ( "delCharBefore" ) ;
18501908 eq ( cm . getValue ( ) . length , 80 , "del chunk" ) ;
1909+ m . clear ( ) ;
1910+ addDoc ( cm , 10 , 10 ) ;
1911+
1912+ // Delete before an atomic marker deletes the entire marker
18511913 m = atom ( 3 , 0 , 5 , 5 ) ;
18521914 cm . setCursor ( Pos ( 3 , 0 ) ) ;
18531915 cm . execCommand ( "delWordAfter" ) ;
1854- eq ( cm . getValue ( ) . length , 53 , "del chunk" ) ;
1916+ eq ( cm . getValue ( ) . length , 82 , "del chunk" ) ;
1917+ m . clear ( ) ;
1918+ addDoc ( cm , 10 , 10 ) ;
18551919} ) ;
18561920
18571921testCM ( "selectionBias" , function ( cm ) {
0 commit comments