Weird output when adding overrides via lsp
laynor opened this issue · 2 comments
laynor commented
Describe the bug
As requested, opening a new issue
When I create a simple widget class
class Foo extends StatelessWidget {
}
and then invoke lsp-execute-code-action
with the cursor on Foo
and select create missing override
I get this weird output:
class Foo extends StatelessWidget {
@override
Widget build(1|BuildContext,Object| context) {
// TODO: implement build
throw UnimplementedError();
}
}
To Reproduce
{populate}
Expected behavior
class Foo extends StatelessWidget {
@override
Widget build(BuildContext context) {
// TODO: implement build
throw UnimplementedError();
}
}
Version
Include here the result of: M-x lsp-dart-version
[LSP Dart] 1.24.2 at 2023.07.05 @ Emacs 30.0.50
[Dart SDK] Dart SDK version: 3.0.5 (stable) (Mon Jun 12 18:31:49 2023 +0000) on "linux_x64"
[Flutter SDK] /home/ale/src/3rdparty/flutter
[Flutter project] true
[Project entrypoint] Not found
laynor commented
As a workaround, I'm using the following:
(defun my/lsp--apply-workspace-edit-advice-dart (orig workspace-edit &rest args)
(let ((document-changes (gethash "documentChanges" workspace-edit)))
(mapc
(lambda (dc-ht)
(let* ((edits (gethash "edits" dc-ht)))
(mapc (lambda (ht)
(let* ((new-text (gethash "newText" ht))
(filtered (if (eq major-mode 'dart-mode)
(my/filter-snippet-for-dart new-text)
new-text)))
(puthash "newText" filtered ht))
)
edits)))
document-changes))
(apply orig workspace-edit args))
(defun advice-unadvice (sym)
"Remove all advices from symbol SYM."
(interactive "aFunction symbol: ")
(advice-mapc (lambda (advice _props) (advice-remove sym advice)) sym))
(advice-add 'lsp--apply-workspace-edit :around #'my/lsp--apply-workspace-edit-advice-dart)