summaryrefslogtreecommitdiff
path: root/test/test_code_action.vader
diff options
context:
space:
mode:
authorTomáš Janoušek <tomi@nomi.cz>2021-02-20 17:16:47 +0100
committerGitHub <noreply@github.com>2021-02-20 16:16:47 +0000
commit2550f5d952caea4ac607ec0796d8f1fae4d7b9a5 (patch)
treef5883b44bea6f9f238b45b93f648c1c4da4e0ebc /test/test_code_action.vader
parentd340710fcfbd4db7bd2a8e4cd126306d4d7ef4e2 (diff)
downloadale-2550f5d952caea4ac607ec0796d8f1fae4d7b9a5.zip
Fixes to code actions (cursor moving, tests, EOL/EOF corner cases) (#3478)
* code_action: Don't move cursor when change covers entire file * code_action: Refactor/simplify ApplyChanges * code_action: Fix EOL at EOF corner cases while performing no changes * code_action: Fix column around EOL corner cases * code_action: Handle positions out of bounds * code_action: Add instructions for verifying corner case tests against vscode
Diffstat (limited to 'test/test_code_action.vader')
-rw-r--r--test/test_code_action.vader22
1 files changed, 10 insertions, 12 deletions
diff --git a/test/test_code_action.vader b/test/test_code_action.vader
index 7eabb759..c613222c 100644
--- a/test/test_code_action.vader
+++ b/test/test_code_action.vader
@@ -1,14 +1,7 @@
Before:
Save g:ale_enabled
-
let g:ale_enabled = 0
- " Enable fix end-of-line as tests below expect that
- set fixeol
-
- runtime autoload/ale/code_action.vim
- runtime autoload/ale/util.vim
-
let g:file1 = tempname()
let g:file2 = tempname()
let g:test = {}
@@ -42,8 +35,6 @@ Before:
endfunction!
After:
- Restore
-
" Close the extra buffers if we opened it.
if bufnr(g:file1) != -1
execute ':bp! | :bd! ' . bufnr(g:file1)
@@ -65,8 +56,7 @@ After:
unlet! g:changes
delfunction WriteFileAndEdit
- runtime autoload/ale/code_action.vim
- runtime autoload/ale/util.vim
+ Restore
Execute(It should modify and save multiple files):
@@ -214,7 +204,6 @@ Execute(End of file can be modified):
\)
AssertEqual g:test.text + [
- \ '',
\ 'type A: string',
\ 'type B: number',
\ '',
@@ -364,6 +353,15 @@ Execute(Cursor will not move when changes happening on lines >= cursor, but afte
AssertEqual ' value: number', getline('.')
AssertEqual [2, 3], getpos('.')[1:2]
+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")),
+ \ {'should_save': 1})
+ AssertEqual [2, 3], getpos('.')[1:2]
+
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")