@theia/plugin-ext 1.29.0-next.31 → 1.29.0-next.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/common/plugin-api-rpc.d.ts +4 -1
- package/lib/common/plugin-api-rpc.d.ts.map +1 -1
- package/lib/plugin/plugin-context.d.ts.map +1 -1
- package/lib/plugin/plugin-context.js +2 -1
- package/lib/plugin/plugin-context.js.map +1 -1
- package/lib/plugin/quick-open.d.ts +5 -1
- package/lib/plugin/quick-open.d.ts.map +1 -1
- package/lib/plugin/quick-open.js +27 -4
- package/lib/plugin/quick-open.js.map +1 -1
- package/lib/plugin/types-impl.d.ts +5 -0
- package/lib/plugin/types-impl.d.ts.map +1 -1
- package/lib/plugin/types-impl.js +7 -1
- package/lib/plugin/types-impl.js.map +1 -1
- package/package.json +24 -24
- package/src/common/plugin-api-rpc.ts +1 -1
- package/src/plugin/plugin-context.ts +4 -2
- package/src/plugin/quick-open.ts +32 -6
- package/src/plugin/types-impl.ts +6 -0
|
@@ -425,7 +425,7 @@ export type Item = string | theia.QuickPickItem;
|
|
|
425
425
|
|
|
426
426
|
export interface QuickOpenExt {
|
|
427
427
|
$onItemSelected(handle: number): void;
|
|
428
|
-
$validateInput(input: string): Promise<string | null | undefined> | undefined;
|
|
428
|
+
$validateInput(input: string): Promise<string | { content: string; severity: Severity; } | null | undefined> | undefined;
|
|
429
429
|
|
|
430
430
|
$acceptOnDidAccept(sessionId: number): Promise<void>;
|
|
431
431
|
$acceptDidChangeValue(sessionId: number, changedValue: string): Promise<void>;
|
|
@@ -144,7 +144,8 @@ import {
|
|
|
144
144
|
ExtensionMode,
|
|
145
145
|
LinkedEditingRanges,
|
|
146
146
|
LanguageStatusSeverity,
|
|
147
|
-
TextDocumentChangeReason
|
|
147
|
+
TextDocumentChangeReason,
|
|
148
|
+
InputBoxValidationSeverity
|
|
148
149
|
} from './types-impl';
|
|
149
150
|
import { AuthenticationExtImpl } from './authentication-ext';
|
|
150
151
|
import { SymbolKind } from '../common/plugin-api-rpc-model';
|
|
@@ -1025,7 +1026,8 @@ export function createAPIFactory(
|
|
|
1025
1026
|
FileDecoration,
|
|
1026
1027
|
CancellationError,
|
|
1027
1028
|
ExtensionMode,
|
|
1028
|
-
LinkedEditingRanges
|
|
1029
|
+
LinkedEditingRanges,
|
|
1030
|
+
InputBoxValidationSeverity
|
|
1029
1031
|
};
|
|
1030
1032
|
};
|
|
1031
1033
|
}
|
package/src/plugin/quick-open.ts
CHANGED
|
@@ -24,13 +24,14 @@ import { CancellationToken } from '@theia/core/lib/common/cancellation';
|
|
|
24
24
|
import { RPCProtocol } from '../common/rpc-protocol';
|
|
25
25
|
import { Emitter, Event } from '@theia/core/lib/common/event';
|
|
26
26
|
import { DisposableCollection } from '@theia/core/lib/common/disposable';
|
|
27
|
-
import { QuickInputButtons, QuickPickItemKind, ThemeIcon } from './types-impl';
|
|
27
|
+
import { InputBoxValidationSeverity, QuickInputButtons, QuickPickItemKind, ThemeIcon } from './types-impl';
|
|
28
28
|
import { URI } from '@theia/core/shared/vscode-uri';
|
|
29
29
|
import * as path from 'path';
|
|
30
30
|
import { convertToTransferQuickPickItems } from './type-converters';
|
|
31
31
|
import { PluginPackage } from '../common/plugin-protocol';
|
|
32
32
|
import { QuickInputButtonHandle } from '@theia/core/lib/browser';
|
|
33
33
|
import { MaybePromise } from '@theia/core/lib/common/types';
|
|
34
|
+
import Severity from '@theia/monaco-editor-core/esm/vs/base/common/severity';
|
|
34
35
|
|
|
35
36
|
const canceledName = 'Canceled';
|
|
36
37
|
/**
|
|
@@ -65,7 +66,7 @@ export function getDarkIconUri(iconPath: URI | { light: URI; dark: URI; }): URI
|
|
|
65
66
|
export class QuickOpenExtImpl implements QuickOpenExt {
|
|
66
67
|
private proxy: QuickOpenMain;
|
|
67
68
|
private onDidSelectItem: undefined | ((handle: number) => void);
|
|
68
|
-
private validateInputHandler?: (input: string) => MaybePromise<string | null | undefined>;
|
|
69
|
+
private validateInputHandler?: (input: string) => MaybePromise<string | theia.InputBoxValidationMessage | null | undefined>;
|
|
69
70
|
private _sessions = new Map<number, QuickInputExt>(); // Each quickinput will have a number so that we know where to fire events
|
|
70
71
|
private _instances = 0;
|
|
71
72
|
|
|
@@ -155,11 +156,36 @@ export class QuickOpenExtImpl implements QuickOpenExt {
|
|
|
155
156
|
return this.proxy.$showInputBox(options, typeof this.validateInputHandler === 'function');
|
|
156
157
|
}
|
|
157
158
|
|
|
158
|
-
$validateInput(input: string): Promise<string |
|
|
159
|
-
if (this.validateInputHandler) {
|
|
160
|
-
return
|
|
159
|
+
async $validateInput(input: string): Promise<string | { content: string; severity: Severity; } | null | undefined> {
|
|
160
|
+
if (!this.validateInputHandler) {
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
const result = await this.validateInputHandler(input);
|
|
165
|
+
if (!result || typeof result === 'string') {
|
|
166
|
+
return result;
|
|
161
167
|
}
|
|
162
|
-
|
|
168
|
+
|
|
169
|
+
let severity: Severity;
|
|
170
|
+
switch (result.severity) {
|
|
171
|
+
case InputBoxValidationSeverity.Info:
|
|
172
|
+
severity = Severity.Info;
|
|
173
|
+
break;
|
|
174
|
+
case InputBoxValidationSeverity.Warning:
|
|
175
|
+
severity = Severity.Warning;
|
|
176
|
+
break;
|
|
177
|
+
case InputBoxValidationSeverity.Error:
|
|
178
|
+
severity = Severity.Error;
|
|
179
|
+
break;
|
|
180
|
+
default:
|
|
181
|
+
severity = result.message ? Severity.Error : Severity.Ignore;
|
|
182
|
+
break;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
return {
|
|
186
|
+
content: result.message,
|
|
187
|
+
severity
|
|
188
|
+
};
|
|
163
189
|
}
|
|
164
190
|
|
|
165
191
|
// ---- QuickInput
|