diff --git a/AUTHORS b/AUTHORS index 926c2737..6c2c6b95 100644 --- a/AUTHORS +++ b/AUTHORS @@ -42,6 +42,7 @@ Contributors: * Kurtis Rader (https://github.com/krader1961); * Lawrence Akka (https://github.com/lawrenceakka); * lee (https://github.com/loyalpartner); +* Lie Ryan (https://github.com/lieryan/); * Lowe Thiderman (http://github.com/thiderman); * Martin Brochhaus (http://github.com/mbrochh); * Matt Dodge (https://github.com/mattdodge); diff --git a/autoload/pymode/motion.vim b/autoload/pymode/motion.vim index a930f35a..c88fb913 100644 --- a/autoload/pymode/motion.vim +++ b/autoload/pymode/motion.vim @@ -51,7 +51,7 @@ fun! pymode#motion#select(first_pattern, second_pattern, inner) "{{{ endif call cursor(snum, 1) - normal! v + normal! V call cursor(enum, len(getline(enum))) endif endfunction "}}} diff --git a/tests/test.sh b/tests/test.sh index b7747308..fe9fcae1 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -20,6 +20,7 @@ declare -a TEST_ARRAY=( "./test_bash/test_autopep8.sh" "./test_bash/test_autocommands.sh" "./test_bash/test_folding.sh" + "./test_bash/test_textobject.sh" ) ## now loop through the above array set +e diff --git a/tests/test_bash/test_autocommands.sh b/tests/test_bash/test_autocommands.sh index 13708c30..bc46b9d5 100644 --- a/tests/test_bash/test_autocommands.sh +++ b/tests/test_bash/test_autocommands.sh @@ -20,10 +20,10 @@ set +e for ONE_PYMODE_COMMANDS_TEST in "${TEST_PYMODE_COMMANDS_ARRAY[@]}" do echo "Starting test: $0:$ONE_PYMODE_COMMANDS_TEST" >> $VIM_OUTPUT_FILE - RETURN_CODE=$(vim -i NONE -u $VIM_TEST_VIMRC -c "source $ONE_PYMODE_COMMANDS_TEST" $VIM_DISPOSABLE_PYFILE > /dev/null 2>&1) + RETURN_CODE=$(vim --clean -i NONE -u $VIM_TEST_VIMRC -c "source $ONE_PYMODE_COMMANDS_TEST" $VIM_DISPOSABLE_PYFILE > /dev/null 2>&1) ### Enable the following to execute one test at a time. - ### FOR PINPOINT TESTING ### vim -i NONE -u $VIM_TEST_VIMRC -c "source $ONE_PYMODE_COMMANDS_TEST" $VIM_DISPOSABLE_PYFILE + ### FOR PINPOINT TESTING ### vim --clean -i NONE -u $VIM_TEST_VIMRC -c "source $ONE_PYMODE_COMMANDS_TEST" $VIM_DISPOSABLE_PYFILE ### FOR PINPOINT TESTING ### exit 1 RETURN_CODE=$? diff --git a/tests/test_bash/test_autopep8.sh b/tests/test_bash/test_autopep8.sh index eae173f3..05585725 100644 --- a/tests/test_bash/test_autopep8.sh +++ b/tests/test_bash/test_autopep8.sh @@ -2,7 +2,7 @@ # Source file. set +e -RETURN_CODE=$(vim -i NONE -u $VIM_TEST_VIMRC -c "source ./test_procedures_vimscript/autopep8.vim" $VIM_DISPOSABLE_PYFILE > /dev/null 2>&1) +RETURN_CODE=$(vim --clean -i NONE -u $VIM_TEST_VIMRC -c "source ./test_procedures_vimscript/autopep8.vim" $VIM_DISPOSABLE_PYFILE > /dev/null 2>&1) RETURN_CODE=$? set -e exit $RETURN_CODE diff --git a/tests/test_bash/test_folding.sh b/tests/test_bash/test_folding.sh index 2902ef8d..d0ac884a 100644 --- a/tests/test_bash/test_folding.sh +++ b/tests/test_bash/test_folding.sh @@ -5,17 +5,17 @@ # Source file. set +e source ./test_helpers_bash/test_prepare_between_tests.sh -vim -i NONE -u $VIM_TEST_VIMRC -c "source ./test_procedures_vimscript/folding1.vim" $VIM_DISPOSABLE_PYFILE > /dev/null +vim --clean -i NONE -u $VIM_TEST_VIMRC -c "source ./test_procedures_vimscript/folding1.vim" $VIM_DISPOSABLE_PYFILE > /dev/null R1=$? source ./test_helpers_bash/test_prepare_between_tests.sh -vim -i NONE -u $VIM_TEST_VIMRC -c "source ./test_procedures_vimscript/folding2.vim" $VIM_DISPOSABLE_PYFILE > /dev/null +vim --clean -i NONE -u $VIM_TEST_VIMRC -c "source ./test_procedures_vimscript/folding2.vim" $VIM_DISPOSABLE_PYFILE > /dev/null R2=$? source ./test_helpers_bash/test_prepare_between_tests.sh # TODO: enable folding3.vim script back. -# vim -i NONE -u $VIM_TEST_VIMRC -c "source ./test_procedures_vimscript/folding3.vim" $VIM_DISPOSABLE_PYFILE > /dev/null +# vim --clean -i NONE -u $VIM_TEST_VIMRC -c "source ./test_procedures_vimscript/folding3.vim" $VIM_DISPOSABLE_PYFILE > /dev/null # R3=$? source ./test_helpers_bash/test_prepare_between_tests.sh -vim -i NONE -u $VIM_TEST_VIMRC -c "source ./test_procedures_vimscript/folding4.vim" $VIM_DISPOSABLE_PYFILE > /dev/null +vim --clean -i NONE -u $VIM_TEST_VIMRC -c "source ./test_procedures_vimscript/folding4.vim" $VIM_DISPOSABLE_PYFILE > /dev/null R4=$? set -e diff --git a/tests/test_bash/test_pymodelint.sh b/tests/test_bash/test_pymodelint.sh index cf8d626d..583d0774 100644 --- a/tests/test_bash/test_pymodelint.sh +++ b/tests/test_bash/test_pymodelint.sh @@ -5,8 +5,8 @@ # Source file. set +e -vim -i NONE -u $VIM_TEST_VIMRC -c "source ./test_procedures_vimscript/pymodelint.vim" $VIM_DISPOSABLE_PYFILE -# RETURN_CODE=$(vim -i NONE -u $VIM_TEST_VIMRC -c "source ./test_procedures_vimscript/pymodeversion.vim" $VIM_DISPOSABLE_PYFILE > /dev/null 2>&1) +vim --clean -i NONE -u $VIM_TEST_VIMRC -c "source ./test_procedures_vimscript/pymodelint.vim" $VIM_DISPOSABLE_PYFILE +# RETURN_CODE=$(vim --clean -i NONE -u $VIM_TEST_VIMRC -c "source ./test_procedures_vimscript/pymodeversion.vim" $VIM_DISPOSABLE_PYFILE > /dev/null 2>&1) # RETURN_CODE=$? set -e # exit $RETURN_CODE diff --git a/tests/test_bash/test_textobject.sh b/tests/test_bash/test_textobject.sh new file mode 100644 index 00000000..43a799f9 --- /dev/null +++ b/tests/test_bash/test_textobject.sh @@ -0,0 +1,15 @@ +#! /bin/bash + +# Source file. +set +e +source ./test_helpers_bash/test_prepare_between_tests.sh +vim --clean -i NONE -u $VIM_TEST_VIMRC -c "source ./test_procedures_vimscript/textobject.vim" $VIM_DISPOSABLE_PYFILE > /dev/null +R1=$? +set -e + +if [[ "$R1" -ne 0 ]] +then + exit 1 +fi + +# vim: set fileformat=unix filetype=sh wrap tw=0 : diff --git a/tests/test_procedures_vimscript/textobject.vim b/tests/test_procedures_vimscript/textobject.vim new file mode 100644 index 00000000..cee9f985 --- /dev/null +++ b/tests/test_procedures_vimscript/textobject.vim @@ -0,0 +1,29 @@ +" Load sample python file. +" With 'def'. +execute "normal! idef func1():\ a = 1\" +execute "normal! idef func2():\ b = 2" +normal 3ggdaMggf(P + +" Assert changes. +let content=getline('^', '$') +call assert_true(content == ['def func2():', ' b = 2', 'def func1():', ' a = 1']) + + +" Clean file. +%delete + +" With 'class'. +execute "normal! iclass Class1():\ a = 1\" +execute "normal! iclass Class2():\ b = 2\" +normal 3ggdaCggf(P + +" Assert changes. +let content=getline('^', '$') +call assert_true(content == ['class Class2():', ' b = 2', '', 'class Class1():', ' a = 1']) + + +if len(v:errors) > 0 + cquit! +else + quit! +endif