Git Product home page Git Product logo

Comments (4)

kadircet avatar kadircet commented on June 8, 2024

It can be reproduced with the following test case:

TEST_F(ClangdVFSTest, TestRandom) {
  MockFSProvider FS;
  ErrorCheckingDiagConsumer DiagConsumer;
  MockCompilationDatabase CDB;

  ClangdServer Server(CDB, FS, DiagConsumer, ClangdServer::optsForTest());

  auto FooCpp = testPath("foo.cpp");
  Annotations Code(R"cpp(
    struct Foo{};
    Foo test() {
     F^oo x;
     return x;
    }
    )cpp");

  runAddDocument(Server, FooCpp, Code.code());

  auto X = runRename(Server, FooCpp, Code.point(), "new_name");
  ASSERT_TRUE(!!X);
  size_t PrevOffset = -1;
  for (const auto &T : X.get()) {
    EXPECT_NE(PrevOffset, T.getOffset());
    PrevOffset = T.getOffset();
  }
}

Unfortunately issue seems to be rather related to clang api we use, https://github.com/llvm/llvm-project/blob/master/clang/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp#L84

Because visitor itself returns duplicate entries for the return type of function test()

from clangd.

kadircet avatar kadircet commented on June 8, 2024

Another case this happens:

void foo() {
    if(auto add_xxx = 5) {
        add_xxx = 3;
    }
}

try renaming add_xxx to added_xxx(either of them results in same breakage). Which simply fails on vscode by saying "overlapping edits" and results in malformed text in vim like added_xxxxx.

from clangd.

bstaletic avatar bstaletic commented on June 8, 2024

Ycmd can cope with this as long as the old and new name have the same length, otherwise a duplicated edit does make a mess. Requesting a RefactorRename foo_bar would correctly replace the text.

from clangd.

sam-mccall avatar sam-mccall commented on June 8, 2024

Fixed in r360116.

from clangd.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.