Skip to content

Add buflines()#5370

Closed
mattn wants to merge 2 commits into
vim:masterfrom
mattn:add-buflines
Closed

Add buflines()#5370
mattn wants to merge 2 commits into
vim:masterfrom
mattn:add-buflines

Conversation

@mattn

@mattn mattn commented Dec 17, 2019

Copy link
Copy Markdown
Member

Vim does not have a way to get number of lines for the buffer. Yes, we know len(getbuflines(nr, 1, '$')) but useless. This change add buflines().

@andymass

Copy link
Copy Markdown

Why not just add an argument to line()?

@mattn

mattn commented Dec 17, 2019

Copy link
Copy Markdown
Member Author

line() already have optional argument. Also winid must be window shown.

@chdiza

chdiza commented Dec 17, 2019

Copy link
Copy Markdown

but useless.

Why is it useless?

Anyway, 99.999% of the time people would want to know the size of the current buffer, in which case line('$') would suffice.

@codecov-io

Copy link
Copy Markdown

Codecov Report

Merging #5370 into master will decrease coverage by 0.43%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #5370      +/-   ##
==========================================
- Coverage   82.23%   81.79%   -0.44%     
==========================================
  Files         134      134              
  Lines      147604   147607       +3     
==========================================
- Hits       121385   120740     -645     
- Misses      26219    26867     +648
Impacted Files Coverage Δ
src/evalfunc.c 90.65% <ø> (-0.3%) ⬇️
src/evalbuffer.c 96.08% <100%> (+0.03%) ⬆️
src/gui_gtk_x11.c 49.01% <0%> (-9.05%) ⬇️
src/gui.c 58.27% <0%> (-5.37%) ⬇️
src/gui_gtk.c 28.57% <0%> (-2.89%) ⬇️
src/os_unix.c 60.83% <0%> (-2.5%) ⬇️
src/buffer.c 82.87% <0%> (-2.49%) ⬇️
src/highlight.c 77.97% <0%> (-2.39%) ⬇️
src/if_xcmdsrv.c 84.02% <0%> (-2.16%) ⬇️
src/ui.c 68.98% <0%> (-2.15%) ⬇️
... and 34 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update afc13bd...292c893. Read the comment docs.

@chrisbra

Copy link
Copy Markdown
Member

Hm, perhaps enhancing getbufinfo() to include the last line number would be more useful?

@mattn

mattn commented Dec 17, 2019

Copy link
Copy Markdown
Member Author

@chrisbra Ah, right.

@chdiza line('$') does not accept bufnr and line('$') can not handle hidden buffer.

Anyway, getbufinfo is good to do this. Thanks.

@mattn mattn closed this Dec 17, 2019
@mattn mattn reopened this Dec 17, 2019
@mattn

mattn commented Dec 17, 2019

Copy link
Copy Markdown
Member Author

@chrisbra Ah, I'll add "lines" into the result of getbufinfo.

@mattn

mattn commented Dec 17, 2019

Copy link
Copy Markdown
Member Author

Fixed patch to add getbufinfo(nr)[0]["lines"]

@chrisbra

Copy link
Copy Markdown
Member

at the risk of bike shading, is lines perhaps to generic? What about lastline or linecount (matches partly with ml_line_count).

@brammool brammool closed this in a9e9679 Dec 17, 2019
janlazo added a commit to janlazo/neovim that referenced this pull request Dec 20, 2019
Problem:    Cannot number of lines of another buffer.
Solution:   Add "linecount" to getbufinfo(). (Yasuhiro Matsumoto,
            closes vim/vim#5370)
vim/vim@a9e9679
janlazo added a commit to janlazo/neovim that referenced this pull request Dec 20, 2019
Problem:    Cannot number of lines of another buffer.
Solution:   Add "linecount" to getbufinfo(). (Yasuhiro Matsumoto,
            closes vim/vim#5370)
vim/vim@a9e9679
qvacua pushed a commit to qvacua/neovim that referenced this pull request Dec 21, 2019
Problem:    Cannot number of lines of another buffer.
Solution:   Add "linecount" to getbufinfo(). (Yasuhiro Matsumoto,
            closes vim/vim#5370)
vim/vim@a9e9679
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.

5 participants