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(format): onTypeFormatting position #3472

Merged
merged 1 commit into from
Dec 21, 2021
Merged

Conversation

fannheyward
Copy link
Member

@fannheyward fannheyward commented Nov 18, 2021

neoclide/coc-yaml#51

I think the position used in onTypeFormatting is incorrect, in this fix, coc.nvim always uses the current position to request.

I've tested with rust-analyzer/yaml, works as expected. But this fix introduced an unexpected behavior for TS with tsserver:

if (obj) {
  console.log(obj);
}

Put cursor on if, fire cw, the if will be removed and enter insert mode, tsserver returns onTypeFormatting, after applied the edits, you got:

(obj) {
  console.log(obj);
}

the space after if is deleted too.

The reason:

  1. coc will check InsertEnter and TextChangedI, try to do onTypeFormatting for o action
  2. cw also fires these two event, and tsserver reposed to do formatting

@codecov
Copy link

codecov bot commented Nov 18, 2021

Codecov Report

Merging #3472 (27e7e31) into master (19a630d) will increase coverage by 0.00%.
The diff coverage is 66.66%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #3472   +/-   ##
=======================================
  Coverage   74.73%   74.74%           
=======================================
  Files         191      191           
  Lines       19481    19481           
  Branches     4360     4359    -1     
=======================================
+ Hits        14560    14561    +1     
+ Misses       3156     3154    -2     
- Partials     1765     1766    +1     
Impacted Files Coverage Δ
src/handler/format.ts 88.48% <66.66%> (-2.16%) ⬇️
src/completion/index.ts 71.77% <0.00%> (-0.27%) ⬇️
src/list/ui.ts 92.25% <0.00%> (ø)
src/handler/semanticTokensHighlights/buffer.ts 71.24% <0.00%> (+3.26%) ⬆️

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 19a630d...27e7e31. Read the comment docs.

@chemzqm chemzqm merged commit 077e470 into master Dec 21, 2021
@chemzqm chemzqm deleted the fix/onTypeFormatting branch December 21, 2021 15:25
chemzqm added a commit that referenced this pull request Dec 21, 2021
077e470 fix(format): onTypeFormatting position (#3472)
d5a4ee8 fix(float): check nvim 0.5.1 for zindex
f59f77c fix(source-language): fix range of textEdit
b532597 chore(handler): fix types for openCommand
4913238 chore(doc): add coc.preferences.semanticTokensHighlights
cbd326b feat(typings): export SemanticTokensBuilder (#3357)
2ff2029 fix(api): preserve register content
19446d6 feat(sources): avoid \ as trigger character
69e8750 fix: typos in schema & docs (#3446)
8175e7a fix(highlight.vim): use default value for compose_hlgroup (#3514)
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.

2 participants