提交 2986851a 编写于 作者: B Benjamin Pasero

Merge branch 'master' into ben/storagehint

......@@ -271,7 +271,7 @@ export class DropdownMenuActionItem extends BaseActionItem {
private actionItemProvider: IActionItemProvider;
private keybindings: (action: IAction) => ResolvedKeybinding;
private clazz: string;
private anchorAlignmentProvider: () => AnchorAlignment;
private anchorAlignmentProvider: (() => AnchorAlignment) | undefined;
constructor(action: IAction, menuActions: IAction[], contextMenuProvider: IContextMenuProvider, actionItemProvider: IActionItemProvider, actionRunner: IActionRunner, keybindings: (action: IAction) => ResolvedKeybinding, clazz: string, anchorAlignmentProvider?: () => AnchorAlignment);
constructor(action: IAction, actionProvider: IActionProvider, contextMenuProvider: IContextMenuProvider, actionItemProvider: IActionItemProvider, actionRunner: IActionRunner, keybindings: (action: IAction) => ResolvedKeybinding, clazz: string, anchorAlignmentProvider?: () => AnchorAlignment);
......@@ -314,16 +314,23 @@ export class DropdownMenuActionItem extends BaseActionItem {
this.dropdownMenu = this._register(new DropdownMenu(container, options));
const that = this;
this.dropdownMenu.menuOptions = {
actionItemProvider: this.actionItemProvider,
actionRunner: this.actionRunner,
getKeyBinding: this.keybindings,
context: this._context,
get anchorAlignment(): AnchorAlignment {
return that.anchorAlignmentProvider();
}
context: this._context
};
if (this.anchorAlignmentProvider) {
const that = this;
this.dropdownMenu.menuOptions = {
...this.dropdownMenu.menuOptions,
get anchorAlignment(): AnchorAlignment {
return that.anchorAlignmentProvider();
}
};
}
}
setActionContext(newContext: any): void {
......
......@@ -11,7 +11,6 @@
.monaco-findInput .monaco-inputbox {
font-size: 13px;
width: 100%;
height: 25px;
}
.monaco-findInput > .controls {
......
......@@ -23,6 +23,7 @@ export interface IFindInputOptions extends IFindInputStyles {
readonly width?: number;
readonly validation?: IInputValidator;
readonly label: string;
readonly flexibleHeight?: boolean;
readonly appendCaseSensitiveLabel?: string;
readonly appendWholeWordsLabel?: string;
......@@ -118,7 +119,7 @@ export class FindInput extends Widget {
this.domNode = null;
this.inputBox = null;
this.buildDomNode(options.appendCaseSensitiveLabel || '', options.appendWholeWordsLabel || '', options.appendRegexLabel || '', options.history);
this.buildDomNode(options.appendCaseSensitiveLabel || '', options.appendWholeWordsLabel || '', options.appendRegexLabel || '', options.history, options.flexibleHeight);
if (Boolean(parent)) {
parent.appendChild(this.domNode);
......@@ -287,7 +288,7 @@ export class FindInput extends Widget {
this.inputBox.width = w;
}
private buildDomNode(appendCaseSensitiveLabel: string, appendWholeWordsLabel: string, appendRegexLabel: string, history: string[]): void {
private buildDomNode(appendCaseSensitiveLabel: string, appendWholeWordsLabel: string, appendRegexLabel: string, history: string[], flexibleHeight: boolean): void {
this.domNode = document.createElement('div');
this.domNode.style.width = this.width + 'px';
dom.addClass(this.domNode, 'monaco-findInput');
......@@ -310,7 +311,8 @@ export class FindInput extends Widget {
inputValidationErrorBackground: this.inputValidationErrorBackground,
inputValidationErrorForeground: this.inputValidationErrorForeground,
inputValidationErrorBorder: this.inputValidationErrorBorder,
history
history,
flexibleHeight
}));
this.regex = this._register(new RegexCheckbox({
......
......@@ -291,6 +291,9 @@ export class InputBox extends Widget {
public set width(width: number) {
this.input.style.width = width + 'px';
if (this.mirror) {
this.mirror.style.width = width + 'px';
}
}
public showMessage(message: IMessage, force?: boolean): void {
......
......@@ -202,13 +202,13 @@ function asTreeEvent<T>(event: IListEvent<ITreeNode<T, any>>): ITreeEvent<T> {
function asTreeMouseEvent<T>(event: IListMouseEvent<ITreeNode<T, any>>): ITreeMouseEvent<T> {
return {
browserEvent: event.browserEvent,
element: event.element.element
element: event.element && event.element.element
};
}
function asTreeContextMenuEvent<T>(event: IListContextMenuEvent<ITreeNode<T, any>>): ITreeContextMenuEvent<T> {
return {
element: event.element.element,
element: event.element && event.element.element,
browserEvent: event.browserEvent,
anchor: event.anchor
};
......
......@@ -92,21 +92,21 @@ class DataTreeRenderer<T, TFilterData, TTemplateData> implements ITreeRenderer<I
function asTreeEvent<T>(e: ITreeEvent<IDataTreeNode<T>>): ITreeEvent<T> {
return {
browserEvent: e.browserEvent,
elements: e.elements.map(e => e.element)
elements: e.elements.map(e => e.element!)
};
}
function asTreeMouseEvent<T>(e: ITreeMouseEvent<IDataTreeNode<T>>): ITreeMouseEvent<T> {
return {
browserEvent: e.browserEvent,
element: e.element.element
element: e.element && e.element.element!
};
}
function asTreeContextMenuEvent<T>(e: ITreeContextMenuEvent<IDataTreeNode<T>>): ITreeContextMenuEvent<T> {
return {
browserEvent: e.browserEvent,
element: e.element.element,
element: e.element && e.element.element!,
anchor: e.anchor
};
}
......
......@@ -15,7 +15,7 @@ import { ILogService } from 'vs/platform/log/common/log';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { parseArgs } from 'vs/platform/environment/node/argv';
import product from 'vs/platform/node/product';
import { IWindowSettings, MenuBarVisibility, IWindowConfiguration, ReadyState, IRunActionInWindowRequest } from 'vs/platform/windows/common/windows';
import { IWindowSettings, MenuBarVisibility, IWindowConfiguration, ReadyState, IRunActionInWindowRequest, getTitleBarStyle } from 'vs/platform/windows/common/windows';
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import { isLinux, isMacintosh, isWindows } from 'vs/base/common/platform';
import { ICodeWindow, IWindowState, WindowMode } from 'vs/platform/windows/electron-main/windows';
......@@ -155,28 +155,11 @@ export class CodeWindow implements ICodeWindow {
}
}
let useNativeTabs = false;
if (isMacintosh && windowConfig && windowConfig.nativeTabs === true) {
options.tabbingIdentifier = product.nameShort; // this opts in to sierra tabs
useNativeTabs = true;
}
let useCustomTitleStyle = false;
if (isMacintosh) {
useCustomTitleStyle = !windowConfig || !windowConfig.titleBarStyle || windowConfig.titleBarStyle === 'custom'; // Default to custom on macOS
const isDev = !this.environmentService.isBuilt || !!config.extensionDevelopmentPath;
if (isDev) {
useCustomTitleStyle = false; // not enabled when developing due to https://github.com/electron/electron/issues/3647
}
} else {
useCustomTitleStyle = !windowConfig || !windowConfig.titleBarStyle || windowConfig.titleBarStyle === 'custom'; // Default to custom
}
if (useNativeTabs) {
useCustomTitleStyle = false; // native tabs on sierra do not work with custom title style
}
const useCustomTitleStyle = getTitleBarStyle(this.configurationService, this.environmentService) === 'custom';
if (useCustomTitleStyle) {
options.titleBarStyle = 'hidden';
this.hiddenTitleBarStyle = true;
......
......@@ -21,11 +21,6 @@ import { IContextMenuService, IContextViewService } from 'vs/platform/contextvie
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
export interface IPosition {
x: number;
y: number;
}
export class ContextMenuController implements IEditorContribution {
private static readonly ID = 'editor.contrib.contextmenu';
......@@ -93,16 +88,16 @@ export class ContextMenuController implements IEditorContribution {
}
// Unless the user triggerd the context menu through Shift+F10, use the mouse position as menu position
let forcedPosition: IPosition;
let anchor: IAnchor;
if (e.target.type !== MouseTargetType.TEXTAREA) {
forcedPosition = { x: e.event.posx + 2, y: e.event.posy + 1 };
anchor = { x: e.event.posx - 1, width: 2, y: e.event.posy - 1, height: 2 };
}
// Show the context menu
this.showContextMenu(forcedPosition);
this.showContextMenu(anchor);
}
public showContextMenu(forcedPosition?: IPosition): void {
public showContextMenu(anchor?: IAnchor): void {
if (!this._editor.getConfiguration().contribInfo.contextmenu) {
return; // Context menu is turned off through configuration
}
......@@ -117,7 +112,7 @@ export class ContextMenuController implements IEditorContribution {
// Show menu if we have actions to show
if (menuActions.length > 0) {
this._doShowContextMenu(menuActions, forcedPosition);
this._doShowContextMenu(menuActions, anchor);
}
}
......@@ -137,7 +132,7 @@ export class ContextMenuController implements IEditorContribution {
return result;
}
private _doShowContextMenu(actions: IAction[], forcedPosition: IPosition | null = null): void {
private _doShowContextMenu(actions: IAction[], anchor: IAnchor | null = null): void {
// Disable hover
const oldHoverSetting = this._editor.getConfiguration().contribInfo.hover;
......@@ -147,7 +142,6 @@ export class ContextMenuController implements IEditorContribution {
}
});
let anchor: IAnchor = forcedPosition;
if (!anchor) {
// Ensure selection is visible
this._editor.revealPosition(this._editor.getPosition(), ScrollType.Immediate);
......
......@@ -17,7 +17,7 @@ import { ModelDecorationOptions } from 'vs/editor/common/model/textModel';
import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService';
import { optional } from 'vs/platform/instantiation/common/instantiation';
import { Choice, Placeholder, SnippetParser, Text, TextmateSnippet } from './snippetParser';
import { ClipboardBasedVariableResolver, CompositeSnippetVariableResolver, ModelBasedVariableResolver, SelectionBasedVariableResolver, TimeBasedVariableResolver } from './snippetVariables';
import { ClipboardBasedVariableResolver, CompositeSnippetVariableResolver, ModelBasedVariableResolver, SelectionBasedVariableResolver, TimeBasedVariableResolver, CommentBasedVariableResolver } from './snippetVariables';
import { registerThemingParticipant } from 'vs/platform/theme/common/themeService';
import * as colors from 'vs/platform/theme/common/colorRegistry';
......@@ -402,6 +402,7 @@ export class SnippetSession {
modelBasedVariableResolver,
new ClipboardBasedVariableResolver(clipboardService, idx, indexedSelections.length),
new SelectionBasedVariableResolver(model, selection),
new CommentBasedVariableResolver(model),
new TimeBasedVariableResolver
]));
......
......@@ -8,6 +8,7 @@ import { basename, dirname } from 'vs/base/common/paths';
import { ITextModel } from 'vs/editor/common/model';
import { Selection } from 'vs/editor/common/core/selection';
import { VariableResolver, Variable, Text } from 'vs/editor/contrib/snippet/snippetParser';
import { LanguageConfigurationRegistry } from 'vs/editor/common/modes/languageConfigurationRegistry';
import { getLeadingWhitespace, commonPrefixLength, isFalsyOrWhitespace, pad } from 'vs/base/common/strings';
import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService';
......@@ -34,6 +35,9 @@ export const KnownSnippetVariableNames = Object.freeze({
'TM_FILENAME_BASE': true,
'TM_DIRECTORY': true,
'TM_FILEPATH': true,
'BLOCK_COMMENT_START': true,
'BLOCK_COMMENT_END': true,
'LINE_COMMENT': true,
});
export class CompositeSnippetVariableResolver implements VariableResolver {
......@@ -180,7 +184,29 @@ export class ClipboardBasedVariableResolver implements VariableResolver {
}
}
}
export class CommentBasedVariableResolver implements VariableResolver {
constructor(
private readonly _model: ITextModel
) {
//
}
resolve(variable: Variable): string | undefined {
const { name } = variable;
const language = this._model.getLanguageIdentifier();
const config = LanguageConfigurationRegistry.getComments(language.id);
if (!config) {
return undefined;
}
if (name === 'LINE_COMMENT') {
return config.lineCommentToken || undefined;
} else if (name === 'BLOCK_COMMENT_START') {
return config.blockCommentStartToken || undefined;
} else if (name === 'BLOCK_COMMENT_END') {
return config.blockCommentEndToken || undefined;
}
return undefined;
}
}
export class TimeBasedVariableResolver implements VariableResolver {
private static readonly dayNames = [nls.localize('Sunday', "Sunday"), nls.localize('Monday', "Monday"), nls.localize('Tuesday', "Tuesday"), nls.localize('Wednesday', "Wednesday"), nls.localize('Thursday', "Thursday"), nls.localize('Friday', "Friday"), nls.localize('Saturday', "Saturday")];
......
......@@ -7,7 +7,7 @@ import * as nls from 'vs/nls';
import { isMacintosh, language } from 'vs/base/common/platform';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { app, shell, Menu, MenuItem, BrowserWindow } from 'electron';
import { OpenContext, IRunActionInWindowRequest } from 'vs/platform/windows/common/windows';
import { OpenContext, IRunActionInWindowRequest, getTitleBarStyle } from 'vs/platform/windows/common/windows';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IUpdateService, StateType } from 'vs/platform/update/common/update';
......@@ -70,7 +70,9 @@ export class Menubar {
this.menubarMenus = Object.create(null);
this.keybindings = Object.create(null);
this.restoreCachedMenubarData();
if (isMacintosh || getTitleBarStyle(this.configurationService, this.environmentService) === 'native') {
this.restoreCachedMenubarData();
}
this.addFallbackHandlers();
......@@ -396,7 +398,7 @@ export class Menubar {
private shouldDrawMenu(menuId: string): boolean {
// We need to draw an empty menu to override the electron default
if (!isMacintosh && this.configurationService.getValue('window.titleBarStyle') === 'custom') {
if (!isMacintosh && getTitleBarStyle(this.configurationService, this.environmentService) === 'custom') {
return false;
}
......
......@@ -7,8 +7,8 @@ import { TPromise } from 'vs/base/common/winjs.base';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
import { Event, latch, anyEvent } from 'vs/base/common/event';
import { ITelemetryData } from 'vs/platform/telemetry/common/telemetry';
import { IProcessEnvironment } from 'vs/base/common/platform';
import { ParsedArgs } from 'vs/platform/environment/common/environment';
import { IProcessEnvironment, isMacintosh, isWindows } from 'vs/base/common/platform';
import { ParsedArgs, IEnvironmentService } from 'vs/platform/environment/common/environment';
import { IWorkspaceIdentifier, IWorkspaceFolderCreationData, ISingleFolderWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces';
import { IRecentlyOpened } from 'vs/platform/history/common/history';
import { ISerializableCommandAction } from 'vs/platform/actions/common/actions';
......@@ -16,6 +16,7 @@ import { ExportData } from 'vs/base/common/performance';
import { LogLevel } from 'vs/platform/log/common/log';
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import { URI, UriComponents } from 'vs/base/common/uri';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
export const IWindowsService = createDecorator<IWindowsService>('windowsService');
......@@ -244,6 +245,39 @@ export interface IWindowSettings {
clickThroughInactive: boolean;
}
export function getTitleBarStyle(configurationService: IConfigurationService, environment: IEnvironmentService): 'native' | 'custom' {
const configuration = configurationService.getValue<IWindowSettings>('window');
const isDev = !environment.isBuilt || environment.isExtensionDevelopment;
if (isMacintosh && isDev) {
return 'native'; // not enabled when developing due to https://github.com/electron/electron/issues/3647
}
if (configuration) {
const useNativeTabs = isMacintosh && configuration.nativeTabs === true;
if (useNativeTabs) {
return 'native'; // native tabs on sierra do not work with custom title style
}
const useSimpleFullScreen = isMacintosh && configuration.nativeFullScreen === false;
if (useSimpleFullScreen) {
return 'native'; // simple fullscreen does not work well with custom title style (https://github.com/Microsoft/vscode/issues/63291)
}
const smoothScrollingWorkaround = isWindows && configuration.smoothScrollingWorkaround === true;
if (smoothScrollingWorkaround) {
return 'native'; // smooth scrolling workaround does not work with custom title style
}
const style = configuration.titleBarStyle;
if (style === 'native') {
return 'native';
}
}
return 'custom'; // default to custom on all OS
}
export const enum OpenContext {
// opening when running from the command line
......
......@@ -9,7 +9,7 @@ import * as strings from 'vs/base/common/strings';
import { IMenubarMenu, IMenubarMenuItemAction, IMenubarMenuItemSubmenu, IMenubarKeybinding, IMenubarService, IMenubarData } from 'vs/platform/menubar/common/menubar';
import { IMenuService, MenuId, IMenu, SubmenuItemAction } from 'vs/platform/actions/common/actions';
import { registerThemingParticipant, ITheme, ICssStyleCollector, IThemeService } from 'vs/platform/theme/common/themeService';
import { IWindowService, MenuBarVisibility, IWindowsService } from 'vs/platform/windows/common/windows';
import { IWindowService, MenuBarVisibility, IWindowsService, getTitleBarStyle } from 'vs/platform/windows/common/windows';
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { ActionRunner, IActionRunner, IAction, Action } from 'vs/base/common/actions';
import { Separator } from 'vs/base/browser/ui/actionbar/actionbar';
......@@ -35,6 +35,7 @@ import { attachMenuStyler } from 'vs/platform/theme/common/styler';
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
import { INotificationService, Severity } from 'vs/platform/notification/common/notification';
import { IPreferencesService } from 'vs/workbench/services/preferences/common/preferences';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
const $ = DOM.$;
......@@ -130,7 +131,8 @@ export class MenubarControl extends Disposable {
@IUpdateService private updateService: IUpdateService,
@IStorageService private storageService: IStorageService,
@INotificationService private notificationService: INotificationService,
@IPreferencesService private preferencesService: IPreferencesService
@IPreferencesService private preferencesService: IPreferencesService,
@IEnvironmentService private environmentService: IEnvironmentService
) {
super();
......@@ -214,7 +216,7 @@ export class MenubarControl extends Disposable {
}
private get currentTitlebarStyleSetting(): string {
return this.configurationService.getValue<string>('window.titleBarStyle');
return getTitleBarStyle(this.configurationService, this.environmentService);
}
private get focusState(): MenubarState {
......
......@@ -8,7 +8,7 @@ import * as paths from 'vs/base/common/paths';
import { Part } from 'vs/workbench/browser/part';
import { ITitleService, ITitleProperties } from 'vs/workbench/services/title/common/titleService';
import { getZoomFactor } from 'vs/base/browser/browser';
import { IWindowService, IWindowsService, MenuBarVisibility } from 'vs/platform/windows/common/windows';
import { IWindowService, IWindowsService, MenuBarVisibility, getTitleBarStyle } from 'vs/platform/windows/common/windows';
import * as errors from 'vs/base/common/errors';
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
import { StandardMouseEvent } from 'vs/base/browser/mouseEvent';
......@@ -509,7 +509,7 @@ export class TitlebarPart extends Part implements ITitleService {
}
layout(dimension: Dimension): Dimension[] {
if (this.configurationService.getValue<string>('window.titleBarStyle') === 'custom') {
if (getTitleBarStyle(this.configurationService, this.environmentService) === 'custom') {
// Only prevent zooming behavior on macOS or when the menubar is not visible
if (isMacintosh || this.configurationService.getValue<MenuBarVisibility>('window.menuBarVisibility') === 'hidden') {
this.title.style.zoom = `${1.0 / getZoomFactor()}`;
......
......@@ -835,7 +835,7 @@ configurationRegistry.registerConfiguration({
'type': 'boolean',
'default': false,
'scope': ConfigurationScope.APPLICATION,
'markdownDescription': nls.localize('window.smoothScrollingWorkaround', "Enable this workaround if scrolling is no longer smooth after restoring a minimized VS Code window. This is a workaround for an issue (https://github.com/Microsoft/vscode/issues/13612) where scrolling starts to lag on devices with precision trackpads like the Surface devices from Microsoft. Enabling this workaround can result in a little bit of layout flickering after restoring the window from minimized state but is otherwise harmless. Note: in order for this workaround to function, make sure to also set `#window.titleBarStyle#` to `native`."),
'markdownDescription': nls.localize('window.smoothScrollingWorkaround', "Enable this workaround if scrolling is no longer smooth after restoring a minimized VS Code window. This is a workaround for an issue (https://github.com/Microsoft/vscode/issues/13612) where scrolling starts to lag on devices with precision trackpads like the Surface devices from Microsoft. Enabling this workaround can result in a little bit of layout flickering after restoring the window from minimized state but is otherwise harmless."),
'included': isWindows
},
'window.clickThroughInactive': {
......
......@@ -75,7 +75,7 @@ import { ITextModelService } from 'vs/editor/common/services/resolverService';
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
import { ShutdownReason } from 'vs/platform/lifecycle/common/lifecycle';
import { LifecycleService } from 'vs/platform/lifecycle/electron-browser/lifecycleService';
import { IWindowService, IWindowConfiguration as IWindowSettings, IWindowConfiguration, IPath, MenuBarVisibility } from 'vs/platform/windows/common/windows';
import { IWindowService, IWindowConfiguration, IPath, MenuBarVisibility, getTitleBarStyle } from 'vs/platform/windows/common/windows';
import { IStatusbarService } from 'vs/platform/statusbar/common/statusbar';
import { IMenuService, SyncActionDescriptor } from 'vs/platform/actions/common/actions';
import { MenuService } from 'vs/platform/actions/common/menuService';
......@@ -357,7 +357,7 @@ export class Workbench extends Disposable implements IPartService {
serviceCollection.set(IContextViewService, this.contextViewService);
// Use themable context menus when custom titlebar is enabled to match custom menubar
if (!isMacintosh && this.getCustomTitleBarStyle() === 'custom') {
if (!isMacintosh && this.useCustomTitleBarStyle()) {
serviceCollection.set(IContextMenuService, new SyncDescriptor(HTMLContextMenuService, [null]));
} else {
serviceCollection.set(IContextMenuService, new SyncDescriptor(NativeContextMenuService));
......@@ -522,8 +522,7 @@ export class Workbench extends Disposable implements IPartService {
}
// Changing fullscreen state of the window has an impact on custom title bar visibility, so we need to update
const hasCustomTitle = this.getCustomTitleBarStyle() === 'custom';
if (hasCustomTitle) {
if (this.useCustomTitleBarStyle()) {
this._onTitleBarVisibilityChange.fire();
this.layout(); // handle title bar when fullscreen changes
}
......@@ -933,26 +932,8 @@ export class Workbench extends Disposable implements IPartService {
this.panelPosition = (panelPosition === 'right') ? Position.RIGHT : Position.BOTTOM;
}
private getCustomTitleBarStyle(): 'custom' {
const isDev = !this.environmentService.isBuilt || this.environmentService.isExtensionDevelopment;
if (isMacintosh && isDev) {
return null; // not enabled when developing due to https://github.com/electron/electron/issues/3647
}
const windowConfig = this.configurationService.getValue<IWindowSettings>();
if (windowConfig && windowConfig.window) {
const useNativeTabs = isMacintosh && windowConfig.window.nativeTabs;
if (useNativeTabs) {
return null; // native tabs on sierra do not work with custom title style
}
const style = windowConfig.window.titleBarStyle;
if (style === 'custom') {
return style;
}
}
return null;
private useCustomTitleBarStyle(): boolean {
return getTitleBarStyle(this.configurationService, this.environmentService) === 'custom';
}
private setStatusBarHidden(hidden: boolean, skipLayout?: boolean): void {
......@@ -1039,7 +1020,7 @@ export class Workbench extends Disposable implements IPartService {
// Menubar visibility changes
if ((isWindows || isLinux) && this.getCustomTitleBarStyle() === 'custom') {
if ((isWindows || isLinux) && this.useCustomTitleBarStyle()) {
this.titlebarPart.onMenubarVisibilityChange()(e => this.onMenubarToggled(e));
}
......@@ -1205,7 +1186,7 @@ export class Workbench extends Disposable implements IPartService {
isVisible(part: Parts): boolean {
switch (part) {
case Parts.TITLEBAR_PART:
if (this.getCustomTitleBarStyle() !== 'custom') {
if (!this.useCustomTitleBarStyle()) {
return false;
} else if (!browser.isFullscreen()) {
return true;
......
......@@ -60,6 +60,7 @@ function createProxyAgent(
extHostWorkspace.resolveProxy(url)
.then(proxy => {
callback(proxy);
extHostLogService.info('ProxyResolver#resolveProxy', url, proxy);
}).then(() => {
count++;
duration = Date.now() - start + duration;
......
......@@ -29,9 +29,21 @@
margin-left: 17px;
}
.search-view .search-widget .input-box,
.search-view .search-widget .input-box .monaco-inputbox {
height: 25px;
.search-view .search-widget .monaco-inputbox > .wrapper {
height: 100%;
}
.search-view .search-widget .monaco-inputbox > .wrapper > .mirror {
max-height: 134px;
}
.search-view .monaco-inputbox > .wrapper > textarea.input {
overflow: initial;
height: 26px; /* set initial height before measure */
}
.search-view .monaco-inputbox > .wrapper > textarea.input::-webkit-scrollbar {
display: none;
}
.search-view .search-widget .monaco-findInput {
......@@ -39,6 +51,10 @@
vertical-align: middle;
}
.search-view .search-widget .monaco-findInput > .controls {
top: 4px; /* Adjust controls, search view input box is slighty taller than find widget due to measurement */
}
.search-view .search-widget .replace-container {
margin-top: 6px;
position: relative;
......
......@@ -281,7 +281,8 @@ export class SearchWidget extends Widget {
appendCaseSensitiveLabel: appendKeyBindingLabel('', this.keyBindingService.lookupKeybinding(Constants.ToggleCaseSensitiveCommandId), this.keyBindingService),
appendWholeWordsLabel: appendKeyBindingLabel('', this.keyBindingService.lookupKeybinding(Constants.ToggleWholeWordCommandId), this.keyBindingService),
appendRegexLabel: appendKeyBindingLabel('', this.keyBindingService.lookupKeybinding(Constants.ToggleRegexCommandId), this.keyBindingService),
history: options.searchHistory
history: options.searchHistory,
flexibleHeight: true
};
let searchInputContainer = dom.append(parent, dom.$('.search-container.input-box'));
......@@ -329,7 +330,8 @@ export class SearchWidget extends Widget {
this.replaceInput = this._register(new ContextScopedHistoryInputBox(replaceBox, this.contextViewService, {
ariaLabel: nls.localize('label.Replace', 'Replace: Type replace term and press Enter to preview or Escape to cancel'),
placeholder: nls.localize('search.replace.placeHolder', "Replace"),
history: options.replaceHistory || []
history: options.replaceHistory || [],
flexibleHeight: true
}, this.contextKeyService));
this._register(attachInputBoxStyler(this.replaceInput, this.themeService));
this.onkeydown(this.replaceInput.inputElement, (keyboardEvent) => this.onReplaceInputKeyDown(keyboardEvent));
......@@ -376,6 +378,7 @@ export class SearchWidget extends Widget {
if (currentState !== newState) {
this.replaceActive.set(newState);
this._onReplaceStateChange.fire(newState);
this.replaceInput.layout();
}
}
......@@ -429,6 +432,20 @@ export class SearchWidget extends Widget {
}
keyboardEvent.preventDefault();
}
else if (keyboardEvent.equals(KeyCode.UpArrow)) {
const ta = this.searchInput.domNode.querySelector('textarea');
if (ta && ta.selectionStart > 0) {
keyboardEvent.stopPropagation();
}
}
else if (keyboardEvent.equals(KeyCode.DownArrow)) {
const ta = this.searchInput.domNode.querySelector('textarea');
if (ta && ta.selectionEnd < ta.value.length) {
keyboardEvent.stopPropagation();
}
}
}
private onCaseSensitiveKeyDown(keyboardEvent: IKeyboardEvent) {
......@@ -466,6 +483,20 @@ export class SearchWidget extends Widget {
this.searchInput.focus();
keyboardEvent.preventDefault();
}
else if (keyboardEvent.equals(KeyCode.UpArrow)) {
const ta = this.searchInput.domNode.querySelector('textarea');
if (ta && ta.selectionStart > 0) {
keyboardEvent.stopPropagation();
}
}
else if (keyboardEvent.equals(KeyCode.DownArrow)) {
const ta = this.searchInput.domNode.querySelector('textarea');
if (ta && ta.selectionEnd < ta.value.length) {
keyboardEvent.stopPropagation();
}
}
}
private onReplaceActionbarKeyDown(keyboardEvent: IKeyboardEvent) {
......
......@@ -67,10 +67,8 @@ export class QueryBuilder {
) { }
text(contentPattern: IPatternInfo, folderResources?: uri[], options: ITextQueryBuilderOptions = {}): ITextQuery {
contentPattern.isCaseSensitive = this.isCaseSensitive(contentPattern);
contentPattern.isMultiline = this.isMultiline(contentPattern);
contentPattern = this.getContentPattern(contentPattern);
const searchConfig = this.configurationService.getValue<ISearchConfiguration>();
contentPattern.wordSeparators = searchConfig.editor.wordSeparators;
const fallbackToPCRE = folderResources && folderResources.some(folder => {
const folderConfig = this.configurationService.getValue<ISearchConfiguration>({ resource: folder });
......@@ -91,6 +89,28 @@ export class QueryBuilder {
};
}
/**
* Adjusts input pattern for config
*/
private getContentPattern(inputPattern: IPatternInfo): IPatternInfo {
const searchConfig = this.configurationService.getValue<ISearchConfiguration>();
const newPattern = {
...inputPattern,
wordSeparators: searchConfig.editor.wordSeparators
};
if (this.isCaseSensitive(inputPattern)) {
newPattern.isCaseSensitive = true;
}
if (this.isMultiline(inputPattern)) {
newPattern.isMultiline = true;
}
return newPattern;
}
file(folderResources: uri[] | undefined, options: IFileQueryBuilderOptions = {}): IFileQuery {
const commonQuery = this.commonQuery(folderResources, options);
return <IFileQuery>{
......@@ -165,6 +185,10 @@ export class QueryBuilder {
return true;
}
if (contentPattern.pattern.indexOf('\n') >= 0) {
return true;
}
return false;
}
......
......@@ -7,7 +7,7 @@ import * as cp from 'child_process';
import { EventEmitter } from 'events';
import * as path from 'path';
import { NodeStringDecoder, StringDecoder } from 'string_decoder';
import { createRegExp, startsWith, startsWithUTF8BOM, stripUTF8BOM } from 'vs/base/common/strings';
import { createRegExp, startsWith, startsWithUTF8BOM, stripUTF8BOM, escapeRegExpCharacters } from 'vs/base/common/strings';
import { URI } from 'vs/base/common/uri';
import { IExtendedExtensionSearchOptions, SearchError, SearchErrorCode, serializeSearchError } from 'vs/platform/search/common/search';
import * as vscode from 'vscode';
......@@ -343,6 +343,11 @@ function getRgArgs(query: vscode.TextSearchQuery, options: vscode.TextSearchOpti
pattern = '\\-\\-';
}
if (query.isMultiline && !query.isRegExp) {
query.pattern = escapeRegExpCharacters(query.pattern);
query.isRegExp = true;
}
if ((<IExtendedExtensionSearchOptions>options).usePCRE2) {
args.push('--pcre2');
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册