Code Monkey home page Code Monkey logo

Comments (10)

lgrammel avatar lgrammel commented on July 20, 2024 3

@OliverJAsh I've released v1.118.0 which allows you to choose what code assists are shown when there is an overlap:

image

I've chosen the opt-out solution, i.e. P42 deactivates overlapping TS code actions by default, to provide a good user experience out of the box for most users.

from js-assistant.

lgrammel avatar lgrammel commented on July 20, 2024 2

@OliverJAsh I've just released v1.115.1. Starting with that version, you can assign keyboard shortcuts to the matching code actions from the JavaScript Assistant:

  {
    "key": "shift+alt+r",
    "command": "editor.action.codeAction",
    "args": { "kind": "refactor.convert.p42.remove-braces-from-arrow-function" }
  },
  {
    "key": "shift+alt+a",
    "command": "editor.action.codeAction",
    "args": { "kind": "refactor.convert.p42.add-braces-to-arrow-function" }
  },

Adding a setting to enable/disable the overlapping typescript refactorings and making this an opt-in experience (because it can affect the current setup) will come in a future release.

Thanks for reporting the issue!

from js-assistant.

lgrammel avatar lgrammel commented on July 20, 2024

There is some overlap between the refactorings that P42 offers and the refactorings that are built into TypeScript.

What UX would you ideally expect here?

from js-assistant.

hediet avatar hediet commented on July 20, 2024

You can implement a typescript language service plugin to disable the TypeScript refactoring.

I would expect to not suggest the same refactoring twice.

from js-assistant.

lgrammel avatar lgrammel commented on July 20, 2024

I agree, seeing the same refactoring twice is not great. I'm a bit hesitant to disable functionality provided by TS or to affect their language service from the P42 extension (which can cause stability issues, especially when they upgrade to different versions).

Maybe I'll implement it as a separate open source companion extension where you can selectively disable some TypeScript refactorings. Would this be an option for you?

from js-assistant.

hediet avatar hediet commented on July 20, 2024

I would ship it with the same extension. You can still add settings to disable it.

The default experience should be a good one, seeing the same refactoring twice is not good.

If you can't or don't want to disable the TypeScript "Add braces to arrow function", you could disable P42's refactoring "Add {...} to arrow function" instead.

from js-assistant.

lgrammel avatar lgrammel commented on July 20, 2024

I'll think about how to best do this, maybe there are other options as well. Disabling the P42 refactoring is safer, it might be a preferrable default option.

from js-assistant.

lgrammel avatar lgrammel commented on July 20, 2024

Fixed in v1.112.3 for add / remove braces to arrow functions. The refactoring from the typescript language service is now hidden, except on web (because typescript does not support plugins on web yet). Thanks for the bug report!

from js-assistant.

OliverJAsh avatar OliverJAsh commented on July 20, 2024

The refactoring from the typescript language service is now hidden

Is there a way to disable this? I have the following keyboard shortcuts setup to use these built-in refactorings and they no longer work:

    {
        "key": "shift+alt+r",
        "command": "editor.action.codeAction",
        "args": { "kind": "refactor.rewrite.arrow.braces.remove" }
    },
    {
        "key": "shift+alt+a",
        "command": "editor.action.codeAction",
        "args": { "kind": "refactor.rewrite.arrow.braces.add" }
    },

image

Alternatively, is it possible to update my keyboard shortcuts to use the refactorings provided by this extension?

from js-assistant.

lgrammel avatar lgrammel commented on July 20, 2024

@OliverJAsh thanks for the bug report! Right now, both options are unfortunately not possible. I'll look into adding a setting for disabling the ts code action hiding, and also expose each refactoring with a specific kind, so it can be mapped to a shortcut.

from js-assistant.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.