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

Support format on paste #13945

Closed
jrieken opened this issue Oct 18, 2016 · 10 comments
Closed

Support format on paste #13945

jrieken opened this issue Oct 18, 2016 · 10 comments
Assignees
Labels
feature-request Request for new features or functionality formatting Source formatter issues
Milestone

Comments

@jrieken
Copy link
Member

jrieken commented Oct 18, 2016

We should add support for format on paste. Idea is to simply invoke selection formatters when paste has happened.

@jrieken jrieken added feature-request Request for new features or functionality formatting Source formatter issues labels Oct 18, 2016
@jrieken jrieken self-assigned this Oct 18, 2016
@jrieken
Copy link
Member Author

jrieken commented Oct 18, 2016

related to #4039

@coreh
Copy link

coreh commented Jan 6, 2017

On OS X, could this be mapped to "Paste and Match Style"? ⌥⇧⌘V

@jrieken
Copy link
Member Author

jrieken commented Jan 12, 2017

@rebornix Do you want me to get started on this? We already have the concept for formatting a range so, my plan is to do the following:

  1. detect paste range
  2. invoke range formatter

@rebornix
Copy link
Member

@jrieken previously I implemented it in another way but we think that's not good, I'll follow your suggestions and do this again :)

alexdima added a commit that referenced this issue Jan 19, 2017
@jrieken jrieken mentioned this issue Jan 23, 2017
2 tasks
@OliverJAsh
Copy link
Contributor

Like @coreh I'm also interested to know whether this can be a command separate from paste so the user can choose which to use on demand (i.e. one keyboard shortcut for paste, one for paste + format)

@jakearchibald
Copy link

Firstly, thanks for adding this, it's been the one feature I really missed from Sublime Text.

Having a play around with it, it seems to create two entries into undo history per single paste. I can't decide if that's a bug or a feature.

@rebornix
Copy link
Member

rebornix commented Feb 6, 2017

@jakearchibald It's not a bug but I can't say it's a feature :( The behavior is consistent with FormatOnType or Save as we hook the formatting handler to Type/Save/Paste event, which makes it two entries in undo/redo stack. cc @jrieken

@jakearchibald
Copy link

Another "is this a bug or not?"

If I paste:

self.addEventListener('fetch', function(event) {
  event.respondWith(
    promiseAny([
      caches.match(event.request),
      fetch(event.request)
    ])
  );
});

It adds a space between function and (event). I didn't expect it to do that.

@rebornix
Copy link
Member

rebornix commented Feb 8, 2017

@mjbvz I suppose what @jakearchibald mentioned is actually TypeScript formatter's default behavior, right?

@mjbvz
Copy link
Collaborator

mjbvz commented Feb 8, 2017

Yes, you can disable this formatting using "javascript.format.insertSpaceAfterFunctionKeywordForAnonymousFunctions": false or "typescript.format.insertSpaceAfterFunctionKeywordForAnonymousFunctions": false

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature-request Request for new features or functionality formatting Source formatter issues
Projects
None yet
Development

No branches or pull requests

6 participants