Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: view.width functions may return strings #3020

Merged
merged 3 commits into from
Dec 8, 2024
Merged

Conversation

ljie-PI
Copy link
Collaborator

@ljie-PI ljie-PI commented Dec 7, 2024

In the function get_size(), if the parameter size is a function which return string like "20%", the function returns the string instead of a number. It fails when vim.api.nvim_win_set_width(winnr, new_size) to set the width.

The get_size() funtion can parse such strings, so invoke the function again to fix this.

@ljie-PI ljie-PI changed the title Fix get_size() function when size is a function return string fix: get_size() function cause error when parameter is a function return string Dec 7, 2024
@alex-courtis
Copy link
Member

Works for:

    width = {
      max = function()
        return "40%"
      end,
      min = function()
        return "30%"
      end,
      padding = function()
        return "1%"
      end,
    },

Copy link
Member

@alex-courtis alex-courtis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Many thanks @ljie-PI !

Updated doc myself for quick turnaround.

@alex-courtis alex-courtis changed the title fix: get_size() function cause error when parameter is a function return string fix: view.width functions may return strings Dec 8, 2024
@alex-courtis alex-courtis merged commit 6b4be1d into master Dec 8, 2024
5 checks passed
@alex-courtis alex-courtis deleted the fix_getsize branch December 8, 2024 00:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants