Skip to content

Commit 295e84d

Browse files
authored
Merge pull request #1037 from lieryan/lieryan-pymode-selection
Fix text objects to be line-wise rather than character-wise operator
2 parents 51c66fa + ff89053 commit 295e84d

9 files changed

Lines changed: 56 additions & 10 deletions

File tree

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ Contributors:
4242
* Kurtis Rader (https://github.com/krader1961);
4343
* Lawrence Akka (https://github.com/lawrenceakka);
4444
* lee (https://github.com/loyalpartner);
45+
* Lie Ryan (https://github.com/lieryan/);
4546
* Lowe Thiderman (http://github.com/thiderman);
4647
* Martin Brochhaus (http://github.com/mbrochh);
4748
* Matt Dodge (https://github.com/mattdodge);

autoload/pymode/motion.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ fun! pymode#motion#select(first_pattern, second_pattern, inner) "{{{
5151
endif
5252

5353
call cursor(snum, 1)
54-
normal! v
54+
normal! V
5555
call cursor(enum, len(getline(enum)))
5656
endif
5757
endfunction "}}}

tests/test.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ declare -a TEST_ARRAY=(
2020
"./test_bash/test_autopep8.sh"
2121
"./test_bash/test_autocommands.sh"
2222
"./test_bash/test_folding.sh"
23+
"./test_bash/test_textobject.sh"
2324
)
2425
## now loop through the above array
2526
set +e

tests/test_bash/test_autocommands.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ set +e
2020
for ONE_PYMODE_COMMANDS_TEST in "${TEST_PYMODE_COMMANDS_ARRAY[@]}"
2121
do
2222
echo "Starting test: $0:$ONE_PYMODE_COMMANDS_TEST" >> $VIM_OUTPUT_FILE
23-
RETURN_CODE=$(vim -i NONE -u $VIM_TEST_VIMRC -c "source $ONE_PYMODE_COMMANDS_TEST" $VIM_DISPOSABLE_PYFILE > /dev/null 2>&1)
23+
RETURN_CODE=$(vim --clean -i NONE -u $VIM_TEST_VIMRC -c "source $ONE_PYMODE_COMMANDS_TEST" $VIM_DISPOSABLE_PYFILE > /dev/null 2>&1)
2424

2525
### Enable the following to execute one test at a time.
26-
### FOR PINPOINT TESTING ### vim -i NONE -u $VIM_TEST_VIMRC -c "source $ONE_PYMODE_COMMANDS_TEST" $VIM_DISPOSABLE_PYFILE
26+
### FOR PINPOINT TESTING ### vim --clean -i NONE -u $VIM_TEST_VIMRC -c "source $ONE_PYMODE_COMMANDS_TEST" $VIM_DISPOSABLE_PYFILE
2727
### FOR PINPOINT TESTING ### exit 1
2828

2929
RETURN_CODE=$?

tests/test_bash/test_autopep8.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# Source file.
44
set +e
5-
RETURN_CODE=$(vim -i NONE -u $VIM_TEST_VIMRC -c "source ./test_procedures_vimscript/autopep8.vim" $VIM_DISPOSABLE_PYFILE > /dev/null 2>&1)
5+
RETURN_CODE=$(vim --clean -i NONE -u $VIM_TEST_VIMRC -c "source ./test_procedures_vimscript/autopep8.vim" $VIM_DISPOSABLE_PYFILE > /dev/null 2>&1)
66
RETURN_CODE=$?
77
set -e
88
exit $RETURN_CODE

tests/test_bash/test_folding.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@
55
# Source file.
66
set +e
77
source ./test_helpers_bash/test_prepare_between_tests.sh
8-
vim -i NONE -u $VIM_TEST_VIMRC -c "source ./test_procedures_vimscript/folding1.vim" $VIM_DISPOSABLE_PYFILE > /dev/null
8+
vim --clean -i NONE -u $VIM_TEST_VIMRC -c "source ./test_procedures_vimscript/folding1.vim" $VIM_DISPOSABLE_PYFILE > /dev/null
99
R1=$?
1010
source ./test_helpers_bash/test_prepare_between_tests.sh
11-
vim -i NONE -u $VIM_TEST_VIMRC -c "source ./test_procedures_vimscript/folding2.vim" $VIM_DISPOSABLE_PYFILE > /dev/null
11+
vim --clean -i NONE -u $VIM_TEST_VIMRC -c "source ./test_procedures_vimscript/folding2.vim" $VIM_DISPOSABLE_PYFILE > /dev/null
1212
R2=$?
1313
source ./test_helpers_bash/test_prepare_between_tests.sh
1414
# TODO: enable folding3.vim script back.
15-
# vim -i NONE -u $VIM_TEST_VIMRC -c "source ./test_procedures_vimscript/folding3.vim" $VIM_DISPOSABLE_PYFILE > /dev/null
15+
# vim --clean -i NONE -u $VIM_TEST_VIMRC -c "source ./test_procedures_vimscript/folding3.vim" $VIM_DISPOSABLE_PYFILE > /dev/null
1616
# R3=$?
1717
source ./test_helpers_bash/test_prepare_between_tests.sh
18-
vim -i NONE -u $VIM_TEST_VIMRC -c "source ./test_procedures_vimscript/folding4.vim" $VIM_DISPOSABLE_PYFILE > /dev/null
18+
vim --clean -i NONE -u $VIM_TEST_VIMRC -c "source ./test_procedures_vimscript/folding4.vim" $VIM_DISPOSABLE_PYFILE > /dev/null
1919
R4=$?
2020
set -e
2121

tests/test_bash/test_pymodelint.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55

66
# Source file.
77
set +e
8-
vim -i NONE -u $VIM_TEST_VIMRC -c "source ./test_procedures_vimscript/pymodelint.vim" $VIM_DISPOSABLE_PYFILE
9-
# RETURN_CODE=$(vim -i NONE -u $VIM_TEST_VIMRC -c "source ./test_procedures_vimscript/pymodeversion.vim" $VIM_DISPOSABLE_PYFILE > /dev/null 2>&1)
8+
vim --clean -i NONE -u $VIM_TEST_VIMRC -c "source ./test_procedures_vimscript/pymodelint.vim" $VIM_DISPOSABLE_PYFILE
9+
# RETURN_CODE=$(vim --clean -i NONE -u $VIM_TEST_VIMRC -c "source ./test_procedures_vimscript/pymodeversion.vim" $VIM_DISPOSABLE_PYFILE > /dev/null 2>&1)
1010
# RETURN_CODE=$?
1111
set -e
1212
# exit $RETURN_CODE

tests/test_bash/test_textobject.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#! /bin/bash
2+
3+
# Source file.
4+
set +e
5+
source ./test_helpers_bash/test_prepare_between_tests.sh
6+
vim --clean -i NONE -u $VIM_TEST_VIMRC -c "source ./test_procedures_vimscript/textobject.vim" $VIM_DISPOSABLE_PYFILE > /dev/null
7+
R1=$?
8+
set -e
9+
10+
if [[ "$R1" -ne 0 ]]
11+
then
12+
exit 1
13+
fi
14+
15+
# vim: set fileformat=unix filetype=sh wrap tw=0 :
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
" Load sample python file.
2+
" With 'def'.
3+
execute "normal! idef func1():\<CR> a = 1\<CR>"
4+
execute "normal! idef func2():\<CR> b = 2"
5+
normal 3ggdaMggf(P
6+
7+
" Assert changes.
8+
let content=getline('^', '$')
9+
call assert_true(content == ['def func2():', ' b = 2', 'def func1():', ' a = 1'])
10+
11+
12+
" Clean file.
13+
%delete
14+
15+
" With 'class'.
16+
execute "normal! iclass Class1():\<CR> a = 1\<CR>"
17+
execute "normal! iclass Class2():\<CR> b = 2\<CR>"
18+
normal 3ggdaCggf(P
19+
20+
" Assert changes.
21+
let content=getline('^', '$')
22+
call assert_true(content == ['class Class2():', ' b = 2', '', 'class Class1():', ' a = 1'])
23+
24+
25+
if len(v:errors) > 0
26+
cquit!
27+
else
28+
quit!
29+
endif

0 commit comments

Comments
 (0)