未验证 提交 03adc22e 编写于 作者: A Alex Dima

Rename `includeEmptyLines` to `ignoreEmptyLines`

上级 20abb1a9
......@@ -1071,10 +1071,10 @@ export interface IEditorCommentsOptions {
*/
insertSpace?: boolean;
/**
* Includes commenting empty lines when inserting line comments.
* Defaults to false.
* Ignore empty lines when inserting line comments.
* Defaults to true.
*/
includeEmptyLines?: boolean;
ignoreEmptyLines?: boolean;
}
export type EditorCommentsOptions = Readonly<Required<IEditorCommentsOptions>>;
......@@ -1084,7 +1084,7 @@ class EditorComments extends BaseEditorOption<EditorOption.comments, EditorComme
constructor() {
const defaults: EditorCommentsOptions = {
insertSpace: true,
includeEmptyLines: false,
ignoreEmptyLines: true,
};
super(
EditorOption.comments, 'comments', defaults,
......@@ -1094,10 +1094,10 @@ class EditorComments extends BaseEditorOption<EditorOption.comments, EditorComme
default: defaults.insertSpace,
description: nls.localize('comments.insertSpace', "Controls whether a space character is inserted when commenting.")
},
'editor.comments.includeEmptyLines': {
'editor.comments.ignoreEmptyLines': {
type: 'boolean',
default: defaults.includeEmptyLines,
description: nls.localize('comments.includeEmptyLines', 'Controls if empty lines should be included with toggle, add or remove actions for line comments.')
default: defaults.ignoreEmptyLines,
description: nls.localize('comments.ignoreEmptyLines', 'Controls if empty lines should be ignored with toggle, add or remove actions for line comments.')
},
}
);
......@@ -1110,7 +1110,7 @@ class EditorComments extends BaseEditorOption<EditorOption.comments, EditorComme
const input = _input as IEditorCommentsOptions;
return {
insertSpace: EditorBooleanOption.boolean(input.insertSpace, this.defaultValue.insertSpace),
includeEmptyLines: EditorBooleanOption.boolean(input.includeEmptyLines, this.defaultValue.includeEmptyLines),
ignoreEmptyLines: EditorBooleanOption.boolean(input.ignoreEmptyLines, this.defaultValue.ignoreEmptyLines),
};
}
}
......
......@@ -41,7 +41,7 @@ abstract class CommentLineAction extends EditorAction {
modelOptions.tabSize,
this._type,
commentsOptions.insertSpace,
commentsOptions.includeEmptyLines
commentsOptions.ignoreEmptyLines
));
}
......
......@@ -53,7 +53,7 @@ export class LineCommentCommand implements ICommand {
private readonly _tabSize: number;
private readonly _type: Type;
private readonly _insertSpace: boolean;
private readonly _includeEmptyLines: boolean;
private readonly _ignoreEmptyLines: boolean;
private _selectionId: string | null;
private _deltaColumn: number;
private _moveEndPositionDown: boolean;
......@@ -63,7 +63,7 @@ export class LineCommentCommand implements ICommand {
tabSize: number,
type: Type,
insertSpace: boolean,
includeEmptyLines: boolean,
ignoreEmptyLines: boolean
) {
this._selection = selection;
this._tabSize = tabSize;
......@@ -72,7 +72,7 @@ export class LineCommentCommand implements ICommand {
this._selectionId = null;
this._deltaColumn = 0;
this._moveEndPositionDown = false;
this._includeEmptyLines = includeEmptyLines;
this._ignoreEmptyLines = ignoreEmptyLines;
}
/**
......@@ -108,7 +108,7 @@ export class LineCommentCommand implements ICommand {
* Analyze lines and decide which lines are relevant and what the toggle should do.
* Also, build up several offsets and lengths useful in the generation of editor operations.
*/
public static _analyzeLines(type: Type, insertSpace: boolean, model: ISimpleModel, lines: ILinePreflightData[], startLineNumber: number, includeEmptyLines: boolean): IPreflightData {
public static _analyzeLines(type: Type, insertSpace: boolean, model: ISimpleModel, lines: ILinePreflightData[], startLineNumber: number, ignoreEmptyLines: boolean): IPreflightData {
let onlyWhitespaceLines = true;
let shouldRemoveComments: boolean;
......@@ -129,13 +129,7 @@ export class LineCommentCommand implements ICommand {
if (lineContentStartOffset === -1) {
// Empty or whitespace only line
if (type === Type.Toggle) {
lineData.ignore = !includeEmptyLines;
} else if (type === Type.ForceAdd) {
lineData.ignore = !includeEmptyLines;
} else {
lineData.ignore = !includeEmptyLines;
}
lineData.ignore = ignoreEmptyLines;
lineData.commentStrOffset = lineContent.length;
continue;
}
......@@ -184,7 +178,7 @@ export class LineCommentCommand implements ICommand {
/**
* Analyze all lines and decide exactly what to do => not supported | insert line comments | remove line comments
*/
public static _gatherPreflightData(type: Type, insertSpace: boolean, model: ITextModel, startLineNumber: number, endLineNumber: number, includeEmptyLines: boolean): IPreflightData {
public static _gatherPreflightData(type: Type, insertSpace: boolean, model: ITextModel, startLineNumber: number, endLineNumber: number, ignoreEmptyLines: boolean): IPreflightData {
const lines = LineCommentCommand._gatherPreflightCommentStrings(model, startLineNumber, endLineNumber);
if (lines === null) {
return {
......@@ -192,7 +186,7 @@ export class LineCommentCommand implements ICommand {
};
}
return LineCommentCommand._analyzeLines(type, insertSpace, model, lines, startLineNumber, includeEmptyLines);
return LineCommentCommand._analyzeLines(type, insertSpace, model, lines, startLineNumber, ignoreEmptyLines);
}
/**
......@@ -340,7 +334,7 @@ export class LineCommentCommand implements ICommand {
model,
s.startLineNumber,
s.endLineNumber,
this._includeEmptyLines
this._ignoreEmptyLines
);
if (data.supported) {
......
......@@ -19,13 +19,13 @@ suite('Editor Contrib - Line Comment Command', () => {
function testLineCommentCommand(lines: string[], selection: Selection, expectedLines: string[], expectedSelection: Selection): void {
let mode = new CommentMode({ lineComment: '!@#', blockComment: ['<!@#', '#@!>'] });
testCommand(lines, mode.getLanguageIdentifier(), selection, (sel) => new LineCommentCommand(sel, 4, Type.Toggle, true, false), expectedLines, expectedSelection);
testCommand(lines, mode.getLanguageIdentifier(), selection, (sel) => new LineCommentCommand(sel, 4, Type.Toggle, true, true), expectedLines, expectedSelection);
mode.dispose();
}
function testAddLineCommentCommand(lines: string[], selection: Selection, expectedLines: string[], expectedSelection: Selection): void {
let mode = new CommentMode({ lineComment: '!@#', blockComment: ['<!@#', '#@!>'] });
testCommand(lines, mode.getLanguageIdentifier(), selection, (sel) => new LineCommentCommand(sel, 4, Type.ForceAdd, true, false), expectedLines, expectedSelection);
testCommand(lines, mode.getLanguageIdentifier(), selection, (sel) => new LineCommentCommand(sel, 4, Type.ForceAdd, true, true), expectedLines, expectedSelection);
mode.dispose();
}
......@@ -47,7 +47,7 @@ suite('Editor Contrib - Line Comment Command', () => {
test('case insensitive', function () {
function testLineCommentCommand(lines: string[], selection: Selection, expectedLines: string[], expectedSelection: Selection): void {
let mode = new CommentMode({ lineComment: 'rem' });
testCommand(lines, mode.getLanguageIdentifier(), selection, (sel) => new LineCommentCommand(sel, 4, Type.Toggle, true, false), expectedLines, expectedSelection);
testCommand(lines, mode.getLanguageIdentifier(), selection, (sel) => new LineCommentCommand(sel, 4, Type.Toggle, true, true), expectedLines, expectedSelection);
mode.dispose();
}
......@@ -631,7 +631,7 @@ suite('Editor Contrib - Line Comment Command', () => {
test('insertSpace false', () => {
function testLineCommentCommand(lines: string[], selection: Selection, expectedLines: string[], expectedSelection: Selection): void {
let mode = new CommentMode({ lineComment: '!@#' });
testCommand(lines, mode.getLanguageIdentifier(), selection, (sel) => new LineCommentCommand(sel, 4, Type.Toggle, false, false), expectedLines, expectedSelection);
testCommand(lines, mode.getLanguageIdentifier(), selection, (sel) => new LineCommentCommand(sel, 4, Type.Toggle, false, true), expectedLines, expectedSelection);
mode.dispose();
}
......@@ -650,7 +650,7 @@ suite('Editor Contrib - Line Comment Command', () => {
test('insertSpace false does not remove space', () => {
function testLineCommentCommand(lines: string[], selection: Selection, expectedLines: string[], expectedSelection: Selection): void {
let mode = new CommentMode({ lineComment: '!@#' });
testCommand(lines, mode.getLanguageIdentifier(), selection, (sel) => new LineCommentCommand(sel, 4, Type.Toggle, false, false), expectedLines, expectedSelection);
testCommand(lines, mode.getLanguageIdentifier(), selection, (sel) => new LineCommentCommand(sel, 4, Type.Toggle, false, true), expectedLines, expectedSelection);
mode.dispose();
}
......@@ -666,10 +666,10 @@ suite('Editor Contrib - Line Comment Command', () => {
);
});
suite('includeEmptyLines true', () => {
suite('ignoreEmptyLines false', () => {
function testLineCommentCommand(lines: string[], selection: Selection, expectedLines: string[], expectedSelection: Selection): void {
let mode = new CommentMode({ lineComment: '!@#', blockComment: ['<!@#', '#@!>'] });
testCommand(lines, mode.getLanguageIdentifier(), selection, (sel) => new LineCommentCommand(sel, 4, Type.Toggle, true, true), expectedLines, expectedSelection);
testCommand(lines, mode.getLanguageIdentifier(), selection, (sel) => new LineCommentCommand(sel, 4, Type.Toggle, true, false), expectedLines, expectedSelection);
mode.dispose();
}
......@@ -762,7 +762,7 @@ suite('Editor Contrib - Line Comment As Block Comment', () => {
function testLineCommentCommand(lines: string[], selection: Selection, expectedLines: string[], expectedSelection: Selection): void {
let mode = new CommentMode({ lineComment: '', blockComment: ['(', ')'] });
testCommand(lines, mode.getLanguageIdentifier(), selection, (sel) => new LineCommentCommand(sel, 4, Type.Toggle, true, false), expectedLines, expectedSelection);
testCommand(lines, mode.getLanguageIdentifier(), selection, (sel) => new LineCommentCommand(sel, 4, Type.Toggle, true, true), expectedLines, expectedSelection);
mode.dispose();
}
......@@ -873,7 +873,7 @@ suite('Editor Contrib - Line Comment As Block Comment', () => {
suite('Editor Contrib - Line Comment As Block Comment 2', () => {
function testLineCommentCommand(lines: string[], selection: Selection, expectedLines: string[], expectedSelection: Selection): void {
let mode = new CommentMode({ lineComment: null, blockComment: ['<!@#', '#@!>'] });
testCommand(lines, mode.getLanguageIdentifier(), selection, (sel) => new LineCommentCommand(sel, 4, Type.Toggle, true, false), expectedLines, expectedSelection);
testCommand(lines, mode.getLanguageIdentifier(), selection, (sel) => new LineCommentCommand(sel, 4, Type.Toggle, true, true), expectedLines, expectedSelection);
mode.dispose();
}
......@@ -1114,7 +1114,7 @@ suite('Editor Contrib - Line Comment in mixed modes', () => {
lines,
outerMode.getLanguageIdentifier(),
selection,
(sel) => new LineCommentCommand(sel, 4, Type.Toggle, true, false),
(sel) => new LineCommentCommand(sel, 4, Type.Toggle, true, true),
expectedLines,
expectedSelection,
true
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册