diff options
| author | TJ DeVries <devries.timothyj@gmail.com> | 2020-09-22 09:58:20 -0400 |
|---|---|---|
| committer | TJ DeVries <devries.timothyj@gmail.com> | 2020-09-22 09:58:20 -0400 |
| commit | fa16efaeb6a3e61d2915c28fb04f21c267e551c2 (patch) | |
| tree | ffb0e4d7a21a4707a1818dc5b22478075c485c71 /scratch/fast_split.lua | |
| parent | 025485fa1fc6a7f960764233d1d19be411d093c3 (diff) | |
scratch: minimal init vim
Diffstat (limited to 'scratch/fast_split.lua')
| -rw-r--r-- | scratch/fast_split.lua | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/scratch/fast_split.lua b/scratch/fast_split.lua new file mode 100644 index 0000000..0c5ea88 --- /dev/null +++ b/scratch/fast_split.lua @@ -0,0 +1,28 @@ +local test_line = "/home/tj/hello/world.lua" + +local function fast_split(line, split) + -- local split_line = vim.split(line, split) + local areas = {} + + local processed = 1 + local line_length = #line + 1 + + local part, start + repeat + start = string.find(line, split, processed, true) or line_length + part = string.sub(line, processed, start - 1) + + if start - processed > 0 then + table.insert(areas, { + word = part, + offset = processed + }) + end + + processed = start + 1 + until start == line_length + + return areas +end + +print(vim.inspect(fast_split(test_line, '/'))) |
