-
Notifications
You must be signed in to change notification settings - Fork 97
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
Display total table relation size in the drawer #257
base: master
Are you sure you want to change the base?
Conversation
Thanks for the PR! This is a very nice feature. |
I think it is a great idea to provide people with this flag as making queries for not only tables' names but sizes as well makes the delay slightly longer when opening the connection. For example, I tested it on a postgres database with over 11000 tables and the request took approximately 6 seconds for the first time and 4 seconds each call after, while the original took only 2 seconds. There is also pretty little I can do regarding optimization of size calculation as it is my first experience with vimscript. I will do something regarding it with bitwise shifts instead of divisions soon. Yet nothing can be done on the db's part. As it feels less straining on smaller databases, I would like to leave some options for people to turn off querying and calculating table size completely, for those of users who wish to retain their workflow speed. What about making it |
But I will take details toggle into development as I think it is a great idea. |
Ok, we can leave it as a togglable variable with the default off in that case. I thought there is no performance hit with it. |
…isations with size calculation, ability to toggle via 'H'.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks solid, but we just need to address few more things.
else | ||
let icon = self.get_toggle_icon('table', a:tables.items[a:table]) | ||
let label = repeat(' ', shiftwidth() * a:level).icon.(!empty(icon) ? " " : "") | ||
if strchars(label) + strchars(a:table) > g:db_ui_winwidth - 8 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's not rely on db_ui_winwidth
variable for this. Table names can be longer than the width.
We should find the longest table name and use that as a reference for padding.
We also need to put the values in parenthesis so it's picked up by highlighter.
This should be enough for the current else
block:
let longest = max(map(copy(a:tables.list), 'strchars(v:val)'))
return printf('%-'.longest.'s (%s)', a:table, a:tables.items[a:table].size)
if !g:db_ui_show_size || !self.show_details | ||
let name = a:table | ||
else |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can just return early here and avoid having an else
block:
if !g:db_ui_show_size || !self.show_details | |
let name = a:table | |
else | |
if !g:db_ui_show_size || !self.show_details | |
return a:table | |
endif |
Changes
The rendering takes into consideration drawer's width and calculates the necessary amount of spaces with repeat() so as to provide the drawer with the label in the format of {table-name}-{whitespace}-{table-size} that would fit with both nerd fonts enabled and different drawer width options. Does not break (throws no errors) if width is less than 8.