fix(runtime/tutor): don't try to close fold when there is none (#24953)

Problem: When double clicking a line starting with a #, the code assumes
there is a fold there and tries to close it, resulting in an error if
there isn't a fold.
Solution: Check foldlevel before performing "zc".
This commit is contained in:
David Moberg 2023-08-31 03:18:39 +02:00 committed by GitHub
parent 839d919098
commit 67fba9affa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -29,7 +29,7 @@ function! tutor#MouseDoubleClick()
if foldclosed(line('.')) > -1
normal! zo
else
if match(getline('.'), '^#\{1,} ') > -1
if match(getline('.'), '^#\{1,} ') > -1 && foldlevel(line('.')) > 0
silent normal! zc
else
call tutor#FollowLink(0)