Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Also select variable when using af on anonymous functions #1341

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion autoload/go/textobj.vim
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,24 @@ function! go#textobj#Function(mode) abort

if a:mode == 'a'
" anonymous functions doesn't have associated doc. Also check if the user
" want's to include doc comments for function declarations
" wants to include doc comments for function declarations
if has_key(info, 'doc') && g:go_textobj_include_function_doc
call cursor(info.doc.line, info.doc.col)
else
call cursor(info.func.line, info.func.col)
endif

" Select variable too when an anonymous function is assigned.
if info['sig']['name'] == ''
" Get function plus two characters before, to see if we're assigning it.
let assign = getline('.')[info['func']['col']-3:][:len(info['sig']['full'])+1]

" Back it up!
if assign == '= ' . info['sig']['full']
normal! bb
endif
endif

normal! v
call cursor(info.rbrace.line, info.rbrace.col)
return
Expand Down