2019-09-12 20:53:23 +00:00
|
|
|
Before:
|
Dispatch textDocument/didChange after rename (2) (#4049)
* Dispatch textDocument/didChange after rename
Previously whenever we renamed a symbol that was referenced from other
files we'd just edit those files in the background, and the LSP wouldn't
know about these changes. If we tried to rename the same symbol again,
the renaming would fail. In some scenarios, the operation would just be
wrong. Here is an attempt to fix this issue.
I also noticed another bug when using Go with `gopls` LSP and the `gofmt`
fixer. Whenever the file was saved, the `gofmt` would run and reformat
the file. But it seems there was some kind of a race condition so I
disabled saving for now, and all of the modified files will be unsaved,
so the user should call `:wa` to save them. I personally like this even
better because I can inspect exactly what changes happened, and I
instantly see them in the other opened buffers, which was previously not
the case.
Fixes #3343, #3642, #3781.
* Address PR comments
* Remove mode tests in corner case tests
* Address PR comments
* Save after ALERename and ALEOrganizeImports
Also provide options to disable automatic saving, as well as instructions to
enable `set hidden` before doing that.
* Fix broken test
* Save only when !&hidden
* Update doc
* Update doc
* Add silent
2022-02-08 11:07:39 +00:00
|
|
|
let g:notified_changes = []
|
|
|
|
|
|
|
|
runtime autoload/ale/lsp.vim
|
|
|
|
|
|
|
|
function! ale#lsp#NotifyForChanges(conn_id, buffer) abort
|
|
|
|
call add(g:notified_changes, {
|
|
|
|
\ 'conn_id': a:conn_id,
|
|
|
|
\ 'buffer': a:buffer
|
|
|
|
\})
|
|
|
|
endfunction
|
|
|
|
|
2020-09-04 08:37:33 +00:00
|
|
|
Save g:ale_enabled
|
|
|
|
let g:ale_enabled = 0
|
|
|
|
|
2019-09-12 20:53:23 +00:00
|
|
|
let g:file1 = tempname()
|
|
|
|
let g:file2 = tempname()
|
|
|
|
let g:test = {}
|
|
|
|
|
|
|
|
let g:test.create_change = {line, offset, end_line, end_offset, value ->
|
|
|
|
\{
|
|
|
|
\ 'changes': [{
|
|
|
|
\ 'fileName': g:file1,
|
|
|
|
\ 'textChanges': [{
|
|
|
|
\ 'start': {
|
|
|
|
\ 'line': line,
|
|
|
|
\ 'offset': offset,
|
|
|
|
\ },
|
|
|
|
\ 'end': {
|
|
|
|
\ 'line': end_line,
|
|
|
|
\ 'offset': end_offset,
|
|
|
|
\ },
|
|
|
|
\ 'newText': value,
|
|
|
|
\ }],
|
|
|
|
\ }]
|
|
|
|
\}}
|
|
|
|
|
|
|
|
function! WriteFileAndEdit() abort
|
|
|
|
let g:test.text = [
|
|
|
|
\ 'class Name {',
|
|
|
|
\ ' value: string',
|
|
|
|
\ '}',
|
|
|
|
\]
|
|
|
|
call writefile(g:test.text, g:file1, 'S')
|
|
|
|
execute 'edit ' . g:file1
|
|
|
|
endfunction!
|
|
|
|
|
|
|
|
After:
|
|
|
|
" Close the extra buffers if we opened it.
|
Dispatch textDocument/didChange after rename (2) (#4049)
* Dispatch textDocument/didChange after rename
Previously whenever we renamed a symbol that was referenced from other
files we'd just edit those files in the background, and the LSP wouldn't
know about these changes. If we tried to rename the same symbol again,
the renaming would fail. In some scenarios, the operation would just be
wrong. Here is an attempt to fix this issue.
I also noticed another bug when using Go with `gopls` LSP and the `gofmt`
fixer. Whenever the file was saved, the `gofmt` would run and reformat
the file. But it seems there was some kind of a race condition so I
disabled saving for now, and all of the modified files will be unsaved,
so the user should call `:wa` to save them. I personally like this even
better because I can inspect exactly what changes happened, and I
instantly see them in the other opened buffers, which was previously not
the case.
Fixes #3343, #3642, #3781.
* Address PR comments
* Remove mode tests in corner case tests
* Address PR comments
* Save after ALERename and ALEOrganizeImports
Also provide options to disable automatic saving, as well as instructions to
enable `set hidden` before doing that.
* Fix broken test
* Save only when !&hidden
* Update doc
* Update doc
* Add silent
2022-02-08 11:07:39 +00:00
|
|
|
if bufnr(g:file1) != -1 && buflisted(bufnr(g:file1))
|
2019-10-10 01:42:41 +00:00
|
|
|
execute ':bp! | :bd! ' . bufnr(g:file1)
|
2019-09-12 20:53:23 +00:00
|
|
|
endif
|
Dispatch textDocument/didChange after rename (2) (#4049)
* Dispatch textDocument/didChange after rename
Previously whenever we renamed a symbol that was referenced from other
files we'd just edit those files in the background, and the LSP wouldn't
know about these changes. If we tried to rename the same symbol again,
the renaming would fail. In some scenarios, the operation would just be
wrong. Here is an attempt to fix this issue.
I also noticed another bug when using Go with `gopls` LSP and the `gofmt`
fixer. Whenever the file was saved, the `gofmt` would run and reformat
the file. But it seems there was some kind of a race condition so I
disabled saving for now, and all of the modified files will be unsaved,
so the user should call `:wa` to save them. I personally like this even
better because I can inspect exactly what changes happened, and I
instantly see them in the other opened buffers, which was previously not
the case.
Fixes #3343, #3642, #3781.
* Address PR comments
* Remove mode tests in corner case tests
* Address PR comments
* Save after ALERename and ALEOrganizeImports
Also provide options to disable automatic saving, as well as instructions to
enable `set hidden` before doing that.
* Fix broken test
* Save only when !&hidden
* Update doc
* Update doc
* Add silent
2022-02-08 11:07:39 +00:00
|
|
|
if bufnr(g:file2) != -1 && buflisted(bufnr(g:file2))
|
2019-10-10 01:42:41 +00:00
|
|
|
execute ':bp! | :bd! ' . bufnr(g:file2)
|
2019-09-12 20:53:23 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
if filereadable(g:file1)
|
|
|
|
call delete(g:file1)
|
|
|
|
endif
|
|
|
|
if filereadable(g:file2)
|
|
|
|
call delete(g:file2)
|
|
|
|
endif
|
|
|
|
|
Dispatch textDocument/didChange after rename (2) (#4049)
* Dispatch textDocument/didChange after rename
Previously whenever we renamed a symbol that was referenced from other
files we'd just edit those files in the background, and the LSP wouldn't
know about these changes. If we tried to rename the same symbol again,
the renaming would fail. In some scenarios, the operation would just be
wrong. Here is an attempt to fix this issue.
I also noticed another bug when using Go with `gopls` LSP and the `gofmt`
fixer. Whenever the file was saved, the `gofmt` would run and reformat
the file. But it seems there was some kind of a race condition so I
disabled saving for now, and all of the modified files will be unsaved,
so the user should call `:wa` to save them. I personally like this even
better because I can inspect exactly what changes happened, and I
instantly see them in the other opened buffers, which was previously not
the case.
Fixes #3343, #3642, #3781.
* Address PR comments
* Remove mode tests in corner case tests
* Address PR comments
* Save after ALERename and ALEOrganizeImports
Also provide options to disable automatic saving, as well as instructions to
enable `set hidden` before doing that.
* Fix broken test
* Save only when !&hidden
* Update doc
* Update doc
* Add silent
2022-02-08 11:07:39 +00:00
|
|
|
unlet! g:notified_changes
|
|
|
|
" unlet! g:expected_notified_changes
|
2020-09-04 08:37:33 +00:00
|
|
|
unlet! g:file1
|
|
|
|
unlet! g:file2
|
|
|
|
unlet! g:test
|
|
|
|
unlet! g:changes
|
2019-09-12 20:53:23 +00:00
|
|
|
delfunction WriteFileAndEdit
|
|
|
|
|
Dispatch textDocument/didChange after rename (2) (#4049)
* Dispatch textDocument/didChange after rename
Previously whenever we renamed a symbol that was referenced from other
files we'd just edit those files in the background, and the LSP wouldn't
know about these changes. If we tried to rename the same symbol again,
the renaming would fail. In some scenarios, the operation would just be
wrong. Here is an attempt to fix this issue.
I also noticed another bug when using Go with `gopls` LSP and the `gofmt`
fixer. Whenever the file was saved, the `gofmt` would run and reformat
the file. But it seems there was some kind of a race condition so I
disabled saving for now, and all of the modified files will be unsaved,
so the user should call `:wa` to save them. I personally like this even
better because I can inspect exactly what changes happened, and I
instantly see them in the other opened buffers, which was previously not
the case.
Fixes #3343, #3642, #3781.
* Address PR comments
* Remove mode tests in corner case tests
* Address PR comments
* Save after ALERename and ALEOrganizeImports
Also provide options to disable automatic saving, as well as instructions to
enable `set hidden` before doing that.
* Fix broken test
* Save only when !&hidden
* Update doc
* Update doc
* Add silent
2022-02-08 11:07:39 +00:00
|
|
|
runtime autoload/ale/lsp.vim
|
|
|
|
|
2021-02-20 16:16:47 +00:00
|
|
|
Restore
|
2019-09-12 20:53:23 +00:00
|
|
|
|
|
|
|
|
|
|
|
Execute(It should modify and save multiple files):
|
|
|
|
call writefile([
|
|
|
|
\ 'class Name {',
|
|
|
|
\ ' value: string',
|
|
|
|
\ '}',
|
|
|
|
\ '',
|
|
|
|
\ 'class B {',
|
|
|
|
\ ' constructor(readonly a: Name) {}',
|
|
|
|
\ '}'
|
|
|
|
\], g:file1, 'S')
|
|
|
|
call writefile([
|
|
|
|
\ 'import A from "A"',
|
|
|
|
\ 'import {',
|
|
|
|
\ ' B,',
|
|
|
|
\ ' C,',
|
|
|
|
\ '} from "module"',
|
|
|
|
\ 'import D from "D"',
|
|
|
|
\], g:file2, 'S')
|
|
|
|
|
2020-10-15 20:56:21 +00:00
|
|
|
call ale#code_action#HandleCodeAction(
|
|
|
|
\ {
|
2019-09-12 20:53:23 +00:00
|
|
|
\ 'changes': [{
|
|
|
|
\ 'fileName': g:file1,
|
|
|
|
\ 'textChanges': [{
|
|
|
|
\ 'start': {
|
|
|
|
\ 'line': 1,
|
|
|
|
\ 'offset': 7,
|
|
|
|
\ },
|
|
|
|
\ 'end': {
|
|
|
|
\ 'line': 1,
|
|
|
|
\ 'offset': 11,
|
|
|
|
\ },
|
|
|
|
\ 'newText': 'Value',
|
|
|
|
\ }, {
|
|
|
|
\ 'start': {
|
|
|
|
\ 'line': 6,
|
|
|
|
\ 'offset': 27,
|
|
|
|
\ },
|
|
|
|
\ 'end': {
|
|
|
|
\ 'line': 6,
|
|
|
|
\ 'offset': 31,
|
|
|
|
\ },
|
|
|
|
\ 'newText': 'Value',
|
|
|
|
\ }],
|
|
|
|
\ }, {
|
|
|
|
\ 'fileName': g:file2,
|
|
|
|
\ 'textChanges': [{
|
|
|
|
\ 'start': {
|
|
|
|
\ 'line': 2,
|
|
|
|
\ 'offset': 1,
|
|
|
|
\ },
|
|
|
|
\ 'end': {
|
|
|
|
\ 'line': 6,
|
|
|
|
\ 'offset': 1,
|
|
|
|
\ },
|
|
|
|
\ 'newText': "import {A, B} from 'module'\n\n",
|
|
|
|
\ }]
|
2020-10-15 20:56:21 +00:00
|
|
|
\ }],
|
|
|
|
\ },
|
Dispatch textDocument/didChange after rename (2) (#4049)
* Dispatch textDocument/didChange after rename
Previously whenever we renamed a symbol that was referenced from other
files we'd just edit those files in the background, and the LSP wouldn't
know about these changes. If we tried to rename the same symbol again,
the renaming would fail. In some scenarios, the operation would just be
wrong. Here is an attempt to fix this issue.
I also noticed another bug when using Go with `gopls` LSP and the `gofmt`
fixer. Whenever the file was saved, the `gofmt` would run and reformat
the file. But it seems there was some kind of a race condition so I
disabled saving for now, and all of the modified files will be unsaved,
so the user should call `:wa` to save them. I personally like this even
better because I can inspect exactly what changes happened, and I
instantly see them in the other opened buffers, which was previously not
the case.
Fixes #3343, #3642, #3781.
* Address PR comments
* Remove mode tests in corner case tests
* Address PR comments
* Save after ALERename and ALEOrganizeImports
Also provide options to disable automatic saving, as well as instructions to
enable `set hidden` before doing that.
* Fix broken test
* Save only when !&hidden
* Update doc
* Update doc
* Add silent
2022-02-08 11:07:39 +00:00
|
|
|
\ {'should_save': 1, 'conn_id': 'test_conn'},
|
2020-10-15 20:56:21 +00:00
|
|
|
\)
|
2019-09-12 20:53:23 +00:00
|
|
|
|
|
|
|
AssertEqual [
|
|
|
|
\ 'class Value {',
|
|
|
|
\ ' value: string',
|
|
|
|
\ '}',
|
|
|
|
\ '',
|
|
|
|
\ 'class B {',
|
|
|
|
\ ' constructor(readonly a: Value) {}',
|
|
|
|
\ '}',
|
|
|
|
\ '',
|
|
|
|
\], readfile(g:file1, 'b')
|
|
|
|
|
|
|
|
AssertEqual [
|
|
|
|
\ 'import A from "A"',
|
|
|
|
\ 'import {A, B} from ''module''',
|
|
|
|
\ '',
|
|
|
|
\ 'import D from "D"',
|
|
|
|
\ '',
|
|
|
|
\], readfile(g:file2, 'b')
|
|
|
|
|
Dispatch textDocument/didChange after rename (2) (#4049)
* Dispatch textDocument/didChange after rename
Previously whenever we renamed a symbol that was referenced from other
files we'd just edit those files in the background, and the LSP wouldn't
know about these changes. If we tried to rename the same symbol again,
the renaming would fail. In some scenarios, the operation would just be
wrong. Here is an attempt to fix this issue.
I also noticed another bug when using Go with `gopls` LSP and the `gofmt`
fixer. Whenever the file was saved, the `gofmt` would run and reformat
the file. But it seems there was some kind of a race condition so I
disabled saving for now, and all of the modified files will be unsaved,
so the user should call `:wa` to save them. I personally like this even
better because I can inspect exactly what changes happened, and I
instantly see them in the other opened buffers, which was previously not
the case.
Fixes #3343, #3642, #3781.
* Address PR comments
* Remove mode tests in corner case tests
* Address PR comments
* Save after ALERename and ALEOrganizeImports
Also provide options to disable automatic saving, as well as instructions to
enable `set hidden` before doing that.
* Fix broken test
* Save only when !&hidden
* Update doc
* Update doc
* Add silent
2022-02-08 11:07:39 +00:00
|
|
|
AssertEqual [{
|
|
|
|
\ 'conn_id': 'test_conn',
|
|
|
|
\ 'buffer': bufnr(g:file1),
|
|
|
|
\}, {
|
|
|
|
\ 'conn_id': 'test_conn',
|
|
|
|
\ 'buffer': bufnr(g:file2),
|
|
|
|
\}], g:notified_changes
|
2019-09-12 20:53:23 +00:00
|
|
|
|
|
|
|
Execute(Beginning of file can be modified):
|
|
|
|
let g:test.text = [
|
|
|
|
\ 'class Name {',
|
|
|
|
\ ' value: string',
|
|
|
|
\ '}',
|
|
|
|
\]
|
|
|
|
call writefile(g:test.text, g:file1, 'S')
|
|
|
|
|
2020-10-15 20:56:21 +00:00
|
|
|
call ale#code_action#HandleCodeAction(
|
|
|
|
\ {
|
2019-09-12 20:53:23 +00:00
|
|
|
\ 'changes': [{
|
|
|
|
\ 'fileName': g:file1,
|
|
|
|
\ 'textChanges': [{
|
|
|
|
\ 'start': {
|
|
|
|
\ 'line': 1,
|
|
|
|
\ 'offset': 1,
|
|
|
|
\ },
|
|
|
|
\ 'end': {
|
|
|
|
\ 'line': 1,
|
|
|
|
\ 'offset': 1,
|
|
|
|
\ },
|
|
|
|
\ 'newText': "type A: string\ntype B: number\n",
|
|
|
|
\ }],
|
|
|
|
\ }]
|
2020-10-15 20:56:21 +00:00
|
|
|
\ },
|
Dispatch textDocument/didChange after rename (2) (#4049)
* Dispatch textDocument/didChange after rename
Previously whenever we renamed a symbol that was referenced from other
files we'd just edit those files in the background, and the LSP wouldn't
know about these changes. If we tried to rename the same symbol again,
the renaming would fail. In some scenarios, the operation would just be
wrong. Here is an attempt to fix this issue.
I also noticed another bug when using Go with `gopls` LSP and the `gofmt`
fixer. Whenever the file was saved, the `gofmt` would run and reformat
the file. But it seems there was some kind of a race condition so I
disabled saving for now, and all of the modified files will be unsaved,
so the user should call `:wa` to save them. I personally like this even
better because I can inspect exactly what changes happened, and I
instantly see them in the other opened buffers, which was previously not
the case.
Fixes #3343, #3642, #3781.
* Address PR comments
* Remove mode tests in corner case tests
* Address PR comments
* Save after ALERename and ALEOrganizeImports
Also provide options to disable automatic saving, as well as instructions to
enable `set hidden` before doing that.
* Fix broken test
* Save only when !&hidden
* Update doc
* Update doc
* Add silent
2022-02-08 11:07:39 +00:00
|
|
|
\ {'should_save': 1, 'conn_id': 'test_conn'},
|
2020-10-15 20:56:21 +00:00
|
|
|
\)
|
2019-09-12 20:53:23 +00:00
|
|
|
|
|
|
|
AssertEqual [
|
|
|
|
\ 'type A: string',
|
|
|
|
\ 'type B: number',
|
|
|
|
\] + g:test.text + [''], readfile(g:file1, 'b')
|
|
|
|
|
Dispatch textDocument/didChange after rename (2) (#4049)
* Dispatch textDocument/didChange after rename
Previously whenever we renamed a symbol that was referenced from other
files we'd just edit those files in the background, and the LSP wouldn't
know about these changes. If we tried to rename the same symbol again,
the renaming would fail. In some scenarios, the operation would just be
wrong. Here is an attempt to fix this issue.
I also noticed another bug when using Go with `gopls` LSP and the `gofmt`
fixer. Whenever the file was saved, the `gofmt` would run and reformat
the file. But it seems there was some kind of a race condition so I
disabled saving for now, and all of the modified files will be unsaved,
so the user should call `:wa` to save them. I personally like this even
better because I can inspect exactly what changes happened, and I
instantly see them in the other opened buffers, which was previously not
the case.
Fixes #3343, #3642, #3781.
* Address PR comments
* Remove mode tests in corner case tests
* Address PR comments
* Save after ALERename and ALEOrganizeImports
Also provide options to disable automatic saving, as well as instructions to
enable `set hidden` before doing that.
* Fix broken test
* Save only when !&hidden
* Update doc
* Update doc
* Add silent
2022-02-08 11:07:39 +00:00
|
|
|
AssertEqual [{
|
|
|
|
\ 'conn_id': 'test_conn',
|
|
|
|
\ 'buffer': bufnr(g:file1),
|
|
|
|
\}], g:notified_changes
|
|
|
|
|
2019-09-12 20:53:23 +00:00
|
|
|
|
|
|
|
Execute(End of file can be modified):
|
|
|
|
let g:test.text = [
|
|
|
|
\ 'class Name {',
|
|
|
|
\ ' value: string',
|
|
|
|
\ '}',
|
|
|
|
\]
|
|
|
|
call writefile(g:test.text, g:file1, 'S')
|
|
|
|
|
2020-10-15 20:56:21 +00:00
|
|
|
call ale#code_action#HandleCodeAction(
|
|
|
|
\ {
|
2019-09-12 20:53:23 +00:00
|
|
|
\ 'changes': [{
|
2020-10-15 20:56:21 +00:00
|
|
|
\ 'fileName': g:file1,
|
|
|
|
\ 'textChanges': [{
|
|
|
|
\ 'start': {
|
|
|
|
\ 'line': 4,
|
|
|
|
\ 'offset': 1,
|
|
|
|
\ },
|
|
|
|
\ 'end': {
|
|
|
|
\ 'line': 4,
|
|
|
|
\ 'offset': 1,
|
|
|
|
\ },
|
|
|
|
\ 'newText': "type A: string\ntype B: number\n",
|
|
|
|
\ }],
|
2019-09-12 20:53:23 +00:00
|
|
|
\ }]
|
2020-10-15 20:56:21 +00:00
|
|
|
\ },
|
Dispatch textDocument/didChange after rename (2) (#4049)
* Dispatch textDocument/didChange after rename
Previously whenever we renamed a symbol that was referenced from other
files we'd just edit those files in the background, and the LSP wouldn't
know about these changes. If we tried to rename the same symbol again,
the renaming would fail. In some scenarios, the operation would just be
wrong. Here is an attempt to fix this issue.
I also noticed another bug when using Go with `gopls` LSP and the `gofmt`
fixer. Whenever the file was saved, the `gofmt` would run and reformat
the file. But it seems there was some kind of a race condition so I
disabled saving for now, and all of the modified files will be unsaved,
so the user should call `:wa` to save them. I personally like this even
better because I can inspect exactly what changes happened, and I
instantly see them in the other opened buffers, which was previously not
the case.
Fixes #3343, #3642, #3781.
* Address PR comments
* Remove mode tests in corner case tests
* Address PR comments
* Save after ALERename and ALEOrganizeImports
Also provide options to disable automatic saving, as well as instructions to
enable `set hidden` before doing that.
* Fix broken test
* Save only when !&hidden
* Update doc
* Update doc
* Add silent
2022-02-08 11:07:39 +00:00
|
|
|
\ {'should_save': 1, 'conn_id': 'test_conn'},
|
2020-10-15 20:56:21 +00:00
|
|
|
\)
|
2019-09-12 20:53:23 +00:00
|
|
|
|
|
|
|
AssertEqual g:test.text + [
|
|
|
|
\ 'type A: string',
|
|
|
|
\ 'type B: number',
|
|
|
|
\ '',
|
|
|
|
\], readfile(g:file1, 'b')
|
|
|
|
|
Dispatch textDocument/didChange after rename (2) (#4049)
* Dispatch textDocument/didChange after rename
Previously whenever we renamed a symbol that was referenced from other
files we'd just edit those files in the background, and the LSP wouldn't
know about these changes. If we tried to rename the same symbol again,
the renaming would fail. In some scenarios, the operation would just be
wrong. Here is an attempt to fix this issue.
I also noticed another bug when using Go with `gopls` LSP and the `gofmt`
fixer. Whenever the file was saved, the `gofmt` would run and reformat
the file. But it seems there was some kind of a race condition so I
disabled saving for now, and all of the modified files will be unsaved,
so the user should call `:wa` to save them. I personally like this even
better because I can inspect exactly what changes happened, and I
instantly see them in the other opened buffers, which was previously not
the case.
Fixes #3343, #3642, #3781.
* Address PR comments
* Remove mode tests in corner case tests
* Address PR comments
* Save after ALERename and ALEOrganizeImports
Also provide options to disable automatic saving, as well as instructions to
enable `set hidden` before doing that.
* Fix broken test
* Save only when !&hidden
* Update doc
* Update doc
* Add silent
2022-02-08 11:07:39 +00:00
|
|
|
AssertEqual [{
|
|
|
|
\ 'conn_id': 'test_conn',
|
|
|
|
\ 'buffer': bufnr(g:file1),
|
|
|
|
\}], g:notified_changes
|
|
|
|
|
2019-09-12 20:53:23 +00:00
|
|
|
|
|
|
|
Execute(Current buffer contents will be reloaded):
|
|
|
|
let g:test.text = [
|
|
|
|
\ 'class Name {',
|
|
|
|
\ ' value: string',
|
|
|
|
\ '}',
|
|
|
|
\]
|
|
|
|
call writefile(g:test.text, g:file1, 'S')
|
|
|
|
|
|
|
|
execute 'edit ' . g:file1
|
|
|
|
let g:test.buffer = bufnr(g:file1)
|
|
|
|
|
2020-10-15 20:56:21 +00:00
|
|
|
call ale#code_action#HandleCodeAction(
|
|
|
|
\ {
|
2019-09-12 20:53:23 +00:00
|
|
|
\ 'changes': [{
|
|
|
|
\ 'fileName': g:file1,
|
|
|
|
\ 'textChanges': [{
|
|
|
|
\ 'start': {
|
|
|
|
\ 'line': 1,
|
|
|
|
\ 'offset': 1,
|
|
|
|
\ },
|
|
|
|
\ 'end': {
|
|
|
|
\ 'line': 1,
|
|
|
|
\ 'offset': 1,
|
|
|
|
\ },
|
|
|
|
\ 'newText': "type A: string\ntype B: number\n",
|
|
|
|
\ }],
|
|
|
|
\ }]
|
2020-10-15 20:56:21 +00:00
|
|
|
\ },
|
Dispatch textDocument/didChange after rename (2) (#4049)
* Dispatch textDocument/didChange after rename
Previously whenever we renamed a symbol that was referenced from other
files we'd just edit those files in the background, and the LSP wouldn't
know about these changes. If we tried to rename the same symbol again,
the renaming would fail. In some scenarios, the operation would just be
wrong. Here is an attempt to fix this issue.
I also noticed another bug when using Go with `gopls` LSP and the `gofmt`
fixer. Whenever the file was saved, the `gofmt` would run and reformat
the file. But it seems there was some kind of a race condition so I
disabled saving for now, and all of the modified files will be unsaved,
so the user should call `:wa` to save them. I personally like this even
better because I can inspect exactly what changes happened, and I
instantly see them in the other opened buffers, which was previously not
the case.
Fixes #3343, #3642, #3781.
* Address PR comments
* Remove mode tests in corner case tests
* Address PR comments
* Save after ALERename and ALEOrganizeImports
Also provide options to disable automatic saving, as well as instructions to
enable `set hidden` before doing that.
* Fix broken test
* Save only when !&hidden
* Update doc
* Update doc
* Add silent
2022-02-08 11:07:39 +00:00
|
|
|
\ {'should_save': 1, 'conn_id': 'test_conn'},
|
2020-10-15 20:56:21 +00:00
|
|
|
\)
|
2019-09-12 20:53:23 +00:00
|
|
|
|
|
|
|
AssertEqual [
|
|
|
|
\ 'type A: string',
|
|
|
|
\ 'type B: number',
|
|
|
|
\] + g:test.text + [''], readfile(g:file1, 'b')
|
|
|
|
|
|
|
|
AssertEqual [
|
|
|
|
\ 'type A: string',
|
|
|
|
\ 'type B: number',
|
|
|
|
\] + g:test.text, getbufline(g:test.buffer, 1, '$')
|
|
|
|
|
Dispatch textDocument/didChange after rename (2) (#4049)
* Dispatch textDocument/didChange after rename
Previously whenever we renamed a symbol that was referenced from other
files we'd just edit those files in the background, and the LSP wouldn't
know about these changes. If we tried to rename the same symbol again,
the renaming would fail. In some scenarios, the operation would just be
wrong. Here is an attempt to fix this issue.
I also noticed another bug when using Go with `gopls` LSP and the `gofmt`
fixer. Whenever the file was saved, the `gofmt` would run and reformat
the file. But it seems there was some kind of a race condition so I
disabled saving for now, and all of the modified files will be unsaved,
so the user should call `:wa` to save them. I personally like this even
better because I can inspect exactly what changes happened, and I
instantly see them in the other opened buffers, which was previously not
the case.
Fixes #3343, #3642, #3781.
* Address PR comments
* Remove mode tests in corner case tests
* Address PR comments
* Save after ALERename and ALEOrganizeImports
Also provide options to disable automatic saving, as well as instructions to
enable `set hidden` before doing that.
* Fix broken test
* Save only when !&hidden
* Update doc
* Update doc
* Add silent
2022-02-08 11:07:39 +00:00
|
|
|
AssertEqual [{
|
|
|
|
\ 'conn_id': 'test_conn',
|
|
|
|
\ 'buffer': bufnr(g:file1),
|
|
|
|
\}], g:notified_changes
|
|
|
|
|
|
|
|
|
|
|
|
Execute(Unlisted buffer contents will be modified correctly):
|
|
|
|
let g:test.text = [
|
|
|
|
\ 'class Name {',
|
|
|
|
\ ' value: string',
|
|
|
|
\ '}',
|
|
|
|
\]
|
|
|
|
call writefile(g:test.text, g:file1, 'S')
|
|
|
|
|
|
|
|
execute 'edit ' . g:file1
|
|
|
|
let g:test.buffer = bufnr(g:file1)
|
|
|
|
|
|
|
|
execute 'bd'
|
|
|
|
AssertEqual bufnr(g:file1), g:test.buffer
|
|
|
|
|
|
|
|
call ale#code_action#HandleCodeAction(
|
|
|
|
\ {
|
|
|
|
\ 'changes': [{
|
|
|
|
\ 'fileName': g:file1,
|
|
|
|
\ 'textChanges': [{
|
|
|
|
\ 'start': {
|
|
|
|
\ 'line': 1,
|
|
|
|
\ 'offset': 1,
|
|
|
|
\ },
|
|
|
|
\ 'end': {
|
|
|
|
\ 'line': 1,
|
|
|
|
\ 'offset': 1,
|
|
|
|
\ },
|
|
|
|
\ 'newText': "type A: string\ntype B: number\n",
|
|
|
|
\ }],
|
|
|
|
\ }]
|
|
|
|
\ },
|
|
|
|
\ {'should_save': 1, 'conn_id': 'test_conn'},
|
|
|
|
\)
|
|
|
|
|
|
|
|
AssertEqual [
|
|
|
|
\ 'type A: string',
|
|
|
|
\ 'type B: number',
|
|
|
|
\] + g:test.text + [''], readfile(g:file1, 'b')
|
|
|
|
|
|
|
|
AssertEqual [{
|
|
|
|
\ 'conn_id': 'test_conn',
|
|
|
|
\ 'buffer': bufnr(g:file1),
|
|
|
|
\}], g:notified_changes
|
2019-09-12 20:53:23 +00:00
|
|
|
|
|
|
|
# Tests for cursor repositioning. In comments `=` designates change range, and
|
|
|
|
# `C` cursor position
|
|
|
|
|
|
|
|
# C ===
|
|
|
|
Execute(Cursor will not move when it is before text change):
|
|
|
|
call WriteFileAndEdit()
|
|
|
|
let g:test.changes = g:test.create_change(2, 3, 2, 8, 'value2')
|
|
|
|
|
|
|
|
call setpos('.', [0, 1, 1, 0])
|
Dispatch textDocument/didChange after rename (2) (#4049)
* Dispatch textDocument/didChange after rename
Previously whenever we renamed a symbol that was referenced from other
files we'd just edit those files in the background, and the LSP wouldn't
know about these changes. If we tried to rename the same symbol again,
the renaming would fail. In some scenarios, the operation would just be
wrong. Here is an attempt to fix this issue.
I also noticed another bug when using Go with `gopls` LSP and the `gofmt`
fixer. Whenever the file was saved, the `gofmt` would run and reformat
the file. But it seems there was some kind of a race condition so I
disabled saving for now, and all of the modified files will be unsaved,
so the user should call `:wa` to save them. I personally like this even
better because I can inspect exactly what changes happened, and I
instantly see them in the other opened buffers, which was previously not
the case.
Fixes #3343, #3642, #3781.
* Address PR comments
* Remove mode tests in corner case tests
* Address PR comments
* Save after ALERename and ALEOrganizeImports
Also provide options to disable automatic saving, as well as instructions to
enable `set hidden` before doing that.
* Fix broken test
* Save only when !&hidden
* Update doc
* Update doc
* Add silent
2022-02-08 11:07:39 +00:00
|
|
|
call ale#code_action#HandleCodeAction(g:test.changes, {
|
|
|
|
\ 'should_save': 1,
|
|
|
|
\ 'conn_id': 'test_conn',
|
|
|
|
\})
|
2019-09-12 20:53:23 +00:00
|
|
|
AssertEqual [1, 1], getpos('.')[1:2]
|
|
|
|
|
Dispatch textDocument/didChange after rename (2) (#4049)
* Dispatch textDocument/didChange after rename
Previously whenever we renamed a symbol that was referenced from other
files we'd just edit those files in the background, and the LSP wouldn't
know about these changes. If we tried to rename the same symbol again,
the renaming would fail. In some scenarios, the operation would just be
wrong. Here is an attempt to fix this issue.
I also noticed another bug when using Go with `gopls` LSP and the `gofmt`
fixer. Whenever the file was saved, the `gofmt` would run and reformat
the file. But it seems there was some kind of a race condition so I
disabled saving for now, and all of the modified files will be unsaved,
so the user should call `:wa` to save them. I personally like this even
better because I can inspect exactly what changes happened, and I
instantly see them in the other opened buffers, which was previously not
the case.
Fixes #3343, #3642, #3781.
* Address PR comments
* Remove mode tests in corner case tests
* Address PR comments
* Save after ALERename and ALEOrganizeImports
Also provide options to disable automatic saving, as well as instructions to
enable `set hidden` before doing that.
* Fix broken test
* Save only when !&hidden
* Update doc
* Update doc
* Add silent
2022-02-08 11:07:39 +00:00
|
|
|
AssertEqual [{
|
|
|
|
\ 'conn_id': 'test_conn',
|
|
|
|
\ 'buffer': bufnr(''),
|
|
|
|
\}], g:notified_changes
|
|
|
|
|
2019-09-12 20:53:23 +00:00
|
|
|
call setpos('.', [0, 2, 2, 0])
|
Dispatch textDocument/didChange after rename (2) (#4049)
* Dispatch textDocument/didChange after rename
Previously whenever we renamed a symbol that was referenced from other
files we'd just edit those files in the background, and the LSP wouldn't
know about these changes. If we tried to rename the same symbol again,
the renaming would fail. In some scenarios, the operation would just be
wrong. Here is an attempt to fix this issue.
I also noticed another bug when using Go with `gopls` LSP and the `gofmt`
fixer. Whenever the file was saved, the `gofmt` would run and reformat
the file. But it seems there was some kind of a race condition so I
disabled saving for now, and all of the modified files will be unsaved,
so the user should call `:wa` to save them. I personally like this even
better because I can inspect exactly what changes happened, and I
instantly see them in the other opened buffers, which was previously not
the case.
Fixes #3343, #3642, #3781.
* Address PR comments
* Remove mode tests in corner case tests
* Address PR comments
* Save after ALERename and ALEOrganizeImports
Also provide options to disable automatic saving, as well as instructions to
enable `set hidden` before doing that.
* Fix broken test
* Save only when !&hidden
* Update doc
* Update doc
* Add silent
2022-02-08 11:07:39 +00:00
|
|
|
call ale#code_action#HandleCodeAction(g:test.changes, {
|
|
|
|
\ 'should_save': 1,
|
|
|
|
\ 'conn_id': 'test_conn',
|
|
|
|
\})
|
2019-09-12 20:53:23 +00:00
|
|
|
AssertEqual [2, 2], getpos('.')[1:2]
|
|
|
|
|
Dispatch textDocument/didChange after rename (2) (#4049)
* Dispatch textDocument/didChange after rename
Previously whenever we renamed a symbol that was referenced from other
files we'd just edit those files in the background, and the LSP wouldn't
know about these changes. If we tried to rename the same symbol again,
the renaming would fail. In some scenarios, the operation would just be
wrong. Here is an attempt to fix this issue.
I also noticed another bug when using Go with `gopls` LSP and the `gofmt`
fixer. Whenever the file was saved, the `gofmt` would run and reformat
the file. But it seems there was some kind of a race condition so I
disabled saving for now, and all of the modified files will be unsaved,
so the user should call `:wa` to save them. I personally like this even
better because I can inspect exactly what changes happened, and I
instantly see them in the other opened buffers, which was previously not
the case.
Fixes #3343, #3642, #3781.
* Address PR comments
* Remove mode tests in corner case tests
* Address PR comments
* Save after ALERename and ALEOrganizeImports
Also provide options to disable automatic saving, as well as instructions to
enable `set hidden` before doing that.
* Fix broken test
* Save only when !&hidden
* Update doc
* Update doc
* Add silent
2022-02-08 11:07:39 +00:00
|
|
|
AssertEqual [{
|
|
|
|
\ 'conn_id': 'test_conn',
|
|
|
|
\ 'buffer': bufnr(''),
|
|
|
|
\}, {
|
|
|
|
\ 'conn_id': 'test_conn',
|
|
|
|
\ 'buffer': bufnr(''),
|
|
|
|
\}], g:notified_changes
|
|
|
|
|
2019-09-12 20:53:23 +00:00
|
|
|
# ====C====
|
|
|
|
Execute(Cursor column will move to the change end when cursor between start/end):
|
|
|
|
let g:test.changes = g:test.create_change(2, 3, 2, 8, 'value2')
|
|
|
|
|
|
|
|
for r in range(3, 8)
|
|
|
|
call WriteFileAndEdit()
|
|
|
|
call setpos('.', [0, 2, r, 0])
|
|
|
|
AssertEqual ' value: string', getline('.')
|
Dispatch textDocument/didChange after rename (2) (#4049)
* Dispatch textDocument/didChange after rename
Previously whenever we renamed a symbol that was referenced from other
files we'd just edit those files in the background, and the LSP wouldn't
know about these changes. If we tried to rename the same symbol again,
the renaming would fail. In some scenarios, the operation would just be
wrong. Here is an attempt to fix this issue.
I also noticed another bug when using Go with `gopls` LSP and the `gofmt`
fixer. Whenever the file was saved, the `gofmt` would run and reformat
the file. But it seems there was some kind of a race condition so I
disabled saving for now, and all of the modified files will be unsaved,
so the user should call `:wa` to save them. I personally like this even
better because I can inspect exactly what changes happened, and I
instantly see them in the other opened buffers, which was previously not
the case.
Fixes #3343, #3642, #3781.
* Address PR comments
* Remove mode tests in corner case tests
* Address PR comments
* Save after ALERename and ALEOrganizeImports
Also provide options to disable automatic saving, as well as instructions to
enable `set hidden` before doing that.
* Fix broken test
* Save only when !&hidden
* Update doc
* Update doc
* Add silent
2022-02-08 11:07:39 +00:00
|
|
|
call ale#code_action#HandleCodeAction(g:test.changes, {
|
|
|
|
\ 'should_save': 1,
|
|
|
|
\ 'conn_id': 'test_conn',
|
|
|
|
\})
|
2019-09-12 20:53:23 +00:00
|
|
|
AssertEqual ' value2: string', getline('.')
|
|
|
|
AssertEqual [2, 9], getpos('.')[1:2]
|
|
|
|
endfor
|
|
|
|
|
Dispatch textDocument/didChange after rename (2) (#4049)
* Dispatch textDocument/didChange after rename
Previously whenever we renamed a symbol that was referenced from other
files we'd just edit those files in the background, and the LSP wouldn't
know about these changes. If we tried to rename the same symbol again,
the renaming would fail. In some scenarios, the operation would just be
wrong. Here is an attempt to fix this issue.
I also noticed another bug when using Go with `gopls` LSP and the `gofmt`
fixer. Whenever the file was saved, the `gofmt` would run and reformat
the file. But it seems there was some kind of a race condition so I
disabled saving for now, and all of the modified files will be unsaved,
so the user should call `:wa` to save them. I personally like this even
better because I can inspect exactly what changes happened, and I
instantly see them in the other opened buffers, which was previously not
the case.
Fixes #3343, #3642, #3781.
* Address PR comments
* Remove mode tests in corner case tests
* Address PR comments
* Save after ALERename and ALEOrganizeImports
Also provide options to disable automatic saving, as well as instructions to
enable `set hidden` before doing that.
* Fix broken test
* Save only when !&hidden
* Update doc
* Update doc
* Add silent
2022-02-08 11:07:39 +00:00
|
|
|
AssertEqual [{
|
|
|
|
\ 'conn_id': 'test_conn',
|
|
|
|
\ 'buffer': bufnr(''),
|
|
|
|
\}, {
|
|
|
|
\ 'conn_id': 'test_conn',
|
|
|
|
\ 'buffer': bufnr(''),
|
|
|
|
\}, {
|
|
|
|
\ 'conn_id': 'test_conn',
|
|
|
|
\ 'buffer': bufnr(''),
|
|
|
|
\}, {
|
|
|
|
\ 'conn_id': 'test_conn',
|
|
|
|
\ 'buffer': bufnr(''),
|
|
|
|
\}, {
|
|
|
|
\ 'conn_id': 'test_conn',
|
|
|
|
\ 'buffer': bufnr(''),
|
|
|
|
\}, {
|
|
|
|
\ 'conn_id': 'test_conn',
|
|
|
|
\ 'buffer': bufnr(''),
|
|
|
|
\}], g:notified_changes
|
|
|
|
|
2019-09-12 20:53:23 +00:00
|
|
|
|
|
|
|
# ====C
|
|
|
|
Execute(Cursor column will move back when new text is shorter):
|
|
|
|
call WriteFileAndEdit()
|
|
|
|
call setpos('.', [0, 2, 8, 0])
|
|
|
|
AssertEqual ' value: string', getline('.')
|
2019-10-10 01:42:41 +00:00
|
|
|
call ale#code_action#HandleCodeAction(
|
2020-10-15 20:56:21 +00:00
|
|
|
\ g:test.create_change(2, 3, 2, 8, 'val'),
|
Dispatch textDocument/didChange after rename (2) (#4049)
* Dispatch textDocument/didChange after rename
Previously whenever we renamed a symbol that was referenced from other
files we'd just edit those files in the background, and the LSP wouldn't
know about these changes. If we tried to rename the same symbol again,
the renaming would fail. In some scenarios, the operation would just be
wrong. Here is an attempt to fix this issue.
I also noticed another bug when using Go with `gopls` LSP and the `gofmt`
fixer. Whenever the file was saved, the `gofmt` would run and reformat
the file. But it seems there was some kind of a race condition so I
disabled saving for now, and all of the modified files will be unsaved,
so the user should call `:wa` to save them. I personally like this even
better because I can inspect exactly what changes happened, and I
instantly see them in the other opened buffers, which was previously not
the case.
Fixes #3343, #3642, #3781.
* Address PR comments
* Remove mode tests in corner case tests
* Address PR comments
* Save after ALERename and ALEOrganizeImports
Also provide options to disable automatic saving, as well as instructions to
enable `set hidden` before doing that.
* Fix broken test
* Save only when !&hidden
* Update doc
* Update doc
* Add silent
2022-02-08 11:07:39 +00:00
|
|
|
\ {
|
|
|
|
\ 'should_save': 1,
|
|
|
|
\ 'conn_id': 'test_conn',
|
|
|
|
\ })
|
2019-09-12 20:53:23 +00:00
|
|
|
AssertEqual ' val: string', getline('.')
|
|
|
|
AssertEqual [2, 6], getpos('.')[1:2]
|
|
|
|
|
Dispatch textDocument/didChange after rename (2) (#4049)
* Dispatch textDocument/didChange after rename
Previously whenever we renamed a symbol that was referenced from other
files we'd just edit those files in the background, and the LSP wouldn't
know about these changes. If we tried to rename the same symbol again,
the renaming would fail. In some scenarios, the operation would just be
wrong. Here is an attempt to fix this issue.
I also noticed another bug when using Go with `gopls` LSP and the `gofmt`
fixer. Whenever the file was saved, the `gofmt` would run and reformat
the file. But it seems there was some kind of a race condition so I
disabled saving for now, and all of the modified files will be unsaved,
so the user should call `:wa` to save them. I personally like this even
better because I can inspect exactly what changes happened, and I
instantly see them in the other opened buffers, which was previously not
the case.
Fixes #3343, #3642, #3781.
* Address PR comments
* Remove mode tests in corner case tests
* Address PR comments
* Save after ALERename and ALEOrganizeImports
Also provide options to disable automatic saving, as well as instructions to
enable `set hidden` before doing that.
* Fix broken test
* Save only when !&hidden
* Update doc
* Update doc
* Add silent
2022-02-08 11:07:39 +00:00
|
|
|
AssertEqual [{
|
|
|
|
\ 'conn_id': 'test_conn',
|
|
|
|
\ 'buffer': bufnr(''),
|
|
|
|
\}], g:notified_changes
|
|
|
|
|
2019-09-12 20:53:23 +00:00
|
|
|
|
|
|
|
# ==== C
|
|
|
|
Execute(Cursor column will move forward when new text is longer):
|
|
|
|
call WriteFileAndEdit()
|
|
|
|
|
|
|
|
call setpos('.', [0, 2, 8, 0])
|
|
|
|
AssertEqual ' value: string', getline('.')
|
2019-10-10 01:42:41 +00:00
|
|
|
call ale#code_action#HandleCodeAction(
|
Dispatch textDocument/didChange after rename (2) (#4049)
* Dispatch textDocument/didChange after rename
Previously whenever we renamed a symbol that was referenced from other
files we'd just edit those files in the background, and the LSP wouldn't
know about these changes. If we tried to rename the same symbol again,
the renaming would fail. In some scenarios, the operation would just be
wrong. Here is an attempt to fix this issue.
I also noticed another bug when using Go with `gopls` LSP and the `gofmt`
fixer. Whenever the file was saved, the `gofmt` would run and reformat
the file. But it seems there was some kind of a race condition so I
disabled saving for now, and all of the modified files will be unsaved,
so the user should call `:wa` to save them. I personally like this even
better because I can inspect exactly what changes happened, and I
instantly see them in the other opened buffers, which was previously not
the case.
Fixes #3343, #3642, #3781.
* Address PR comments
* Remove mode tests in corner case tests
* Address PR comments
* Save after ALERename and ALEOrganizeImports
Also provide options to disable automatic saving, as well as instructions to
enable `set hidden` before doing that.
* Fix broken test
* Save only when !&hidden
* Update doc
* Update doc
* Add silent
2022-02-08 11:07:39 +00:00
|
|
|
\ g:test.create_change(2, 3, 2, 8, 'longValue'),
|
|
|
|
\ {
|
|
|
|
\ 'should_save': 1,
|
|
|
|
\ 'conn_id': 'test_conn',
|
|
|
|
\ })
|
2019-09-12 20:53:23 +00:00
|
|
|
AssertEqual ' longValue: string', getline('.')
|
|
|
|
AssertEqual [2, 12], getpos('.')[1:2]
|
|
|
|
|
Dispatch textDocument/didChange after rename (2) (#4049)
* Dispatch textDocument/didChange after rename
Previously whenever we renamed a symbol that was referenced from other
files we'd just edit those files in the background, and the LSP wouldn't
know about these changes. If we tried to rename the same symbol again,
the renaming would fail. In some scenarios, the operation would just be
wrong. Here is an attempt to fix this issue.
I also noticed another bug when using Go with `gopls` LSP and the `gofmt`
fixer. Whenever the file was saved, the `gofmt` would run and reformat
the file. But it seems there was some kind of a race condition so I
disabled saving for now, and all of the modified files will be unsaved,
so the user should call `:wa` to save them. I personally like this even
better because I can inspect exactly what changes happened, and I
instantly see them in the other opened buffers, which was previously not
the case.
Fixes #3343, #3642, #3781.
* Address PR comments
* Remove mode tests in corner case tests
* Address PR comments
* Save after ALERename and ALEOrganizeImports
Also provide options to disable automatic saving, as well as instructions to
enable `set hidden` before doing that.
* Fix broken test
* Save only when !&hidden
* Update doc
* Update doc
* Add silent
2022-02-08 11:07:39 +00:00
|
|
|
AssertEqual [{
|
|
|
|
\ 'conn_id': 'test_conn',
|
|
|
|
\ 'buffer': bufnr(''),
|
|
|
|
\}], g:notified_changes
|
|
|
|
|
2019-09-12 20:53:23 +00:00
|
|
|
# =========
|
|
|
|
# =
|
|
|
|
# C
|
|
|
|
Execute(Cursor line will move when updates are happening on lines above):
|
|
|
|
call WriteFileAndEdit()
|
|
|
|
call setpos('.', [0, 3, 1, 0])
|
|
|
|
AssertEqual '}', getline('.')
|
2019-10-10 01:42:41 +00:00
|
|
|
call ale#code_action#HandleCodeAction(
|
Dispatch textDocument/didChange after rename (2) (#4049)
* Dispatch textDocument/didChange after rename
Previously whenever we renamed a symbol that was referenced from other
files we'd just edit those files in the background, and the LSP wouldn't
know about these changes. If we tried to rename the same symbol again,
the renaming would fail. In some scenarios, the operation would just be
wrong. Here is an attempt to fix this issue.
I also noticed another bug when using Go with `gopls` LSP and the `gofmt`
fixer. Whenever the file was saved, the `gofmt` would run and reformat
the file. But it seems there was some kind of a race condition so I
disabled saving for now, and all of the modified files will be unsaved,
so the user should call `:wa` to save them. I personally like this even
better because I can inspect exactly what changes happened, and I
instantly see them in the other opened buffers, which was previously not
the case.
Fixes #3343, #3642, #3781.
* Address PR comments
* Remove mode tests in corner case tests
* Address PR comments
* Save after ALERename and ALEOrganizeImports
Also provide options to disable automatic saving, as well as instructions to
enable `set hidden` before doing that.
* Fix broken test
* Save only when !&hidden
* Update doc
* Update doc
* Add silent
2022-02-08 11:07:39 +00:00
|
|
|
\ g:test.create_change(1, 1, 2, 1, "test\ntest\n"),
|
|
|
|
\ {
|
|
|
|
\ 'should_save': 1,
|
|
|
|
\ 'conn_id': 'test_conn',
|
|
|
|
\ })
|
2019-09-12 20:53:23 +00:00
|
|
|
AssertEqual '}', getline('.')
|
|
|
|
AssertEqual [4, 1], getpos('.')[1:2]
|
|
|
|
|
Dispatch textDocument/didChange after rename (2) (#4049)
* Dispatch textDocument/didChange after rename
Previously whenever we renamed a symbol that was referenced from other
files we'd just edit those files in the background, and the LSP wouldn't
know about these changes. If we tried to rename the same symbol again,
the renaming would fail. In some scenarios, the operation would just be
wrong. Here is an attempt to fix this issue.
I also noticed another bug when using Go with `gopls` LSP and the `gofmt`
fixer. Whenever the file was saved, the `gofmt` would run and reformat
the file. But it seems there was some kind of a race condition so I
disabled saving for now, and all of the modified files will be unsaved,
so the user should call `:wa` to save them. I personally like this even
better because I can inspect exactly what changes happened, and I
instantly see them in the other opened buffers, which was previously not
the case.
Fixes #3343, #3642, #3781.
* Address PR comments
* Remove mode tests in corner case tests
* Address PR comments
* Save after ALERename and ALEOrganizeImports
Also provide options to disable automatic saving, as well as instructions to
enable `set hidden` before doing that.
* Fix broken test
* Save only when !&hidden
* Update doc
* Update doc
* Add silent
2022-02-08 11:07:39 +00:00
|
|
|
AssertEqual [{
|
|
|
|
\ 'conn_id': 'test_conn',
|
|
|
|
\ 'buffer': bufnr(''),
|
|
|
|
\}], g:notified_changes
|
|
|
|
|
2019-09-12 20:53:23 +00:00
|
|
|
|
|
|
|
# =========
|
|
|
|
# =C
|
|
|
|
Execute(Cursor line and column will move when change on lines above and just before cursor column):
|
|
|
|
call WriteFileAndEdit()
|
|
|
|
call setpos('.', [0, 2, 2, 0])
|
|
|
|
AssertEqual ' value: string', getline('.')
|
2019-10-10 01:42:41 +00:00
|
|
|
call ale#code_action#HandleCodeAction(
|
Dispatch textDocument/didChange after rename (2) (#4049)
* Dispatch textDocument/didChange after rename
Previously whenever we renamed a symbol that was referenced from other
files we'd just edit those files in the background, and the LSP wouldn't
know about these changes. If we tried to rename the same symbol again,
the renaming would fail. In some scenarios, the operation would just be
wrong. Here is an attempt to fix this issue.
I also noticed another bug when using Go with `gopls` LSP and the `gofmt`
fixer. Whenever the file was saved, the `gofmt` would run and reformat
the file. But it seems there was some kind of a race condition so I
disabled saving for now, and all of the modified files will be unsaved,
so the user should call `:wa` to save them. I personally like this even
better because I can inspect exactly what changes happened, and I
instantly see them in the other opened buffers, which was previously not
the case.
Fixes #3343, #3642, #3781.
* Address PR comments
* Remove mode tests in corner case tests
* Address PR comments
* Save after ALERename and ALEOrganizeImports
Also provide options to disable automatic saving, as well as instructions to
enable `set hidden` before doing that.
* Fix broken test
* Save only when !&hidden
* Update doc
* Update doc
* Add silent
2022-02-08 11:07:39 +00:00
|
|
|
\ g:test.create_change(1, 1, 2, 1, "test\ntest\n123"),
|
|
|
|
\ {
|
|
|
|
\ 'should_save': 1,
|
|
|
|
\ 'conn_id': 'test_conn',
|
|
|
|
\ })
|
2019-09-12 20:53:23 +00:00
|
|
|
AssertEqual '123 value: string', getline('.')
|
|
|
|
AssertEqual [3, 5], getpos('.')[1:2]
|
|
|
|
|
Dispatch textDocument/didChange after rename (2) (#4049)
* Dispatch textDocument/didChange after rename
Previously whenever we renamed a symbol that was referenced from other
files we'd just edit those files in the background, and the LSP wouldn't
know about these changes. If we tried to rename the same symbol again,
the renaming would fail. In some scenarios, the operation would just be
wrong. Here is an attempt to fix this issue.
I also noticed another bug when using Go with `gopls` LSP and the `gofmt`
fixer. Whenever the file was saved, the `gofmt` would run and reformat
the file. But it seems there was some kind of a race condition so I
disabled saving for now, and all of the modified files will be unsaved,
so the user should call `:wa` to save them. I personally like this even
better because I can inspect exactly what changes happened, and I
instantly see them in the other opened buffers, which was previously not
the case.
Fixes #3343, #3642, #3781.
* Address PR comments
* Remove mode tests in corner case tests
* Address PR comments
* Save after ALERename and ALEOrganizeImports
Also provide options to disable automatic saving, as well as instructions to
enable `set hidden` before doing that.
* Fix broken test
* Save only when !&hidden
* Update doc
* Update doc
* Add silent
2022-02-08 11:07:39 +00:00
|
|
|
AssertEqual [{
|
|
|
|
\ 'conn_id': 'test_conn',
|
|
|
|
\ 'buffer': bufnr(''),
|
|
|
|
\}], g:notified_changes
|
|
|
|
|
2019-09-12 20:53:23 +00:00
|
|
|
# =========
|
|
|
|
# ======C==
|
|
|
|
# =
|
|
|
|
Execute(Cursor line and column will move at the end of changes):
|
|
|
|
call WriteFileAndEdit()
|
|
|
|
call setpos('.', [0, 2, 10, 0])
|
|
|
|
AssertEqual ' value: string', getline('.')
|
2019-10-10 01:42:41 +00:00
|
|
|
call ale#code_action#HandleCodeAction(
|
Dispatch textDocument/didChange after rename (2) (#4049)
* Dispatch textDocument/didChange after rename
Previously whenever we renamed a symbol that was referenced from other
files we'd just edit those files in the background, and the LSP wouldn't
know about these changes. If we tried to rename the same symbol again,
the renaming would fail. In some scenarios, the operation would just be
wrong. Here is an attempt to fix this issue.
I also noticed another bug when using Go with `gopls` LSP and the `gofmt`
fixer. Whenever the file was saved, the `gofmt` would run and reformat
the file. But it seems there was some kind of a race condition so I
disabled saving for now, and all of the modified files will be unsaved,
so the user should call `:wa` to save them. I personally like this even
better because I can inspect exactly what changes happened, and I
instantly see them in the other opened buffers, which was previously not
the case.
Fixes #3343, #3642, #3781.
* Address PR comments
* Remove mode tests in corner case tests
* Address PR comments
* Save after ALERename and ALEOrganizeImports
Also provide options to disable automatic saving, as well as instructions to
enable `set hidden` before doing that.
* Fix broken test
* Save only when !&hidden
* Update doc
* Update doc
* Add silent
2022-02-08 11:07:39 +00:00
|
|
|
\ g:test.create_change(1, 1, 3, 1, "test\n"),
|
|
|
|
\ {
|
|
|
|
\ 'should_save': 1,
|
|
|
|
\ 'conn_id': 'test_conn',
|
|
|
|
\ })
|
2019-09-12 20:53:23 +00:00
|
|
|
AssertEqual '}', getline('.')
|
|
|
|
AssertEqual [2, 1], getpos('.')[1:2]
|
|
|
|
|
Dispatch textDocument/didChange after rename (2) (#4049)
* Dispatch textDocument/didChange after rename
Previously whenever we renamed a symbol that was referenced from other
files we'd just edit those files in the background, and the LSP wouldn't
know about these changes. If we tried to rename the same symbol again,
the renaming would fail. In some scenarios, the operation would just be
wrong. Here is an attempt to fix this issue.
I also noticed another bug when using Go with `gopls` LSP and the `gofmt`
fixer. Whenever the file was saved, the `gofmt` would run and reformat
the file. But it seems there was some kind of a race condition so I
disabled saving for now, and all of the modified files will be unsaved,
so the user should call `:wa` to save them. I personally like this even
better because I can inspect exactly what changes happened, and I
instantly see them in the other opened buffers, which was previously not
the case.
Fixes #3343, #3642, #3781.
* Address PR comments
* Remove mode tests in corner case tests
* Address PR comments
* Save after ALERename and ALEOrganizeImports
Also provide options to disable automatic saving, as well as instructions to
enable `set hidden` before doing that.
* Fix broken test
* Save only when !&hidden
* Update doc
* Update doc
* Add silent
2022-02-08 11:07:39 +00:00
|
|
|
AssertEqual [{
|
|
|
|
\ 'conn_id': 'test_conn',
|
|
|
|
\ 'buffer': bufnr(''),
|
|
|
|
\}], g:notified_changes
|
|
|
|
|
2019-09-12 20:53:23 +00:00
|
|
|
# C ==
|
|
|
|
# ===
|
|
|
|
Execute(Cursor will not move when changes happening on lines >= cursor, but after cursor):
|
|
|
|
call WriteFileAndEdit()
|
|
|
|
call setpos('.', [0, 2, 3, 0])
|
|
|
|
AssertEqual ' value: string', getline('.')
|
2019-10-10 01:42:41 +00:00
|
|
|
call ale#code_action#HandleCodeAction(
|
Dispatch textDocument/didChange after rename (2) (#4049)
* Dispatch textDocument/didChange after rename
Previously whenever we renamed a symbol that was referenced from other
files we'd just edit those files in the background, and the LSP wouldn't
know about these changes. If we tried to rename the same symbol again,
the renaming would fail. In some scenarios, the operation would just be
wrong. Here is an attempt to fix this issue.
I also noticed another bug when using Go with `gopls` LSP and the `gofmt`
fixer. Whenever the file was saved, the `gofmt` would run and reformat
the file. But it seems there was some kind of a race condition so I
disabled saving for now, and all of the modified files will be unsaved,
so the user should call `:wa` to save them. I personally like this even
better because I can inspect exactly what changes happened, and I
instantly see them in the other opened buffers, which was previously not
the case.
Fixes #3343, #3642, #3781.
* Address PR comments
* Remove mode tests in corner case tests
* Address PR comments
* Save after ALERename and ALEOrganizeImports
Also provide options to disable automatic saving, as well as instructions to
enable `set hidden` before doing that.
* Fix broken test
* Save only when !&hidden
* Update doc
* Update doc
* Add silent
2022-02-08 11:07:39 +00:00
|
|
|
\ g:test.create_change(2, 10, 3, 1, "number\n"),
|
|
|
|
\ {
|
|
|
|
\ 'should_save': 1,
|
|
|
|
\ 'conn_id': 'test_conn',
|
|
|
|
\ })
|
2019-09-12 20:53:23 +00:00
|
|
|
AssertEqual ' value: number', getline('.')
|
|
|
|
AssertEqual [2, 3], getpos('.')[1:2]
|
2019-10-10 01:42:41 +00:00
|
|
|
|
Dispatch textDocument/didChange after rename (2) (#4049)
* Dispatch textDocument/didChange after rename
Previously whenever we renamed a symbol that was referenced from other
files we'd just edit those files in the background, and the LSP wouldn't
know about these changes. If we tried to rename the same symbol again,
the renaming would fail. In some scenarios, the operation would just be
wrong. Here is an attempt to fix this issue.
I also noticed another bug when using Go with `gopls` LSP and the `gofmt`
fixer. Whenever the file was saved, the `gofmt` would run and reformat
the file. But it seems there was some kind of a race condition so I
disabled saving for now, and all of the modified files will be unsaved,
so the user should call `:wa` to save them. I personally like this even
better because I can inspect exactly what changes happened, and I
instantly see them in the other opened buffers, which was previously not
the case.
Fixes #3343, #3642, #3781.
* Address PR comments
* Remove mode tests in corner case tests
* Address PR comments
* Save after ALERename and ALEOrganizeImports
Also provide options to disable automatic saving, as well as instructions to
enable `set hidden` before doing that.
* Fix broken test
* Save only when !&hidden
* Update doc
* Update doc
* Add silent
2022-02-08 11:07:39 +00:00
|
|
|
AssertEqual [{
|
|
|
|
\ 'conn_id': 'test_conn',
|
|
|
|
\ 'buffer': bufnr(''),
|
|
|
|
\}], g:notified_changes
|
|
|
|
|
2021-02-20 16:16:47 +00:00
|
|
|
Execute(Cursor will not move when change covers entire file):
|
|
|
|
call WriteFileAndEdit()
|
|
|
|
call setpos('.', [0, 2, 3, 0])
|
|
|
|
call ale#code_action#HandleCodeAction(
|
|
|
|
\ g:test.create_change(1, 1, len(g:test.text) + 1, 1,
|
|
|
|
\ join(g:test.text + ['x'], "\n")),
|
Dispatch textDocument/didChange after rename (2) (#4049)
* Dispatch textDocument/didChange after rename
Previously whenever we renamed a symbol that was referenced from other
files we'd just edit those files in the background, and the LSP wouldn't
know about these changes. If we tried to rename the same symbol again,
the renaming would fail. In some scenarios, the operation would just be
wrong. Here is an attempt to fix this issue.
I also noticed another bug when using Go with `gopls` LSP and the `gofmt`
fixer. Whenever the file was saved, the `gofmt` would run and reformat
the file. But it seems there was some kind of a race condition so I
disabled saving for now, and all of the modified files will be unsaved,
so the user should call `:wa` to save them. I personally like this even
better because I can inspect exactly what changes happened, and I
instantly see them in the other opened buffers, which was previously not
the case.
Fixes #3343, #3642, #3781.
* Address PR comments
* Remove mode tests in corner case tests
* Address PR comments
* Save after ALERename and ALEOrganizeImports
Also provide options to disable automatic saving, as well as instructions to
enable `set hidden` before doing that.
* Fix broken test
* Save only when !&hidden
* Update doc
* Update doc
* Add silent
2022-02-08 11:07:39 +00:00
|
|
|
\ {
|
|
|
|
\ 'should_save': 1,
|
|
|
|
\ 'conn_id': 'test_conn',
|
|
|
|
\ })
|
2021-02-20 16:16:47 +00:00
|
|
|
AssertEqual [2, 3], getpos('.')[1:2]
|
|
|
|
|
Dispatch textDocument/didChange after rename (2) (#4049)
* Dispatch textDocument/didChange after rename
Previously whenever we renamed a symbol that was referenced from other
files we'd just edit those files in the background, and the LSP wouldn't
know about these changes. If we tried to rename the same symbol again,
the renaming would fail. In some scenarios, the operation would just be
wrong. Here is an attempt to fix this issue.
I also noticed another bug when using Go with `gopls` LSP and the `gofmt`
fixer. Whenever the file was saved, the `gofmt` would run and reformat
the file. But it seems there was some kind of a race condition so I
disabled saving for now, and all of the modified files will be unsaved,
so the user should call `:wa` to save them. I personally like this even
better because I can inspect exactly what changes happened, and I
instantly see them in the other opened buffers, which was previously not
the case.
Fixes #3343, #3642, #3781.
* Address PR comments
* Remove mode tests in corner case tests
* Address PR comments
* Save after ALERename and ALEOrganizeImports
Also provide options to disable automatic saving, as well as instructions to
enable `set hidden` before doing that.
* Fix broken test
* Save only when !&hidden
* Update doc
* Update doc
* Add silent
2022-02-08 11:07:39 +00:00
|
|
|
AssertEqual [{
|
|
|
|
\ 'conn_id': 'test_conn',
|
|
|
|
\ 'buffer': bufnr(''),
|
|
|
|
\}], g:notified_changes
|
|
|
|
|
2019-10-10 01:42:41 +00:00
|
|
|
Execute(It should just modify file when should_save is set to v:false):
|
|
|
|
call WriteFileAndEdit()
|
|
|
|
let g:test.change = g:test.create_change(1, 1, 1, 1, "import { writeFile } from 'fs';\n")
|
Dispatch textDocument/didChange after rename (2) (#4049)
* Dispatch textDocument/didChange after rename
Previously whenever we renamed a symbol that was referenced from other
files we'd just edit those files in the background, and the LSP wouldn't
know about these changes. If we tried to rename the same symbol again,
the renaming would fail. In some scenarios, the operation would just be
wrong. Here is an attempt to fix this issue.
I also noticed another bug when using Go with `gopls` LSP and the `gofmt`
fixer. Whenever the file was saved, the `gofmt` would run and reformat
the file. But it seems there was some kind of a race condition so I
disabled saving for now, and all of the modified files will be unsaved,
so the user should call `:wa` to save them. I personally like this even
better because I can inspect exactly what changes happened, and I
instantly see them in the other opened buffers, which was previously not
the case.
Fixes #3343, #3642, #3781.
* Address PR comments
* Remove mode tests in corner case tests
* Address PR comments
* Save after ALERename and ALEOrganizeImports
Also provide options to disable automatic saving, as well as instructions to
enable `set hidden` before doing that.
* Fix broken test
* Save only when !&hidden
* Update doc
* Update doc
* Add silent
2022-02-08 11:07:39 +00:00
|
|
|
call ale#code_action#HandleCodeAction(g:test.change, {
|
|
|
|
\ 'conn_id': 'test_conn',
|
|
|
|
\})
|
2019-10-10 01:42:41 +00:00
|
|
|
AssertEqual 1, getbufvar(bufnr(''), '&modified')
|
|
|
|
AssertEqual [
|
|
|
|
\ 'import { writeFile } from ''fs'';',
|
|
|
|
\ 'class Name {',
|
|
|
|
\ ' value: string',
|
|
|
|
\ '}',
|
|
|
|
\], getline(1, '$')
|
2020-09-04 08:37:33 +00:00
|
|
|
|
Dispatch textDocument/didChange after rename (2) (#4049)
* Dispatch textDocument/didChange after rename
Previously whenever we renamed a symbol that was referenced from other
files we'd just edit those files in the background, and the LSP wouldn't
know about these changes. If we tried to rename the same symbol again,
the renaming would fail. In some scenarios, the operation would just be
wrong. Here is an attempt to fix this issue.
I also noticed another bug when using Go with `gopls` LSP and the `gofmt`
fixer. Whenever the file was saved, the `gofmt` would run and reformat
the file. But it seems there was some kind of a race condition so I
disabled saving for now, and all of the modified files will be unsaved,
so the user should call `:wa` to save them. I personally like this even
better because I can inspect exactly what changes happened, and I
instantly see them in the other opened buffers, which was previously not
the case.
Fixes #3343, #3642, #3781.
* Address PR comments
* Remove mode tests in corner case tests
* Address PR comments
* Save after ALERename and ALEOrganizeImports
Also provide options to disable automatic saving, as well as instructions to
enable `set hidden` before doing that.
* Fix broken test
* Save only when !&hidden
* Update doc
* Update doc
* Add silent
2022-02-08 11:07:39 +00:00
|
|
|
AssertEqual [{
|
|
|
|
\ 'conn_id': 'test_conn',
|
|
|
|
\ 'buffer': bufnr(''),
|
|
|
|
\}], g:notified_changes
|
|
|
|
|
2020-09-04 08:37:33 +00:00
|
|
|
Given typescript(An example TypeScript file):
|
|
|
|
type Foo = {}
|
|
|
|
|
|
|
|
export interface ISomething {
|
|
|
|
fooLongName: Foo | null
|
|
|
|
}
|
|
|
|
|
|
|
|
export class SomethingElse implements ISomething {
|
|
|
|
// Bindings
|
|
|
|
fooLongName!: ISomething['fooLongName']
|
|
|
|
}
|
|
|
|
|
|
|
|
Execute():
|
|
|
|
let g:changes = [
|
|
|
|
\ {'end': {'offset': 14, 'line': 4}, 'newText': 'foo', 'start': {'offset': 3, 'line': 4}},
|
|
|
|
\ {'end': {'offset': 40, 'line': 9}, 'newText': 'foo', 'start': {'offset': 29, 'line': 9}},
|
|
|
|
\ {'end': {'offset': 14, 'line': 9}, 'newText': 'foo', 'start': {'offset': 3, 'line': 9}},
|
|
|
|
\]
|
|
|
|
|
Dispatch textDocument/didChange after rename (2) (#4049)
* Dispatch textDocument/didChange after rename
Previously whenever we renamed a symbol that was referenced from other
files we'd just edit those files in the background, and the LSP wouldn't
know about these changes. If we tried to rename the same symbol again,
the renaming would fail. In some scenarios, the operation would just be
wrong. Here is an attempt to fix this issue.
I also noticed another bug when using Go with `gopls` LSP and the `gofmt`
fixer. Whenever the file was saved, the `gofmt` would run and reformat
the file. But it seems there was some kind of a race condition so I
disabled saving for now, and all of the modified files will be unsaved,
so the user should call `:wa` to save them. I personally like this even
better because I can inspect exactly what changes happened, and I
instantly see them in the other opened buffers, which was previously not
the case.
Fixes #3343, #3642, #3781.
* Address PR comments
* Remove mode tests in corner case tests
* Address PR comments
* Save after ALERename and ALEOrganizeImports
Also provide options to disable automatic saving, as well as instructions to
enable `set hidden` before doing that.
* Fix broken test
* Save only when !&hidden
* Update doc
* Update doc
* Add silent
2022-02-08 11:07:39 +00:00
|
|
|
call ale#code_action#ApplyChanges(expand('%:p'), g:changes, {
|
|
|
|
\ 'conn_id': 'test_conn',
|
|
|
|
\})
|
|
|
|
|
|
|
|
AssertEqual [{
|
|
|
|
\ 'conn_id': 'test_conn',
|
|
|
|
\ 'buffer': bufnr(''),
|
|
|
|
\}], g:notified_changes
|
2020-09-04 08:37:33 +00:00
|
|
|
|
|
|
|
Expect(The changes should be applied correctly):
|
|
|
|
type Foo = {}
|
|
|
|
|
|
|
|
export interface ISomething {
|
|
|
|
foo: Foo | null
|
|
|
|
}
|
|
|
|
|
|
|
|
export class SomethingElse implements ISomething {
|
|
|
|
// Bindings
|
|
|
|
foo!: ISomething['foo']
|
|
|
|
}
|