File tree 1 file changed +8
-5
lines changed
1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -592,11 +592,13 @@ class EditContextManager {
592
592
for ( let format of e . getTextFormats ( ) ) {
593
593
let lineStyle = format . underlineStyle , thickness = format . underlineThickness
594
594
if ( lineStyle != "None" && thickness != "None" ) {
595
- let style = `text-decoration: underline ${
596
- lineStyle == "Dashed" ? "dashed " : lineStyle == "Squiggle" ? "wavy " : ""
597
- } ${ thickness == "Thin" ? 1 : 2 } px`
598
- deco . push ( Decoration . mark ( { attributes : { style} } )
599
- . range ( this . toEditorPos ( format . rangeStart ) , this . toEditorPos ( format . rangeEnd ) ) )
595
+ let from = this . toEditorPos ( format . rangeStart ) , to = this . toEditorPos ( format . rangeEnd )
596
+ if ( from < to ) {
597
+ let style = `text-decoration: underline ${
598
+ lineStyle == "Dashed" ? "dashed " : lineStyle == "Squiggle" ? "wavy " : ""
599
+ } ${ thickness == "Thin" ? 1 : 2 } px`
600
+ deco . push ( Decoration . mark ( { attributes : { style} } ) . range ( from , to ) )
601
+ }
600
602
}
601
603
}
602
604
view . dispatch ( { effects : setEditContextFormatting . of ( Decoration . set ( deco ) ) } )
@@ -713,6 +715,7 @@ class EditContextManager {
713
715
}
714
716
715
717
toEditorPos ( contextPos : number ) {
718
+ contextPos = Math . min ( contextPos , this . to - this . from )
716
719
let c = this . composing
717
720
return c && c . drifted ? c . editorBase + ( contextPos - c . contextBase ) : contextPos + this . from
718
721
}
You can’t perform that action at this time.
0 commit comments