66import { RGBA } from 'vs/base/common/color' ;
77import { hash } from 'vs/base/common/hash' ;
88import { IDisposable , dispose } from 'vs/base/common/lifecycle' ;
9- import { TPromise } from 'vs/base/common/winjs.base' ;
109import { IEditorContribution } from 'vs/editor/common/editorCommon' ;
1110import { registerEditorContribution } from 'vs/editor/browser/editorExtensions' ;
1211import { ICodeEditor } from 'vs/editor/browser/editorBrowser' ;
@@ -17,7 +16,7 @@ import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService
1716import { getColors , IColorData } from 'vs/editor/contrib/colorPicker/color' ;
1817import { IConfigurationService } from 'vs/platform/configuration/common/configuration' ;
1918import { ModelDecorationOptions } from 'vs/editor/common/model/textModel' ;
20- import { TimeoutTimer } from 'vs/base/common/async' ;
19+ import { TimeoutTimer , CancelablePromise , createCancelablePromise } from 'vs/base/common/async' ;
2120
2221const MAX_DECORATORS = 500 ;
2322
@@ -29,7 +28,7 @@ export class ColorDetector implements IEditorContribution {
2928
3029 private _globalToDispose : IDisposable [ ] = [ ] ;
3130 private _localToDispose : IDisposable [ ] = [ ] ;
32- private _computePromise : TPromise < void > ;
31+ private _computePromise : CancelablePromise < void > ;
3332 private _timeoutTimer : TimeoutTimer ;
3433
3534 private _decorationsIds : string [ ] = [ ] ;
@@ -128,10 +127,12 @@ export class ColorDetector implements IEditorContribution {
128127 }
129128
130129 private beginCompute ( ) : void {
131- this . _computePromise = getColors ( this . _editor . getModel ( ) ) . then ( colorInfos => {
132- this . updateDecorations ( colorInfos ) ;
133- this . updateColorDecorators ( colorInfos ) ;
134- this . _computePromise = null ;
130+ this . _computePromise = createCancelablePromise ( token => {
131+ return getColors ( this . _editor . getModel ( ) , token ) . then ( colorInfos => {
132+ this . updateDecorations ( colorInfos ) ;
133+ this . updateColorDecorators ( colorInfos ) ;
134+ this . _computePromise = null ;
135+ } ) ;
135136 } ) ;
136137 }
137138
0 commit comments