@@ -592,8 +592,10 @@ const frontDecorationDispatcher = {
592592 * @access private
593593 */
594594function drawLineDecoration ( decoration , data , decorationColor ) {
595- data . context . fillStyle = decorationColor
596- data . context . fillRect ( 0 , data . yRow , data . canvasWidth , data . lineHeight )
595+ const { context, lineHeight, canvasWidth, yRow } = data
596+
597+ context . fillStyle = decorationColor
598+ context . fillRect ( 0 , yRow , canvasWidth , lineHeight )
597599}
598600
599601/**
@@ -605,8 +607,10 @@ function drawLineDecoration (decoration, data, decorationColor) {
605607 * @access private
606608 */
607609function drawGutterDecoration ( decoration , data , decorationColor ) {
608- data . context . fillStyle = decorationColor
609- data . context . fillRect ( 0 , data . yRow , 1 , data . lineHeight )
610+ const { context, lineHeight, yRow } = data
611+
612+ context . fillStyle = decorationColor
613+ context . fillRect ( 0 , yRow , 1 , lineHeight )
610614}
611615
612616/**
@@ -621,21 +625,23 @@ function drawGutterDecoration (decoration, data, decorationColor) {
621625 * @access private
622626 */
623627function drawHighlightDecoration ( decoration , data , decorationColor ) {
628+ const { context, lineHeight, charWidth, canvasWidth, screenRow, yRow } = data
629+
624630 const range = decoration . getMarker ( ) . getScreenRange ( )
625631 const rowSpan = range . end . row - range . start . row
626632
627- data . context . fillStyle = decorationColor
633+ context . fillStyle = decorationColor
628634
629635 if ( rowSpan === 0 ) {
630636 const colSpan = range . end . column - range . start . column
631- data . context . fillRect ( range . start . column * data . charWidth , data . yRow , colSpan * data . charWidth , data . lineHeight )
632- } else if ( data . screenRow === range . start . row ) {
633- const x = range . start . column * data . charWidth
634- data . context . fillRect ( x , data . yRow , data . canvasWidth - x , data . lineHeight )
635- } else if ( data . screenRow === range . end . row ) {
636- data . context . fillRect ( 0 , data . yRow , range . end . column * data . charWidth , data . lineHeight )
637+ context . fillRect ( range . start . column * charWidth , yRow , colSpan * charWidth , lineHeight )
638+ } else if ( screenRow === range . start . row ) {
639+ const x = range . start . column * charWidth
640+ context . fillRect ( x , yRow , canvasWidth - x , lineHeight )
641+ } else if ( screenRow === range . end . row ) {
642+ context . fillRect ( 0 , yRow , range . end . column * charWidth , lineHeight )
637643 } else {
638- data . context . fillRect ( 0 , data . yRow , data . canvasWidth , data . lineHeight )
644+ context . fillRect ( 0 , yRow , canvasWidth , lineHeight )
639645 }
640646}
641647
@@ -651,70 +657,71 @@ function drawHighlightDecoration (decoration, data, decorationColor) {
651657 * @access private
652658 */
653659function drawHighlightOutlineDecoration ( decoration , data , decorationColor ) {
660+ const { context, lineHeight, charWidth, canvasWidth, screenRow, yRow } = data
661+
654662 let bottomWidth , colSpan , width , xBottomStart , xEnd , xStart
655- const { lineHeight, charWidth, canvasWidth, screenRow } = data
656663 const range = decoration . getMarker ( ) . getScreenRange ( )
657664 const rowSpan = range . end . row - range . start . row
658- const yStart = data . yRow
665+ const yStart = yRow
659666 const yEnd = yStart + lineHeight
660667
661- data . context . fillStyle = decorationColor
668+ context . fillStyle = decorationColor
662669
663670 if ( rowSpan === 0 ) {
664671 colSpan = range . end . column - range . start . column
665672 width = colSpan * charWidth
666673 xStart = range . start . column * charWidth
667674 xEnd = xStart + width
668675
669- data . context . fillRect ( xStart , yStart , width , 1 )
670- data . context . fillRect ( xStart , yEnd - 1 , width , 1 )
671- data . context . fillRect ( xStart , yStart , 1 , lineHeight )
672- data . context . fillRect ( xEnd , yStart , 1 , lineHeight )
676+ context . fillRect ( xStart , yStart , width , 1 )
677+ context . fillRect ( xStart , yEnd - 1 , width , 1 )
678+ context . fillRect ( xStart , yStart , 1 , lineHeight )
679+ context . fillRect ( xEnd , yStart , 1 , lineHeight )
673680 } else if ( rowSpan === 1 ) {
674- xStart = range . start . column * data . charWidth
675- xEnd = range . end . column * data . charWidth
681+ xStart = range . start . column * charWidth
682+ xEnd = range . end . column * charWidth
676683
677684 if ( screenRow === range . start . row ) {
678- width = data . canvasWidth - xStart
685+ width = canvasWidth - xStart
679686 xBottomStart = Math . max ( xStart , xEnd )
680- bottomWidth = data . canvasWidth - xBottomStart
687+ bottomWidth = canvasWidth - xBottomStart
681688
682- data . context . fillRect ( xStart , yStart , width , 1 )
683- data . context . fillRect ( xBottomStart , yEnd - 1 , bottomWidth , 1 )
684- data . context . fillRect ( xStart , yStart , 1 , lineHeight )
685- data . context . fillRect ( canvasWidth - 1 , yStart , 1 , lineHeight )
689+ context . fillRect ( xStart , yStart , width , 1 )
690+ context . fillRect ( xBottomStart , yEnd - 1 , bottomWidth , 1 )
691+ context . fillRect ( xStart , yStart , 1 , lineHeight )
692+ context . fillRect ( canvasWidth - 1 , yStart , 1 , lineHeight )
686693 } else {
687694 width = canvasWidth - xStart
688695 bottomWidth = canvasWidth - xEnd
689696
690- data . context . fillRect ( 0 , yStart , xStart , 1 )
691- data . context . fillRect ( 0 , yEnd - 1 , xEnd , 1 )
692- data . context . fillRect ( 0 , yStart , 1 , lineHeight )
693- data . context . fillRect ( xEnd , yStart , 1 , lineHeight )
697+ context . fillRect ( 0 , yStart , xStart , 1 )
698+ context . fillRect ( 0 , yEnd - 1 , xEnd , 1 )
699+ context . fillRect ( 0 , yStart , 1 , lineHeight )
700+ context . fillRect ( xEnd , yStart , 1 , lineHeight )
694701 }
695702 } else {
696703 xStart = range . start . column * charWidth
697704 xEnd = range . end . column * charWidth
698705 if ( screenRow === range . start . row ) {
699706 width = canvasWidth - xStart
700707
701- data . context . fillRect ( xStart , yStart , width , 1 )
702- data . context . fillRect ( xStart , yStart , 1 , lineHeight )
703- data . context . fillRect ( canvasWidth - 1 , yStart , 1 , lineHeight )
708+ context . fillRect ( xStart , yStart , width , 1 )
709+ context . fillRect ( xStart , yStart , 1 , lineHeight )
710+ context . fillRect ( canvasWidth - 1 , yStart , 1 , lineHeight )
704711 } else if ( screenRow === range . end . row ) {
705712 width = canvasWidth - xStart
706713
707- data . context . fillRect ( 0 , yEnd - 1 , xEnd , 1 )
708- data . context . fillRect ( 0 , yStart , 1 , lineHeight )
709- data . context . fillRect ( xEnd , yStart , 1 , lineHeight )
714+ context . fillRect ( 0 , yEnd - 1 , xEnd , 1 )
715+ context . fillRect ( 0 , yStart , 1 , lineHeight )
716+ context . fillRect ( xEnd , yStart , 1 , lineHeight )
710717 } else {
711- data . context . fillRect ( 0 , yStart , 1 , lineHeight )
712- data . context . fillRect ( canvasWidth - 1 , yStart , 1 , lineHeight )
718+ context . fillRect ( 0 , yStart , 1 , lineHeight )
719+ context . fillRect ( canvasWidth - 1 , yStart , 1 , lineHeight )
713720 if ( screenRow === range . start . row + 1 ) {
714- data . context . fillRect ( 0 , yStart , xStart , 1 )
721+ context . fillRect ( 0 , yStart , xStart , 1 )
715722 }
716723 if ( screenRow === range . end . row - 1 ) {
717- data . context . fillRect ( xEnd , yEnd - 1 , canvasWidth - xEnd , 1 )
724+ context . fillRect ( xEnd , yEnd - 1 , canvasWidth - xEnd , 1 )
718725 }
719726 }
720727 }
0 commit comments