feat: Add basic support for arrays

This commit is contained in:
Myzel394 2024-04-11 23:02:47 +02:00
parent 8d7bf6e2fe
commit 3b481818d8
No known key found for this signature in database
GPG Key ID: DEC4AAB876F73185
2 changed files with 20 additions and 5 deletions

View File

@ -375,7 +375,13 @@ local function grok_object(self, text, start, options)
local new_val, new_i = grok_one(self, text, i, options)
---- Add start position so we can quickly jump to it
VALUE[key] = {value = new_val, key_start = key_start, key_end = key_end, newlines = newlines, relative_start = relative_start}
VALUE[key] = {
value = new_val,
key_start = key_start,
key_end = key_end,
newlines = newlines or 0,
relative_start = relative_start,
}
--
-- Expect now either '}' to end things, or a ',' to allow us to continue.
@ -417,9 +423,17 @@ local function grok_array(self, text, start, options)
local text_len = text:len()
while i <= text_len do
local val, new_i = grok_one(self, text, i, options)
local newlines = count_newlines(text, i)
local relative_start = get_relative_i(text, i)
-- can't table.insert(VALUE, val) here because it's a no-op if val is nil
VALUE[VALUE_INDEX] = val
VALUE[VALUE_INDEX] = {
value = val,
key_start = new_i,
key_end = new_i,
newlines = newlines or 0,
relative_start = relative_start,
}
VALUE_INDEX = VALUE_INDEX + 1
i = skip_whitespace(text, new_i)

View File

@ -159,6 +159,7 @@ return require"telescope".register_extension {
},
previewer = conf.grep_previewer(opts),
sorter = conf.generic_sorter(opts),
sorting_strategy = "ascending",
}):find()
end
}