0
0
mirror of https://github.com/vim/vim.git synced 2025-09-26 04:04:07 -04:00

patch 8.2.1741: pathshorten() only supports using one character

Problem:    pathshorten() only supports using one character.
Solution:   Add an argument to control the length. (closes #7006)
This commit is contained in:
Bram Moolenaar
2020-09-25 22:42:48 +02:00
parent 58dbef330c
commit 6a33ef0deb
6 changed files with 103 additions and 48 deletions

View File

@@ -500,6 +500,24 @@ func Test_pathshorten()
call assert_equal('.~f/bar', pathshorten('.~foo/bar'))
call assert_equal('~/f/bar', pathshorten('~/foo/bar'))
call assert_fails('call pathshorten([])', 'E730:')
" test pathshorten with optional variable to set preferred size of shortening
call assert_equal('', pathshorten('', 2))
call assert_equal('foo', pathshorten('foo', 2))
call assert_equal('/foo', pathshorten('/foo', 2))
call assert_equal('fo/', pathshorten('foo/', 2))
call assert_equal('fo/bar', pathshorten('foo/bar', 2))
call assert_equal('fo/ba/foobar', pathshorten('foo/bar/foobar', 2))
call assert_equal('/fo/ba/foobar', pathshorten('/foo/bar/foobar', 2))
call assert_equal('.fo/bar', pathshorten('.foo/bar', 2))
call assert_equal('~fo/bar', pathshorten('~foo/bar', 2))
call assert_equal('~.fo/bar', pathshorten('~.foo/bar', 2))
call assert_equal('.~fo/bar', pathshorten('.~foo/bar', 2))
call assert_equal('~/fo/bar', pathshorten('~/foo/bar', 2))
call assert_fails('call pathshorten([],2)', 'E730:')
call assert_notequal('~/fo/bar', pathshorten('~/foo/bar', 3))
call assert_equal('~/foo/bar', pathshorten('~/foo/bar', 3))
call assert_equal('~/f/bar', pathshorten('~/foo/bar', 0))
endfunc
func Test_strpart()