Change:
<!-- Do Not Delete This! featurerequesttemplate --<!-- Please read our Rules of Conduct: --<!-- Please search existing issues to avoid creating duplicates. --<!-- Describe the feature you'd like. --Currently, the inlay hints will clean and shows again as scheduler's strategy. It's might not friendly if you are editing some line who has many hints. I have an idea: Clean all hints where the cursor’s line when we are editing the code and append new hints by the scheduler. I think It's might improve the experience about inlay hints.
(Experimental duplicate detection) Thanks for submitting this issue. Please also check if it is already covered by an existing one, like: <!-- score: 0.494 --<!-- potentialduplicatescomment --
/gifPlease
!
I think inlay hints should disappear immediately if the surrounding text is deleted. Afaik, currently, when text gets deleted, decorations inside of that text get collapsed but are not deleted.
Yes, I agree that hints should disappear immediately when their "anchor" position is removed. Maybe it's not so easy to know what remove actually means in this case. Arguably this is an editor bug as I was expecting this to work?
I wouldn't call this a bug - decorations are never removed automatically. Alex suggests (I asked him before his vacation): I also suggest to extend the inlay hints API so that a hint refers to a range. The hint itself then can either be after or before the range. The range allows to better predict what should happen with the hint if the text changes. With injected text, we now have two cursor stops around inlay hints - both refer to the same model position. Maybe the move behavior of inlay text should depend on the view position where the text change was caused from? I suggest to think about how we can better predict synchronously how a text change affects inlay hints.
This is how we started, mostly to optionally support overlay hints, and everyone was confused about ranges for inlay hints. Using a range with before/after screams "position" and I don't want to leak an implementation detail into the API. We would also still have the case of empty ranges... I'd rather create "fake ranges" from positions so that I can use the notion of collapsed ranges.
I have pushed a change () to use the range of touching words of inlay positions (when possible). In that case will be and my expectation was that decorations hide/disappear when removing all their text.. is that a bug in decorations land or am I using this wrong? Should I listen to decoration changes and "manually" remove them?
I think so, decorations are not removed automatically.
But what does mean then?
Ah, maybe I forgot to consider that flag for injected text, I'll look into it tomorrow.

Discussion:
public getInjectedTextInInterval(host: IDecorationsTreesHost, start: number, end: number, filterOwnerId: number): model.IModelDecoration[] { const versionId = host.getVersionId(); const result = this._injectedTextDecorationsTree.intervalSearch(start, end, filterOwnerId, false, versionId); <del> return this._ensureNodesHaveRanges(host, result); </del> <ins> return this._ensureNodesHaveRanges(host, result).filter((i) => i.options.showIfCollapsed || !i.range.isEmpty()); </ins> } public getAllInjectedText(host: IDecorationsTreesHost, filterOwnerId: number): model.IModelDecoration[] { const versionId = host.getVersionId(); const result = this._injectedTextDecorationsTree.search(filterOwnerId, false, versionId); <del> return this._ensureNodesHaveRanges(host, result); </del> <ins> return this._ensureNodesHaveRanges(host, result).filter((i) => i.options.showIfCollapsed || !i.range.isEmpty()); </ins> } public getAll(host: IDecorationsTreesHost, filterOwnerId: number, filterOutValidation: boolean, overviewRulerOnly: boolean): model.IModelDecoration[] {

range: Range.fromPositions(new Position(lineNumber, p.column)), options: shouldUseInjectedText ? { description: 'ghost-text', <del> after: { content: contentText, inlineClassName: p.preview ? 'ghost-text-decoration-preview' : 'ghost-text-decoration' } </del> <ins> after: { content: contentText, inlineClassName: p.preview ? 'ghost-text-decoration-preview' : 'ghost-text-decoration' }, showIfCollapsed: true, </ins> } : { ...decorationType.resolve() }

options: { after: { content: 'injected1' }, description: 'test1', <ins> showIfCollapsed: true </ins> }, range: new Range(1, 1, 1, 1), }]);

options: { after: { content: 'injected1' }, description: 'test1', <ins> showIfCollapsed: true </ins> }, range: new Range(2, 1, 2, 1), }, { options: { after: { content: 'injected2' }, description: 'test2', <ins> showIfCollapsed: true </ins> }, range: new Range(2, 2, 2, 2), }]);

description: 'example', after: { content: 'very very long injected text that causes a line break' <del> } </del> <ins> }, showIfCollapsed: true, </ins> } }]);

description: 'test', before: { content: 'bar' <del> } </del> <ins> }, showIfCollapsed: true </ins> } }, {

description: 'test', before: { content: 'bz' <del> } </del> <ins> }, showIfCollapsed: true </ins> } }, ]);

content: renderStringAsPlaintext(message), inlineClassName: `test-message-inline-content test-message-inline-content-s${severity} ${this.contentIdClass}` }; <ins> options.showIfCollapsed = true; </ins> const rulerColor = severity === TestMessageType.Error ? overviewRulerError