Merge VS Code 1.23.1 (#1520)

This commit is contained in:
Matt Irvine
2018-06-05 11:24:51 -07:00
committed by GitHub
parent e3baf5c443
commit 0c58f09e59
3651 changed files with 74249 additions and 48599 deletions

View File

@@ -32,10 +32,24 @@ export class BlockCommentCommand implements editorCommon.ICommand {
if (offset + needleLength > haystackLength) {
return false;
}
for (let i = 0; i < needleLength; i++) {
if (haystack.charCodeAt(offset + i) !== needle.charCodeAt(i)) {
return false;
const codeA = haystack.charCodeAt(offset + i);
const codeB = needle.charCodeAt(i);
if (codeA === codeB) {
continue;
}
if (codeA >= CharCode.A && codeA <= CharCode.Z && codeA + 32 === codeB) {
// codeA is upper-case variant of codeB
continue;
}
if (codeB >= CharCode.A && codeB <= CharCode.Z && codeB + 32 === codeA) {
// codeB is upper-case variant of codeA
continue;
}
return false;
}
return true;
}

View File

@@ -51,7 +51,7 @@ class ToggleCommentLineAction extends CommentLineAction {
alias: 'Toggle Line Comment',
precondition: EditorContextKeys.writable,
kbOpts: {
kbExpr: EditorContextKeys.textFocus,
kbExpr: EditorContextKeys.editorTextFocus,
primary: KeyMod.CtrlCmd | KeyCode.US_SLASH
}
});
@@ -66,7 +66,7 @@ class AddLineCommentAction extends CommentLineAction {
alias: 'Add Line Comment',
precondition: EditorContextKeys.writable,
kbOpts: {
kbExpr: EditorContextKeys.textFocus,
kbExpr: EditorContextKeys.editorTextFocus,
primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_C)
}
});
@@ -81,7 +81,7 @@ class RemoveLineCommentAction extends CommentLineAction {
alias: 'Remove Line Comment',
precondition: EditorContextKeys.writable,
kbOpts: {
kbExpr: EditorContextKeys.textFocus,
kbExpr: EditorContextKeys.editorTextFocus,
primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_U)
}
});
@@ -97,7 +97,7 @@ class BlockCommentAction extends EditorAction {
alias: 'Toggle Block Comment',
precondition: EditorContextKeys.writable,
kbOpts: {
kbExpr: EditorContextKeys.textFocus,
kbExpr: EditorContextKeys.editorTextFocus,
primary: KeyMod.Shift | KeyMod.Alt | KeyCode.KEY_A,
linux: { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_A }
}

View File

@@ -336,10 +336,10 @@ export class LineCommentCommand implements editorCommon.ICommand {
}
return new Selection(
result.startLineNumber,
result.startColumn + this._deltaColumn,
result.endLineNumber,
result.endColumn + this._deltaColumn
result.selectionStartLineNumber,
result.selectionStartColumn + this._deltaColumn,
result.positionLineNumber,
result.positionColumn + this._deltaColumn
);
}

View File

@@ -45,6 +45,25 @@ 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), expectedLines, expectedSelection);
mode.dispose();
}
testLineCommentCommand(
[
'REM some text'
],
new Selection(1, 1, 1, 1),
[
'some text'
],
new Selection(1, 1, 1, 1)
);
});
function createSimpleModel(lines: string[]): ISimpleModel {
return {
getLineContent: (lineNumber: number) => {
@@ -237,7 +256,7 @@ suite('Editor Contrib - Line Comment Command', () => {
'\t!@# some text',
'\t!@# some more text'
],
new Selection(1, 1, 2, 2)
new Selection(2, 2, 1, 1)
);
});
@@ -252,7 +271,7 @@ suite('Editor Contrib - Line Comment Command', () => {
'\t!@# some text',
' !@# some more text'
],
new Selection(1, 1, 2, 2)
new Selection(2, 2, 1, 1)
);
});
@@ -271,7 +290,7 @@ suite('Editor Contrib - Line Comment Command', () => {
'',
'\t!@# some more text'
],
new Selection(1, 1, 4, 2)
new Selection(4, 2, 1, 1)
);
});
@@ -288,7 +307,7 @@ suite('Editor Contrib - Line Comment Command', () => {
'\t ',
'\t\tsome more text'
],
new Selection(1, 1, 3, 2)
new Selection(3, 2, 1, 1)
);
});
@@ -305,7 +324,7 @@ suite('Editor Contrib - Line Comment Command', () => {
'\t!@# ',
'\t\tsome more text'
],
new Selection(1, 1, 3, 1)
new Selection(3, 1, 1, 1)
);
});
@@ -350,7 +369,7 @@ suite('Editor Contrib - Line Comment Command', () => {
'first!@#',
'\t!@# second line'
],
new Selection(2, 1, 2, 7)
new Selection(2, 7, 2, 1)
);
});
@@ -371,7 +390,7 @@ suite('Editor Contrib - Line Comment Command', () => {
'fourth line',
'fifth'
],
new Selection(1, 5, 2, 1)
new Selection(2, 1, 1, 5)
);
});
@@ -392,7 +411,7 @@ suite('Editor Contrib - Line Comment Command', () => {
'fourth line',
'fifth'
],
new Selection(1, 5, 2, 8)
new Selection(2, 8, 1, 5)
);
});
@@ -413,7 +432,7 @@ suite('Editor Contrib - Line Comment Command', () => {
'!@# fourth line',
'fifth'
],
new Selection(3, 5, 4, 8)
new Selection(4, 8, 3, 5)
);
});
@@ -474,7 +493,7 @@ suite('Editor Contrib - Line Comment Command', () => {
'fourth line',
'fifth'
],
new Selection(1, 5, 2, 8)
new Selection(2, 8, 1, 5)
);
testLineCommentCommand(
@@ -493,7 +512,7 @@ suite('Editor Contrib - Line Comment Command', () => {
'fourth line',
'fifth'
],
new Selection(1, 1, 2, 3)
new Selection(2, 3, 1, 1)
);
});
@@ -588,6 +607,21 @@ suite('Editor Contrib - Line Comment Command', () => {
new Selection(1, 1, 8, 60)
);
});
test('issue #47004: Toggle comments shouldn\'t move cursor', () => {
testAddLineCommentCommand(
[
' A line',
' Another line'
],
new Selection(2, 7, 1, 1),
[
' !@# A line',
' !@# Another line'
],
new Selection(2, 11, 1, 1)
);
});
});
suite('Editor Contrib - Line Comment As Block Comment', () => {
@@ -636,7 +670,7 @@ suite('Editor Contrib - Line Comment As Block Comment', () => {
'fourth line',
'fifth'
],
new Selection(1, 1, 1, 6)
new Selection(1, 6, 1, 1)
);
});
@@ -678,7 +712,7 @@ suite('Editor Contrib - Line Comment As Block Comment', () => {
'fourth line',
'fifth'
],
new Selection(1, 5, 3, 2)
new Selection(3, 2, 1, 5)
);
testLineCommentCommand(
@@ -697,7 +731,7 @@ suite('Editor Contrib - Line Comment As Block Comment', () => {
'fourth line',
'fifth'
],
new Selection(1, 1, 3, 11)
new Selection(3, 11, 1, 1)
);
});
});
@@ -823,7 +857,7 @@ suite('Editor Contrib - Line Comment As Block Comment 2', () => {
'fourth line',
'\t\tfifth\t\t'
],
new Selection(5, 3, 5, 8)
new Selection(5, 8, 5, 3)
);
testLineCommentCommand(
@@ -842,7 +876,7 @@ suite('Editor Contrib - Line Comment As Block Comment 2', () => {
'fourth line',
'\t\tfifth\t\t'
],
new Selection(5, 3, 5, 8)
new Selection(5, 8, 5, 3)
);
testLineCommentCommand(