[all-commits] [llvm/llvm-project] a53f89: [clangd] Heuristic to avoid desync if editors are ...

Sam McCall via All-commits all-commits at lists.llvm.org
Tue Nov 29 04:15:37 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: a53f89522f46dd10f87f163d8501738182729b8d
      https://github.com/llvm/llvm-project/commit/a53f89522f46dd10f87f163d8501738182729b8d
  Author: Sam McCall <sam.mccall at gmail.com>
  Date:   2022-11-29 (Tue, 29 Nov 2022)

  Changed paths:
    M clang-tools-extra/clangd/SourceCode.cpp
    M clang-tools-extra/clangd/unittests/SourceCodeTests.cpp

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

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

Differential Revision: https://reviews.llvm.org/D135508




More information about the All-commits mailing list