mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-03-20 20:10:11 -04:00
Merge from vscode a5cf1da01d5db3d2557132be8d30f89c38019f6c (#8525)
* Merge from vscode a5cf1da01d5db3d2557132be8d30f89c38019f6c * remove files we don't want * fix hygiene * update distro * update distro * fix hygiene * fix strict nulls * distro * distro * fix tests * fix tests * add another edit * fix viewlet icon * fix azure dialog * fix some padding * fix more padding issues
This commit is contained in:
@@ -10,6 +10,7 @@ import { IKeyboardEvent } from 'vs/base/browser/keyboardEvent';
|
||||
import { IMouseEvent } from 'vs/base/browser/mouseEvent';
|
||||
import { IContextViewProvider } from 'vs/base/browser/ui/contextview/contextview';
|
||||
import { alert as alertFn } from 'vs/base/browser/ui/aria/aria';
|
||||
import { Checkbox } from 'vs/base/browser/ui/checkbox/checkbox';
|
||||
import { FindInput, IFindInputStyles } from 'vs/base/browser/ui/findinput/findInput';
|
||||
import { IMessage as InputBoxMessage } from 'vs/base/browser/ui/inputbox/inputBox';
|
||||
import { ReplaceInput } from 'vs/base/browser/ui/findinput/replaceInput';
|
||||
@@ -120,7 +121,7 @@ export class FindWidget extends Widget implements IOverlayWidget, IHorizontalSas
|
||||
private _matchesCount!: HTMLElement;
|
||||
private _prevBtn!: SimpleButton;
|
||||
private _nextBtn!: SimpleButton;
|
||||
private _toggleSelectionFind!: SimpleCheckbox;
|
||||
private _toggleSelectionFind!: Checkbox;
|
||||
private _closeBtn!: SimpleButton;
|
||||
private _replaceBtn!: SimpleButton;
|
||||
private _replaceAllBtn!: SimpleButton;
|
||||
@@ -290,12 +291,6 @@ export class FindWidget extends Widget implements IOverlayWidget, IHorizontalSas
|
||||
|
||||
private _onStateChanged(e: FindReplaceStateChangedEvent): void {
|
||||
if (e.searchString) {
|
||||
if (this._state.searchString.indexOf('\n') >= 0) {
|
||||
dom.addClass(this._domNode, 'multipleline');
|
||||
} else {
|
||||
dom.removeClass(this._domNode, 'multipleline');
|
||||
}
|
||||
|
||||
try {
|
||||
this._ignoreChangeEvent = true;
|
||||
this._findInput.setValue(this._state.searchString);
|
||||
@@ -436,7 +431,11 @@ export class FindWidget extends Widget implements IOverlayWidget, IHorizontalSas
|
||||
let isSelection = selection ? (selection.startLineNumber !== selection.endLineNumber || selection.startColumn !== selection.endColumn) : false;
|
||||
let isChecked = this._toggleSelectionFind.checked;
|
||||
|
||||
this._toggleSelectionFind.setEnabled(this._isVisible && (isChecked || isSelection));
|
||||
if (this._isVisible && (isChecked || isSelection)) {
|
||||
this._toggleSelectionFind.enable();
|
||||
} else {
|
||||
this._toggleSelectionFind.disable();
|
||||
}
|
||||
}
|
||||
|
||||
private _updateButtons(): void {
|
||||
@@ -466,12 +465,23 @@ export class FindWidget extends Widget implements IOverlayWidget, IHorizontalSas
|
||||
this._isVisible = true;
|
||||
|
||||
const selection = this._codeEditor.getSelection();
|
||||
const isSelection = selection ? (selection.startLineNumber !== selection.endLineNumber || selection.startColumn !== selection.endColumn) : false;
|
||||
if (isSelection && this._codeEditor.getOption(EditorOption.find).autoFindInSelection) {
|
||||
this._toggleSelectionFind.checked = true;
|
||||
} else {
|
||||
this._toggleSelectionFind.checked = false;
|
||||
|
||||
switch (this._codeEditor.getOption(EditorOption.find).autoFindInSelection) {
|
||||
case 'always':
|
||||
this._toggleSelectionFind.checked = true;
|
||||
break;
|
||||
case 'never':
|
||||
this._toggleSelectionFind.checked = false;
|
||||
break;
|
||||
case 'multiline':
|
||||
const isSelectionMultipleLine = !!selection && selection.startLineNumber !== selection.endLineNumber;
|
||||
this._toggleSelectionFind.checked = isSelectionMultipleLine;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
this._tryUpdateWidgetWidth();
|
||||
this._updateButtons();
|
||||
|
||||
@@ -636,6 +646,7 @@ export class FindWidget extends Widget implements IOverlayWidget, IHorizontalSas
|
||||
};
|
||||
this._findInput.style(inputStyles);
|
||||
this._replaceInput.style(inputStyles);
|
||||
this._toggleSelectionFind.style(inputStyles);
|
||||
}
|
||||
|
||||
private _tryUpdateWidgetWidth() {
|
||||
@@ -981,26 +992,30 @@ export class FindWidget extends Widget implements IOverlayWidget, IHorizontalSas
|
||||
actionsContainer.appendChild(this._nextBtn.domNode);
|
||||
|
||||
// Toggle selection button
|
||||
this._toggleSelectionFind = this._register(new SimpleCheckbox({
|
||||
parent: actionsContainer,
|
||||
this._toggleSelectionFind = this._register(new Checkbox({
|
||||
actionClassName: 'codicon codicon-selection',
|
||||
title: NLS_TOGGLE_SELECTION_FIND_TITLE + this._keybindingLabelFor(FIND_IDS.ToggleSearchScopeCommand),
|
||||
onChange: () => {
|
||||
if (this._toggleSelectionFind.checked) {
|
||||
if (this._codeEditor.hasModel()) {
|
||||
let selection = this._codeEditor.getSelection();
|
||||
if (selection.endColumn === 1 && selection.endLineNumber > selection.startLineNumber) {
|
||||
selection = selection.setEndPosition(selection.endLineNumber - 1, this._codeEditor.getModel().getLineMaxColumn(selection.endLineNumber - 1));
|
||||
}
|
||||
if (!selection.isEmpty()) {
|
||||
this._state.change({ searchScope: selection }, true);
|
||||
}
|
||||
isChecked: false
|
||||
}));
|
||||
|
||||
this._register(this._toggleSelectionFind.onChange(() => {
|
||||
if (this._toggleSelectionFind.checked) {
|
||||
if (this._codeEditor.hasModel()) {
|
||||
let selection = this._codeEditor.getSelection();
|
||||
if (selection.endColumn === 1 && selection.endLineNumber > selection.startLineNumber) {
|
||||
selection = selection.setEndPosition(selection.endLineNumber - 1, this._codeEditor.getModel().getLineMaxColumn(selection.endLineNumber - 1));
|
||||
}
|
||||
if (!selection.isEmpty()) {
|
||||
this._state.change({ searchScope: selection }, true);
|
||||
}
|
||||
} else {
|
||||
this._state.change({ searchScope: null }, true);
|
||||
}
|
||||
} else {
|
||||
this._state.change({ searchScope: null }, true);
|
||||
}
|
||||
}));
|
||||
|
||||
actionsContainer.appendChild(this._toggleSelectionFind.domNode);
|
||||
|
||||
// Close button
|
||||
this._closeBtn = this._register(new SimpleButton({
|
||||
label: NLS_CLOSE_BTN_LABEL + this._keybindingLabelFor(FIND_IDS.CloseFindWidgetCommand),
|
||||
@@ -1054,7 +1069,7 @@ export class FindWidget extends Widget implements IOverlayWidget, IHorizontalSas
|
||||
this._prevBtn.focus();
|
||||
} else if (this._nextBtn.isEnabled()) {
|
||||
this._nextBtn.focus();
|
||||
} else if (this._toggleSelectionFind.isEnabled()) {
|
||||
} else if (this._toggleSelectionFind.enabled) {
|
||||
this._toggleSelectionFind.focus();
|
||||
} else if (this._closeBtn.isEnabled()) {
|
||||
this._closeBtn.focus();
|
||||
@@ -1200,91 +1215,6 @@ export class FindWidget extends Widget implements IOverlayWidget, IHorizontalSas
|
||||
}
|
||||
}
|
||||
|
||||
interface ISimpleCheckboxOpts {
|
||||
readonly parent: HTMLElement;
|
||||
readonly title: string;
|
||||
readonly onChange: () => void;
|
||||
}
|
||||
|
||||
class SimpleCheckbox extends Widget {
|
||||
|
||||
private static _COUNTER = 0;
|
||||
|
||||
private readonly _opts: ISimpleCheckboxOpts;
|
||||
private readonly _domNode: HTMLElement;
|
||||
private readonly _checkbox: HTMLInputElement;
|
||||
private readonly _label: HTMLLabelElement;
|
||||
|
||||
constructor(opts: ISimpleCheckboxOpts) {
|
||||
super();
|
||||
this._opts = opts;
|
||||
|
||||
this._domNode = document.createElement('div');
|
||||
this._domNode.className = 'monaco-checkbox';
|
||||
this._domNode.title = this._opts.title;
|
||||
this._domNode.tabIndex = 0;
|
||||
|
||||
this._checkbox = document.createElement('input');
|
||||
this._checkbox.type = 'checkbox';
|
||||
this._checkbox.className = 'checkbox';
|
||||
this._checkbox.id = 'checkbox-' + SimpleCheckbox._COUNTER++;
|
||||
this._checkbox.tabIndex = -1;
|
||||
|
||||
this._label = document.createElement('label');
|
||||
this._label.className = 'codicon codicon-selection';
|
||||
// Connect the label and the checkbox. Checkbox will get checked when the label receives a click.
|
||||
this._label.htmlFor = this._checkbox.id;
|
||||
this._label.tabIndex = -1;
|
||||
|
||||
this._domNode.appendChild(this._checkbox);
|
||||
this._domNode.appendChild(this._label);
|
||||
|
||||
this._opts.parent.appendChild(this._domNode);
|
||||
|
||||
this.onchange(this._checkbox, () => {
|
||||
this._opts.onChange();
|
||||
});
|
||||
}
|
||||
|
||||
public get domNode(): HTMLElement {
|
||||
return this._domNode;
|
||||
}
|
||||
|
||||
public isEnabled(): boolean {
|
||||
return (this._domNode.tabIndex >= 0);
|
||||
}
|
||||
|
||||
public get checked(): boolean {
|
||||
return this._checkbox.checked;
|
||||
}
|
||||
|
||||
public set checked(newValue: boolean) {
|
||||
this._checkbox.checked = newValue;
|
||||
}
|
||||
|
||||
public focus(): void {
|
||||
this._domNode.focus();
|
||||
}
|
||||
|
||||
private enable(): void {
|
||||
this._checkbox.removeAttribute('disabled');
|
||||
}
|
||||
|
||||
private disable(): void {
|
||||
this._checkbox.disabled = true;
|
||||
}
|
||||
|
||||
public setEnabled(enabled: boolean): void {
|
||||
if (enabled) {
|
||||
this.enable();
|
||||
this.domNode.tabIndex = 0;
|
||||
} else {
|
||||
this.disable();
|
||||
this.domNode.tabIndex = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export interface ISimpleButtonOpts {
|
||||
readonly label: string;
|
||||
readonly className: string;
|
||||
@@ -1390,7 +1320,7 @@ registerThemingParticipant((theme, collector) => {
|
||||
|
||||
const hcBorder = theme.getColor(contrastBorder);
|
||||
if (hcBorder) {
|
||||
collector.addRule(`.monaco-editor .find-widget { border: 2px solid ${hcBorder}; }`);
|
||||
collector.addRule(`.monaco-editor .find-widget { border: 1px solid ${hcBorder}; }`);
|
||||
}
|
||||
|
||||
const foreground = theme.getColor(editorWidgetForeground);
|
||||
|
||||
Reference in New Issue
Block a user