mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-20 00:04:14 +08:00
have valueSelection instead of noValuePreselect, #10582
This commit is contained in:
parent
f15d1e96d1
commit
fda8a1beb4
@ -757,10 +757,13 @@ export class QuickOpenWidget implements IModelProvider {
|
||||
}
|
||||
}
|
||||
|
||||
public setValue(value: string, select: boolean): void {
|
||||
public setValue(value: string, selection?: [number, number]): void {
|
||||
if (this.inputBox) {
|
||||
this.inputBox.value = value;
|
||||
if (select) {
|
||||
if (Array.isArray(selection)) {
|
||||
const [start, end] = selection;
|
||||
this.inputBox.select({ start, end });
|
||||
} else {
|
||||
this.inputBox.select();
|
||||
}
|
||||
}
|
||||
@ -920,4 +923,4 @@ export class QuickOpenWidget implements IModelProvider {
|
||||
this.inputBox.dispose();
|
||||
this.tree.dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -67,9 +67,9 @@ export interface IInputOptions {
|
||||
value?: string;
|
||||
|
||||
/**
|
||||
* whether to automatically select the first value set
|
||||
* the selection of value, default to the whole word
|
||||
*/
|
||||
noValuePreselect?: boolean;
|
||||
valueSelection?: [number, number];
|
||||
|
||||
/**
|
||||
* the text to display underneath the input box
|
||||
|
||||
7
src/vs/vscode.d.ts
vendored
7
src/vs/vscode.d.ts
vendored
@ -1466,9 +1466,12 @@ declare module 'vscode' {
|
||||
value?: string;
|
||||
|
||||
/**
|
||||
* Whether to preselect the given `value` when the box is first shown.
|
||||
* Selection of the prefilled [`value`](#InputBoxOptions.value). Defined as tuple of two number where the
|
||||
* first is the inclusive start index and the second the exclusive end index. When `undefined` the whole
|
||||
* word will be selected, when empty (start equals end) only the cursor will be set,
|
||||
* otherwise the defined range will be selected.
|
||||
*/
|
||||
noValuePreselect?: boolean;
|
||||
valueSelection?: [number, number];
|
||||
|
||||
/**
|
||||
* The text to display underneath the input box.
|
||||
|
||||
@ -82,7 +82,7 @@ export class MainThreadQuickOpen extends MainThreadQuickOpenShape {
|
||||
if (options) {
|
||||
inputOptions.password = options.password;
|
||||
inputOptions.placeHolder = options.placeHolder;
|
||||
inputOptions.noValuePreselect = options.noValuePreselect;
|
||||
inputOptions.valueSelection = options.valueSelection;
|
||||
inputOptions.prompt = options.prompt;
|
||||
inputOptions.value = options.value;
|
||||
inputOptions.ignoreFocusLost = options.ignoreFocusOut;
|
||||
|
||||
@ -65,7 +65,7 @@ interface IWorkbenchQuickOpenConfiguration {
|
||||
|
||||
interface IInternalPickOptions {
|
||||
value?: string;
|
||||
valueSelect?: boolean;
|
||||
valueSelection?: [number, number];
|
||||
placeHolder?: string;
|
||||
inputDecoration?: Severity;
|
||||
password?: boolean;
|
||||
@ -184,7 +184,7 @@ export class QuickOpenController extends Component implements IQuickOpenService
|
||||
password: options.password,
|
||||
placeHolder: options.placeHolder,
|
||||
value: lastValue === void 0 ? options.value : lastValue,
|
||||
valueSelect: options.noValuePreselect ? false : lastValue === void 0,
|
||||
valueSelection: options.valueSelection,
|
||||
inputDecoration: currentDecoration,
|
||||
onDidType: (value) => {
|
||||
lastValue = value;
|
||||
@ -306,7 +306,7 @@ export class QuickOpenController extends Component implements IQuickOpenService
|
||||
|
||||
// Respect input value
|
||||
if (options.value) {
|
||||
this.pickOpenWidget.setValue(options.value, options.valueSelect);
|
||||
this.pickOpenWidget.setValue(options.value, options.valueSelection);
|
||||
}
|
||||
|
||||
// Respect password
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user