提交 140c1c74 编写于 作者: J Joao Moreno

Merge remote-tracking branch 'origin/master'

......@@ -40,12 +40,7 @@ export interface IModelDecorationOverviewRulerOptions {
* CSS color to render in the overview ruler.
* e.g.: rgba(100, 100, 100, 0.5) or a color from the color registry
*/
darkColor: string | ThemeColor;
/**
* CSS color to render in the overview ruler.
* e.g.: rgba(100, 100, 100, 0.5) or a color from the color registry
*/
hcColor?: string | ThemeColor;
darkColor?: string | ThemeColor;
/**
* The position in the overview ruler.
*/
......
......@@ -198,7 +198,7 @@ export class IntervalNode implements IModelDecoration {
|| className === ClassName.EditorInfoDecoration
));
_setNodeStickiness(this, <number>this.options.stickiness);
setNodeIsInOverviewRuler(this, this.options.overviewRuler.color ? true : false);
setNodeIsInOverviewRuler(this, (this.options.overviewRuler && this.options.overviewRuler.color) ? true : false);
}
public setCachedOffsets(absoluteStart: number, absoluteEnd: number, cachedVersionId: number): void {
......
......@@ -16,7 +16,7 @@ import { onUnexpectedError } from 'vs/base/common/errors';
import { IMarkdownString } from 'vs/base/common/htmlContent';
import * as strings from 'vs/base/common/strings';
import { CharCode } from 'vs/base/common/charCode';
import { ThemeColor } from 'vs/platform/theme/common/themeService';
import { ThemeColor, ITheme } from 'vs/platform/theme/common/themeService';
import { IntervalNode, IntervalTree, recomputeMaxEnd, getNodeIsInOverviewRuler } from 'vs/editor/common/model/intervalTree';
import { Disposable, IDisposable } from 'vs/base/common/lifecycle';
import { StopWatch } from 'vs/base/common/stopwatch';
......@@ -1676,8 +1676,8 @@ export class TextModel extends Disposable implements model.ITextModel {
return;
}
const nodeWasInOverviewRuler = (node.options.overviewRuler.color ? true : false);
const nodeIsInOverviewRuler = (options.overviewRuler.color ? true : false);
const nodeWasInOverviewRuler = (node.options.overviewRuler && node.options.overviewRuler.color ? true : false);
const nodeIsInOverviewRuler = (options.overviewRuler && options.overviewRuler.color ? true : false);
if (nodeWasInOverviewRuler !== nodeIsInOverviewRuler) {
// Delete + Insert due to an overview ruler status change
......@@ -2783,30 +2783,40 @@ function cleanClassName(className: string): string {
export class ModelDecorationOverviewRulerOptions implements model.IModelDecorationOverviewRulerOptions {
readonly color: string | ThemeColor;
readonly darkColor: string | ThemeColor;
readonly hcColor: string | ThemeColor;
readonly position: model.OverviewRulerLane;
_resolvedColor: string;
private _resolvedColor: string;
constructor(options: model.IModelDecorationOverviewRulerOptions) {
this.color = strings.empty;
this.darkColor = strings.empty;
this.hcColor = strings.empty;
this.position = model.OverviewRulerLane.Center;
this.color = options.color || strings.empty;
this.darkColor = options.darkColor || strings.empty;
this.position = (typeof options.position === 'number' ? options.position : model.OverviewRulerLane.Center);
this._resolvedColor = null;
}
if (options && options.color) {
this.color = options.color;
}
if (options && options.darkColor) {
this.darkColor = options.darkColor;
this.hcColor = options.darkColor;
public getColor(theme: ITheme): string {
if (!this._resolvedColor) {
if (theme.type !== 'light' && this.darkColor) {
this._resolvedColor = this._resolveColor(this.darkColor, theme);
} else {
this._resolvedColor = this._resolveColor(this.color, theme);
}
}
if (options && options.hcColor) {
this.hcColor = options.hcColor;
return this._resolvedColor;
}
public invalidateCachedColor(): void {
this._resolvedColor = null;
}
private _resolveColor(color: string | ThemeColor, theme: ITheme): string {
if (typeof color === 'string') {
return color;
}
if (options && options.hasOwnProperty('position')) {
this.position = options.position;
let c = color ? theme.getColor(color.id) : null;
if (!c) {
return strings.empty;
}
return c.toString();
}
}
......@@ -2841,19 +2851,19 @@ export class ModelDecorationOptions implements model.IModelDecorationOptions {
private constructor(options: model.IModelDecorationOptions) {
this.stickiness = options.stickiness || model.TrackedRangeStickiness.AlwaysGrowsWhenTypingAtEdges;
this.zIndex = options.zIndex || 0;
this.className = options.className ? cleanClassName(options.className) : strings.empty;
this.hoverMessage = options.hoverMessage || [];
this.glyphMarginHoverMessage = options.glyphMarginHoverMessage || [];
this.className = options.className ? cleanClassName(options.className) : null;
this.hoverMessage = options.hoverMessage || null;
this.glyphMarginHoverMessage = options.glyphMarginHoverMessage || null;
this.isWholeLine = options.isWholeLine || false;
this.showIfCollapsed = options.showIfCollapsed || false;
this.overviewRuler = new ModelDecorationOverviewRulerOptions(options.overviewRuler);
this.glyphMarginClassName = options.glyphMarginClassName ? cleanClassName(options.glyphMarginClassName) : strings.empty;
this.linesDecorationsClassName = options.linesDecorationsClassName ? cleanClassName(options.linesDecorationsClassName) : strings.empty;
this.marginClassName = options.marginClassName ? cleanClassName(options.marginClassName) : strings.empty;
this.inlineClassName = options.inlineClassName ? cleanClassName(options.inlineClassName) : strings.empty;
this.overviewRuler = options.overviewRuler ? new ModelDecorationOverviewRulerOptions(options.overviewRuler) : null;
this.glyphMarginClassName = options.glyphMarginClassName ? cleanClassName(options.glyphMarginClassName) : null;
this.linesDecorationsClassName = options.linesDecorationsClassName ? cleanClassName(options.linesDecorationsClassName) : null;
this.marginClassName = options.marginClassName ? cleanClassName(options.marginClassName) : null;
this.inlineClassName = options.inlineClassName ? cleanClassName(options.inlineClassName) : null;
this.inlineClassNameAffectsLetterSpacing = options.inlineClassNameAffectsLetterSpacing || false;
this.beforeContentClassName = options.beforeContentClassName ? cleanClassName(options.beforeContentClassName) : strings.empty;
this.afterContentClassName = options.afterContentClassName ? cleanClassName(options.afterContentClassName) : strings.empty;
this.beforeContentClassName = options.beforeContentClassName ? cleanClassName(options.beforeContentClassName) : null;
this.afterContentClassName = options.afterContentClassName ? cleanClassName(options.afterContentClassName) : null;
}
}
ModelDecorationOptions.EMPTY = ModelDecorationOptions.register({});
......
......@@ -129,7 +129,6 @@ class ModelMarkerHandler {
let className: string;
let color: ThemeColor;
let darkColor: ThemeColor;
let zIndex: number;
let inlineClassName: string;
......@@ -145,20 +144,17 @@ class ModelMarkerHandler {
case MarkerSeverity.Warning:
className = ClassName.EditorWarningDecoration;
color = themeColorFromId(overviewRulerWarning);
darkColor = themeColorFromId(overviewRulerWarning);
zIndex = 20;
break;
case MarkerSeverity.Info:
className = ClassName.EditorInfoDecoration;
color = themeColorFromId(overviewRulerInfo);
darkColor = themeColorFromId(overviewRulerInfo);
zIndex = 10;
break;
case MarkerSeverity.Error:
default:
className = ClassName.EditorErrorDecoration;
color = themeColorFromId(overviewRulerError);
darkColor = themeColorFromId(overviewRulerError);
zIndex = 30;
break;
}
......@@ -205,7 +201,6 @@ class ModelMarkerHandler {
showIfCollapsed: true,
overviewRuler: {
color,
darkColor,
position: OverviewRulerLane.Right
},
zIndex,
......
......@@ -12,8 +12,7 @@ import { ViewLineData, ICoordinatesConverter, IOverviewRulerDecorations } from '
import * as viewEvents from 'vs/editor/common/view/viewEvents';
import { WrappingIndent } from 'vs/editor/common/config/editorOptions';
import { ModelDecorationOptions, ModelDecorationOverviewRulerOptions } from 'vs/editor/common/model/textModel';
import { ThemeColor, ITheme } from 'vs/platform/theme/common/themeService';
import { Color } from 'vs/base/common/color';
import { ITheme } from 'vs/platform/theme/common/themeService';
import { IModelDecoration, ITextModel, IModelDeltaDecoration, EndOfLinePreference, IActiveIndentGuideInfo } from 'vs/editor/common/model';
export class OutputPosition {
......@@ -793,11 +792,11 @@ export class SplitLinesCollection implements IViewModelLinesCollection {
for (let i = 0, len = decorations.length; i < len; i++) {
const decoration = decorations[i];
const opts = <ModelDecorationOverviewRulerOptions>decoration.options.overviewRuler;
const lane = opts.position;
const lane = opts ? opts.position : 0;
if (lane === 0) {
continue;
}
const color = resolveColor(opts, theme);
const color = opts.getColor(theme);
const viewStartLineNumber = this._getViewLineNumberForModelPosition(decoration.range.startLineNumber, decoration.range.startColumn);
const viewEndLineNumber = this._getViewLineNumberForModelPosition(decoration.range.endLineNumber, decoration.range.endColumn);
......@@ -812,7 +811,8 @@ export class SplitLinesCollection implements IViewModelLinesCollection {
if (modelEnd.lineNumber - modelStart.lineNumber <= range.endLineNumber - range.startLineNumber) {
// most likely there are no hidden lines => fast path
return this.model.getDecorationsInRange(new Range(modelStart.lineNumber, modelStart.column, modelEnd.lineNumber, modelEnd.column), ownerId, filterOutValidation);
// fetch decorations from column 1 to cover the case of wrapped lines that have whole line decorations at column 1
return this.model.getDecorationsInRange(new Range(modelStart.lineNumber, 1, modelEnd.lineNumber, modelEnd.column), ownerId, filterOutValidation);
}
let result: IModelDecoration[] = [];
......@@ -1356,11 +1356,11 @@ export class IdentityLinesCollection implements IViewModelLinesCollection {
for (let i = 0, len = decorations.length; i < len; i++) {
const decoration = decorations[i];
const opts = <ModelDecorationOverviewRulerOptions>decoration.options.overviewRuler;
const lane = opts.position;
const lane = opts ? opts.position : 0;
if (lane === 0) {
continue;
}
const color = resolveColor(opts, theme);
const color = opts.getColor(theme);
const viewStartLineNumber = decoration.range.startLineNumber;
const viewEndLineNumber = decoration.range.endLineNumber;
......@@ -1402,24 +1402,3 @@ class OverviewRulerDecorations {
}
}
}
function resolveColor(opts: ModelDecorationOverviewRulerOptions, theme: ITheme): string {
if (!opts._resolvedColor) {
const themeType = theme.type;
const color = (themeType === 'dark' ? opts.darkColor : themeType === 'light' ? opts.color : opts.hcColor);
opts._resolvedColor = resolveRulerColor(color, theme);
}
return opts._resolvedColor;
}
function resolveRulerColor(color: string | ThemeColor, theme: ITheme): string {
if (typeof color === 'string') {
return color;
}
let c = color ? theme.getColor(color.id) : null;
if (!c) {
c = Color.transparent;
}
return c.toString();
}
......@@ -539,7 +539,9 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel
for (let i = 0, len = decorations.length; i < len; i++) {
const decoration = decorations[i];
const opts = <ModelDecorationOverviewRulerOptions>decoration.options.overviewRuler;
opts._resolvedColor = null;
if (opts) {
opts.invalidateCachedColor();
}
}
}
......
......@@ -234,7 +234,6 @@ export class BracketMatchingController extends Disposable implements editorCommo
className: 'bracket-match',
overviewRuler: {
color: themeColorFromId(overviewRulerBracketMatchForeground),
darkColor: themeColorFromId(overviewRulerBracketMatchForeground),
position: OverviewRulerLane.Center
}
});
......
......@@ -272,7 +272,6 @@ export class FindDecorations implements IDisposable {
showIfCollapsed: true,
overviewRuler: {
color: themeColorFromId(overviewRulerFindMatchForeground),
darkColor: themeColorFromId(overviewRulerFindMatchForeground),
position: OverviewRulerLane.Center
}
});
......@@ -283,7 +282,6 @@ export class FindDecorations implements IDisposable {
showIfCollapsed: true,
overviewRuler: {
color: themeColorFromId(overviewRulerFindMatchForeground),
darkColor: themeColorFromId(overviewRulerFindMatchForeground),
position: OverviewRulerLane.Center
}
});
......@@ -298,7 +296,6 @@ export class FindDecorations implements IDisposable {
stickiness: TrackedRangeStickiness.NeverGrowsWhenTypingAtEdges,
overviewRuler: {
color: themeColorFromId(overviewRulerFindMatchForeground),
darkColor: themeColorFromId(overviewRulerFindMatchForeground),
position: OverviewRulerLane.Center
}
});
......
......@@ -897,7 +897,6 @@ export class SelectionHighlighter extends Disposable implements IEditorContribut
className: 'selectionHighlight',
overviewRuler: {
color: themeColorFromId(overviewRulerSelectionHighlightForeground),
darkColor: themeColorFromId(overviewRulerSelectionHighlightForeground),
position: OverviewRulerLane.Center
}
});
......
......@@ -433,7 +433,6 @@ class WordHighlighter {
className: 'wordHighlightStrong',
overviewRuler: {
color: themeColorFromId(overviewRulerWordHighlightStrongForeground),
darkColor: themeColorFromId(overviewRulerWordHighlightStrongForeground),
position: OverviewRulerLane.Center
}
});
......@@ -443,7 +442,6 @@ class WordHighlighter {
className: 'selectionHighlight',
overviewRuler: {
color: themeColorFromId(overviewRulerSelectionHighlightForeground),
darkColor: themeColorFromId(overviewRulerSelectionHighlightForeground),
position: OverviewRulerLane.Center
}
});
......@@ -453,7 +451,6 @@ class WordHighlighter {
className: 'wordHighlight',
overviewRuler: {
color: themeColorFromId(overviewRulerWordHighlightForeground),
darkColor: themeColorFromId(overviewRulerWordHighlightForeground),
position: OverviewRulerLane.Center
}
});
......
......@@ -81,6 +81,7 @@ suite('ViewModelDecorations', () => {
});
assert.deepEqual(actualDecorations, [
'dec1',
'dec2',
'dec3',
'dec4',
......
......@@ -1187,12 +1187,7 @@ declare namespace monaco.editor {
* CSS color to render in the overview ruler.
* e.g.: rgba(100, 100, 100, 0.5) or a color from the color registry
*/
darkColor: string | ThemeColor;
/**
* CSS color to render in the overview ruler.
* e.g.: rgba(100, 100, 100, 0.5) or a color from the color registry
*/
hcColor?: string | ThemeColor;
darkColor?: string | ThemeColor;
/**
* The position in the overview ruler.
*/
......
......@@ -64,7 +64,7 @@ const MOVE_FILE_TO_TRASH_ID = 'moveFileToTrash';
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: MOVE_FILE_TO_TRASH_ID,
weight: KeybindingWeight.WorkbenchContrib + explorerCommandsWeightBonus,
when: ContextKeyExpr.and(FilesExplorerFocusCondition, ExplorerRootContext.toNegated(), ExplorerResourceNotReadonlyContext),
when: ContextKeyExpr.and(FilesExplorerFocusCondition, ExplorerRootContext.toNegated(), ExplorerResourceNotReadonlyContext, ContextKeyExpr.has('config.files.enableTrash')),
primary: KeyCode.Delete,
mac: {
primary: KeyMod.CtrlCmd | KeyCode.Backspace
......@@ -76,7 +76,7 @@ const DELETE_FILE_ID = 'deleteFile';
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: DELETE_FILE_ID,
weight: KeybindingWeight.WorkbenchContrib + explorerCommandsWeightBonus,
when: ContextKeyExpr.and(FilesExplorerFocusCondition, ExplorerRootContext.toNegated(), ExplorerResourceNotReadonlyContext),
when: ContextKeyExpr.and(FilesExplorerFocusCondition, ExplorerRootContext.toNegated(), ExplorerResourceNotReadonlyContext, ContextKeyExpr.has('config.files.enableTrash')),
primary: KeyMod.Shift | KeyCode.Delete,
mac: {
primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.Backspace
......@@ -84,6 +84,17 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
handler: deleteFileHandler
});
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: DELETE_FILE_ID,
weight: KeybindingWeight.WorkbenchContrib + explorerCommandsWeightBonus,
when: ContextKeyExpr.and(FilesExplorerFocusCondition, ExplorerRootContext.toNegated(), ExplorerResourceNotReadonlyContext, ContextKeyExpr.not('config.files.enableTrash')),
primary: KeyCode.Delete,
mac: {
primary: KeyMod.CtrlCmd | KeyCode.Backspace
},
handler: deleteFileHandler
});
const COPY_FILE_ID = 'filesExplorer.copy';
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: COPY_FILE_ID,
......@@ -474,7 +485,18 @@ MenuRegistry.appendMenuItem(MenuId.ExplorerContext, {
title: nls.localize('deleteFile', "Delete Permanently"),
precondition: ExplorerResourceNotReadonlyContext
},
when: ExplorerRootContext.toNegated()
when: ContextKeyExpr.and(ExplorerRootContext.toNegated(), ContextKeyExpr.has('config.files.enableTrash'))
});
MenuRegistry.appendMenuItem(MenuId.ExplorerContext, {
group: '7_modification',
order: 20,
command: {
id: DELETE_FILE_ID,
title: nls.localize('deleteFile', "Delete Permanently"),
precondition: ExplorerResourceNotReadonlyContext
},
when: ContextKeyExpr.and(ExplorerRootContext.toNegated(), ContextKeyExpr.not('config.files.enableTrash'))
});
// Empty Editor Group Context Menu
......
......@@ -248,6 +248,11 @@ configurationRegistry.registerConfiguration({
'description': nls.localize('eol', "The default end of line character."),
'scope': ConfigurationScope.RESOURCE
},
'files.enableTrash': {
'type': 'boolean',
'default': true,
'description': nls.localize('useTrash', "Moves files/folders to the OS trash (recycle bin on Windows) when deleting. Disabling this will delete files/folders permanently.")
},
'files.trimTrailingWhitespace': {
'type': 'boolean',
'default': false,
......
......@@ -352,7 +352,6 @@ export class KeybindingEditorDecorationsRenderer extends Disposable {
hoverMessage: msg,
overviewRuler: {
color: overviewRulerColor,
darkColor: overviewRulerColor,
position: OverviewRulerLane.Right
}
}
......
......@@ -262,7 +262,6 @@ export class GotoLineHandler extends QuickOpenHandler {
options: {
overviewRuler: {
color: themeColorFromId(overviewRulerRangeHighlight),
darkColor: themeColorFromId(overviewRulerRangeHighlight),
position: OverviewRulerLane.Full
}
}
......
......@@ -531,7 +531,6 @@ export class GotoSymbolHandler extends QuickOpenHandler {
options: {
overviewRuler: {
color: themeColorFromId(overviewRulerRangeHighlight),
darkColor: themeColorFromId(overviewRulerRangeHighlight),
position: OverviewRulerLane.Full
}
}
......
......@@ -808,7 +808,6 @@ class DirtyDiffDecorator {
if (options.overview) {
decorationOptions.overviewRuler = {
color: themeColorFromId(foregroundColor),
darkColor: themeColorFromId(foregroundColor),
position: OverviewRulerLane.Left
};
}
......
......@@ -116,7 +116,6 @@ export class FileMatch extends Disposable {
className: 'currentFindMatch',
overviewRuler: {
color: themeColorFromId(overviewRulerFindMatchForeground),
darkColor: themeColorFromId(overviewRulerFindMatchForeground),
position: OverviewRulerLane.Center
}
});
......@@ -126,7 +125,6 @@ export class FileMatch extends Disposable {
className: 'findMatch',
overviewRuler: {
color: themeColorFromId(overviewRulerFindMatchForeground),
darkColor: themeColorFromId(overviewRulerFindMatchForeground),
position: OverviewRulerLane.Center
}
});
......
......@@ -25,6 +25,7 @@ import { emptyProgressRunner, IProgress, IProgressRunner } from 'vs/platform/pro
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
import { ILabelService } from 'vs/platform/label/common/label';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
abstract class Recording {
......@@ -233,7 +234,8 @@ export class BulkEdit {
@ITextModelService private readonly _textModelService: ITextModelService,
@IFileService private readonly _fileService: IFileService,
@ITextFileService private readonly _textFileService: ITextFileService,
@ILabelService private readonly _uriLabelServie: ILabelService
@ILabelService private readonly _uriLabelServie: ILabelService,
@IConfigurationService private readonly _configurationService: IConfigurationService
) {
this._editor = editor;
this._progress = progress || emptyProgressRunner;
......@@ -316,7 +318,7 @@ export class BulkEdit {
} else if (!edit.newUri && edit.oldUri) {
// delete file
if (!options.ignoreIfNotExists || await this._fileService.existsFile(edit.oldUri)) {
await this._textFileService.delete(edit.oldUri, { useTrash: true, recursive: options.recursive });
await this._textFileService.delete(edit.oldUri, { useTrash: this._configurationService.getValue<boolean>('files.enableTrash'), recursive: options.recursive });
}
} else if (edit.newUri && !edit.oldUri) {
......@@ -369,7 +371,8 @@ export class BulkEditService implements IBulkEditService {
@ITextModelService private readonly _textModelService: ITextModelService,
@IFileService private readonly _fileService: IFileService,
@ITextFileService private readonly _textFileService: ITextFileService,
@ILabelService private readonly _labelService: ILabelService
@ILabelService private readonly _labelService: ILabelService,
@IConfigurationService private readonly _configurationService: IConfigurationService
) {
}
......@@ -400,7 +403,7 @@ export class BulkEditService implements IBulkEditService {
}
}
const bulkEdit = new BulkEdit(options.editor, options.progress, this._logService, this._textModelService, this._fileService, this._textFileService, this._labelService);
const bulkEdit = new BulkEdit(options.editor, options.progress, this._logService, this._textModelService, this._fileService, this._textFileService, this._labelService, this._configurationService);
bulkEdit.add(edits);
return TPromise.wrap(bulkEdit.perform().then(() => {
......
......@@ -84,7 +84,7 @@ suite('MainThreadEditors', () => {
}
};
const bulkEditService = new BulkEditService(new NullLogService(), modelService, new TestEditorService(), textModelService, new TestFileService(), textFileService, new LabelService(TestEnvironmentService, new TestContextService()));
const bulkEditService = new BulkEditService(new NullLogService(), modelService, new TestEditorService(), textModelService, new TestFileService(), textFileService, new LabelService(TestEnvironmentService, new TestContextService()), configService);
const rpcProtocol = new TestRPCProtocol();
rpcProtocol.set(ExtHostContext.ExtHostDocuments, new class extends mock<ExtHostDocumentsShape>() {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册