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

Improve unmapper file heuristic, add limited warning support, and ignore internal errors #2128

Merged
merged 23 commits into from
May 13, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions packages/react-error-overlay/src/utils/unmapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,15 @@ import { getLinesAround } from './getLinesAround';
import path from 'path';

function count(search: string, string: string): number {
let count = -1, index = 0;
for (; index !== -1; count++, (index = string.indexOf(search, index + 1)));
// Count starts at -1 becuse a do-while loop always runs at least once
let count = -1, index = -1;
do {
// First call or the while case evaluated true, meaning we have to make
// count 0 or we found a character
++count;
// Find the index of our search string, starting after the previous index
index = string.indexOf(search, index + 1);
} while (index !== -1);
Copy link
Contributor

Choose a reason for hiding this comment

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

That's better thanks!

return count;
}

Expand Down