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

fix(main): check if line is nil when colorizing lsp range #687

Conversation

stong1994
Copy link
Contributor

@stong1994 stong1994 commented Apr 24, 2024

fix: #685

Regresion test

Platforms

  • windows
  • macOS
  • linux

Tasks

  • FzfxFiles
    • Press CTRL-J/CTRL-K to move down/up and preview contents.
    • Press CTRL-U/CTRL-R to switch between restricted/unrestricted mode, and the lines count is consistent when press multiple times.
    • Use V/W/P/R variants (visual selection, cursor word, yank text, resume last).
    • Press ESC to quit, ENTER to open file, and open the test/hello world.txt, test/goodbye world/goodbye.lua files.
    • Both fd and find works.
  • FzfxLiveGrep
    • Press CTRL-J/CTRL-K to move down/up and preview contents.
    • Press CTRL-U/CTRL-R to switch between restricted/unrestricted mode, and the lines count is consistent when press multiple times.
    • Use -w to match word only, use -g *.lua to search only lua files.
    • Use V/W/P/R variants (visual selection, cursor word, yank text, resume last).
    • Press ESC to quit, ENTER to open file, and open the test/hello world.txt, test/goodbye world/goodbye.lua files.
    • Both rg and grep works.
  • FzfxBufLiveGrep
    • Press CTRL-J/CTRL-K to move down/up and preview contents.
    • Use -w to match word only, use -g *.lua to search only lua files.
    • Use V/W/P/R variants (visual selection, cursor word, yank text, resume last).
    • Press ESC to quit, ENTER to open file.
    • Both rg and grep works.
  • FzfxBuffers
    • Press CTRL-J/CTRL-K to move down/up and preview contents.
    • Press CTRL-D to delete buffers, and delete the test/hello world.txt, test/goodbye world/goodbye.lua buffers.
    • Use V/W/P/R variants (visual selection, cursor word, yank text, resume last).
    • Press ESC to quit, ENTER to open file.
  • FzfxGFiles
    • Press CTRL-J/CTRL-K to move down/up and preview contents.
    • Press CTRL-U/CTRL-W to switch between workspace/current folder mode.
    • Use V/W/P/R variants (visual selection, cursor word, yank text, resume last).
    • Press ESC to quit, ENTER to open file.
  • FzfxGLiveGrep
    • Press CTRL-J/CTRL-K to move down/up and preview contents.
    • Use V/W/P/R variants (visual selection, cursor word, yank text, resume last).
    • Press ESC to quit, ENTER to open file.
  • FzfxGStatus
    • Press CTRL-J/CTRL-K to move down/up and preview contents.
    • Press CTRL-U/CTRL-W to switch between workspace/current folder mode.
    • Use V/W/P/R variants (visual selection, cursor word, yank text, resume last).
    • Press ESC to quit, ENTER to open file.
    • Both with/without delta works.
  • FzfxGBranches
    • Press CTRL-J/CTRL-K to move down/up and preview contents.
    • Press CTRL-R/CTRL-O to switch between local/remote branches.
    • Use V/W/P/R variants (visual selection, cursor word, yank text, resume last).
    • Press ESC to quit, ENTER to checkout branch.
  • FzfxGCommits
    • Press CTRL-J/CTRL-K to move down/up and preview contents.
    • Press CTRL-U/CTRL-A to switch between git repo commits/current buffer commits.
    • Use V/W/P/R variants (visual selection, cursor word, yank text, resume last).
    • Press ESC to quit, ENTER to copy commit hash.
    • Both with/without delta works.
  • FzfxGBlame
    • Press CTRL-J/CTRL-K to move down/up and preview contents.
    • Use V/W/P/R variants (visual selection, cursor word, yank text, resume last).
    • Press ESC to quit, ENTER to copy commit hash.
    • Both with/without delta works.
  • FzfxLspDiagnostics
    • Press CTRL-J/CTRL-K to move down/up and preview contents.
    • Press CTRL-U/CTRL-W to switch between workspace/current buffer diagnostics.
    • Use V/W/P/R variants (visual selection, cursor word, yank text, resume last).
    • Press ESC to quit, ENTER to open file.
  • FzfxLspDefinitions, FzfxLspTypeDefinitions, FzfxLspReferences, FzfxLspImplementations
    • Press CTRL-J/CTRL-K to move down/up and preview contents.
    • Go to definitions/references (this is the most 2 easiest use case when developing this lua plugin with lua_ls).
    • Press ESC to quit, ENTER to open file.
  • FzfxLspIncomingCalls, FzfxLspOutgoingCalls
    • Press CTRL-J/CTRL-K to move down/up and preview contents.
    • Go to incoming/outgoing calls.
    • Press ESC to quit, ENTER to open file.
  • FzfxCommands
    • Press CTRL-J/CTRL-K to move down/up and preview contents.
    • Press CTRL-U/CTRL-E/CTRL-A to switch between user/ex/all vim commands.
    • Use V/W/P/R variants (visual selection, cursor word, yank text, resume last).
    • Press ESC to quit, ENTER to feed vim command.
  • FzfxKeyMaps
    • Press CTRL-J/CTRL-K to move down/up and preview contents.
    • Press CTRL-O/CTRL-I/CTRL-A/CTRL-V to switch between normal/insert/visual/all vim key mappings.
    • Use V/W/P/R variants (visual selection, cursor word, yank text, resume last).
    • Press ESC to quit, ENTER to feed vim keys.
  • FzfxMarks
    • Press CTRL-J/CTRL-K to move down/up and preview contents.
    • Use V/W/P/R variants (visual selection, cursor word, yank text, resume last).
    • Press ESC to quit, ENTER to open file.
  • FzfxFileExplorer
    • Press CTRL-J/CTRL-K to move down/up and preview contents.
    • Press CTRL-U/CTRL-R to switch between filter/include hidden files mode.
    • Press ALT-L/ALT-H to cd into folder and cd upper folder.
    • Use V/W/P/R variants (visual selection, cursor word, yank text, resume last).
    • Press ESC to quit, ENTER to open file, and open the test/hello world.txt, test/goodbye world/goodbye.lua files.
    • All eza/lsd/ls works.

@@ -47,6 +47,9 @@ end
--- @param renderer fun(text:string):string
--- @return string?
M._colorize_lsp_range = function(line, range, renderer)
if not line then
Copy link
Owner

Choose a reason for hiding this comment

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

hi @stong1994 ,

Can you use str.empty(line) to detect whether a line is nil or empty string?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have identified the issue. It appears there is a problem when executing the vim.lsp.buf_request_sync function(the 'method' param is "callHierarchy/outgoingCalls"), as the response I received is incorrect.

I have generated some logs to help diagnose the problem, and here is the output:
lsp1

The crux of the issue is that the sms_error.go file contains only 24 lines of code. However, the fromRange in the response is pointing to lines 38 and 68, which is not possible given the file's length.

Copy link
Owner

@linrongbin16 linrongbin16 Apr 25, 2024

Choose a reason for hiding this comment

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

hi @stong1994 , thanks to your work!

can you give me a golang repository that can reproduce this issue? so I may also could help fix this issue.

Copy link
Owner

Choose a reason for hiding this comment

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

And, can you take a look at this line:

It's the request body that sent to the lsp server, can you help verify if the request is correct?

This comment was marked as resolved.

Copy link
Owner

Choose a reason for hiding this comment

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

hi @stong1994 ,

Once you had tested these changes, please select the related items in the "Regresion test" check list, to make sure they're working.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hi @linrongbin16
The 'Ctrl+J' and 'Ctrl+K' shortcuts are not working. Could I be missing some configuration settings?

Press CTRL-J/CTRL-K to move down/up and preview contents.

Copy link
Contributor Author

@stong1994 stong1994 Apr 26, 2024

Choose a reason for hiding this comment

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

In my configuration, there are key bindings set for <C-J> and <C-K>. How can I utilize these two shortcuts while using 'fzf'?
image

Copy link
Owner

Choose a reason for hiding this comment

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

I think you can simply skip CTRL-J/CTRL-K keys.

Just see if the outgoing/incoming calls results are expected, without exceptions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, It works well in my macOS.

@linrongbin16
Copy link
Owner

linrongbin16 commented Apr 25, 2024

hi @stong1994 ,
CI lint issue is been fixed, please merge your PR with latest main branch.

@stong1994
Copy link
Contributor Author

hi @stong1994 , CI lint issue is been fixed, please merge your PR with latest main branch.

Should I create a new PR?

@stong1994
Copy link
Contributor Author

hi @stong1994 , CI lint issue is been fixed, please merge your PR with latest main branch.

Should I create a new PR?

Ok, I has merged the latest main branch

Copy link

codecov bot commented Apr 25, 2024

Codecov Report

Attention: Patch coverage is 5.88235% with 16 lines in your changes are missing coverage. Please review.

Project coverage is 79.10%. Comparing base (352906f) to head (f97c593).

Files Patch % Lines
lua/fzfx/cfg/_lsp_locations.lua 5.88% 16 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #687      +/-   ##
==========================================
- Coverage   79.11%   79.10%   -0.01%     
==========================================
  Files          53       53              
  Lines        6296     6298       +2     
==========================================
+ Hits         4981     4982       +1     
- Misses       1315     1316       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

change code style in _lsp_locations.lua
It lacks index check with filelines when calling _colorize_lsp_range in
_render_lsp_hierarchy_line. After that, we don't need to check if line
is empty.
@linrongbin16 linrongbin16 merged commit ba8d3ef into linrongbin16:main Apr 26, 2024
9 checks passed
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.

It reports 'attempt to get length of local line (a nil value)' when I searching outgoing calls sometimes
2 participants