-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathConst.lua
More file actions
34 lines (31 loc) · 949 Bytes
/
Const.lua
File metadata and controls
34 lines (31 loc) · 949 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
---@class diff
---@field start integer # The number of bytes at the beginning of the replacement
---@field finish integer # The number of bytes at the end of the replacement
---@field text string # What to replace
---@param uri string # The uri of file
---@param text string # The content of file
---@return nil|diff[]
function OnSetText(uri, text)
local diffs = {}
-- print(text);
for start, a, finish in text:gmatch("()(%%[^%% %s%.]*_[^%% %s%.]*%%)()") do
print(start, a, finish);
diffs[#diffs+1] = {
start = start,
finish = finish - 1,
text = "0",
}
end
for start, a, finish in text:gmatch("()(%%[A-Za-z0-9_]+%%)()") do
print(start, a, finish);
diffs[#diffs+1] = {
start = start,
finish = finish - 1,
text = "0",
}
end
if #diffs == 0 then
return nil
end
return diffs
end