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

Add arrows selection to typeahead #3386

Merged
merged 11 commits into from
May 4, 2017

Conversation

rogeliog
Copy link
Contributor

@rogeliog rogeliog commented Apr 27, 2017

Fixes #2589

This puts a lot of the typeahead logic inside the prompt class, but we should move it to a typeahead module eventually.

Still needs to be tested in Windows and other terminals

We still need to do all of these as part of a follow up PR

  • Clean up a lot of the code
  • Extract all the scrolling logic into its own typeahead component.

Summary
Also, do we even want to move forward with this?

filters-2

@@ -0,0 +1,75 @@
const scroll = (size, { offset, max }) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Needs to be moved and cleaned

@thymikee
Copy link
Collaborator

Yes! It looks awesome

@jest-bot
Copy link
Contributor

jest-bot commented Apr 27, 2017

Fails
🚫 New JS files do not have the Facebook copyright header: packages/jest-cli/src/lib/__tests__/scrollList-test.js
🚫 Please ensure that 'use strict' is enabled on: packages/jest-cli/src/lib/__tests__/scrollList-test.js

Generated by 🚫 dangerJS

@rogeliog rogeliog force-pushed the add-arrows-to-typeahead branch from df8db39 to f3a7f40 Compare April 27, 2017 21:09
.map(name => formatTestNameByPattern(name, pattern, width - 4))
.map((item, i) => {
if (i === index) {
this._prompt.setTypheadheadSelection(chalk.stripColor(item));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should this be this._prompt.setTypheadheadSelection('^' + chalk.stripColor(item) + '$'); instead?

@rogeliog rogeliog changed the title [WIP] Add arrows selection to typeahead Add arrows selection to typeahead Apr 27, 2017
@rogeliog rogeliog added this to the Jest 20 milestone Apr 27, 2017
@thymikee thymikee force-pushed the add-arrows-to-typeahead branch from f3a7f40 to b253111 Compare May 4, 2017 19:47
updateCachedTestResults(testResults: Array<TestResult>) {
this._cachedTestResults = testResults || [];
updateCachedTestResults(testResults: Array<TestResult> = []) {
this._cachedTestResults = testResults;
Copy link
Member

Choose a reason for hiding this comment

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

Any particular reason for this change?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I just like initial values better :)

// eslint-disable-next-line max-len
`\n\n ${chalk.italic.yellow('Start typing to filter by a filename regex pattern.')}`,
);
printStartTyping('filename', pipe);
Copy link
Member

Choose a reason for hiding this comment

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

this could use this._entityName, right?

Copy link
Member

Choose a reason for hiding this comment

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

Actually, nevermind, it's more of a coincidence that they line up. Let's keep it this way.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I see now that I'm mixing singular with plural in couple of places, need to fix it properly.

@cpojer
Copy link
Member

cpojer commented May 4, 2017

This is really fantastic. There is one bug that we found about the arrow selection scrambling the results but other than that it looks really solid. There are a few more things we could do, like using composition instead of inheritance and some stricter flow types (ie. not using Function) but given that we are pressed on time here, I would suggest merging it after fixing the one bug and then, if we have time, improving it further once @rogeliog is back. @thymikee and @rogeliog both, this is awesome.

@codecov-io
Copy link

Codecov Report

Merging #3386 into master will increase coverage by 0.28%.
The diff coverage is 99.26%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3386      +/-   ##
==========================================
+ Coverage    64.1%   64.38%   +0.28%     
==========================================
  Files         179      182       +3     
  Lines        6647     6694      +47     
  Branches        5        5              
==========================================
+ Hits         4261     4310      +49     
+ Misses       2384     2382       -2     
  Partials        2        2
Impacted Files Coverage Δ
packages/jest-cli/src/lib/patternModeHelpers.js 100% <100%> (ø)
packages/jest-cli/src/lib/scrollList.js 100% <100%> (ø)
packages/jest-cli/src/lib/Prompt.js 95.34% <100%> (+2.24%) ⬆️
packages/jest-cli/src/PatternPrompt.js 100% <100%> (ø)
packages/jest-cli/src/TestPathPatternPrompt.js 100% <100%> (+1.75%) ⬆️
packages/jest-cli/src/TestNamePatternPrompt.js 95.12% <95.83%> (+0.29%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7ccd640...6370943. Read the comment docs.

@cpojer cpojer merged commit 829531f into jestjs:master May 4, 2017
tushardhole pushed a commit to tushardhole/jest that referenced this pull request Aug 21, 2017
* Add typeahead arrow selection

* Handle max typeahead max offset

* Add tests for scroll list

* Add simple tests to typeheahead selection

* Clear typeahead selection on enter

* Fix prompt test

* Refactor pattern prompts

* Stress 'cached' in TestNamePatternPrompt

* Fix eslint

* Fix scrolling edgecase

* Live update number of remaining typeahead items
@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Typeahead Arrow selection
6 participants