Commit Graph

54 Commits

Author SHA1 Message Date
Lewis Russell
81fc27124b refactor(test): inject after_each differently 2024-04-10 15:53:50 +01:00
dundargoc
7035125b2b test: improve test conventions
Work on https://github.com/neovim/neovim/issues/27004.
2024-04-08 22:51:00 +02:00
bfredl
35f2bb05a5 refactor(tests): use new global defaults instead of set_default_attr_ids
This will be done in batches.
2024-03-26 21:28:05 +01:00
bfredl
0c59771e31 refactor(tests): all screen tests should use highlights
This is the first installment of a multi-PR series significantly
refactoring how highlights are being specified.

The end goal is to have a base set of 20 ish most common highlights,
and then specific files only need to add more groups to that as needed.

As a complicating factor, we also want to migrate to the new default
color scheme eventually. But by sharing a base set, that future PR
will hopefully be a lot smaller since a lot of tests will be migrated
just simply by updating the base set in place.

As a first step, fix the anti-pattern than Screen defaults to ignoring
highlights. Highlights are integral part of the screen state, not
something "extra" which we only test "sometimes". For now, we still
allow opt-out via the intentionally ugly

  screen._default_attr_ids = nil

The end goal is to get rid of all of these eventually (which will be
easier as part of the color scheme migration)
2024-03-23 13:44:35 +01:00
luukvbaal
dbf6be296d
fix(column): full redraw with 'stc, 'rnu' and inserted lines (#27712)
Problem:  Text is not redrawn with 'relativenumber' when only the 'statuscolumn' is redrawn after inserted lines.
Solution: Force a full redraw if statuscolumn width changed.
2024-03-03 08:40:46 +08:00
zeertzjq
0db6946b39
fix(column): handle w_redr_statuscol at end filler lines (#27365)
There doesn't seem to be an easy solution that doesn't involve a goto.
Also remove duplicate assignment in win_line().
2024-02-06 23:01:44 +08:00
Luuk van Baal
c6864b0d14 fix(column): redraw 'statuscolumn' on wrapped lines with 'relativenumber'
Problem:  The 'statuscolumn' is not redrawn on the wrapped part of a
          line when moving the cursor with 'relativenumber' set.
Solution: Redraw the 'statuscolumn' for the entire line height in the
          "col_rows" win_line() code path.
2024-01-16 12:13:36 +01:00
Luuk van Baal
967c7abde3 fix(column): keep track of number of lines with number of signs
Problem:  Some edge cases to the old (pre-#26406) and current "b_signcols"
          structure result in an incorrectly sized "auto" 'signcolumn'.
Solution: * Implement a simpler 'signcolumn' validation strategy by immediately
            counting the number of signs in a range upon sign insertion and
            deletion. Decrease in performance here but there is a clear path
            forward to decreasing this performance hit by moving signs to a
            dedicated marktree, or by adding meta-data to the existing
            marktree which may be queried more efficiently?
          * Also replace "max_count" and keep track of the number of lines with
            a certain number of signs. This makes it so that it is no longer
            necessary to scan the entire buffer when the maximum number of signs
            decreases. This likely makes the commit a net increase in performance.
          * To ensure correctness we also have re-initialize the count for an
            edited region that spans multiple lines. Such an edit may move the
            signs within it. Thus we count and decrement before splicing the
            marktree and count and increment after.
2024-01-15 09:37:53 +00:00
Lewis Russell
795f896a57 test: rename (meths, funcs) -> (api, fn) 2024-01-12 18:59:14 +00:00
Lewis Russell
c30f2e3182 test: typing for helpers.meths 2024-01-12 13:01:06 +00:00
luukvbaal
c509f4907b
fix(column): fill 'statuscolumn' clickdefs with evaluated width (#26891) 2024-01-05 21:34:54 +08:00
Justin M. Keyes
04f2f864e2 refactor: format test/* 2024-01-03 02:09:29 +01:00
luukvbaal
ec74538044
fix(column): correct width after truncated 'statuscolumn' error (#26737)
Problem:  Default number column has incorrect width after 'statuscolumn'
          is unset due to an error, but was also truncated.
Solution: Reverse 'statuscolumn' error and truncate return branches.
2023-12-26 09:07:58 +08:00
zeertzjq
1037ce2e46 test: avoid repeated screen lines in expected states
This is the command invoked repeatedly to make the changes:

    :%s/^\(.*\)|\%(\*\(\d\+\)\)\?$\n\1|\%(\*\(\d\+\)\)\?$/\=submatch(1)..'|*'..(max([str2nr(submatch(2)),1])+max([str2nr(submatch(3)),1]))/g
2023-12-09 22:15:02 +08:00
luukvbaal
6a2a37b1e1
fix(mouse): avoid dragging when clicking next to popupmenu (#26201) 2023-11-25 07:10:19 +08:00
luukvbaal
a8a93e517f
fix(mouse): avoid dragging after click label popupmenu callback (#26187) 2023-11-24 09:15:50 +08:00
Luuk van Baal
df399ea0d2 fix(column): reset decor state before starting from top 2023-11-23 16:27:17 +00:00
Luuk van Baal
c4afb9788c refactor(sign): move legacy signs to extmarks
Problem:  The legacy signlist data structures and associated functions are
          redundant since the introduction of extmark signs.
Solution: Store signs defined through the legacy commands in a hashmap, placed
          signs in the extmark tree. Replace signlist associated functions.

Usage of the legacy sign commands should yield no change in behavior with the
exception of:
  - "orphaned signs" are now always removed when the line it is placed on is
    deleted. This used to depend on the value of 'signcolumn'.
  - It is no longer possible to place multiple signs with the same identifier
    in a single group on multiple lines. This will now move the sign instead.

Moreover, both signs placed through the legacy sign commands and through
|nvim_buf_set_extmark()|:
  - Will show up in both |sign-place| and |nvim_buf_get_extmarks()|.
  - Are displayed by increasing sign identifier, left to right.
    Extmark signs used to be ordered decreasingly as opposed to legacy signs.
2023-11-17 15:10:15 +01:00
luukvbaal
d3582e102b
feat(statuscolumn): re-evaluate for every screen line (#25885)
Problem:  v:virtnum is less useful than it could be.
Solution: Always re-evaluate 'statuscolumn', and update v:virtnum
          accordingly.
2023-11-13 11:24:02 +08:00
zeertzjq
dc6c11394b
fix(statuscolumn): update number hl for each screen line (#25277) 2023-09-21 07:03:26 +08:00
zeertzjq
2b475cb5cc
fix(mouse): click on 'statuscolumn' with 'rightleft' (#25090) 2023-09-11 08:29:33 +08:00
luukvbaal
afd0c648a8
fix(statuscolumn): force full redraw when signcolumn is invalid (#24859)
Fix #24655
2023-08-26 21:10:04 +08:00
zeertzjq
01e273c340
fix(statuscolumn): don't update clicks if current width is 0 (#24459) 2023-07-24 15:18:24 +08:00
zeertzjq
25e62697c3
fix(column): fix wrong cursor with 'statuscolumn' and cpo+=n (#24268) 2023-07-06 11:07:23 +08:00
zeertzjq
7d0a23973b
fix(column): handle unprintable chars in 'statuscolumn' (#24198) 2023-06-29 11:37:55 +08:00
luukvbaal
70da793c5e
fix(statusline): corrupted screen with minwid sign item in 'statuscolumn' (#23823) 2023-05-30 20:56:12 +08:00
zeertzjq
ee986ee044
fix(folds): combined Folded and Visual highlights (#23752)
Also combine high-priority CursorLine with Folded.
2023-05-25 22:14:12 +08:00
zeertzjq
678548a2b4
fix(folds): show Folded highlight in Visual selection (#23741)
Note: CursorLine highlight is now combined with Folded.
2023-05-24 21:25:39 +08:00
luukvbaal
60f69014a8
fix(redraw): multibyte characters are wrapped at the end of a line (#23696)
Problem:    Multibyte characters may be wrapped at the end of a line
            when 'statuscolumn' and 'spell' are set.
Solution:   Update line pointerdiff "v" before fetching the line pointer
            after evaluating 'statuscolumn'.
2023-05-21 19:00:37 +08:00
luukvbaal
a4b2400804
fix(statusline): also allow right click when 'mousemodel' is "popup*" (#23258)
Problem:    The 'statusline'-format ui elements do not receive right
            click events when "mousemodel" is "popup*"
Solution:   Do not draw popupmenu and handle click event instead.
2023-04-25 11:05:04 +08:00
Luuk van Baal
44d4f03573 fix(column): rebuild status column when sign column is invalid 2023-04-19 03:22:27 +02:00
Luuk van Baal
d799456a6b test(column): statuscolumn is rebuild when signs are (un)placed 2023-04-19 01:09:45 +02:00
luukvbaal
84a4319545
fix(mouse): cmdline click registered as statuscolumn (#23163) 2023-04-18 08:00:49 +08:00
luukvbaal
cdc028e97d
fix(column): add truncated width during estimation for 'statuscolumn'
Problem:    Estimated 'statuscolumn' width estimated is not properly used,
            executing the `w_redr_statuscol` path unnecessarily.
Solution:   Adjust `w_nrwidth` and 'statuscolumn' width before anything
            is actually drawn in a `win_update()`.
2023-04-12 16:40:58 +01:00
luukvbaal
3c724fe1f3
fix(column): 'statuscolumn' not drawn after virt_lines with "n" in 'cpo' (#22967)
Problem:    The 'statuscolumn' is not drawn and the line itself is drawn
            at an offset to the rest of the buffer after virt_lines if
            'cpoptions' includes "n".
Solution:   Make sure 'statuscolumn' is drawn.
2023-04-10 08:39:27 +08:00
luukvbaal
204a8b17c8
fix(column): rebuild status column when sign column is invalidated (#22690)
* fix(column): rebuild status column when sign column is invalidated

Problem:    When implementing a custom sign column through
            `'statuscolumn'`, the status column is not properly rebuilt
            when the sign column width changes.
Solution:   Force a rebuild of the status column when the sign column
            width is invalidated.

* test(column): 'statuscolumn' has correct width when (un)placing signs
2023-03-18 11:44:44 +00:00
zeertzjq
8916669d50
test(statuscolumn_spec): remove unnecessary feed('lh')
It is no longer needed after #22706.
2023-03-18 19:06:24 +08:00
luukvbaal
bf4eada2c8
fix(column): issues with 'statuscolumn' width (#22542)
Problem:    'statuscolumn' width can be incorrect when toggling 'number'
            or setting 'statuscolumn'.
Solution:   Make sure the width is reset and re-estimated when
            'statuscolumn' and 'number' are set. (When 'relativenumber'
            is set this already happens because it always changes
            "nrwidth_line_count".)
2023-03-07 08:45:08 +08:00
zeertzjq
b7d59649ac fix(redraw): get the line again after evaluating something 2023-03-04 13:53:09 +08:00
luukvbaal
9a271f6afd
fix(column): cmdwin cursor is offset with 'statuscolumn' (#22445) 2023-02-28 10:19:58 +08:00
Luuk van Baal
08fb3b5309 perf(column): only build fold/sign column when present in 'statuscolumn'
Problem:    The fold and sign column is built and stored regardless of
            whether the corresponding item is present in 'statuscolumn'.
Solution:   Since the 'statuscolumn' parses itself, we can defer
            building the columns until the corresponding item is
            actually encountered.
2023-02-04 11:04:43 +01:00
luukvbaal
64fa75a86a
fix(column): estimate 'statuscolumn' width appropriately
Problem:    The 'statuscolumn' width is being estimated without the
            proper context. In particular, this resulted in the fact
            that a custom fold column could be included in the estimated
            `number_width()`, and doubly added when actually drawing the
            statuscolumn due to `win_col_off()` also adding the
            `'foldcolumn'` width. Resulting in a status column that is
            `'foldcolumn'` cells wider than necessary.
Solution:   Estimate 'statuscolumn' width in `get_statuscol_str()` when
            a buffer's line count has changed.
2023-02-02 09:35:51 +00:00
luukvbaal
999bb983f0
perf(statuscolumn): only fill click defs array once per redraw (#21884)
Problem:    'statuscolumn' click definitions are cleared, evaluated,
            allocated and filled each redraw for every row in a window.
            This despite the fact that we only store a single click
            definition array for the entire column as opposed to one
            for each row.
Solution:   Only fill the 'statuscolumn' click definition array once per
            window per redraw.

Resolve https://github.com/neovim/neovim/issues/21767.
2023-01-20 07:47:02 +08:00
zeertzjq
36555730da
fix(statuscolumn): always fill click defs array (#21878)
Click definitions are always filled for tabline, statusline and winbar,
so they should also be always filled for statuscolumn, otherwise it will
leak memory.

Note: this doesn't actually change the existing code much, because of a
typo in the existing code.
2023-01-18 17:55:03 +08:00
Brian Koropoff
bbdded5cf7
test(statuscolumn): %l should follow default wrap behavior (#21766) 2023-01-17 08:02:33 +08:00
Luuk van Baal
54470336ff fix(column): avoid drawing columns for virt_lines_leftcol
Problem:    The default fold column, as well as the 'statuscolumn', were
            drawn unnecessarily/unexpectedly for virtual lines placed
            with `virt_lines_leftcol` set.
Solution:   Skip the column states if a virtual line with
            `virt_lines_leftcol` set will be drawn.
2023-01-16 15:09:12 +01:00
Luuk van Baal
85111ca0f4 fix(column)!: ensure 'statuscolumn' works with virtual and wrapped lines
Problem:    The `'statuscolumn'` was not re-evaluated for wrapped lines,
            when preceded by virtual/filler lines. There was also no way
            to distinguish virtual and wrapped lines in the status column.
Solution:   Make sure to rebuild the statuscolumn, and replace variable
            `v:wrap` with `v:virtnum`. `v:virtnum` is negative when drawing
            virtual lines, zero when drawing the actual buffer line, and
            positive when drawing the wrapped part of a buffer line.
2023-01-16 14:03:09 +01:00
luukvbaal
4a12372ccf
fix(statuscolumn): make %l/%r respect 'number'/'relativenumber' (#21747)
Resolve https://github.com/neovim/neovim/issues/21745.
2023-01-13 09:41:19 +00:00
luukvbaal
4876654d4c
fix(mouse): statusline click registered as statuscolumn (#21748)
fix(statuscolumn): statusline click registered as statuscolumn

Problem:  Status line click is registered as status status column click.
Solution: Check that mouse is not on the status line.

Resolve https://github.com/luukvbaal/statuscol.nvim/issues/4.
2023-01-13 07:36:59 +08:00
luukvbaal
0fd59f0121
fix(statuscolumn): foldcolumn buffer is too small (#21761)
Resolve https://github.com/neovim/neovim/issues/21759.
2023-01-12 23:04:43 +08:00