This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Expose offset <-> LSP position functions, and fix bugs
ClosedPublic

Authored by sammccall on Dec 18 2017, 5:56 AM.

Details

Summary
  • Moved these functions to SourceCode.h
  • added unit tests
  • fix off by one in positionToOffset: Offset - 1 in final calculation was wrong
  • fixed formatOnType which had an equal and opposite off-by-one
  • positionToOffset and offsetToPosition both consistently clamp to beginning/end of file when input is out of range
  • gave variables more descriptive names
  • removed windows line ending fixmes where there is nothing to fix
  • elaborated on UTF-8 fixmes

This will conflict with Eric's D41281, but in a pretty easy-to-resolve way.

Diff Detail

Event Timeline

sammccall created this revision.Dec 18 2017, 5:56 AM
ioeric accepted this revision.Dec 19 2017, 3:26 AM

lgtm

This revision is now accepted and ready to land.Dec 19 2017, 3:26 AM
This revision was automatically updated to reflect the committed changes.