Skip to content

Conversation

yatli
Copy link

@yatli yatli commented Feb 24, 2020

This PR addresses #11879.

Before:
image

After:
image

Front-end changes: post the position and size information of pum with:
image

Back-end plugins don't need changes. Correct pum geometry will be passed to CompleteChanged.

@yatli yatli requested a review from justinmk February 24, 2020 08:47
@yatli
Copy link
Author

yatli commented Feb 24, 2020

Not familiar with the tests. Advices on how to proceed please?

@yatli
Copy link
Author

yatli commented Mar 2, 2020

@bfredl is there anything I can do to improve this PR?

@yatli
Copy link
Author

yatli commented Mar 3, 2020

Thanks @bfredl, addressed the review comments. :)

@yatli
Copy link
Author

yatli commented Mar 3, 2020

Got this in the CI build:

../src/nvim/popupmnu.c:928:40: error: implicit conversion turns floating-point number into integer: 'float' to 'varnumber_T' (aka 'long') [-Werror,-Wfloat-conversion]

Doesn't seem right, but I'm not sure what's the appropriate way to add floats.

Edit: add tv_dict_add_float

@yatli
Copy link
Author

yatli commented Mar 3, 2020

Existing tests should be OK now.

@yatli
Copy link
Author

yatli commented Mar 5, 2020

@bfredl is meths.ui_pum_set_bounds auto-generated? I'm having trouble getting it work in the tests.
Also, could have FloatOrInteger in the generator to auto cast it.

@bfredl
Copy link
Member

bfredl commented Mar 5, 2020

meths.ui_pum_set_bounds is just syntax for sending the rpc request nvim_ui_pum_set_bounds.

Also, could have FloatOrInteger in the generator to auto cast it.

Sounds over-engineering. bare Float args (as opposed to nested ones inside Object) are rare, we should just allow msgpack int for all of them (just as for all Buffer, Boolean etc).

@yatli
Copy link
Author

yatli commented Mar 5, 2020

Updated gen_api_dispatch.lua.

@yatli
Copy link
Author

yatli commented Mar 6, 2020

Tests should be OK now.

@bfredl
Copy link
Member

bfredl commented Mar 6, 2020

Right, lua (5.1/luajit) doesn't even have proper int/float distinction, so you will get a msgpack int for 0.0 .

@yatli
Copy link
Author

yatli commented Mar 6, 2020

Ah, that's why the tests were failing. :D

@yatli yatli changed the title [RFC] API/UI: Allow UI to set PUM position and size, and pass the position to CompleteChanged [RDY] API/UI: Allow UI to set PUM position and size, and pass the position to CompleteChanged Mar 22, 2020
@yatli
Copy link
Author

yatli commented Mar 22, 2020

Add test for tv_dict_add_float and I think this PR is getting ready.
May I ask if this can be considered for merge?

@yatli
Copy link
Author

yatli commented Mar 22, 2020

Updated, thanks @bfredl.

src/nvim/ui.c Outdated
if (!uis[i]->pum_pos) {
continue;
}
w = uis[i]->pum_width;
Copy link
Member

Choose a reason for hiding this comment

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

you can assign pwidth etc directly here and call return. then found var can be eliminated.

tv_dict_add_nr(dict, S_LEN("row"), pum_row);
tv_dict_add_nr(dict, S_LEN("col"), pum_col);
double w, h, r, c;
ui_pum_get_pos(&w, &h, &r, &c);
Copy link
Member

Choose a reason for hiding this comment

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

Now I think ui_pum_get_pos could return a bool if any UI was found. Then this could be

if(!ui_pum_get_pos(&w, &h, &r, &c)) {
  w = pum_width;
  h = pum_height;
  ...
}

and pum_get_internal_pos removed.

@yatli
Copy link
Author

yatli commented Mar 22, 2020

done 🎵

@yatli
Copy link
Author

yatli commented Mar 22, 2020

Done. Also updated a few other occurrences in the file.

@yatli
Copy link
Author

yatli commented Mar 22, 2020

getting this: test/functional/ui/popupmenu_spec.lua:426: attempt to call global 'pcall_err' (a nil value)
importing that from helpers now..

@teto
Copy link
Member

teto commented Apr 25, 2020

could you rebase please (master has a fix for my build system) ? I could but dont want to push on your branch.

@yatli
Copy link
Author

yatli commented Apr 26, 2020

@teto rebase and force pushed.

@teto
Copy link
Member

teto commented Apr 27, 2020

this looks good. Could you simplify history a bit ?

@yatli
Copy link
Author

yatli commented Apr 27, 2020

Yeah, time to learn some new git tricks :p
Edit: it was fun :D
Edit: Github shows wrong commit order but the order is fine on my branch?

@teto teto merged commit c7d3630 into neovim:master Apr 27, 2020
@little-dude
Copy link

Github shows wrong commit order but the order is fine on my branch?

@yatli Github orders the commits by author date instead of commit date. When you rebase the author date remains unchanged but the commit date is updated.

@dundargoc dundargoc removed the request for review from justinmk October 3, 2022 19:55
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.

6 participants