Commit Graph

84 Commits

Author SHA1 Message Date
Johannes
a5ab2536d9 log when an editor action doesn't run because of enablement 2023-05-26 15:34:32 +02:00
Alex Dima
8ab52fa9e8 Add a mechanism to instantiate editor features and adopt it for SemanticColoringFeature 2023-02-17 12:05:30 +01:00
Martin Aeschlimann
d4237bd8d5 merge ThemeIcon and CSSIcon (#171279) 2023-01-13 20:15:16 +01:00
Johannes Rieken
34c9b3f400 use var args and spread for editor command extra arguments all the way (#169532)
(actually) fixes https://github.com/microsoft/vscode/issues/167564
2022-12-19 14:07:33 +01:00
Matt Bierner
14cd3149a8 Always require passing in explicit instantiation for editor contribution (#167458)
Always require passing in explicit instantiation for editor contributions
2022-11-28 21:46:37 +00:00
Alexandru Dima
8a894eb038 Adopt idle instantiation in editor contributions and use explicit syntax in the ones which need to be eager (#166966)
* Adopt idle instantiation in editor contributions and use explicit syntax in the ones which need to be eager

* Make sure all editor contributions are eventually instantiated

* Introduce multiple values for `EditorContributionInstantiation` and adopt them
2022-11-25 16:52:36 +01:00
Matt Bierner
e4b6657f93 Allow editor contributions to mark themselves as instantiated on idle (#166065)
* Allow editor contributions to mark themselves as instantiated on idle

For #164171

Editor contributions are currently created eagerly when editors are instantiated. In many cases however, the contribution is not needed instantly. A contributed widget for instance may only be shown after a user action, while some info that shows in the editor also does not need to be shown instantly as soon as the editor opens

Contributions like those can be lazily created, but actually adopting lazy instantiation for individual contributions is a lot of work

Instead this PR lets editor contributions tell VS Code that the entire contribution does not need to be eagerly created and can be instead on idle

With `EditorContributionInstantiation.Idle`, the contribution will be created:

- Either when the editor is idle
- Or when the contribution is explicitly requested.

Idle contributions cannot participate in saving and restoring of editor view states

This change will make it easier to lazily create editor contributions and also lets us remove existing code that was added to make individual editor contributions lazy

* Mark as optional

* Addressing comments

* IdleValue should throw again if there's ctor error
2022-11-16 01:07:24 -08:00
Alexandru Dima
f195c00f1e Add API to register global actions, commands, or keybinding rules (#163859) 2022-10-18 09:55:00 +02:00
Matt Bierner
4c53499e8a Revert "Make returned editor contributions an iterable instead of an array (#163309)" (#163689)
This reverts commit 90054ae22f.
2022-10-14 13:56:47 -07:00
Matt Bierner
01de02ba72 Also make getEditorActions return an iterable instead of an array (#163320)
This lets us avoid an extra `.slice(0)` when returning the actions
2022-10-11 10:22:38 -07:00
Matt Bierner
90054ae22f Make returned editor contributions an iterable instead of an array (#163309)
This lets us avoid having to call `.slice(0)` for the contributions
2022-10-11 18:35:32 +02:00
Alexandru Dima
0945ef6e35 Add comments to properties of telemetry events (#155584) 2022-07-19 08:49:19 -04:00
Logan Ramos
d937389358 Add owners to all telemetry events (#150296) 2022-05-24 14:58:08 -04:00
Johannes Rieken
4a130c40ed enable @typescript-eslint/member-delimiter-style, https://github.com/microsoft/vscode/issues/140391 2022-02-02 14:35:33 +01:00
Matt Bierner
161710f9ab Use variadic version of IConstructor signature
Instead of having unique versions of `IConstructor` for various argument counts, instead take the expected argument types as a tuple. This cleans up the code a little and lets us pass in as many arg types as we wish
2022-02-01 17:05:19 -08:00
Johannes Rieken
05a6debf18 replace SelectionRangeRegistry with service property 2022-01-31 14:07:00 +01:00
Johannes Rieken
5dc873f464 move ReferenceProviderRegistry into new ILanguageFeaturesService service 2022-01-28 18:19:52 +01:00
Alex Dima
c8e2fd7bae Renames 2021-12-29 00:37:35 +01:00
Alex Dima
7663e88b07 Fix treeshaking problems 2021-12-06 19:18:30 +01:00
Alex Dima
2fc1dac229 ICodeEditor.getContribution can return null 2021-12-06 17:57:09 +01:00
Alexandru Dima
cdfee23440 Rename KeyCode enum members to more closely resemble ScanCode enum members 2021-10-19 15:38:09 +02:00
Alex Dima
6971f1dc3d Add more tracing for commands with multiple implementations 2021-08-20 16:07:51 +02:00
Alex Dima
1f76da28f6 Fixes microsoft/monaco-editor#2355 2021-05-12 16:59:03 +02:00
Alex Dima
95150d4443 Remove duplicated editor actions 2021-05-07 13:12:19 +02:00
Alex Dima
afca44535d Add a trace statement to be able to track down which implementation handles a MultiCommand 2021-03-23 12:55:13 +01:00
Alex Dima
60222b710d Align MultiEditorAction with MultiCommand 2021-03-05 16:53:25 +01:00
Johannes Rieken
443c0db7c9 modernize vscode.executeColorPresentationProvider-command 2020-11-13 11:56:27 +01:00
Johannes Rieken
74703883e3 modernize vscode.executeSignatureHelpProvider-command 2020-11-13 11:56:27 +01:00
SteVen Batten
979f9f73b3 fixes #991 2020-10-16 16:16:56 -07:00
Alex Dima
443508c4c9 Add test for #107739 2020-10-06 22:18:30 +02:00
rebornix
7a34ec55d9 fix #102441. 2020-07-30 18:29:52 -07:00
Johannes Rieken
6a9f98bc86 debt - migrate rename api command 2020-07-16 11:51:36 +02:00
Johannes Rieken
97fc588e65 use Action2 for call hierarchy title commands 2020-07-11 11:48:43 +02:00
Matt Bierner
97650fb8f3 Let core command such as undo/redo be overridden by webviews and notebooks (#98288)
* Add CoreCommandService

For #90110

This change introduce a new service (`ICoreCommandService`) that lets high levels parts of the editor (such as webviews) hook into core commands such as undo and redo that are fired from the editor menus.

## Why is this needed?
To implement undo/redo in custom editors / webviews, we currently register special commands (`editor.action.customEditor.undo` and `editor.action.customEditor.redo`). This is not ideal since it means that users have to update multiple commands if they wish to rebind undo/redo

These custom command also are not invoked when the user goes to the `edit` menu and select `undo` or `redo`. Instead, the edit menu always calls the core `UndoCommand`

We cannot make `UndoCommand` know about custom editors because it lives in `base`

## What this change does?
This change adds a new `ICoreCommandService` that lets higher level parts of the editor override core commands such as undo and redo. We use a similar approach in the `IOpenerService`.

Right now only `undo` and `redo` are overridable. If this approach looks ok, we could also extend it to `copy`, `paste`, `cut`, and `select all`

* Add docs and clean up types

* Rework implementation

Switch from using a command service to having each command state if is overrideable or not.

This hooks up overrides for:

- Undo/redo
- cut/copy/paste

for webviews, custom editors, and notebooks

* Add ProxyCommand so that multiple registered commands can share a single implementation

* Fix compilation & missing file being referenced

* Introduce and adopt MultiCommand for Undo

* Adopt MultiCommand for Redo and SelectAll

* Adopt MultiCommand for Cut, Copy and Paste

Co-authored-by: Alex Dima <alexdima@microsoft.com>
2020-06-19 16:54:22 -07:00
Alex Dima
5b28babfb8 Fixes #96809: Add sticky argument and have it be false by default 2020-06-04 15:39:10 +02:00
Johannes Rieken
27db1bebd8 make goto error widget action a menu and contribute navigation commands to it, #96708 2020-05-04 15:32:06 +02:00
Johannes Rieken
fd487a7ed6 fix https://github.com/microsoft/vscode/issues/91852 2020-03-03 11:02:23 +01:00
Alex Dima
0c29fa309f Distinguish context key factory from type 2020-02-28 13:52:13 +01:00
Johannes Rieken
783970456b debt - migrate more language api commands onto new format 2019-12-11 16:39:57 +01:00
Matt Bierner
2d0b37f031 Strict function work
#81574
2019-11-22 15:18:01 -08:00
Johannes Rieken
a78363abd0 fix missing entries from global go menu 2019-11-22 12:33:29 +01:00
Johannes Rieken
724b433e2c simplify how editor commands/actions register menu entries 2019-11-21 12:36:16 +01:00
Alexandru Dima
ca81ca47db More changes for #81574 2019-11-15 18:02:35 +01:00
Matt Bierner
a77da1b1d8 For #81574 (#84669)
Our code currently uses the `IConstructorSignature` types in a two main ways:

- As argument types in functions that take a service constructor.
- As return types or property types when we expose a service constructor in the API

This first usage is not valid with strict function types. The reason is that the `IConstructorSignature` types takes a rest array of `...services: BrandedService[]` , while the concrete constructors you pass in use actual services. With strict function types, you cannot convert the concrete constructor type to an `IConstructorSignature` because this would drop important type information that the implementation needs. As an example

```ts
class Foo {
    constructor(@ILogService service: ILogService) {}
}

registerFoo(Foo);

// The type of `ctor` inlines `IConstructorSignature0`
function registerFoo(ctor: { new(....serivces: BrandedService[]): Foo}) {
   // When registerFoo(Foo) is called, the implementation here would need to know that
   // ctor needs to be invoked with exactly one `ILogService`. However the type of `IConstructorSignature0`
   // does not express this. Strict function types therefore disallows this conversion
}
```

To fix this, I have converted a few places were we were taking `IConstructorSignature` arguments so that they preserve the full type of the constructor. This fixed over half of our 900 strict function type errors. Unfortunatly I can not figure out a more elegant way to express this besides inlining the types

However, even after this change, we still need to figure out how to deal with:

- Places in the code where `IConstructorSignature` is exposed as a return type or object property
- How to deal with all of our descriptor types (such as `SyncActionDescriptor`)
2019-11-13 14:42:42 -08:00
Alexandru Dima
620a5e80a0 Fixes #82603: Remove SelectionClipboardController from web 2019-10-17 11:37:10 +02:00
Alexandru Dima
3b16cc4622 Register editor contributions with their ID (#82603) 2019-10-17 11:26:31 +02:00
Alex Dima
fb043c53c6 Add DiffEditor contributions 2019-10-12 01:39:16 +02:00
Matt Bierner
4c4edcefeb Fixing more TS 3.7 related compile errors
- Import aliasing symbol in file
- Missing function calls in conditional
- Missing return statement
2019-10-07 11:04:31 -07:00
Matt Bierner
42b59f5017 Fix strict function type error for registerLanguageCommand
#81574
2019-09-27 17:58:30 -07:00
Logan Ramos
9f5fffe73e More strongly typed telemetry events (#77658)
* More strongly typed events

* Fixed typo
2019-07-24 15:02:16 -07:00