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

Commitb09d46e

Browse files
committed
fix(inspect): escape identifiers that are lua keywords
A lua keyword is not a valid table identifier
1 parentbaaaa1f commitb09d46e

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

‎runtime/lua/vim/inspect.lua‎

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,32 @@ local function escape(str)
9090
end
9191

9292
localfunctionisIdentifier(str)
93-
returntype(str)=='string'andnotnotstr:match('^[_%a][_%a%d]*$')
93+
returntype(str)=='string'
94+
-- identifier must start with a letter and underscore, and be followed by letters, numbers, and uderscores
95+
andnotnotstr:match('^[_%a][_%a%d]*$')
96+
andnot (-- lua keywords are not valid identifiers
97+
str=='and'
98+
orstr=='break'
99+
orstr=='do'
100+
orstr=='else'
101+
orstr=='elseif'
102+
orstr=='end'
103+
orstr=='false'
104+
orstr=='for'
105+
orstr=='function'
106+
orstr=='if'
107+
orstr=='in'
108+
orstr=='local'
109+
orstr=='nil'
110+
orstr=='not'
111+
orstr=='or'
112+
orstr=='repeat'
113+
orstr=='return'
114+
orstr=='then'
115+
orstr=='true'
116+
orstr=='until'
117+
orstr=='while'
118+
)
94119
end
95120

96121
localflr=math.floor

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp