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

add or remove braces to arrow function #309

Closed
linde12 opened this issue Aug 30, 2021 · 5 comments
Closed

add or remove braces to arrow function #309

linde12 opened this issue Aug 30, 2021 · 5 comments

Comments

@linde12
Copy link

linde12 commented Aug 30, 2021

I cant get this feature to work (or maybe it needs implementation in coc-tsserver?) It should be available in typescript: microsoft/TypeScript#23423

The only option i get is to create a function statement. I want to be able to quickly add braces around an arrow function, e.g. if i have something like:

<button onClick={() => setCount(count + 1)}>
  Click me!
</button>

Then i want to be able to quickly convert that arrow function to a block as such:

<button onClick={() => {
  return setCount(count + 1)
}}>
  Click me!
</button>

image

vim version: NVIM v0.5.0
node version: v14.17.2
coc.nvim version: 0.0.80-3086844413
coc.nvim directory: /home/linde/.vim/plugged/coc.nvim
term: alacritty
platform: linux

@fannheyward
Copy link
Member

In my tests, put your cursor on => and fire <Plug>(coc-codeaction-cursor), you will get:

截屏2021-08-31 上午9 52 35

After the first action executed:

截屏2021-08-31 上午9 53 20

@fannheyward
Copy link
Member

What's your coc-tsserver version? I'm using 1.8.6.

@chemzqm
Copy link
Member

chemzqm commented Aug 31, 2021

@chemzqm chemzqm closed this as completed Aug 31, 2021
@linde12
Copy link
Author

linde12 commented Aug 31, 2021

In my tests, put your cursor on => and fire <Plug>(coc-codeaction-cursor), you will get:

截屏2021-08-31 上午9 52 35

After the first action executed:

截屏2021-08-31 上午9 53 20

Thank you! I was using coc-codeaction, i didn't know of coc-codeaction-cursor 😃

@chemzqm
Copy link
Member

chemzqm commented Sep 1, 2021

coc-codeaction-cursor is recommended

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants