提交 7a15a509 编写于 作者: A Alex Dima

Remove browser.enableEmptySelectionClipboard

上级 371000f2
......@@ -153,8 +153,6 @@ export function canUseTranslate3d(): boolean {
return true;
}
export const enableEmptySelectionClipboard = isWebKit;
export function supportsExecCommand(command: string): boolean {
return (
(isIE || Platform.isNative)
......
......@@ -351,6 +351,7 @@ export class Configuration extends CommonEditorConfiguration {
outerWidth: this._elementSizeObserver.getWidth(),
outerHeight: this._elementSizeObserver.getHeight(),
canUseTranslate3d: browser.canUseTranslate3d(),
emptySelectionClipboard: browser.isWebKit,
pixelRatio: browser.getPixelRatio(),
zoomLevel: browser.getZoomLevel()
};
......
......@@ -63,6 +63,7 @@ export class TextAreaHandler extends ViewPart {
private _experimentalScreenReader: boolean;
private _fontInfo: BareFontInfo;
private _lineHeight: number;
private _emptySelectionClipboard: boolean;
/**
* Defined only when the text area is visible (composition case).
......@@ -93,6 +94,7 @@ export class TextAreaHandler extends ViewPart {
this._experimentalScreenReader = conf.viewInfo.experimentalScreenReader;
this._fontInfo = conf.fontInfo;
this._lineHeight = conf.lineHeight;
this._emptySelectionClipboard = conf.emptySelectionClipboard;
this._visibleTextArea = null;
this._selections = [new Selection(1, 1, 1, 1)];
......@@ -130,9 +132,9 @@ export class TextAreaHandler extends ViewPart {
const textAreaInputHost: ITextAreaInputHost = {
getPlainTextToCopy: (): string => {
const whatToCopy = this._context.model.getPlainTextToCopy(this._selections, browser.enableEmptySelectionClipboard);
const whatToCopy = this._context.model.getPlainTextToCopy(this._selections, this._emptySelectionClipboard);
if (browser.enableEmptySelectionClipboard) {
if (this._emptySelectionClipboard) {
if (browser.isFirefox) {
// When writing "LINE\r\n" to the clipboard and then pasting,
// Firefox pastes "LINE\n", so let's work around this quirk
......@@ -149,7 +151,7 @@ export class TextAreaHandler extends ViewPart {
},
getHTMLToCopy: (): string => {
return this._context.model.getHTMLToCopy(this._selections, browser.enableEmptySelectionClipboard);
return this._context.model.getHTMLToCopy(this._selections, this._emptySelectionClipboard);
},
getScreenReaderContent: (currentState: TextAreaState): TextAreaState => {
......@@ -181,7 +183,7 @@ export class TextAreaHandler extends ViewPart {
this._register(this._textAreaInput.onPaste((e: IPasteData) => {
let pasteOnNewLine = false;
if (browser.enableEmptySelectionClipboard) {
if (this._emptySelectionClipboard) {
pasteOnNewLine = (e.text === this._lastCopiedValue && this._lastCopiedValueIsFromEmptySelection);
}
this._viewController.paste('keyboard', e.text, pasteOnNewLine);
......@@ -285,6 +287,9 @@ export class TextAreaHandler extends ViewPart {
if (e.pixelRatio) {
this._pixelRatio = conf.pixelRatio;
}
if (e.emptySelectionClipboard) {
this._emptySelectionClipboard = conf.emptySelectionClipboard;
}
return true;
}
......
......@@ -9,7 +9,6 @@ import 'vs/editor/common/view/editorColorRegistry'; // initialze editor theming
import 'vs/css!./media/tokens';
import { onUnexpectedError } from 'vs/base/common/errors';
import { TPromise } from 'vs/base/common/winjs.base';
import * as browser from 'vs/base/browser/browser';
import * as dom from 'vs/base/browser/dom';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { ICommandService } from 'vs/platform/commands/common/commands';
......@@ -415,10 +414,6 @@ export abstract class CodeEditorWidget extends CommonCodeEditor implements edito
}
}
protected _enableEmptySelectionClipboard(): boolean {
return browser.enableEmptySelectionClipboard;
}
protected _createView(): void {
this._view = new View(
this._commandService,
......
......@@ -902,8 +902,7 @@ export abstract class CommonCodeEditor extends Disposable implements editorCommo
this.cursor = new Cursor(
this._configuration,
this.model,
viewModelHelper,
this._enableEmptySelectionClipboard()
viewModelHelper
);
this.viewCursor = new ViewModelCursors(
......@@ -938,8 +937,6 @@ export abstract class CommonCodeEditor extends Disposable implements editorCommo
}
}
protected abstract _enableEmptySelectionClipboard(): boolean;
protected abstract _createView(): void;
protected _postDetachModelCleanup(detachedModel: editorCommon.IModel): void {
......
......@@ -56,6 +56,7 @@ export interface IEnvConfiguration {
outerWidth: number;
outerHeight: number;
canUseTranslate3d: boolean;
emptySelectionClipboard: boolean;
pixelRatio: number;
zoomLevel: number;
}
......@@ -119,6 +120,7 @@ export abstract class CommonEditorConfiguration extends Disposable implements ed
isDominatedByLongLines: this._isDominatedByLongLines,
lineNumbersDigitCount: this._lineNumbersDigitCount,
canUseTranslate3d: partialEnv.canUseTranslate3d,
emptySelectionClipboard: partialEnv.emptySelectionClipboard,
pixelRatio: partialEnv.pixelRatio,
tabFocusMode: TabFocus.getTabFocusMode()
};
......
......@@ -1219,6 +1219,7 @@ export interface IEnvironmentalOptions {
readonly isDominatedByLongLines: boolean;
readonly lineNumbersDigitCount: number;
readonly canUseTranslate3d: boolean;
readonly emptySelectionClipboard: boolean;
readonly pixelRatio: number;
readonly tabFocusMode: boolean;
}
......@@ -1665,7 +1666,7 @@ export class InternalEditorOptionsFactory {
useTabStops: opts.useTabStops,
tabFocusMode: opts.readOnly ? true : env.tabFocusMode,
dragAndDrop: opts.dragAndDrop,
emptySelectionClipboard: opts.emptySelectionClipboard,
emptySelectionClipboard: opts.emptySelectionClipboard && env.emptySelectionClipboard,
layoutInfo: layoutInfo,
fontInfo: env.fontInfo,
viewInfo: opts.viewInfo,
......
......@@ -77,19 +77,16 @@ export class Cursor extends Disposable implements ICursors {
private _isDoingComposition: boolean;
private _columnSelectData: IColumnSelectData;
private enableEmptySelectionClipboard: boolean;
private _handlers: {
[key: string]: (ctx: IMultipleCursorOperationContext) => void;
};
constructor(configuration: editorCommon.IConfiguration, model: editorCommon.IModel, viewModelHelper: IViewModelHelper, enableEmptySelectionClipboard: boolean) {
constructor(configuration: editorCommon.IConfiguration, model: editorCommon.IModel, viewModelHelper: IViewModelHelper) {
super();
this._eventEmitter = this._register(new EventEmitter());
this.configuration = configuration;
this.model = model;
this.viewModelHelper = viewModelHelper;
this.enableEmptySelectionClipboard = enableEmptySelectionClipboard;
const createCursorContext = () => {
const config = new CursorConfiguration(
......@@ -1062,7 +1059,7 @@ export class Cursor extends Disposable implements ICursors {
}
private _cut(ctx: IMultipleCursorOperationContext): void {
this._applyEdits(ctx, DeleteOperations.cut(this.context.config, this.context.model, this._getAllCursorsModelState(), this.enableEmptySelectionClipboard));
this._applyEdits(ctx, DeleteOperations.cut(this.context.config, this.context.model, this._getAllCursorsModelState()));
}
// -------------------- END editing operations
......
......@@ -61,6 +61,7 @@ export class CursorConfiguration {
public readonly lineHeight: number;
public readonly useTabStops: boolean;
public readonly wordSeparators: string;
public readonly emptySelectionClipboard: boolean;
public readonly autoClosingBrackets: boolean;
public readonly autoClosingPairsOpen: CharacterMap;
public readonly autoClosingPairsClose: CharacterMap;
......@@ -71,6 +72,7 @@ export class CursorConfiguration {
return (
e.layoutInfo
|| e.wordSeparators
|| e.emptySelectionClipboard
|| e.autoClosingBrackets
|| e.useTabStops
|| e.lineHeight
......@@ -94,6 +96,7 @@ export class CursorConfiguration {
this.lineHeight = c.lineHeight;
this.useTabStops = c.useTabStops;
this.wordSeparators = c.wordSeparators;
this.emptySelectionClipboard = c.emptySelectionClipboard;
this.autoClosingBrackets = c.autoClosingBrackets;
this.autoClosingPairsOpen = {};
......
......@@ -163,14 +163,14 @@ export class DeleteOperations {
});
}
public static cut(config: CursorConfiguration, model: ICursorSimpleModel, cursors: SingleCursorState[], enableEmptySelectionClipboard: boolean): EditOperationResult {
public static cut(config: CursorConfiguration, model: ICursorSimpleModel, cursors: SingleCursorState[]): EditOperationResult {
let commands: CommandResult[] = [];
for (let i = 0, len = cursors.length; i < len; i++) {
const cursor = cursors[i];
let selection = cursor.selection;
if (selection.isEmpty()) {
if (enableEmptySelectionClipboard) {
if (config.emptySelectionClipboard) {
// This is a full line cut
let position = cursor.position;
......
......@@ -39,6 +39,7 @@ export class ViewConfigurationChangedEvent {
public readonly editorClassName: boolean;
public readonly lineHeight: boolean;
public readonly readOnly: boolean;
public readonly emptySelectionClipboard: boolean;
public readonly layoutInfo: boolean;
public readonly fontInfo: boolean;
public readonly viewInfo: boolean;
......@@ -50,6 +51,7 @@ export class ViewConfigurationChangedEvent {
this.editorClassName = source.editorClassName;
this.lineHeight = source.lineHeight;
this.readOnly = source.readOnly;
this.emptySelectionClipboard = source.emptySelectionClipboard;
this.layoutInfo = source.layoutInfo;
this.fontInfo = source.fontInfo;
this.viewInfo = source.viewInfo;
......
......@@ -137,8 +137,8 @@ export interface IViewModel {
getModelLineMaxColumn(modelLineNumber: number): number;
validateModelPosition(modelPosition: IPosition): Position;
getPlainTextToCopy(ranges: Range[], enableEmptySelectionClipboard: boolean): string;
getHTMLToCopy(ranges: Range[], enableEmptySelectionClipboard: boolean): string;
getPlainTextToCopy(ranges: Range[], emptySelectionClipboard: boolean): string;
getHTMLToCopy(ranges: Range[], emptySelectionClipboard: boolean): string;
}
export class MinimapLinesRenderingData {
......
......@@ -520,13 +520,13 @@ export class ViewModel extends ViewEventEmitter implements IViewModel {
return this.model.validatePosition(position);
}
public getPlainTextToCopy(ranges: Range[], enableEmptySelectionClipboard: boolean): string {
public getPlainTextToCopy(ranges: Range[], emptySelectionClipboard: boolean): string {
let newLineCharacter = this.model.getEOL();
if (ranges.length === 1) {
let range: Range = ranges[0];
if (range.isEmpty()) {
if (enableEmptySelectionClipboard) {
if (emptySelectionClipboard) {
let modelLineNumber = this.coordinatesConverter.convertViewPositionToModelPosition(new Position(range.startLineNumber, 1)).lineNumber;
return this.model.getLineContent(modelLineNumber) + newLineCharacter;
} else {
......@@ -546,7 +546,7 @@ export class ViewModel extends ViewEventEmitter implements IViewModel {
}
}
public getHTMLToCopy(viewRanges: Range[], enableEmptySelectionClipboard: boolean): string {
public getHTMLToCopy(viewRanges: Range[], emptySelectionClipboard: boolean): string {
if (this.model.getLanguageIdentifier().id === LanguageId.PlainText) {
return null;
}
......@@ -558,7 +558,7 @@ export class ViewModel extends ViewEventEmitter implements IViewModel {
let range = this.coordinatesConverter.convertViewRangeToModelRange(viewRanges[0]);
if (range.isEmpty()) {
if (!enableEmptySelectionClipboard) {
if (!emptySelectionClipboard) {
// nothing to copy
return null;
}
......
......@@ -81,9 +81,9 @@ class ExecCommandCutAction extends ExecCommandAction {
}
public run(accessor: ServicesAccessor, editor: editorCommon.ICommonCodeEditor): void {
var enableEmptySelectionClipboard = editor.getConfiguration().emptySelectionClipboard && browser.enableEmptySelectionClipboard;
const emptySelectionClipboard = editor.getConfiguration().emptySelectionClipboard;
if (!enableEmptySelectionClipboard && editor.getSelection().isEmpty()) {
if (!emptySelectionClipboard && editor.getSelection().isEmpty()) {
return;
}
......@@ -113,9 +113,9 @@ class ExecCommandCopyAction extends ExecCommandAction {
}
public run(accessor: ServicesAccessor, editor: editorCommon.ICommonCodeEditor): void {
var enableEmptySelectionClipboard = editor.getConfiguration().emptySelectionClipboard && browser.enableEmptySelectionClipboard;
const emptySelectionClipboard = editor.getConfiguration().emptySelectionClipboard;
if (!enableEmptySelectionClipboard && editor.getSelection().isEmpty()) {
if (!emptySelectionClipboard && editor.getSelection().isEmpty()) {
return;
}
......@@ -162,9 +162,9 @@ class ExecCommandCopyWithSyntaxHighlightingAction extends ExecCommandAction {
}
public run(accessor: ServicesAccessor, editor: editorCommon.ICommonCodeEditor): void {
var enableEmptySelectionClipboard = editor.getConfiguration().emptySelectionClipboard && browser.enableEmptySelectionClipboard;
const emptySelectionClipboard = editor.getConfiguration().emptySelectionClipboard;
if (!enableEmptySelectionClipboard && editor.getSelection().isEmpty()) {
if (!emptySelectionClipboard && editor.getSelection().isEmpty()) {
return;
}
......
......@@ -25,7 +25,7 @@ export function testCommand(
let model = Model.createFromString(lines.join('\n'), undefined, languageIdentifier);
let config = new TestConfiguration(null);
let cursor = new Cursor(config, model, viewModelHelper(model), false);
let cursor = new Cursor(config, model, viewModelHelper(model));
cursor.setSelections('tests', [selection]);
......
......@@ -21,7 +21,7 @@ const NO_TAB_SIZE = 0;
function testCommand(lines: string[], selections: Selection[], edits: IIdentifiedSingleEditOperation[], expectedLines: string[], expectedSelections: Selection[]): void {
let model = Model.createFromString(lines.join('\n'));
let config = new TestConfiguration(null);
let cursor = new Cursor(config, model, viewModelHelper(model), false);
let cursor = new Cursor(config, model, viewModelHelper(model));
cursor.setSelections('tests', selections);
......
......@@ -59,6 +59,7 @@ suite('Common Editor Config', () => {
outerWidth: 1000,
outerHeight: 100,
canUseTranslate3d: true,
emptySelectionClipboard: true,
pixelRatio: 1,
zoomLevel: 0
};
......
......@@ -146,7 +146,7 @@ suite('Editor Controller - Cursor', () => {
thisModel = Model.createFromString(text);
thisConfiguration = new TestConfiguration(null);
thisCursor = new Cursor(thisConfiguration, thisModel, viewModelHelper(thisModel), false);
thisCursor = new Cursor(thisConfiguration, thisModel, viewModelHelper(thisModel));
});
teardown(() => {
......@@ -705,7 +705,7 @@ suite('Editor Controller - Cursor', () => {
'\t\t}',
'\t}'
].join('\n'));
let cursor = new Cursor(new TestConfiguration(null), model, viewModelHelper(model), true);
let cursor = new Cursor(new TestConfiguration(null), model, viewModelHelper(model));
moveTo(cursor, 1, 7, false);
assertCursor(cursor, new Position(1, 7));
......@@ -739,7 +739,7 @@ suite('Editor Controller - Cursor', () => {
'var concat = require("gulp-concat");',
'var newer = require("gulp-newer");',
].join('\n'));
let cursor = new Cursor(new TestConfiguration(null), model, viewModelHelper(model), true);
let cursor = new Cursor(new TestConfiguration(null), model, viewModelHelper(model));
moveTo(cursor, 1, 4, false);
assertCursor(cursor, new Position(1, 4));
......@@ -774,7 +774,7 @@ suite('Editor Controller - Cursor', () => {
'<property id="SomeThing" key="SomeKey" value="000"/>',
'<property id="SomeThing" key="SomeKey" value="00X"/>',
].join('\n'));
let cursor = new Cursor(new TestConfiguration(null), model, viewModelHelper(model), true);
let cursor = new Cursor(new TestConfiguration(null), model, viewModelHelper(model));
moveTo(cursor, 10, 10, false);
assertCursor(cursor, new Position(10, 10));
......@@ -832,7 +832,7 @@ suite('Editor Controller - Cursor', () => {
'<property id="SomeThing" key="SomeKey" value="000"/>',
'<property id="SomeThing" key="SomeKey" value="00X"/>',
].join('\n'));
let cursor = new Cursor(new TestConfiguration(null), model, viewModelHelper(model), true);
let cursor = new Cursor(new TestConfiguration(null), model, viewModelHelper(model));
moveTo(cursor, 10, 10, false);
assertCursor(cursor, new Position(10, 10));
......@@ -877,7 +877,7 @@ suite('Editor Controller - Cursor', () => {
'var concat = require("gulp-concat");',
'var newer = require("gulp-newer");',
].join('\n'));
let cursor = new Cursor(new TestConfiguration(null), model, viewModelHelper(model), true);
let cursor = new Cursor(new TestConfiguration(null), model, viewModelHelper(model));
moveTo(cursor, 1, 4, false);
assertCursor(cursor, new Position(1, 4));
......@@ -1421,7 +1421,7 @@ suite('Editor Controller - Regression tests', () => {
'qwerty'
];
let model = Model.createFromString(text.join('\n'));
let cursor = new Cursor(new TestConfiguration(null), model, viewModelHelper(model), true);
let cursor = new Cursor(new TestConfiguration(null), model, viewModelHelper(model));
moveTo(cursor, 2, 1, false);
assertCursor(cursor, new Selection(2, 1, 2, 1));
......@@ -1439,7 +1439,7 @@ suite('Editor Controller - Regression tests', () => {
''
];
model = Model.createFromString(text.join('\n'));
cursor = new Cursor(new TestConfiguration(null), model, viewModelHelper(model), true);
cursor = new Cursor(new TestConfiguration(null), model, viewModelHelper(model));
moveTo(cursor, 2, 1, false);
assertCursor(cursor, new Selection(2, 1, 2, 1));
......@@ -2719,7 +2719,7 @@ interface ICursorOpts {
function usingCursor(opts: ICursorOpts, callback: (model: Model, cursor: Cursor) => void): void {
let model = Model.createFromString(opts.text.join('\n'), opts.modelOpts, opts.languageIdentifier);
let config = new TestConfiguration(opts.editorOpts);
let cursor = new Cursor(config, model, viewModelHelper(model), false);
let cursor = new Cursor(config, model, viewModelHelper(model));
callback(model, cursor);
......
......@@ -454,7 +454,7 @@ suite('Cursor move command test', () => {
});
function aCursor(viewModelHelper?: IViewModelHelper): Cursor {
return new Cursor(thisConfiguration, thisModel, viewModelHelper || aViewModelHelper(thisModel), false);
return new Cursor(thisConfiguration, thisModel, viewModelHelper || aViewModelHelper(thisModel));
}
});
......
......@@ -21,6 +21,7 @@ export class TestConfiguration extends CommonEditorConfiguration {
outerWidth: 100,
outerHeight: 100,
canUseTranslate3d: true,
emptySelectionClipboard: true,
pixelRatio: 1,
zoomLevel: 0
};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册