Change:
<!-- Do Not Delete This! bugreporttemplate --<!-- Please read our Rules of Conduct: --<!-- Read our guide about submitting issues: --<!-- Search existing issues to avoid creating duplicates. --<!-- Test using the latest Insiders build to see if your issue has already been fixed: --<!-- Instead of creating your report here, use 'Report Issue' from the 'Help' menu in VS Code to pre-fill useful information. --<!-- Launch with to check. --Does this issue occur when all extensions are disabled?: Yes <!-- If you answered No above, use 'Help: Start Extension Bisect' from Command Palette to try to identify the cause. --<!-- Issues caused by an extension need to be reported directly to the extension publisher. The 'Help Report Issue' dialog can assist with this. --- VS Code Version: 1.85.0 OS Version: Ubuntu 23.04 a file with contents a file with contents the explorer, right click on file and select the explorer, right click on file and select , opening the diff editor the diff editor that , and event listeners have been but not been removed The issue is not present in VS Code 1.84.2. It seems to be caused by

Discussion:
*  Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ <ins> import { addDisposableListener, h, EventType } from 'vs/base/browser/dom'; import { renderIcon } from 'vs/base/browser/ui/iconLabel/iconLabels'; import { Codicon } from 'vs/base/common/codicons'; </ins> import { Disposable, toDisposable } from 'vs/base/common/lifecycle'; import { IObservable, autorunWithStore, derived } from 'vs/base/common/observable'; import { IGlyphMarginWidget, IGlyphMarginWidgetPosition } from 'vs/editor/browser/editorBrowser';

import { DiffEditorWidget } from 'vs/editor/browser/widget/diffEditor/diffEditorWidget'; import { LineRange, LineRangeSet } from 'vs/editor/common/core/lineRange'; import { Range } from 'vs/editor/common/core/range'; <ins> import { RangeMapping } from 'vs/editor/common/diff/rangeMapping'; </ins> import { GlyphMarginLane } from 'vs/editor/common/model'; import { localize } from 'vs/nls'; <del> import { RangeMapping } from 'vs/editor/common/diff/rangeMapping'; import { renderIcon } from 'vs/base/browser/ui/iconLabel/iconLabels'; import { Codicon } from 'vs/base/common/codicons'; import { h } from 'vs/base/browser/dom'; </del> export class RevertButtonsFeature extends Disposable { constructor(

if (selectedDiffs_.length > 0) { const selections = this._editors.modifiedSelections.read(reader); <del> const btn = new RevertButton(selections[selections.length - 1].positionLineNumber, this._widget, selectedDiffs_.flatMap(d => d.rangeMappings), true); </del> <ins> const btn = store.add(new RevertButton(selections[selections.length - 1].positionLineNumber, this._widget, selectedDiffs_.flatMap(d => d.rangeMappings), true)); </ins> this._editors.modified.addGlyphMarginWidget(btn); glyphWidgetsModified.push(btn); }

continue; } if (!m.lineRangeMapping.modified.isEmpty && m.lineRangeMapping.innerChanges) { <del> const btn = new RevertButton(m.lineRangeMapping.modified.startLineNumber, this._widget, m.lineRangeMapping.innerChanges, false); </del> <ins> const btn = store.add(new RevertButton(m.lineRangeMapping.modified.startLineNumber, this._widget, m.lineRangeMapping.innerChanges, false)); </ins> this._editors.modified.addGlyphMarginWidget(btn); glyphWidgetsModified.push(btn); }

} } <del> export class RevertButton implements IGlyphMarginWidget { </del> <ins> export class RevertButton extends Disposable implements IGlyphMarginWidget { </ins> public static counter = 0; private readonly _id: string = `revertButton${RevertButton.counter++}`;

private readonly _diffs: RangeMapping[], private readonly _selection: boolean, ) { <del> this._domNode.onmousedown = e => { </del> <ins> super(); this._register(addDisposableListener(this._domNode, EventType.MOUSE_DOWN, e => { </ins> // don't prevent context menu from showing up if (e.button !== 2) { e.stopPropagation(); e.preventDefault(); } <del> }; this._domNode.onmouseup = e => { </del> <ins> })); this._register(addDisposableListener(this._domNode, EventType.MOUSE_UP, e => { </ins> e.stopPropagation(); e.preventDefault(); <del> }; this._domNode.onclick = (e) => { </del> <ins> })); this._register(addDisposableListener(this._domNode, EventType.CLICK, (e) => { </ins> this._widget.revertRangeMappings(this._diffs); e.stopPropagation(); e.preventDefault(); <del> }; </del> <ins> })); </ins> } /**