-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
Provide a command to close all unchanged files #25692
Conversation
- Editor Action Support for Closing Unmodified files in a group from - Explorer Open Editors context menu - Editor Tab context menu - Command Palette - Test updates - Interface methods implemented in the affected source and tests Scenarios Handled - Action will close only the unmodified files in a targetted group - Only the active group with an active editor will be targetted when executed from the Command palette - In explorer the group targetted will be of the file on which the context menu is triggered. - If the menu is accessed via the context menu from the Editor tab that group will be the target - If there are no editors open and the command is invoked from the command palette it is ignored
@soneymathew, thanks for your PR! By analyzing the history of the files in this pull request, we identified @bpasero and @egamma to be potential reviewers. |
@soneymathew, |
@soneymathew thanks for your work in this area. However, I am not convinced this command should be part of the core experience. It looks like you are also the author of #25667 which is does not seem to get votes from other users. I would like to keep the context menus as small and concise as possible. Instead, we encourage people to write extensions so that functionality can be provided from there and installed for users that want this feature. I suggest you give it a try through an extension and report issues for missing API that you find on the way. |
@bpasero I have shared my perspective in the issue, |
@soneymathew can't this be much simplified without having to introduce new API to stacks model and editor service with all the API we already have? Just change the run method of public run(context?: IEditorContext): TPromise<any> {
const activeGroup = this.editorGroupService.getStacksModel().activeGroup;
const groupId = context && context.group ? context.group.id : activeGroup ? activeGroup.id : null;
if (groupId !== null) {
const stacks = this.editorGroupService.getStacksModel();
const group = stacks.getGroup(groupId);
// this is new:
group.getEditors().filter(e => !e.isDirty()).forEach(e => this.editorService.closeEditor(stacks.positionOfGroup(group), e));
return TPromise.as(null);
}
return TPromise.as(false);
} |
Yes you are right, I will update and test, thanks |
@bpasero Thanks for the feedback and the changes feels so much simpler after removing the API changes. Haven't noticed any performance impact after testing with >20 files in each group. |
Also I was wondering if it is a good idea to show this option conditionally to reduce the clutter, or will it be a performance concern ? const hasUnModifiedEditors = this
.editorGroupService
.getStacksModel()
.activeGroup
.getEditors()
.reduce(function (unModifiedEditors, editor) {
if (!editor.isDirty()) {
unModifiedEditors.push(editor);
}
return unModifiedEditors;
}, [])
.length > 0;
if (hasUnModifiedEditors) {
actions.push(this.closeUnmodifiedEditorsInGroupAction);
} |
@soneymathew no I think it is fine to show the action always, we typically do not hide actions for discoverability reasons. |
LGTM, thanks 👍 |
@nikitavoloboev This renamed to Close unsaved as part of |
@nikitavoloboev Hope this helps 🙏 |
Close Saved Editors in Group closes all tabs. I want as the name of this PR. To close only tabs that are unchanged and leave only tabs that have changes inside them. Is this possible as command? |
Can you explain what you mean as unchanged files here? Are you referring to unsaved files ? |
Then it's working as expected. |
Oh right, maybe I did it wrong. Indeed it does. Thanks |
Is there an option to Should I open an issue for it? |
New Feature (#25667) - Support to bulk close Unmodified Files
Change Summary
Editor Action Support for Closing Unmodified files in a group from
Explorer Open Editor's context menu
Editor Tab context menu
Command Palette
Test updates
Interface methods implemented in the affected source and tests
Scenarios Handled
Please let me know if some scenario is missed.