Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
forked fromneovim/neovim

Commitc86cbbb

Browse files
svvaclvimuser
authored andcommitted
fix(inspect): escape identifiers that are lua keywords (neovim#19898)
A lua keyword is not a valid table identifier
1 parentd459b66 commitc86cbbb

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

‎runtime/lua/vim/inspect.lua‎

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,38 @@ local function escape(str)
8989
)
9090
end
9191

92+
-- List of lua keywords
93+
localluaKeywords= {
94+
['and']=true,
95+
['break']=true,
96+
['do']=true,
97+
['else']=true,
98+
['elseif']=true,
99+
['end']=true,
100+
['false']=true,
101+
['for']=true,
102+
['function']=true,
103+
['goto']=true,
104+
['if']=true,
105+
['in']=true,
106+
['local']=true,
107+
['nil']=true,
108+
['not']=true,
109+
['or']=true,
110+
['repeat']=true,
111+
['return']=true,
112+
['then']=true,
113+
['true']=true,
114+
['until']=true,
115+
['while']=true,
116+
}
117+
92118
localfunctionisIdentifier(str)
93-
returntype(str)=='string'andnotnotstr:match('^[_%a][_%a%d]*$')
119+
returntype(str)=='string'
120+
-- identifier must start with a letter and underscore, and be followed by letters, numbers, and underscores
121+
andnotnotstr:match('^[_%a][_%a%d]*$')
122+
-- lua keywords are not valid identifiers
123+
andnotluaKeywords[str]
94124
end
95125

96126
localflr=math.floor

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp