Comments (8)
Yes, it used to. However, I found it hard to remember when to use left/right vs up/down, and there were conflicts with existing shortcuts (expand/shrink selection). Therefore I've changed most move actions to up/down and removed left/right. In cases where there is a conflict (here: move statement vs move if branch), the less common action (here: move if branch) is only accessible through the move context menu (or the refactor context menu). You can access it with Ctrl+Alt+m
on Windows.
It seems you have custom shortcuts set up tho? Maybe there is a good way to provide code action kinds that would work for such custom setups 🤔
from js-assistant.
It seems you have custom shortcuts set up tho? Maybe there is a good way to provide code action kinds that would work for such custom setups 🤔
Just removed them.
Therefore I've changed most move actions to up/down and removed left/right.
I like that!
In cases where there is a conflict (here: move statement vs move if branch), the less common action (here: move if branch) is only accessible through the move context menu (or the refactor context menu). You can access it with Ctrl+Alt+m on Windows.
I would use anchors to distinguish between these cases.
E.g. when the cursor is no the else
or if
, it should swap branches. Otherwise the statement.
from js-assistant.
I would use anchors to distinguish between these cases. E.g. when the cursor is no the
else
orif
, it should swap branches. Otherwise the statement.
I was thinking the same and first prototyped enabling move up/down from the else
keyword. That leads to issues with the inverse action, so really the branch switch also needs to be activated on the if
as well. However, this conflicts with move statement, because you can move all other statements at the beginning of the statement. I'm sure there are ways around it with different activation ranges (i.e. cursor positions / selections), but they are not necessarily obvious or easy to learn imo.
My current take is that learnability is one of the main challenges with the JavaScript Assistant, and I want to make it easier by having fairly simple systems for common cases (move up/down) and then context menus for different intents (e.g. move, extract, convert) with more specialized actions. While different activation ranges are part of it, I try not to make them too complex - otherwise it gets hard to find/activate the right code assist.
I'm open to changing this of course if I get more feedback or additional functionality like move in / move out requires it.
from js-assistant.
Fair points. What about using the if/else-if condition as anchor?
from js-assistant.
That could work - re-opening the issue. The one conflict I could see is with Move expression in homogenous condition (a && |b && c -> |b && a && c) (note: overlap/replacement of 'flip operator')
, so I'll wait until that is available and then I'll experiment to see how activating on the condition would work.
from js-assistant.
Hmm, it is a bummer that this still does not work:
I would say reordering is the most valuable feature that p42 offers, but it often does not work :(
So I have to do the reordering of the if branches manually again...
from js-assistant.
Hey thanks for bringing this to my attention. The functionality is there, but it is currently hidden in the refactor menu. I'll look into a better key mapping this week, now that things have settled a bit around the shortcuts and the code action menu.
My current thinking on the anchors:
- use the content of the condition as anchor for moving if/else blocks -- other anchors are used form moving statements
- for moving parts of
||
conditions, require selection (can easily be smart selected) to enable move shortcuts (will come later)
from js-assistant.
Check out v1.157.1
- the move if-else up/down can now be triggered on the condition. Outside of the condition, a regular move statement is triggered (to enable both operations to be easily accessible).
from js-assistant.
Related Issues (20)
- Please return the "Move up/down" commands HOT 6
- Issue with convert-if-else-to-conditional-expression HOT 1
- Wrong code generated by "Convert if-else into conditional expression" using p42 VSCode plugin v1.163.1 HOT 1
- Cannot pass the payment process on the select country window HOT 3
- Remove unused imports/class methods/variables HOT 2
- Unsafe suggestions HOT 2
- Support for Svelte components HOT 1
- Insert console.log for variable HOT 2
- Command Palette integration HOT 2
- Convert to destructuring assignment
- Create new file when extract React component
- convert-function-to-object-method potentially unsafe
- p42.ai is down HOT 2
- Refactor Idea: extract functions inside functions
- is the site https://p42.ai/ down? HOT 1
- Make P42 settings apply to remote and workspace, honour jsconfig/tsconfig settings
- provide setting to set default suggestion level
- provide setting to disable the codeActionsOnSave HOT 2
- TypeScript's built-in "inline variable" refactoring should be declared as an overlapping code assist HOT 1
- Feature Request: transform object property assignment to `defineProperty`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from js-assistant.