@@ -42,6 +42,8 @@ function decoEditor(doc: string, decorations: any = []) {
4242 return tempView ( doc , decos ( Decoration . set ( decorations , true ) ) )
4343}
4444
45+ function near ( a : number , b : number ) { return Math . abs ( a - b ) < 1 }
46+
4547describe ( "EditorView decoration" , ( ) => {
4648 it ( "renders tag names" , ( ) => {
4749 let cm = decoEditor ( "one\ntwo" , d ( 2 , 5 , { tagName : "em" } ) )
@@ -230,7 +232,7 @@ describe("EditorView decoration", () => {
230232 pos = nextPos
231233 }
232234 let reopen : Range < Decoration > [ ] = [ ]
233- if ( nextStop <= pos || next && active . some ( a => a . to < next . to ) ) {
235+ if ( nextStop <= pos || next && active . some ( a => a . to < next ! . to ) ) {
234236 let closeTo = active . findIndex ( mark => mark . to == pos || next && mark . to < next . to )
235237 while ( active . length > closeTo ) {
236238 let close = active . pop ( ) !
@@ -934,11 +936,11 @@ describe("EditorView decoration", () => {
934936 let eltTop = cm . elementAtHeight ( cm . coordsAtPos ( 1 ) ! . bottom + 2 - cm . documentTop )
935937 ist ( eltTop . type , BlockType . WidgetRange )
936938 ist ( eltTop . from , 2 )
937- ist ( Math . abs ( eltTop . height - 3 ) , 0.1 , "<" )
939+ ist ( eltTop . height , 3 , near )
938940 let elt2 = cm . elementAtHeight ( cm . coordsAtPos ( 2 ) ! . top + 1 - cm . documentTop )
939941 ist ( elt2 . type , BlockType . Text )
940942 ist ( elt2 . from , 2 )
941- ist ( Math . abs ( elt2 . top - eltTop . bottom ) , 0.1 , "<" )
943+ ist ( elt2 . top , eltTop . bottom , near )
942944 let eltBot = cm . elementAtHeight ( cm . coordsAtPos ( 5 ) ! . bottom + 2 - cm . documentTop )
943945 ist ( eltBot . type , BlockType . WidgetRange )
944946 let blocks = cm . viewportLineBlocks
@@ -955,9 +957,9 @@ describe("EditorView decoration", () => {
955957 ] )
956958 cm . measure ( )
957959 let gapAbove = ( line : BlockInfo ) => Array . isArray ( line . type ) ? line . type [ 0 ] . height : 0
958- ist ( gapAbove ( cm . viewportLineBlocks [ 1 ] ) , 5 )
959- ist ( gapAbove ( cm . viewportLineBlocks [ 2 ] ) , 4 )
960- ist ( gapAbove ( cm . viewportLineBlocks [ 3 ] ) , 3 )
960+ ist ( gapAbove ( cm . viewportLineBlocks [ 1 ] ) , 5 , near )
961+ ist ( gapAbove ( cm . viewportLineBlocks [ 2 ] ) , 4 , near )
962+ ist ( gapAbove ( cm . viewportLineBlocks [ 3 ] ) , 3 , near )
961963 } )
962964 } )
963965} )
0 commit comments