emacs-lsp / lsp-dart

lsp-mode :heart: dart
https://emacs-lsp.github.io/lsp-dart
GNU General Public License v3.0
201 stars 25 forks source link

Project-root discovery doesn't work with multiple projects #221

Open markhepburn opened 4 months ago

markhepburn commented 4 months ago

Describe the bug There seems to be a bug in lsp-dart-get-project-root, where it picks up the wrong default-directory from an existing test-process buffer (I'm speculating a little here)

Note Before logging the bug please make sure that the issue is reproducible with latest melpa packages.

To Reproduce Create two flutter projects, eg

flutter create proj_one
flutter create proj_two

Open proj_one/test/test_widget.dart (selecting proj_one as the project root). Confirm that tests can run, eg M-x lsp-dart-run-all-tests.

Open proj_two/test/test_widget.dart (selecting proj_two as the project root). Run tests again.

Notice that the tests executed are actually in proj_one! (This is more obvious if you run lsp-dart-run-test-file)

If you first kill the *LSP Dart - tests process* buffer, the expected tests are run.

Expected behavior The tests in proj_two/test/test_widget.dart are run.

Screenshots If applicable, add screenshots to help explain your problem.

Version Include here the result of: M-x lsp-dart-version

[LSP Dart] 1.24.3 at 2024.05.25 @ Emacs 30.0.50
[Dart SDK] Dart SDK version: 3.3.4 (stable) (Tue Apr 16 19:56:12 2024 +0000) on "linux_x64"
markhepburn commented 4 months ago

I first picked this up running file-tests from a project with multiple sub-packages (eg, a flutter app, with a few library projects in the packages/ directory. You wind up with some fairly convoluted paths such as projectroot/packages/lastlib/packages/currentlib/test/some_test.dart)

I'm not entirely sure if that's not a separate issue, but the two-project scenario seemed to the simplest reproduction case for now.