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

Provide a command to close all unchanged files #25692

Merged
merged 4 commits into from
Jun 15, 2017

Conversation

soneymathew
Copy link
Contributor

@soneymathew soneymathew commented Apr 30, 2017

New Feature (#25667) - Support to bulk close Unmodified Files

Change Summary

  • Editor Action Support for Closing Unmodified files in a group from

    1. Explorer Open Editor's context menu
      closeviaexplorercontextmenu

    2. Editor Tab context menu
      closeviaeditortabcontextmenu

    3. Command Palette
      closeviacommandpalette

  • 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
  • Group is closed if all editors are unmodified
  • Action can be triggered using the keyboard shortcut

Please let me know if some scenario is missed.

    - 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
@mention-bot
Copy link

@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.

@msftclas
Copy link

@soneymathew,
Thanks for having already signed the Contribution License Agreement. Your agreement has not been validated yet. We will now review your pull request.
Thanks,
Microsoft Pull Request Bot

@kieferrm kieferrm requested a review from bpasero May 1, 2017 18:21
@soneymathew soneymathew changed the title New Feature (#25667) - Support to bulk close Unmodified Files Provide a command to close all unchanged files May 5, 2017
@soneymathew
Copy link
Contributor Author

@bpasero / @kieferrm could you please share some feedback on these changes.
I would appreciate if we can get this merged before it goes way out of sync with the master if the changes are satisfactory.

@bpasero
Copy link
Member

bpasero commented May 14, 2017

@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.

@soneymathew
Copy link
Contributor Author

@bpasero I have shared my perspective in the issue,
Looks like the pull request have at least 4 people reacting to it 👍 perhaps they should have voted in the issue instead of the pull request :)

@bpasero bpasero modified the milestone: Backlog May 20, 2017
@bpasero
Copy link
Member

bpasero commented Jun 1, 2017

@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 CloseUnmodifiedEditorsInGroupAction to:

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);
}

@soneymathew
Copy link
Contributor Author

Yes you are right, I will update and test, thanks

@bpasero bpasero modified the milestones: June 2017, Backlog Jun 14, 2017
@soneymathew
Copy link
Contributor Author

@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.

@soneymathew
Copy link
Contributor Author

soneymathew commented Jun 14, 2017

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 ?
This would mean a group with all modified files will not display this option.

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);
}

@bpasero
Copy link
Member

bpasero commented Jun 15, 2017

@soneymathew no I think it is fine to show the action always, we typically do not hide actions for discoverability reasons.

@bpasero bpasero merged commit 079ad46 into microsoft:master Jun 15, 2017
@bpasero
Copy link
Member

bpasero commented Jun 15, 2017

LGTM, thanks 👍

@nikitavoloboev
Copy link

I can't find Close Unmodified action in vs code (running insiders)

image

What am I missing?

@soneymathew
Copy link
Contributor Author

@nikitavoloboev This renamed to Close unsaved as part of
#44269

@nikitavoloboev
Copy link

image

I don't see it. Running 1.43.0-insider

@soneymathew
Copy link
Contributor Author

@nikitavoloboev
The text is updated to be more clear as part of the mentioned PR
Menu option is now
image
image

Commands are renamed to
image

Hope this helps 🙏

@nikitavoloboev
Copy link

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?

@soneymathew
Copy link
Contributor Author

Can you explain what you mean as unchanged files here?

Are you referring to unsaved files ?
or Are you referring to saved files which are not committed to a git repo?

@nikitavoloboev
Copy link

Files that have no changes in them. Files that have changes are often marked with circle in VS Code. Like here magefile.go is file with changes and LICENSE is not changed.

image

This command if activated would close LICENSE tab.

@soneymathew
Copy link
Contributor Author

Then it's working as expected.
This command closes all files that are not having the circle mark.
Are you expecting the opposite behaviour by any chance?

@nikitavoloboev
Copy link

Oh right, maybe I did it wrong. Indeed it does. Thanks

@nikitavoloboev
Copy link

Is there an option to Close Saved Editors, not just ones in a group. And if not is it possible to please add it?

Should I open an issue for it?

@github-actions github-actions bot locked and limited conversation to collaborators Mar 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants