GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix bug · chxuan/cpp-mode@09087dc

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • autoload/cppmode
    • gen_fun.vim
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎autoload/cppmode/gen_fun.vim‎

Copy file name to clipboardExpand all lines: autoload/cppmode/gen_fun.vim
+8-11Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ function! cppmode#gen_fun#copy_function()
2121
echo s:fun_template_declaration
2222
echo s:fun_declaration
2323

24-
let row_num = <sid>get_row_num_of_class_name()
25-
let s:class_name = <sid>get_class_name_of_fun(row_num)
24+
let row_num = <sid>get_class_name_row_num()
25+
let s:class_name = <sid>get_class_name(row_num)
2626
let s:class_template_declaration = <sid>get_class_template_declaration(row_num)
2727
endfunction
2828

@@ -50,7 +50,7 @@ function! s:get_fun_template_declaration()
5050
endfunction
5151

5252
" 获得类名所在行号
53-
function! s:get_row_num_of_class_name()
53+
function! s:get_class_name_row_num()
5454
let current_num = cppmode#util#get_current_row_num()
5555

5656
while current_num >= 1
@@ -65,7 +65,7 @@ function! s:get_row_num_of_class_name()
6565
endfunction
6666

6767
" 获得函数所在类名
68-
function! s:get_class_name_of_fun(row_num)
68+
function! s:get_class_name(row_num)
6969
let text = cppmode#util#get_row_text(a:row_num)
7070
return <sid>parse_class_name(text)
7171
endfunction
@@ -124,11 +124,8 @@ endfunction
124124

125125
" 获得一般类成员函数
126126
function! s:get_normal_fun(fun)
127-
let pos = cppmode#util#find(a:fun, "(")
128-
let temp = cppmode#util#substr(a:fun, 0, pos)
129-
let fun_pos = cppmode#util#find_r(temp, " ")
130-
131-
return cppmode#util#substr(a:fun, 0, fun_pos) . " " . s:class_name . "::" . cppmode#util#substr(a:fun, fun_pos + 1, len(a:fun))
127+
let ret = matchlist(a:fun, '\s*\(\w\+\s\+\)\(\w\+(.*)\)')
128+
return ret[1] . s:class_name . "::" . ret[2]
132129
endfunction
133130

134131
" 注释函数默认参数值
@@ -164,8 +161,8 @@ endfunction
164161

165162
" 获得类类型
166163
function! s:get_class_template_type()
167-
let key_words = ["template", "typename", "class"]
168-
return cppmode#util#erase_char(cppmode#util#erase_string_list(s:class_template_declaration, key_words), " ")
164+
let type = matchlist(s:class_template_declaration, '\s*template\s*<\s*\w\+\s*\(\w\+\)\s*>')[1]
165+
return "<" . type . ">"
169166
endfunction
170167

171168
" 增加函数体

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.