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

Set active editor on startup #6152

Merged
merged 1 commit into from
Sep 12, 2019
Merged

Set active editor on startup #6152

merged 1 commit into from
Sep 12, 2019

Conversation

tolusha
Copy link
Contributor

@tolusha tolusha commented Sep 10, 2019

Signed-off-by: Anatoliy Bazko abazko@redhat.com

Reference issue

#6101

What it does

When Thiea is started the editors which had been created were not taking into account. Which leads to setting window.activeTextEditor to undefined and impossibility to add a new python configuration [2]

[1] https://github.com/theia-ide/theia/blob/ab/fixActiveEditor/packages/plugin/src/theia.d.ts#L2985
[2] https://github.com/Microsoft/vscode-python/blob/master/src/client/debugger/extension/configuration/launch.json/updaterService.ts#L26

How to test

  1. Download and put VS Code python extension [1] in plugins folder
  2. Open any python plugin to active the extension
  3. Open launch.json and try to add any python configuration
  4. A new configuration is added to the launch.json

[1] https://github.com/microsoft/vscode-python/releases/download/2019.5.18875/ms-python-release.vsix

Review checklist

Reminder for reviewers

@tolusha tolusha added the editor issues related to the editor label Sep 10, 2019
@tolusha tolusha requested a review from a team as a code owner September 10, 2019 12:46
@tolusha tolusha self-assigned this Sep 10, 2019
@akosyakov akosyakov added the plug-in system issues related to the plug-in system label Sep 10, 2019
@@ -43,6 +43,7 @@ export class TextEditorServiceImpl implements TextEditorService {
constructor(@inject(EditorManager) private editorManager: EditorManager) {
editorManager.onCurrentEditorChanged(this.onEditorChanged);
editorManager.onCreated(w => this.onEditorCreated(w));
editorManager.all.forEach(w => this.onEditorCreated(w));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tolusha thanks for tackling this! 🙏

in general this should work, but we could actually clean up the editorManager.onCurrentEditorChanged(this.onEditorChanged) here, no?

WDYT of renaming onEditorCreated to connectEditor or something like that, adjusting onCurrentEditorChanged handler, and now calling connectEditor for editorManager.currentEditor once?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe a bit off topic as this is not related to the issue in scope of this PR, but before I forget to mention it: I think we should remove this.editors map which holds references to MonacoEditor instances without a real reason.

e.g. getActiveEditor uses editorManager an so could listTextEditors be implemented as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AlexTugarev
I've done some refactoring as you mentioned.
I am not sure if changes regarding connectEditor make sense.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok with me. let's test with many opened editors to see how it works with many events being fired.

@@ -38,25 +38,19 @@ export class TextEditorServiceImpl implements TextEditorService {
onTextEditorAdd: Event<MonacoEditor> = this.onTextEditorAddEmitter.event;
onTextEditorRemove: Event<MonacoEditor> = this.onTextEditorRemoveEmitter.event;

private editors = new Map<string, MonacoEditor>();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

always nice to remove duplicate state! 😊

@akosyakov
Copy link
Member

@AlexTugarev please finish the review

Copy link
Contributor

@AlexTugarev AlexTugarev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works as advertised! Thanks!

@tolusha
Copy link
Contributor Author

tolusha commented Sep 12, 2019

I am going to squash commits and merge...

Signed-off-by: Anatoliy Bazko <abazko@redhat.com>
@tolusha tolusha merged commit 393efba into master Sep 12, 2019
@tolusha tolusha deleted the ab/fixActiveEditor branch September 12, 2019 08:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
editor issues related to the editor plug-in system issues related to the plug-in system
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants