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

Keybindings editor should emit change events on changes #142020

Closed
bpasero opened this issue Feb 2, 2022 · 7 comments
Closed

Keybindings editor should emit change events on changes #142020

bpasero opened this issue Feb 2, 2022 · 7 comments
Assignees
Labels
insiders-released Patch has been released in VS Code Insiders keybindings-editor Keybinding editor issues
Milestone

Comments

@bpasero
Copy link
Member

bpasero commented Feb 2, 2022

Update

This was originally a test failure, but my suggestion in the end would be to come up with a solution that lets the keybindings editor emit change events when they occur via the keybindings editor.

Original:

https://dev.azure.com/monacotools/Monaco/_build/results?buildId=153487&view=logs&j=672276a2-8d3a-5fab-615d-090c51352f92&t=0699ae84-7245-5a45-5eee-80b086af2725&l=101

1) VSCode Smoke Tests (Electron)
       Preferences
         changes "workbench.action.toggleSidebarPosition" command key binding and verifies it:
     Error: Timeout: get element '.keybindings-table-container .keybinding-label div[title="Control+U"]' after 20 seconds.
      at poll (D:\a\1\s\test\automation\src\code.ts:109:10)
      at Code.waitForElement (D:\a\1\s\test\automation\src\code.ts:263:10)
      at KeybindingsEditor.updateKeybinding (D:\a\1\s\test\automation\src\keybindings.ts:32:3)
      at Context.<anonymous> (src\areas\preferences\preferences.test.ts:30:4)

This test suffers from the same "relies on file changes events" issue.

@bpasero
Copy link
Member Author

bpasero commented Feb 2, 2022

I think this might require a change in the way the keybindings editor works: i.e. if a change is made, issue a change event, independent from the underlying file itself. I think the settings editor does the same.

@sandy081 sandy081 assigned alexdima and sandy081 and unassigned sandy081 Feb 2, 2022
@sandy081
Copy link
Member

sandy081 commented Feb 2, 2022

I think this might require a change in the way the keybindings editor works: i.e. if a change is made, issue a change event, independent from the underlying file itself. I think the settings editor does the same.

@alexdima we might need a way to refresh keybindings model

@bpasero bpasero added keybindings-editor Keybinding editor issues and removed smoke-test-failure labels Feb 2, 2022
@bpasero
Copy link
Member Author

bpasero commented Feb 2, 2022

After a bit of discussion with Sandeep, we came to the conclusion that a change from me probably is the underlying reason for the recent flakiness in the test. Specifically, file watching is more delayed on startup ever since it moved to the shared process and if a component or test relies on file events alone, there is a higher chance of failure.

I have opened #142027 for me to revisit this and I can bring back this test in its old form when that happened.

Nevertheless: I believe that we should never use file events as the only source of truth for changes when changes are made from within VSCode. File events are meant to detect changes from outside VSCode or an external program, not when changes are made within VSCode. As indicated, the keybindings editor should follow a similar strategy as the UI settings editor and update the keybindings settings file through some kind of higher level service that also sends out change events.

@bpasero bpasero changed the title changes "workbench.action.toggleSidebarPosition" command key binding and verifies it Keybindings editor should emit change events on changes Feb 2, 2022
@alexdima
Copy link
Member

alexdima commented Feb 3, 2022

I believe that we should never use file events as the only source of truth for changes when changes are made from within VSCode.

This sounds reasonable. But since we always use IFileService for writing files, shouldn't it simply emit events after it finishes writing to a file? It sounds like a lot of work for each piece of code that writes files using IFileService to both listen to change events from IFileService and then also emit its own logical change event.

Also, there are cases when users edit keybindings.json or settings.json files directly from a code editor. In the code editor we don't know that these file are special and should trigger configuration model updates.

@bpasero
Copy link
Member Author

bpasero commented Feb 3, 2022

Yeah, we already have the infrastructure for events like that called IFileService.onDidRunOperation and we currently do not emit events for write operations, but that would be easy enough for me to add.

You could then globally listen on that event as well as the file events to ensure you get hold of any updates.

Also, there are cases when users edit keybindings.json or settings.json files directly from a code editor

That is fine. Somewhere in the keybindings model code you already listen to file change events and now all you have to add is the additional listener for IFileService.onDidRunOperation.

@bpasero bpasero self-assigned this Feb 3, 2022
@bpasero bpasero added this to the February 2022 milestone Feb 3, 2022
@bpasero bpasero removed their assignment Feb 4, 2022
bpasero added a commit that referenced this issue Feb 4, 2022
@bpasero
Copy link
Member Author

bpasero commented Feb 4, 2022

I pushed a change to have a FileOperationEvent of operation: FileOperation.WRITE that provides its resource: URI. You can listen to this via IFileService.onDidRunOperation.

@bpasero
Copy link
Member Author

bpasero commented Feb 5, 2022

👏

sandy081 added a commit that referenced this issue Feb 8, 2022
@sandy081 sandy081 removed their assignment Feb 22, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Mar 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
insiders-released Patch has been released in VS Code Insiders keybindings-editor Keybinding editor issues
Projects
None yet
Development

No branches or pull requests

4 participants
@bpasero @alexdima @sandy081 and others