diff options
author | Alexandru Dima <alexdima@microsoft.com> | 2022-07-28 16:23:14 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-28 16:23:14 +0300 |
commit | e65cf31952eb7d7a925b12da13726ea832c56b34 (patch) | |
tree | b93c7b446d7394796da98bbe91072daf1c89b270 /src | |
parent | 95fd5bf198bc9f0083421ce5a53c05ca0294a7fd (diff) |
Fix view model event and expose a way to get hidden areas (#156571)
* Fix emitting of wrong event in view model
* Add `IViewModel.getHiddenAreas`
Diffstat (limited to 'src')
-rw-r--r-- | src/vs/editor/common/viewModel.ts | 2 | ||||
-rw-r--r-- | src/vs/editor/common/viewModel/viewModelImpl.ts | 8 |
2 files changed, 8 insertions, 2 deletions
diff --git a/src/vs/editor/common/viewModel.ts b/src/vs/editor/common/viewModel.ts index d4b67391d99..55f613af360 100644 --- a/src/vs/editor/common/viewModel.ts +++ b/src/vs/editor/common/viewModel.ts @@ -48,6 +48,8 @@ export interface IViewModel extends ICursorSimpleModel { getCompletelyVisibleViewRange(): Range; getCompletelyVisibleViewRangeAtScrollTop(scrollTop: number): Range; + getHiddenAreas(): Range[]; + getLineCount(): number; getLineContent(lineNumber: number): string; getLineLength(lineNumber: number): number; diff --git a/src/vs/editor/common/viewModel/viewModelImpl.ts b/src/vs/editor/common/viewModel/viewModelImpl.ts index 160d63c8b33..a241643468e 100644 --- a/src/vs/editor/common/viewModel/viewModelImpl.ts +++ b/src/vs/editor/common/viewModel/viewModelImpl.ts @@ -36,7 +36,7 @@ import { ILineBreaksComputer, ILineBreaksComputerFactory, InjectedText } from 'v import { ViewEventHandler } from 'vs/editor/common/viewEventHandler'; import { ICoordinatesConverter, InlineDecoration, IViewModel, IWhitespaceChangeAccessor, MinimapLinesRenderingData, OverviewRulerDecorationsGroup, ViewLineData, ViewLineRenderingData, ViewModelDecoration } from 'vs/editor/common/viewModel'; import { ViewModelDecorations } from 'vs/editor/common/viewModel/viewModelDecorations'; -import { FocusChangedEvent, ModelContentChangedEvent, ModelDecorationsChangedEvent, ModelLanguageChangedEvent, ModelLanguageConfigurationChangedEvent, ModelOptionsChangedEvent, ModelTokensChangedEvent, OutgoingViewModelEvent, ReadOnlyEditAttemptEvent, ScrollChangedEvent, ViewModelEventDispatcher, ViewModelEventsCollector, ViewZonesChangedEvent } from 'vs/editor/common/viewModelEventDispatcher'; +import { FocusChangedEvent, HiddenAreasChangedEvent, ModelContentChangedEvent, ModelDecorationsChangedEvent, ModelLanguageChangedEvent, ModelLanguageConfigurationChangedEvent, ModelOptionsChangedEvent, ModelTokensChangedEvent, OutgoingViewModelEvent, ReadOnlyEditAttemptEvent, ScrollChangedEvent, ViewModelEventDispatcher, ViewModelEventsCollector, ViewZonesChangedEvent } from 'vs/editor/common/viewModelEventDispatcher'; import { IViewModelLines, ViewModelLinesFromModelAsIs, ViewModelLinesFromProjectedModel } from 'vs/editor/common/viewModel/viewModelLines'; import { IThemeService } from 'vs/platform/theme/common/themeService'; @@ -485,7 +485,7 @@ export class ViewModel extends Disposable implements IViewModel { this._updateConfigurationViewLineCount.schedule(); if (lineMappingChanged) { - this._eventDispatcher.emitOutgoingEvent(new ViewZonesChangedEvent()); + this._eventDispatcher.emitOutgoingEvent(new HiddenAreasChangedEvent()); } } @@ -508,6 +508,10 @@ export class ViewModel extends Disposable implements IViewModel { return this._toModelVisibleRanges(visibleViewRange); } + public getHiddenAreas(): Range[] { + return this._lines.getHiddenAreas(); + } + private _toModelVisibleRanges(visibleViewRange: Range): Range[] { const visibleRange = this.coordinatesConverter.convertViewRangeToModelRange(visibleViewRange); const hiddenAreas = this._lines.getHiddenAreas(); |