fix autocomplete with Windows line endings
fix autocomplete with Windows line endings

Summary:
Pull Request resolved: https://github.com/facebook/flow/pull/8070

Autocomplete works by inserting a sigil into the document at the requested line/column. It does this by walking the file character by character, counting any `\r` or `\n` as a line terminator. This is incorrect because, on Windows, `\r\n` is a single line terminator, but we were counting it as two lines, so inserting the sigil in the wrong place.

This also fixes Line Separator (U+2028) and Paragraph Separator (U+2029) (even though I doubt we'll ever see it in practice). We're assuming that the input string is UTF8, which is what we assume elsewhere (especially in the parser). this causes problems when the string is actually UTF-16 (or UCS-2?) when it comes from JS or via js_of_ocaml, but we'll fix that assumption holistically.

Fixes https://github.com/facebook/flow/issues/8066
Fixes https://github.com/flowtype/flow-for-vscode/issues/361

Changelog: fix(lsp): Fixed autocomplete on files with Windows line endings

Reviewed By: gabelevi

Differential Revision: D17284514

fbshipit-source-id: 5c362632668cbbdd54dc4fab0c36436aad8f3d0d

nmote/flow,nmote/flow,nmote/flow,nmote/flow,nmote/flow,nmote/flow,nmote/flow