stevearc / dressing.nvim

Neovim plugin to improve the default vim.ui interfaces
MIT License
1.69k stars 32 forks source link

fix: handle extra scenario where the prompt is sent with trailing spaces #138

Closed 231tr0n closed 5 months ago

231tr0n commented 5 months ago

Handle extra prompt scenario where the prompt has trailing spaces leading to unwanted behaviour.

Context

The way trim_prompt works is that if the last character is ":" it trims it. But the issue is there are plugins like nvim-dap which send prompts like this "Configurations: " with an extra trailing space leading to the addition of extra space by my last pr for fzf backend https://github.com/stevearc/dressing.nvim/pull/136 to add an unwanted extra space. This pr fixes that behaviour.

Behaviour withou this pr Screenshot 2024-01-18 063313

Behaviour with this pr Screenshot 2024-01-18 064157

Description

It changes the prompts functionality by removing trailing spaces from prompts.

Test Plan

bootstrap_paq({
    {
        "junegunn/fzf",
        build = ":call fzf#install()",
    },
    "junegunn/fzf.vim",
    "stevearc/dressing.nvim",
    "mfussenegger/nvim-dap",
        {
        "microsoft/vscode-js-debug",
        build = function()
            local path = vim.fn.stdpath("data") .. "/site/pack/paqs/start/vscode-js-debug"
            vim.fn.system({
                "bash",
                "-c",
                "cd " .. path .. " && rm -rf dist out && npm install && npx gulp vsDebugServerBundle && mv dist out",
            })
            return true
        end,
    },
    "mxsdev/nvim-dap-vscode-js",
})

require("dap-vscode-js").setup({
    debugger_path = vim.fn.stdpath("data") .. "/site/pack/paqs/start/vscode-js-debug",
    adapters = { "pwa-node" },
})
for _, language in ipairs({ "typescript", "javascript" }) do
    require("dap").configurations[language] = {
        {
            type = "pwa-node",
            request = "launch",
            name = "Launch file",
            program = "${file}",
            cwd = "${workspaceFolder}",
        },
        {
            type = "pwa-node",
            request = "attach",
            name = "Attach",
            processId = require("dap.utils").pick_process,
            cwd = "${workspaceFolder}",
        },
    }
end

require("dressing").setup({
    select = {
        backend = { "fzf", "nui", "builtin" },
        trim_prompt = false,
    },
})

You can start a debug session to see the above difference.

:lua require('dap').continue()