-
-
Notifications
You must be signed in to change notification settings - Fork 96
feat(statusTile): Display status bar tile only if active file matches one of the scopes in settings #200
Conversation
… one of the scopes (file extens Fixes prettier#170
…er can click on it to toggle `F
There was a problem hiding this 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) { |
There was a problem hiding this comment.
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'); |
There was a problem hiding this comment.
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?
All done! Thanks @robwise |
|
||
// 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 && |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
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 😒