Skip to content
This repository has been archived by the owner on Apr 17, 2023. It is now read-only.

feat(statusTile): Display status bar tile only if active file matches one of the scopes in settings #200

Merged
merged 4 commits into from
Jun 17, 2017

Conversation

darahak
Copy link
Collaborator

@darahak darahak commented Jun 16, 2017

Fixes #170

Also updated the tooltip to show the user can click on it to toggle Format on Save.

PS: My commit messages were truncated for some reason 😒

Copy link
Collaborator

@robwise robwise left a comment

Choose a reason for hiding this comment

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

Minor comments, but LGTM, no need for re-review.

I think it truncates the message because the main summary needs to be short otherwise it's going to wreak havoc on the git tree view. If you want to add more info, put in the longer description which has no maximum length.

const { getAllScopes } = require('../atomInterface');

const updateStatusTileScope = (element: HTMLElement, editor: TextEditor) => {
if (element) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

prefer guard clauses for exceptional scenarios, this way you don't have to wrap the entire implementation inside of an if statement.

if (!element) return;

// ...
``

it('sets the match-scope data attribute to true if the editor is in scope', () => {
getCurrentScope.mockImplementation(() => 'source.js');
const { div } = callUpdateStatusTileScope();
expect(div.dataset.prettierMatchScope).toBe('true');
Copy link
Collaborator

Choose a reason for hiding this comment

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

can we separate the "given, when, then" parts of the test with blank lines, just for readability?

@darahak
Copy link
Collaborator Author

darahak commented Jun 17, 2017

All done! Thanks @robwise

@darahak darahak merged commit 6d309c4 into prettier:master Jun 17, 2017
@darahak darahak deleted the tile-visibility branch June 17, 2017 10:59

// The editor can be undefined if there is no active editor (e.g. closed all tabs).
// eslint-disable-next-line no-param-reassign
element.dataset.prettierMatchScope = editor !== undefined &&
Copy link
Collaborator

Choose a reason for hiding this comment

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

@darahak What's the practical difference between returning undefined and returning 'false' here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We set display: none in the statusTile stylesheet if this attribute is set to "false", so it would not work if we returned undefined.
I'm not sure I understood correctly though, does that answer your question?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh okay, yeah.

I was thinking, if the editor can potentially be undefined here, we need to use a maybe type in the flow annotation (e.g.,?TextEditor) to indicate this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You're right, I'll change that.

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.

2 participants