From 10abcb661ecad9fa9b222045cb35bb33b9be76e2 Mon Sep 17 00:00:00 2001 From: Oleksandr Smirnov Date: Wed, 19 Mar 2025 15:53:30 +0200 Subject: [PATCH] feat(struct_tags): trim output --- lua/gopher/struct_tags.lua | 4 ++++ spec/fixtures/tags/remove_output.go | 12 ++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/lua/gopher/struct_tags.lua b/lua/gopher/struct_tags.lua index 198f7a4..82aaf04 100644 --- a/lua/gopher/struct_tags.lua +++ b/lua/gopher/struct_tags.lua @@ -62,6 +62,10 @@ local function handle_tags(fpath, bufnr, user_args) error("failed to set tags " .. vim.inspect(res["errors"])) end + for i, v in ipairs(res["lines"]) do + res["lines"][i] = string.gsub(v, "%s+$", "") + end + vim.api.nvim_buf_set_lines( bufnr, res["start"] - 1, diff --git a/spec/fixtures/tags/remove_output.go b/spec/fixtures/tags/remove_output.go index 6d9fe70..7e27a27 100644 --- a/spec/fixtures/tags/remove_output.go +++ b/spec/fixtures/tags/remove_output.go @@ -1,11 +1,11 @@ package main type Test struct { - ID int - Name string - Num int64 + ID int + Name string + Num int64 Another struct { - First int - Second string - } + First int + Second string + } }