rest-nvim / rest.nvim

A very fast, powerful, extensible and asynchronous Neovim HTTP client written in Lua.
GNU General Public License v3.0
1.62k stars 143 forks source link

Wrong request section #464

Open eeeXun opened 2 months ago

eeeXun commented 2 months ago

Prerequisites

Neovim Version

v0.10.1

Operating system/version

Linux

Actual behavior

If run rest.nvim with horizontal split, :hor Rest open. And you set splitkeep to screen or topline, which will change the cursor position when necessary.

If your cursor changed, the request section may be wrong.

e.g. Suppose my cursor is on the line http://test2.com. And I set splitkeep to topline. After running :hor Rest open, the rest_nvim_result shows that I requested http://test1.com.

GET http://test1.com

###
GET http://test2.com

Expected behavior

Maybe we should request http://test1.com first and then open/split the rest_nvim_result panel.

Steps to reproduce

Set splitkeep to screen or topline, which will change your cursor position when horizontal split. Then run :hor Rest open

Other information

No response

Repro (lazy.nvim)

vim.env.LAZY_STDPATH = ".repro"
load(vim.fn.system("curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua"))()
vim.opt.splitkeep="topline"

require("lazy.minit").repro({
    spec = {
        "rest-nvim/rest.nvim",
        {
            "nvim-treesitter/nvim-treesitter",
            build = ":TSUpdate",
            main = "nvim-treesitter.configs",
            opts = {
                ensure_installed = { "http" },
                sync_install = false,
                highlight = { enable = true },
                indent = { enable = true },
            },
        },
    },
})
boltlessengineer commented 2 months ago

Thank you for your report.

I won’t change the behavior of :Rest open because it doesn’t run any requests, but I can change :Rest run to report the request first and then open the UI. Will this satisfy your need?

eeeXun commented 2 months ago

I won’t change the behavior of :Rest open because it doesn’t run any requests,

Oh sorry. I messed up the open and run command. All my description about :hor Rest open should be substituted with :hor Rest run

but I can change :Rest run to report the request first and then open the UI. Will this satisfy your need?

Yes, I think that should fix this problem