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

Use extmarks for highlighting and carets #2099

Merged
merged 11 commits into from
Aug 18, 2022

Conversation

codegangsta
Copy link
Contributor

Description

Pulled out as a subset of the changes from #1491

This PR uses extmarks and virtual text instead of typical highlighting and text replacement to consolidate the highlight/rendering logic to highlights.lua. This should give us more flexibility in the future when we want to improve rendering of telescope.

Type of change

Please delete options that are not relevant.

  • Internal Changes

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list relevant details about your configuration

  • All the tests in lua/tests/automated/

Configuration:

  • Neovim version (nvim --version): NVIM v0.7.2
  • Operating system and version: macOS 12.3.1

Checklist:

  • My code follows the style guidelines of this project (stylua)
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (lua annotations)

@Conni2461
Copy link
Member

Thank you very much for pulling out these changes :)

I'll review and test it tomorrow evening. I can't make it before

@codegangsta
Copy link
Contributor Author

codegangsta commented Jul 27, 2022 via email

@tjdevries
Copy link
Member

@codegangsta you can run stylua over a direction stylua . to autoformat (not sure if you were doing that alreayd)

@codegangsta
Copy link
Contributor Author

@tjdevries Yeah I thought I has stylua installed already but it looks like I didn't. Should be all good now

@@ -56,65 +61,106 @@ end

function Highlighter:hi_sorter(row, prompt, display)
local picker = self.picker
local sorter = picker.sorter
Copy link
Member

Choose a reason for hiding this comment

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

there is no need for having sorter in a local var. Its only used in line 74 so we can just do picker.sorter there. esp because line 65 also uses picker.sorter

Comment on lines 142 to 143
local line = a.nvim_buf_get_lines(results_bufnr, row, row + 1, false)[1]
if not line then
Copy link
Member

Choose a reason for hiding this comment

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

line 108 also does this check. but it compares with "", I think it doesnt hurt to check for both nil and "" in 108 and here

@Conni2461
Copy link
Member

Overall LGTM, just a couple of nits 😆 Thanks again for pulling it out :)

One thing i noticed while testing is that on multiselect we change the highlighting for the icon, which we currently dont do. I think priority is causing this and i am currently thinking if DISPLAY should have a higher priority compared to SELECTION.

CC @fdschmidt93

@codegangsta
Copy link
Contributor Author

Oh good catch on the highlight. If we want to keep it compatible the priority fix should be easy enough. If we decide later we want to change it to highlight the multi-select cursor we can do that in a followup PR.

@Conni2461
Copy link
Member

Yeah can you update the priorities, and fix the other things. You also need to rebase 😬

Once this is fixed, @fdschmidt93 can you retest and merge. I am leaving this evening for a 10 day vacation and will not take a laptop and actually going to uninstall github from my phone, so yeah thanks :)

@codegangsta
Copy link
Contributor Author

@Conni2461 and @fdschmidt93 fixed the feedback in this PR. LMK if there are any outstanding issues

Copy link
Member

@tjdevries tjdevries left a comment

Choose a reason for hiding this comment

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

Tested it out locally and seems to work for me

@tjdevries
Copy link
Member

oh right, tests will fail because we no longer overwrite the text in the line -- you can just update the tests to pass @codegangsta they all seem like failures that are OK to just be shifted to new results

@codegangsta
Copy link
Contributor Author

Whoops. Missed that one as it looks like that test was disabled on mac. All fixed now @tjdevries

Copy link
Member

@fdschmidt93 fdschmidt93 left a comment

Choose a reason for hiding this comment

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

I've briefly tested this PR. As evident by screenshots before and after mismatch in:

  • selection caret not appropriately highlighted
  • multi icon does not blend with cursorline

Before

image

After

image

Solution: incorporate suggested changes

Co-authored-by: Fabian David Schmidt <[email protected]>
@codegangsta
Copy link
Contributor Author

Thanks for the suggestions @fdschmidt93. I added those to this PR

Copy link
Member

@fdschmidt93 fdschmidt93 left a comment

Choose a reason for hiding this comment

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

Re-tested and works fine now :)

Just to be on the safe side, I'll merge Thursday morning around 9 CEST just in case something goes wrong in master and then I could hotfix it if required; tomorrow I'm traveling all day.

@tjdevries
Copy link
Member

Sounds good to me :)

@fdschmidt93 fdschmidt93 merged commit 8d13f4c into nvim-telescope:master Aug 18, 2022
fdschmidt93 added a commit that referenced this pull request Aug 19, 2022
fdschmidt93 added a commit that referenced this pull request Aug 19, 2022
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.

None yet

4 participants