Change:
Open the chat sidebar Type , pick from suggest widget Pick a file, so it reads eg Delete the full contents of the input with cmd+backspace Get this error I think I understand what's happening here. I have two listeners that each call . The first one runs, and after setting decorations, it calls to continue firing events, so my second listener runs, and also calls . And this is considered recursive because it happens before was decremented but isn't "really" recursive, to me. So is it bad practice to call synchronously inside ? Or is there something else I should be doing differently?
I think the actual problem is that is used here: This should use instead. Feel free to provide a PR.

Discussion:
import 'vs/editor/browser/services/markerDecorations'; <del> import 'vs/css!./media/editor'; import * as nls from 'vs/nls'; </del> import * as dom from 'vs/base/browser/dom'; import { IKeyboardEvent } from 'vs/base/browser/keyboardEvent'; import { IMouseWheelEvent } from 'vs/base/browser/mouseEvent';

import { onUnexpectedError } from 'vs/base/common/errors'; import { Emitter, EmitterOptions, Event, EventDeliveryQueue, createEventDeliveryQueue } from 'vs/base/common/event'; import { hash } from 'vs/base/common/hash'; <del> import { Disposable, IDisposable, dispose, DisposableStore } from 'vs/base/common/lifecycle'; </del> <ins> import { Disposable, DisposableStore, IDisposable, dispose } from 'vs/base/common/lifecycle'; </ins> import { Schemas } from 'vs/base/common/network'; <ins> import 'vs/css!./media/editor'; import { applyFontInfo } from 'vs/editor/browser/config/domFontInfo'; </ins> import { EditorConfiguration, IEditorConstructionOptions } from 'vs/editor/browser/config/editorConfiguration'; <ins> import { TabFocus } from 'vs/editor/browser/config/tabFocus'; </ins> import * as editorBrowser from 'vs/editor/browser/editorBrowser'; import { EditorExtensionsRegistry, IEditorContributionDescription } from 'vs/editor/browser/editorExtensions'; import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService'; <del> import { ICommandDelegate } from 'vs/editor/browser/view/viewController'; </del> import { IContentWidgetData, IGlyphMarginWidgetData, IOverlayWidgetData, View } from 'vs/editor/browser/view'; <ins> import { DOMLineBreaksComputerFactory } from 'vs/editor/browser/view/domLineBreaksComputer'; import { ICommandDelegate } from 'vs/editor/browser/view/viewController'; </ins> import { ViewUserInputEvents } from 'vs/editor/browser/view/viewUserInputEvents'; <del> import { ConfigurationChangedEvent, EditorLayoutInfo, IEditorOptions, EditorOption, IComputedEditorOptions, FindComputedEditorOptionValueById, filterValidationDecorations } from 'vs/editor/common/config/editorOptions'; </del> <ins> import { CodeEditorContributions } from 'vs/editor/browser/widget/codeEditorContributions'; import { IEditorConfiguration } from 'vs/editor/common/config/editorConfiguration'; import { ConfigurationChangedEvent, EditorLayoutInfo, EditorOption, FindComputedEditorOptionValueById, IComputedEditorOptions, IEditorOptions, filterValidationDecorations } from 'vs/editor/common/config/editorOptions'; </ins> import { CursorColumns } from 'vs/editor/common/core/cursorColumns'; <del> import { CursorChangeReason, ICursorPositionChangedEvent, ICursorSelectionChangedEvent } from 'vs/editor/common/cursorEvents'; </del> <ins> import { IDimension } from 'vs/editor/common/core/dimension'; import { editorUnnecessaryCodeOpacity } from 'vs/editor/common/core/editorColorRegistry'; </ins> import { IPosition, Position } from 'vs/editor/common/core/position'; import { IRange, Range } from 'vs/editor/common/core/range'; import { ISelection, Selection } from 'vs/editor/common/core/selection'; <ins> import { IWordAtPosition } from 'vs/editor/common/core/wordHelper'; import { WordOperations } from 'vs/editor/common/cursor/cursorWordOperations'; import { CursorChangeReason, ICursorPositionChangedEvent, ICursorSelectionChangedEvent } from 'vs/editor/common/cursorEvents'; </ins> import { InternalEditorAction } from 'vs/editor/common/editorAction'; import * as editorCommon from 'vs/editor/common/editorCommon'; import { EditorContextKeys } from 'vs/editor/common/editorContextKeys'; <del> import { EndOfLinePreference, IIdentifiedSingleEditOperation, IModelDecoration, IModelDecorationOptions, IModelDecorationsChangeAccessor, IModelDeltaDecoration, ITextModel, ICursorStateComputer, IAttachedView } from 'vs/editor/common/model'; import { IWordAtPosition } from 'vs/editor/common/core/wordHelper'; </del> <ins> import { ILanguageConfigurationService } from 'vs/editor/common/languages/languageConfigurationRegistry'; import { EndOfLinePreference, IAttachedView, ICursorStateComputer, IIdentifiedSingleEditOperation, IModelDecoration, IModelDecorationOptions, IModelDecorationsChangeAccessor, IModelDeltaDecoration, ITextModel } from 'vs/editor/common/model'; </ins> import { ClassName } from 'vs/editor/common/model/intervalTree'; import { ModelDecorationOptions } from 'vs/editor/common/model/textModel'; <ins> import { ILanguageFeaturesService } from 'vs/editor/common/services/languageFeatures'; </ins> import { IModelContentChangedEvent, IModelDecorationsChangedEvent, IModelLanguageChangedEvent, IModelLanguageConfigurationChangedEvent, IModelOptionsChangedEvent, IModelTokensChangedEvent } from 'vs/editor/common/textModelEvents'; <del> import { editorUnnecessaryCodeOpacity } from 'vs/editor/common/core/editorColorRegistry'; import { editorErrorForeground, editorHintForeground, editorInfoForeground, editorWarningForeground } from 'vs/platform/theme/common/colorRegistry'; </del> import { VerticalRevealType } from 'vs/editor/common/viewEvents'; <ins> import { IEditorWhitespace, IViewModel } from 'vs/editor/common/viewModel'; import { MonospaceLineBreaksComputerFactory } from 'vs/editor/common/viewModel/monospaceLineBreaksComputer'; </ins> import { ViewModel } from 'vs/editor/common/viewModel/viewModelImpl'; <ins> import { OutgoingViewModelEventKind } from 'vs/editor/common/viewModelEventDispatcher'; import * as nls from 'vs/nls'; import { IAccessibilityService } from 'vs/platform/accessibility/common/accessibility'; </ins> import { ICommandService } from 'vs/platform/commands/common/commands'; import { ContextKeyValue, IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation'; import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection'; import { INotificationService, Severity } from 'vs/platform/notification/common/notification'; <ins> import { editorErrorForeground, editorHintForeground, editorInfoForeground, editorWarningForeground } from 'vs/platform/theme/common/colorRegistry'; </ins> import { IThemeService, registerThemingParticipant } from 'vs/platform/theme/common/themeService'; <del> import { IAccessibilityService } from 'vs/platform/accessibility/common/accessibility'; import { MonospaceLineBreaksComputerFactory } from 'vs/editor/common/viewModel/monospaceLineBreaksComputer'; import { DOMLineBreaksComputerFactory } from 'vs/editor/browser/view/domLineBreaksComputer'; import { WordOperations } from 'vs/editor/common/cursor/cursorWordOperations'; import { IEditorWhitespace, IViewModel } from 'vs/editor/common/viewModel'; import { OutgoingViewModelEventKind } from 'vs/editor/common/viewModelEventDispatcher'; import { ILanguageConfigurationService } from 'vs/editor/common/languages/languageConfigurationRegistry'; import { applyFontInfo } from 'vs/editor/browser/config/domFontInfo'; import { IEditorConfiguration } from 'vs/editor/common/config/editorConfiguration'; import { IDimension } from 'vs/editor/common/core/dimension'; import { ILanguageFeaturesService } from 'vs/editor/common/services/languageFeatures'; import { CodeEditorContributions } from 'vs/editor/browser/widget/codeEditorContributions'; import { TabFocus } from 'vs/editor/browser/config/tabFocus'; </del> let EDITOR_ID = 0;

// update all decorations const oldDecorationsIds = this._decorationTypeKeysToIds[decorationTypeKey] || []; <del> this._decorationTypeKeysToIds[decorationTypeKey] = this.deltaDecorations(oldDecorationsIds, newModelDecorations); </del> <ins> this.changeDecorations(accessor => this._decorationTypeKeysToIds[decorationTypeKey] = accessor.deltaDecorations(oldDecorationsIds, newModelDecorations)); </ins> } public setDecorationsByTypeFast(decorationTypeKey: string, ranges: IRange[]): void {

// update all decorations const oldDecorationsIds = this._decorationTypeKeysToIds[decorationTypeKey] || []; <del> this._decorationTypeKeysToIds[decorationTypeKey] = this.deltaDecorations(oldDecorationsIds, newModelDecorations); </del> <ins> this.changeDecorations(accessor => this._decorationTypeKeysToIds[decorationTypeKey] = accessor.deltaDecorations(oldDecorationsIds, newModelDecorations)); </ins> } public removeDecorationsByType(decorationTypeKey: string): void { // remove decorations for type and sub type const oldDecorationsIds = this._decorationTypeKeysToIds[decorationTypeKey]; if (oldDecorationsIds) { <del> this.deltaDecorations(oldDecorationsIds, []); </del> <ins> this.changeDecorations(accessor => accessor.deltaDecorations(oldDecorationsIds, [])); </ins> } if (this._decorationTypeKeysToIds.hasOwnProperty(decorationTypeKey)) { delete this._decorationTypeKeysToIds[decorationTypeKey];