@@ -23,13 +23,11 @@ import { LineDecoration } from 'vs/editor/common/viewLayout/lineDecorations';
2323import { renderViewLine , RenderLineInput } from 'vs/editor/common/viewLayout/viewLineRenderer' ;
2424import * as editorBrowser from 'vs/editor/browser/editorBrowser' ;
2525import { CodeEditor } from 'vs/editor/browser/codeEditor' ;
26- import { LineTokens } from 'vs/editor/common/core/lineTokens' ;
2726import { Configuration } from 'vs/editor/browser/config/configuration' ;
2827import { Position , IPosition } from 'vs/editor/common/core/position' ;
2928import { Selection , ISelection } from 'vs/editor/common/core/selection' ;
3029import { InlineDecoration , InlineDecorationType , ViewLineRenderingData } from 'vs/editor/common/viewModel/viewModel' ;
3130import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection' ;
32- import { ColorId , MetadataConsts , FontStyle } from 'vs/editor/common/modes' ;
3331import { Event , Emitter } from 'vs/base/common/event' ;
3432import * as editorOptions from 'vs/editor/common/config/editorOptions' ;
3533import { registerThemingParticipant , IThemeService , ITheme , getThemeTypeSelector } from 'vs/platform/theme/common/themeService' ;
@@ -1175,7 +1173,7 @@ interface IDataSource {
11751173 getModifiedEditor ( ) : editorBrowser . ICodeEditor ;
11761174}
11771175
1178- class DiffEditorWidgetStyle extends Disposable {
1176+ abstract class DiffEditorWidgetStyle extends Disposable {
11791177
11801178 _dataSource : IDataSource ;
11811179 _insertColor : Color ;
@@ -1223,17 +1221,9 @@ class DiffEditorWidgetStyle extends Disposable {
12231221 } ;
12241222 }
12251223
1226- _getViewZones ( lineChanges : editorCommon . ILineChange [ ] , originalForeignVZ : IEditorWhitespace [ ] , modifiedForeignVZ : IEditorWhitespace [ ] , originalEditor : editorBrowser . ICodeEditor , modifiedEditor : editorBrowser . ICodeEditor , renderIndicators : boolean ) : IEditorsZones {
1227- return null ;
1228- }
1229-
1230- _getOriginalEditorDecorations ( lineChanges : editorCommon . ILineChange [ ] , ignoreTrimWhitespace : boolean , renderIndicators : boolean , originalEditor : editorBrowser . ICodeEditor , modifiedEditor : editorBrowser . ICodeEditor ) : IEditorDiffDecorations {
1231- return null ;
1232- }
1233-
1234- _getModifiedEditorDecorations ( lineChanges : editorCommon . ILineChange [ ] , ignoreTrimWhitespace : boolean , renderIndicators : boolean , originalEditor : editorBrowser . ICodeEditor , modifiedEditor : editorBrowser . ICodeEditor ) : IEditorDiffDecorations {
1235- return null ;
1236- }
1224+ protected abstract _getViewZones ( lineChanges : editorCommon . ILineChange [ ] , originalForeignVZ : IEditorWhitespace [ ] , modifiedForeignVZ : IEditorWhitespace [ ] , originalEditor : editorBrowser . ICodeEditor , modifiedEditor : editorBrowser . ICodeEditor , renderIndicators : boolean ) : IEditorsZones ;
1225+ protected abstract _getOriginalEditorDecorations ( lineChanges : editorCommon . ILineChange [ ] , ignoreTrimWhitespace : boolean , renderIndicators : boolean , originalEditor : editorBrowser . ICodeEditor , modifiedEditor : editorBrowser . ICodeEditor ) : IEditorDiffDecorations ;
1226+ protected abstract _getModifiedEditorDecorations ( lineChanges : editorCommon . ILineChange [ ] , ignoreTrimWhitespace : boolean , renderIndicators : boolean , originalEditor : editorBrowser . ICodeEditor , modifiedEditor : editorBrowser . ICodeEditor ) : IEditorDiffDecorations ;
12371227}
12381228
12391229interface IMyViewZone extends editorBrowser . IViewZone {
@@ -1617,12 +1607,12 @@ class DiffEdtorWidgetSideBySide extends DiffEditorWidgetStyle implements IDiffEd
16171607 return this . _dataSource . getHeight ( ) ;
16181608 }
16191609
1620- _getViewZones ( lineChanges : editorCommon . ILineChange [ ] , originalForeignVZ : IEditorWhitespace [ ] , modifiedForeignVZ : IEditorWhitespace [ ] , originalEditor : editorBrowser . ICodeEditor , modifiedEditor : editorBrowser . ICodeEditor ) : IEditorsZones {
1610+ protected _getViewZones ( lineChanges : editorCommon . ILineChange [ ] , originalForeignVZ : IEditorWhitespace [ ] , modifiedForeignVZ : IEditorWhitespace [ ] , originalEditor : editorBrowser . ICodeEditor , modifiedEditor : editorBrowser . ICodeEditor ) : IEditorsZones {
16211611 let c = new SideBySideViewZonesComputer ( lineChanges , originalForeignVZ , modifiedForeignVZ ) ;
16221612 return c . getViewZones ( ) ;
16231613 }
16241614
1625- _getOriginalEditorDecorations ( lineChanges : editorCommon . ILineChange [ ] , ignoreTrimWhitespace : boolean , renderIndicators : boolean , originalEditor : editorBrowser . ICodeEditor , modifiedEditor : editorBrowser . ICodeEditor ) : IEditorDiffDecorations {
1615+ protected _getOriginalEditorDecorations ( lineChanges : editorCommon . ILineChange [ ] , ignoreTrimWhitespace : boolean , renderIndicators : boolean , originalEditor : editorBrowser . ICodeEditor , modifiedEditor : editorBrowser . ICodeEditor ) : IEditorDiffDecorations {
16261616 const overviewZoneColor = this . _removeColor . toString ( ) ;
16271617
16281618 let result : IEditorDiffDecorations = {
@@ -1682,7 +1672,7 @@ class DiffEdtorWidgetSideBySide extends DiffEditorWidgetStyle implements IDiffEd
16821672 return result ;
16831673 }
16841674
1685- _getModifiedEditorDecorations ( lineChanges : editorCommon . ILineChange [ ] , ignoreTrimWhitespace : boolean , renderIndicators : boolean , originalEditor : editorBrowser . ICodeEditor , modifiedEditor : editorBrowser . ICodeEditor ) : IEditorDiffDecorations {
1675+ protected _getModifiedEditorDecorations ( lineChanges : editorCommon . ILineChange [ ] , ignoreTrimWhitespace : boolean , renderIndicators : boolean , originalEditor : editorBrowser . ICodeEditor , modifiedEditor : editorBrowser . ICodeEditor ) : IEditorDiffDecorations {
16861676 const overviewZoneColor = this . _insertColor . toString ( ) ;
16871677
16881678 let result : IEditorDiffDecorations = {
@@ -1749,7 +1739,7 @@ class SideBySideViewZonesComputer extends ViewZonesComputer {
17491739 super ( lineChanges , originalForeignVZ , modifiedForeignVZ ) ;
17501740 }
17511741
1752- _produceOriginalFromDiff ( lineChange : editorCommon . ILineChange , lineChangeOriginalLength : number , lineChangeModifiedLength : number ) : IMyViewZone {
1742+ protected _produceOriginalFromDiff ( lineChange : editorCommon . ILineChange , lineChangeOriginalLength : number , lineChangeModifiedLength : number ) : IMyViewZone {
17531743 if ( lineChangeModifiedLength > lineChangeOriginalLength ) {
17541744 return {
17551745 afterLineNumber : Math . max ( lineChange . originalStartLineNumber , lineChange . originalEndLineNumber ) ,
@@ -1760,7 +1750,7 @@ class SideBySideViewZonesComputer extends ViewZonesComputer {
17601750 return null ;
17611751 }
17621752
1763- _produceModifiedFromDiff ( lineChange : editorCommon . ILineChange , lineChangeOriginalLength : number , lineChangeModifiedLength : number ) : IMyViewZone {
1753+ protected _produceModifiedFromDiff ( lineChange : editorCommon . ILineChange , lineChangeOriginalLength : number , lineChangeModifiedLength : number ) : IMyViewZone {
17641754 if ( lineChangeOriginalLength > lineChangeModifiedLength ) {
17651755 return {
17661756 afterLineNumber : Math . max ( lineChange . modifiedStartLineNumber , lineChange . modifiedEndLineNumber ) ,
@@ -1797,12 +1787,12 @@ class DiffEdtorWidgetInline extends DiffEditorWidgetStyle implements IDiffEditor
17971787 // Nothing to do..
17981788 }
17991789
1800- _getViewZones ( lineChanges : editorCommon . ILineChange [ ] , originalForeignVZ : IEditorWhitespace [ ] , modifiedForeignVZ : IEditorWhitespace [ ] , originalEditor : editorBrowser . ICodeEditor , modifiedEditor : editorBrowser . ICodeEditor , renderIndicators : boolean ) : IEditorsZones {
1790+ protected _getViewZones ( lineChanges : editorCommon . ILineChange [ ] , originalForeignVZ : IEditorWhitespace [ ] , modifiedForeignVZ : IEditorWhitespace [ ] , originalEditor : editorBrowser . ICodeEditor , modifiedEditor : editorBrowser . ICodeEditor , renderIndicators : boolean ) : IEditorsZones {
18011791 let computer = new InlineViewZonesComputer ( lineChanges , originalForeignVZ , modifiedForeignVZ , originalEditor , modifiedEditor , renderIndicators ) ;
18021792 return computer . getViewZones ( ) ;
18031793 }
18041794
1805- _getOriginalEditorDecorations ( lineChanges : editorCommon . ILineChange [ ] , ignoreTrimWhitespace : boolean , renderIndicators : boolean , originalEditor : editorBrowser . ICodeEditor , modifiedEditor : editorBrowser . ICodeEditor ) : IEditorDiffDecorations {
1795+ protected _getOriginalEditorDecorations ( lineChanges : editorCommon . ILineChange [ ] , ignoreTrimWhitespace : boolean , renderIndicators : boolean , originalEditor : editorBrowser . ICodeEditor , modifiedEditor : editorBrowser . ICodeEditor ) : IEditorDiffDecorations {
18061796 const overviewZoneColor = this . _removeColor . toString ( ) ;
18071797
18081798 let result : IEditorDiffDecorations = {
@@ -1831,7 +1821,7 @@ class DiffEdtorWidgetInline extends DiffEditorWidgetStyle implements IDiffEditor
18311821 return result ;
18321822 }
18331823
1834- _getModifiedEditorDecorations ( lineChanges : editorCommon . ILineChange [ ] , ignoreTrimWhitespace : boolean , renderIndicators : boolean , originalEditor : editorBrowser . ICodeEditor , modifiedEditor : editorBrowser . ICodeEditor ) : IEditorDiffDecorations {
1824+ protected _getModifiedEditorDecorations ( lineChanges : editorCommon . ILineChange [ ] , ignoreTrimWhitespace : boolean , renderIndicators : boolean , originalEditor : editorBrowser . ICodeEditor , modifiedEditor : editorBrowser . ICodeEditor ) : IEditorDiffDecorations {
18351825 const overviewZoneColor = this . _insertColor . toString ( ) ;
18361826
18371827 let result : IEditorDiffDecorations = {
@@ -1913,7 +1903,7 @@ class InlineViewZonesComputer extends ViewZonesComputer {
19131903 this . renderIndicators = renderIndicators ;
19141904 }
19151905
1916- _produceOriginalFromDiff ( lineChange : editorCommon . ILineChange , lineChangeOriginalLength : number , lineChangeModifiedLength : number ) : IMyViewZone {
1906+ protected _produceOriginalFromDiff ( lineChange : editorCommon . ILineChange , lineChangeOriginalLength : number , lineChangeModifiedLength : number ) : IMyViewZone {
19171907 let marginDomNode = document . createElement ( 'div' ) ;
19181908 marginDomNode . className = 'inline-added-margin-view-zone' ;
19191909 Configuration . applyFontInfoSlow ( marginDomNode , this . modifiedEditorConfiguration . fontInfo ) ;
@@ -1926,7 +1916,7 @@ class InlineViewZonesComputer extends ViewZonesComputer {
19261916 } ;
19271917 }
19281918
1929- _produceModifiedFromDiff ( lineChange : editorCommon . ILineChange , lineChangeOriginalLength : number , lineChangeModifiedLength : number ) : IMyViewZone {
1919+ protected _produceModifiedFromDiff ( lineChange : editorCommon . ILineChange , lineChangeOriginalLength : number , lineChangeModifiedLength : number ) : IMyViewZone {
19301920 let decorations : InlineDecoration [ ] = [ ] ;
19311921 if ( lineChange . charChanges ) {
19321922 for ( let j = 0 , lengthJ = lineChange . charChanges . length ; j < lengthJ ; j ++ ) {
@@ -1946,7 +1936,7 @@ class InlineViewZonesComputer extends ViewZonesComputer {
19461936 let lineDecorationsWidth = this . modifiedEditorConfiguration . layoutInfo . decorationsWidth ;
19471937 let lineHeight = this . modifiedEditorConfiguration . lineHeight ;
19481938 for ( let lineNumber = lineChange . originalStartLineNumber ; lineNumber <= lineChange . originalEndLineNumber ; lineNumber ++ ) {
1949- this . renderOriginalLine ( lineNumber - lineChange . originalStartLineNumber , this . originalModel , this . modifiedEditorConfiguration , this . modifiedEditorTabSize , lineNumber , decorations , sb ) ;
1939+ this . _renderOriginalLine ( lineNumber - lineChange . originalStartLineNumber , this . originalModel , this . modifiedEditorConfiguration , this . modifiedEditorTabSize , lineNumber , decorations , sb ) ;
19501940
19511941 if ( this . renderIndicators ) {
19521942 let index = lineNumber - lineChange . originalStartLineNumber ;
@@ -1975,22 +1965,11 @@ class InlineViewZonesComputer extends ViewZonesComputer {
19751965 } ;
19761966 }
19771967
1978- private renderOriginalLine ( count : number , originalModel : ITextModel , config : editorOptions . InternalEditorOptions , tabSize : number , lineNumber : number , decorations : InlineDecoration [ ] , sb : IStringBuilder ) : void {
1979- let lineContent = originalModel . getLineContent ( lineNumber ) ;
1980-
1981- let actualDecorations = LineDecoration . filter ( decorations , lineNumber , 1 , lineContent . length + 1 ) ;
1982-
1983- const defaultMetadata = (
1984- ( FontStyle . None << MetadataConsts . FONT_STYLE_OFFSET )
1985- | ( ColorId . DefaultForeground << MetadataConsts . FOREGROUND_OFFSET )
1986- | ( ColorId . DefaultBackground << MetadataConsts . BACKGROUND_OFFSET )
1987- ) >>> 0 ;
1988-
1989- const tokens = new Uint32Array ( 2 ) ;
1990- tokens [ 0 ] = lineContent . length ;
1991- tokens [ 1 ] = defaultMetadata ;
1968+ private _renderOriginalLine ( count : number , originalModel : ITextModel , config : editorOptions . InternalEditorOptions , tabSize : number , lineNumber : number , decorations : InlineDecoration [ ] , sb : IStringBuilder ) : void {
1969+ const lineTokens = originalModel . getLineTokens ( lineNumber ) ;
1970+ const lineContent = lineTokens . getLineContent ( ) ;
19921971
1993- const lineTokens = new LineTokens ( tokens , lineContent ) ;
1972+ const actualDecorations = LineDecoration . filter ( decorations , lineNumber , 1 , lineContent . length + 1 ) ;
19941973
19951974 sb . appendASCIIString ( '<div class="view-line' ) ;
19961975 if ( decorations . length === 0 ) {
0 commit comments