Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Support for parsing more than one filter suffix. #17

Merged
merged 4 commits into from
Feb 6, 2018

Conversation

gushuro
Copy link
Contributor

@gushuro gushuro commented Feb 5, 2018

Added support to expand abbreviations with several suffixes (see microsoft/vscode#35984 )
Example input:

ul.search-form._wide>li.-querystring+li.-btn_large|bem|c

(Or, equivalently, ending with |c|bem)
Example output:

<ul class="search-form search-form_wide">
	<li class="search-form__querystring">|</li>
	<!-- /.search-form__querystring -->
	<li class="search-form__btn search-form__btn_large">|</li>
	<!-- /.search-form__btn search-form__btn_large -->
</ul>
<!-- /.search-form search-form_wide -->

@gushuro
Copy link
Contributor Author

gushuro commented Feb 5, 2018

@ramya-rao-a would you take a look?

@@ -27,6 +27,7 @@ const bemFilterSuffix = 'bem';
const filterDelimitor = '|';
const trimFilterSuffix = 't';
const commentFilterSuffix = 'c';
const differentFilters = 3;
Copy link
Contributor

Choose a reason for hiding this comment

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

rename to maxFilters

expandedAbbr.label = abbreviation + filterDelimitor + (filter === 'bem' ? bemFilterSuffix : commentFilterSuffix);
}
expandedAbbr.label = abbreviation;
expandedAbbr.label += filter ? '|' + filter.replace(', ', '|') : "";
Copy link
Contributor

Choose a reason for hiding this comment

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

let's not use the space along with the comma as separator

lengthOccupiedByFilter = 2;
pos -= lengthOccupiedByFilter;
filter = commentFilterSuffix;
for (let i = 0; i < differentFilters; i++) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This whole logic is being repeated twice. It would be good to have this in a separate function which returns an object with pos and filter. lengthOccupiedByFilter can then be calculated as filter.length + 1

Copy link
Contributor

@ramya-rao-a ramya-rao-a left a comment

Choose a reason for hiding this comment

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

Great, works well
I've a left a few comments, take a look

@ramya-rao-a ramya-rao-a merged commit 59b9c55 into microsoft:master Feb 6, 2018
@gushuro gushuro deleted the filters branch February 7, 2018 00:10
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants