Skip to content

Fix GetLineAndCharacterOfPosition and audit all usersย #1578

@jakebailey

Description

@jakebailey

Things are very weird with GetLineAndCharacterOfPosition and its users.

  • GetLineAndCharacterOfPosition returns col position in terms of rune count. This could be fine, but some callers assume that it's a byte offset and then break on non-ASCII code. Most callers don't notice this because they actually only want the line number.
  • GetLineAndCharacterOfPosition uses GetLineStarts, but that uses line separators as defined by ECMAScript. This can be fine, but should really only be done for things like parsing and source maps. But, we have users of this in the language server, and the language server should be using the LSP definition of newlines (\n, \r\n, \r).

We should redo these, likely renaming funcs or something to make it very obvious what each of them are actually doing.

See also:

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions