~p00f/public-inbox

Chinmay Dalal: 1
 Fix windows

 5 files changed, 25 insertions(+), 8 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~p00f/public-inbox/patches/25296/mbox | git am -3
Learn more about email & git

[PATCH] Fix windows Export this patch

From: unknown <dalal.chinmay.0101@gmail.com>

Stylua

add comments to `run_tests.lua`

strip CR in run_tests.lua instead of helpers.comparetables()

Space out receive()
---
 lua/cphelper/definitions.lua |  6 +++---
 lua/cphelper/helpers.lua     |  2 +-
 lua/cphelper/receive.lua     |  3 +++
 lua/cphelper/run_test.lua    | 14 ++++++++++++++
 plugin/cphelper.vim          |  8 ++++----
 5 files changed, 25 insertions(+), 8 deletions(-)

diff --git a/lua/cphelper/definitions.lua b/lua/cphelper/definitions.lua
index d53bd4a..3391b80 100644
--- a/lua/cphelper/definitions.lua
+++ b/lua/cphelper/definitions.lua
@@ -5,11 +5,11 @@ return {
        rust = "rustc solution.rs -o rust.out",
    },
    run_cmd = {
        c = "./c.out",
        cpp = "./cpp.out",
        c = vim.fn.has("win32") == 1 and ".\\c.out" or "./c.out",
        cpp = vim.fn.has("win32") == 1 and ".\\cpp.out" or "./cpp.out",
        lua = "lua solution.lua",
        python = "python solution.py",
        rust = "./rust.out",
        rust = vim.fn.has("win32") == 1 and ".\\rust.out" or "./rust.out",
    },
    extensions = {
        c = "c",
diff --git a/lua/cphelper/helpers.lua b/lua/cphelper/helpers.lua
index 794c2dc..b031ca6 100644
--- a/lua/cphelper/helpers.lua
+++ b/lua/cphelper/helpers.lua
@@ -24,7 +24,7 @@ function M.comparetables(t1, t2)
        return false
    end
    for k, v in pairs(t1) do
        if t2[k] ~= v then
        if t2[k] ~= t1[k] then
            return false
        end
    end
diff --git a/lua/cphelper/receive.lua b/lua/cphelper/receive.lua
index a0b6b9d..bbac930 100644
--- a/lua/cphelper/receive.lua
+++ b/lua/cphelper/receive.lua
@@ -26,14 +26,17 @@ function M.receive()
            else
                client:shutdown()
                client:close()

                local lines = {}
                for line in string.gmatch(buffer, "[^\r\n]+") do
                    table.insert(lines, line)
                end
                buffer = lines[#lines]

                vim.schedule(function()
                    process(buffer)
                end)

                M.server:shutdown()
            end
        end)
diff --git a/lua/cphelper/run_test.lua b/lua/cphelper/run_test.lua
index ba50ca1..5cb1967 100644
--- a/lua/cphelper/run_test.lua
+++ b/lua/cphelper/run_test.lua
@@ -18,6 +18,8 @@ function M.run_test(case, cmd)
    vim.list_extend(result, exp_out_arr)
    local output_arr = {}
    local err_arr = {}

    -- Run executable
    local job_id = vim.fn.jobstart(cmd, {
        on_stdout = function(_, data, _)
            vim.list_extend(output_arr, data)
@@ -27,6 +29,13 @@ function M.run_test(case, cmd)
            vim.list_extend(err_arr, data)
        end,
        on_exit = function(_, exit_code, _)
            -- Strip CR on Windows
            if vim.fn.has("win32") then
                for k, v in pairs(output_arr) do
                    output_arr[k] = string.gsub(v, "\r", "")
                end
            end

            if #output_arr ~= 0 then
                vim.list_extend(result, { "Received output:" })
                vim.list_extend(result, output_arr)
@@ -49,12 +58,17 @@ function M.run_test(case, cmd)
            end
        end,
    })

    -- Send input
    vim.fn.chansend(job_id, vim.list_extend(vim.fn.readfile(case), { "" }))

    -- Wait till `timeout`
    local len = vim.fn.jobwait({ job_id }, timeout)
    if len[1] == -1 then
        vim.list_extend(result, { string.format("Status: Timed out after %d ms", timeout) })
        vim.fn.jobstop(job_id)
    end

    return result, status
end
return M
diff --git a/plugin/cphelper.vim b/plugin/cphelper.vim
index 0ff2865..977d108 100644
--- a/plugin/cphelper.vim
+++ b/plugin/cphelper.vim
@@ -1,7 +1,7 @@
command CphReceive lua require 'cphelper.receive'.receive()
command CphStop lua require 'cphelper.receive'.stop()
command -nargs=* CphTest lua require 'cphelper.process_tests'.process(<f-args>)
command -nargs=* CphRetest lua require 'cphelper.process_tests'.process_retests(<f-args>)
command -nargs=+ CphDelete lua require 'cphelper.modify_tc'.deletetc(<f-args>)
command -nargs=1 CphEdit lua require 'cphelper.modify_tc'.edittc(<f-args>)
command -nargs=* CphTest silent lcd %:p:h | lua require 'cphelper.process_tests'.process(<f-args>)
command -nargs=* CphRetest silent lcd %:p:h | lua require 'cphelper.process_tests'.process_retests(<f-args>)
command -nargs=+ CphDelete silent lcd %:p:h | lua require 'cphelper.modify_tc'.deletetc(<f-args>)
command -nargs=1 CphEdit silent lcd %:p:h | lua require 'cphelper.modify_tc'.edittc(<f-args>)
highlight Underline gui=underline cterm=underline
-- 
2.33.0.windows.2