Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Editor decoration doesn't show up when changing from multiple lines to one line at the same time #208511

Closed
roblourens opened this issue Mar 23, 2024 · 4 comments · Fixed by #210917
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug editor-core Editor basic functionality insiders-released Patch has been released in VS Code Insiders verified Verification succeeded
Milestone

Comments

@roblourens
Copy link
Member

I set a 'placeholder' editor decoration here:

this.widget.inputEditor.setDecorationsByType(decorationDescription, placeholderDecorationType, decoration);

I noticed that when the chat input had multiple lines of text in it, then the placeholder doesn't show up. Here I show it not working, then working with a single line of text.

Recording 2024-03-23 at 16 22 10

Maybe it's related somehow to the issue we had in #203902? I can't debug this on my own, but it reproes 100% of the time for me, happy to help investigate.

@hediet
Copy link
Member

hediet commented Mar 26, 2024

setTimeout(() => {
  this.widget.inputEditor.setDecorationsByType(decorationDescription, placeholderDecorationType, decoration);
}, 0);

This fixes it, but it sucks.

@alexdima it looks like setDecorationsByType cannot be used when certain events are fired.
Looks like the view fires a scroll change event, which causes the event queue to flush, which causes a content change event, which calls the callback that sets the decoration...

@hediet hediet assigned alexdima and unassigned hediet Mar 26, 2024
@alexdima
Copy link
Member

AFAIK nothing changed here in the editor recently, so @roblourens not sure if this is bad enough to add the workaround Henning found for this release on your side.

IMHO we need to add proper placeholder API to the editor instead of doing this from the outside with injected text. We now have something like 3 or 4 places implementing placeholder text via injected text, which doesn't make sense to me.

@alexdima alexdima added this to the April 2024 milestone Mar 27, 2024
@hediet
Copy link
Member

hediet commented Mar 28, 2024

Created #208976 for the placeholder API.
Feel free to close this one in favor of #208976

hediet added a commit that referenced this issue Apr 22, 2024
@hediet hediet added bug Issue identified by VS Code Team member as probable bug editor-core Editor basic functionality labels Apr 22, 2024
@hediet
Copy link
Member

hediet commented Apr 22, 2024

The event stack is quite complicated. Below is the stack of where the decoration is set.
The core problem is that ViewLines.renderText fires an event and allows event handlers to run immediately:

Code_-_Insiders_YlXucgKjRm

Error
at eval
at vs/workbench/contrib/chat/browser/contrib/chatInputEditorContrib.ts:147:8
at vs/workbench/contrib/chat/browser/contrib/chatInputEditorContrib.ts:68:76
at vs/base/common/event.ts:1156:12
at vs/base/common/event.ts:1167:8
at vs/base/common/event.ts:1178:8
at vs/editor/browser/widget/codeEditor/codeEditorWidget.ts:1631:29
at vs/base/common/event.ts:1156:12
at vs/base/common/event.ts:1187:8
at vs/editor/common/viewModelEventDispatcher.ts:64:17
at vs/editor/common/viewModelEventDispatcher.ts:39:7
at vs/editor/common/viewModel/viewModelImpl.ts:135:25
at vs/base/common/event.ts:1156:12
at vs/base/common/event.ts:1187:8
at vs/editor/common/viewLayout/viewLayout.ts:127:32
at vs/editor/common/viewLayout/viewLayout.ts:350:19
at vs/editor/common/viewLayout/viewLayout.ts:340:7
at vs/editor/browser/viewParts/lines/viewLines.ts:676:38
at vs/editor/browser/viewParts/lines/viewLines.ts:560:7
at vs/editor/browser/viewParts/lines/viewLines.ts:513:14
at vs/editor/browser/viewParts/lines/viewLines.ts:643:12
at vs/editor/browser/view.ts:501:21
at func vs/editor/browser/view.ts:676:9
at safeInvokeNoArg vs/editor/browser/view.ts:447:15
at vs/editor/browser/view.ts:582:8
at vs/editor/browser/widget/codeEditor/codeEditorWidget.ts:1566:23
at vs/editor/browser/widget/codeEditor/codeEditorWidget.ts:1384:8
at vs/workbench/contrib/chat/browser/chatInputPart.ts:468:21
at vs/workbench/contrib/chat/browser/chatInputPart.ts:450:14
at vs/workbench/contrib/chat/browser/chatWidget.ts:769:17
at vs/workbench/contrib/chat/browser/chatWidget.ts:603:8
at vs/workbench/contrib/chat/browser/chatWidget.ts:576:69
at vs/base/common/event.ts:1156:12
at vs/base/common/event.ts:1167:8
at vs/base/common/event.ts:1178:8
at vs/editor/browser/widget/codeEditor/codeEditorWidget.ts:1676:37
at vs/base/common/event.ts:1156:12
at vs/base/common/event.ts:1187:8
at vs/editor/common/viewModelEventDispatcher.ts:64:17
at vs/editor/common/viewModelEventDispatcher.ts:109:7
at vs/editor/common/viewModel/viewModelImpl.ts:147:26
at vs/base/common/event.ts:1156:12
at vs/base/common/event.ts:1187:8
at vs/editor/browser/config/editorConfiguration.ts:105:24
at vs/editor/browser/config/editorConfiguration.ts:90:64
at vs/base/common/event.ts:1156:12
at vs/base/common/event.ts:1187:8
at vs/editor/browser/config/elementSizeObserver.ts:117:22
at vs/editor/browser/config/elementSizeObserver.ts:98:7
at vs/editor/browser/config/editorConfiguration.ts:167:26
at vs/editor/browser/widget/codeEditor/codeEditorWidget.ts:1382:22
at vs/workbench/contrib/chat/browser/chatInputPart.ts:468:21
at vs/workbench/contrib/chat/browser/chatInputPart.ts:450:14
at vs/workbench/contrib/chat/browser/chatWidget.ts:769:17
at vs/workbench/contrib/chat/browser/chatWidget.ts:572:9
at vs/base/common/event.ts:1156:12
at vs/base/common/event.ts:1187:8
at vs/workbench/contrib/chat/browser/chatInputPart.ts:320:28
at vs/base/common/event.ts:1156:12
at vs/base/common/event.ts:1167:8
at vs/base/common/event.ts:1191:8
at vs/editor/browser/widget/codeEditor/codeEditorWidget.ts:1702:35
at vs/base/common/event.ts:1156:12
at vs/base/common/event.ts:1187:8
at vs/editor/common/viewModelEventDispatcher.ts:64:17
at vs/editor/common/viewModelEventDispatcher.ts:109:7
at vs/editor/common/viewModel/viewModelImpl.ts:1109:25
at vs/editor/common/viewModel/viewModelImpl.ts:1043:7
at vs/editor/common/viewModel/viewModelImpl.ts:1064:7
at vs/editor/browser/widget/codeEditor/codeEditorWidget.ts:1132:28
at vs/editor/browser/widget/codeEditor/codeEditorWidget.ts:1763:10
at vs/editor/browser/view/viewController.ts:88:23
at vs/editor/browser/controller/textAreaHandler.ts:336:24
at vs/base/common/event.ts:1156:12
at vs/base/common/event.ts:1187:8
at vs/editor/browser/controller/textAreaInput.ts:221:80
at vs/base/common/async.ts:1022:15
at vs/base/common/async.ts:1017:8

hediet added a commit that referenced this issue Apr 22, 2024
@vscodenpa vscodenpa added the unreleased Patch has not yet been released in VS Code Insiders label Apr 22, 2024
sergioengineer pushed a commit to sergioengineer/VimSCode that referenced this issue Apr 23, 2024
@vscodenpa vscodenpa added insiders-released Patch has been released in VS Code Insiders and removed unreleased Patch has not yet been released in VS Code Insiders labels Apr 23, 2024
@eleanorjboyd eleanorjboyd added the verified Verification succeeded label Apr 24, 2024
@microsoft microsoft locked and limited conversation to collaborators Jun 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug editor-core Editor basic functionality insiders-released Patch has been released in VS Code Insiders verified Verification succeeded
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants