Refresh master with initial release/0.24 snapshot (#332)

* Initial port of release/0.24 source code

* Fix additional headers

* Fix a typo in launch.json
This commit is contained in:
Karl Burtram
2017-12-15 15:38:57 -08:00
committed by GitHub
parent 271b3a0b82
commit 6ad0df0e3e
7118 changed files with 107999 additions and 56466 deletions

View File

@@ -14,6 +14,7 @@ import { EditorContextKeys } from 'vs/editor/common/editorContextKeys';
import { ReplaceCommand, ReplaceCommandThatPreservesSelection } from 'vs/editor/common/commands/replaceCommand';
import { Range } from 'vs/editor/common/core/range';
import { Selection } from 'vs/editor/common/core/selection';
import { Position } from 'vs/editor/common/core/position';
import { editorAction, ServicesAccessor, IActionOptions, EditorAction } from 'vs/editor/common/editorCommonExtensions';
import { CopyLinesCommand } from './copyLinesCommand';
import { DeleteLinesCommand } from './deleteLinesCommand';
@@ -206,9 +207,17 @@ export class TrimTrailingWhitespaceAction extends EditorAction {
});
}
public run(accessor: ServicesAccessor, editor: ICommonCodeEditor): void {
public run(accessor: ServicesAccessor, editor: ICommonCodeEditor, args: any): void {
var command = new TrimTrailingWhitespaceCommand(editor.getSelection());
let cursors: Position[] = [];
if (args.reason === 'auto-save') {
// See https://github.com/editorconfig/editorconfig-vscode/issues/47
// It is very convenient for the editor config extension to invoke this action.
// So, if we get a reason:'auto-save' passed in, let's preserve cursor positions.
cursors = editor.getSelections().map(s => new Position(s.positionLineNumber, s.positionColumn));
}
var command = new TrimTrailingWhitespaceCommand(editor.getSelection(), cursors);
editor.pushUndoStop();
editor.executeCommands(this.id, [command]);
@@ -407,7 +416,9 @@ export abstract class AbstractDeleteAllToBoundaryAction extends EditorAction {
return EditOperation.replace(range, '');
});
editor.pushUndoStop();
editor.executeEdits(this.id, edits, endCursorState);
editor.pushUndoStop();
}
/**
@@ -673,8 +684,9 @@ export class JoinLinesAction extends EditorAction {
}
endCursorState.unshift(endPrimaryCursor);
editor.pushUndoStop();
editor.executeEdits(this.id, edits, endCursorState);
editor.pushUndoStop();
}
}

View File

@@ -108,7 +108,7 @@ export class MoveLinesCommand implements ICommand {
insertingText = newIndentation + this.trimLeft(movingLineText);
} else {
// no enter rule matches, let's check indentatin rules then.
virtualModel.getLineContent = (lineNumber) => {
virtualModel.getLineContent = (lineNumber: number) => {
if (lineNumber === s.startLineNumber) {
return model.getLineContent(movingLineNumber);
} else {
@@ -140,7 +140,7 @@ export class MoveLinesCommand implements ICommand {
}
} else {
// it doesn't match onEnter rules, let's check indentation rules then.
virtualModel.getLineContent = (lineNumber) => {
virtualModel.getLineContent = (lineNumber: number) => {
if (lineNumber === s.startLineNumber) {
return insertingText;
} else if (lineNumber >= s.startLineNumber + 1 && lineNumber <= s.endLineNumber + 1) {

View File

@@ -73,6 +73,32 @@ suite('Editor Contrib - Line Operations', () => {
assert.equal(model.getLineContent(5), 'horlworld', '005');
});
});
test('issue #36234: should push undo stop', () => {
withMockCodeEditor(
[
'one',
'two',
'three'
], {}, (editor, cursor) => {
let model = editor.getModel();
let deleteAllLeftAction = new DeleteAllLeftAction();
editor.setSelection(new Selection(1, 1, 1, 1));
editor.trigger('keyboard', Handler.Type, { text: 'Typing some text here on line ' });
assert.equal(model.getLineContent(1), 'Typing some text here on line one');
assert.deepEqual(editor.getSelection(), new Selection(1, 31, 1, 31));
deleteAllLeftAction.run(null, editor);
assert.equal(model.getLineContent(1), 'one');
assert.deepEqual(editor.getSelection(), new Selection(1, 1, 1, 1));
editor.trigger('keyboard', Handler.Undo, {});
assert.equal(model.getLineContent(1), 'Typing some text here on line one');
assert.deepEqual(editor.getSelection(), new Selection(1, 31, 1, 31));
});
});
});
suite('JoinLinesAction', () => {
@@ -164,6 +190,31 @@ suite('Editor Contrib - Line Operations', () => {
assert.deepEqual(editor.getSelection().toString(), new Selection(3, 4, 3, 8).toString(), '003');
});
});
test('should push undo stop', function () {
withMockCodeEditor(
[
'hello',
'world'
], {}, (editor, cursor) => {
let model = editor.getModel();
let joinLinesAction = new JoinLinesAction();
editor.setSelection(new Selection(1, 6, 1, 6));
editor.trigger('keyboard', Handler.Type, { text: ' my dear' });
assert.equal(model.getLineContent(1), 'hello my dear');
assert.deepEqual(editor.getSelection(), new Selection(1, 14, 1, 14));
joinLinesAction.run(null, editor);
assert.equal(model.getLineContent(1), 'hello my dear world');
assert.deepEqual(editor.getSelection(), new Selection(1, 14, 1, 14));
editor.trigger('keyboard', Handler.Undo, {});
assert.equal(model.getLineContent(1), 'hello my dear');
assert.deepEqual(editor.getSelection(), new Selection(1, 14, 1, 14));
});
});
});
test('transpose', function () {

View File

@@ -77,7 +77,7 @@ suite('Editor Contrib - Sort Lines Command', () => {
'third line',
'fifth'
],
new Selection(3, 3, 4, 2)
new Selection(3, 3, 4, 1)
);
});
@@ -119,7 +119,7 @@ suite('Editor Contrib - Sort Lines Command', () => {
'second line',
'third line',
],
new Selection(1, 1, 5, 6)
new Selection(1, 1, 5, 11)
);
});