[PATCH] D135508: [clangd] Heuristic to avoid desync if editors are confused about newline-at-eof

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 7 21:40:02 PDT 2022


sammccall created this revision.
sammccall added a reviewer: kadircet.
Herald added a subscriber: arphaman.
Herald added a project: All.
sammccall requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

As strange as it seems to our files-are-strings view of the world, some editors
that treat files as arrays of lines can get confused about whether the last line
has a newline or not.

The consequences of failing to handle a bad incremental update are catastrophic.
If an update would be valid except for a missing newline at end of file, pretend
one exists.

This fixes problems still present in neovim where deleting all text often leads
to a desync shortly afterwards: https://github.com/neovim/neovim/issues/17085


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D135508

Files:
  clang-tools-extra/clangd/SourceCode.cpp
  clang-tools-extra/clangd/unittests/SourceCodeTests.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D135508.466251.patch
Type: text/x-patch
Size: 4139 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20221008/160abd74/attachment-0001.bin>


More information about the cfe-commits mailing list