diff --git a/package.json b/package.json index cee5e19332714..4adc271a85709 100644 --- a/package.json +++ b/package.json @@ -35,6 +35,7 @@ "applicationinsights": "1.0.8", "chokidar": "3.2.3", "graceful-fs": "4.1.11", + "gulp-bom": "^3.0.0", "http-proxy-agent": "^2.1.0", "https-proxy-agent": "^2.2.3", "iconv-lite": "0.5.0", diff --git a/src/vs/editor/common/controller/cursorCommon.ts b/src/vs/editor/common/controller/cursorCommon.ts index ac2699979188a..d981f26a0a088 100644 --- a/src/vs/editor/common/controller/cursorCommon.ts +++ b/src/vs/editor/common/controller/cursorCommon.ts @@ -277,18 +277,21 @@ export class SingleCursorState { public readonly position: Position; public readonly leftoverVisibleColumns: number; public readonly selection: Selection; + public readonly isEnd: boolean; constructor( selectionStart: Range, selectionStartLeftoverVisibleColumns: number, position: Position, leftoverVisibleColumns: number, + isEnd: boolean = false ) { this.selectionStart = selectionStart; this.selectionStartLeftoverVisibleColumns = selectionStartLeftoverVisibleColumns; this.position = position; this.leftoverVisibleColumns = leftoverVisibleColumns; this.selection = SingleCursorState._computeSelection(this.selectionStart, this.position); + this.isEnd = isEnd; } public equals(other: SingleCursorState) { @@ -304,14 +307,15 @@ export class SingleCursorState { return (!this.selection.isEmpty() || !this.selectionStart.isEmpty()); } - public move(inSelectionMode: boolean, lineNumber: number, column: number, leftoverVisibleColumns: number): SingleCursorState { + public move(inSelectionMode: boolean, lineNumber: number, column: number, leftoverVisibleColumns: number, isEnd: boolean = false): SingleCursorState { if (inSelectionMode) { // move just position return new SingleCursorState( this.selectionStart, this.selectionStartLeftoverVisibleColumns, new Position(lineNumber, column), - leftoverVisibleColumns + leftoverVisibleColumns, + isEnd ); } else { // move everything @@ -319,7 +323,8 @@ export class SingleCursorState { new Range(lineNumber, column, lineNumber, column), leftoverVisibleColumns, new Position(lineNumber, column), - leftoverVisibleColumns + leftoverVisibleColumns, + isEnd ); } } diff --git a/src/vs/editor/common/controller/cursorMoveOperations.ts b/src/vs/editor/common/controller/cursorMoveOperations.ts index 1d414dd1f32a1..8be77b1031c7c 100644 --- a/src/vs/editor/common/controller/cursorMoveOperations.ts +++ b/src/vs/editor/common/controller/cursorMoveOperations.ts @@ -122,9 +122,13 @@ export class MoveOperations { column = cursor.position.column; } + if (cursor.isEnd) { + column = model.getLineMaxColumn(lineNumber + 1); + } + let r = MoveOperations.down(config, model, lineNumber, column, cursor.leftoverVisibleColumns, linesCount, true); - return cursor.move(inSelectionMode, r.lineNumber, r.column, r.leftoverVisibleColumns); + return cursor.move(inSelectionMode, r.lineNumber, cursor.isEnd ? column : r.column, r.leftoverVisibleColumns, cursor.isEnd); } public static translateDown(config: CursorConfiguration, model: ICursorSimpleModel, cursor: SingleCursorState): SingleCursorState { @@ -174,9 +178,13 @@ export class MoveOperations { column = cursor.position.column; } + if (cursor.isEnd) { + column = model.getLineMaxColumn(lineNumber - 1); + } + let r = MoveOperations.up(config, model, lineNumber, column, cursor.leftoverVisibleColumns, linesCount, true); - return cursor.move(inSelectionMode, r.lineNumber, r.column, r.leftoverVisibleColumns); + return cursor.move(inSelectionMode, r.lineNumber, cursor.isEnd ? column : r.column, r.leftoverVisibleColumns, cursor.isEnd); } public static translateUp(config: CursorConfiguration, model: ICursorSimpleModel, cursor: SingleCursorState): SingleCursorState { @@ -214,7 +222,7 @@ export class MoveOperations { public static moveToEndOfLine(config: CursorConfiguration, model: ICursorSimpleModel, cursor: SingleCursorState, inSelectionMode: boolean): SingleCursorState { let lineNumber = cursor.position.lineNumber; let maxColumn = model.getLineMaxColumn(lineNumber); - return cursor.move(inSelectionMode, lineNumber, maxColumn, 0); + return cursor.move(inSelectionMode, lineNumber, maxColumn, 0, true); } public static moveToBeginningOfBuffer(config: CursorConfiguration, model: ICursorSimpleModel, cursor: SingleCursorState, inSelectionMode: boolean): SingleCursorState { diff --git a/src/vs/editor/common/controller/oneCursor.ts b/src/vs/editor/common/controller/oneCursor.ts index 2bb0958313395..07716dbb5de98 100644 --- a/src/vs/editor/common/controller/oneCursor.ts +++ b/src/vs/editor/common/controller/oneCursor.ts @@ -99,7 +99,7 @@ export class OneCursor { ); const leftoverVisibleColumns = modelState.position.equals(position) ? modelState.leftoverVisibleColumns : 0; - modelState = new SingleCursorState(selectionStart, selectionStartLeftoverVisibleColumns, position, leftoverVisibleColumns); + modelState = new SingleCursorState(selectionStart, selectionStartLeftoverVisibleColumns, position, leftoverVisibleColumns, modelState.isEnd); } if (!viewState) { @@ -108,12 +108,12 @@ export class OneCursor { const viewSelectionStart2 = context.convertModelPositionToViewPosition(new Position(modelState.selectionStart.endLineNumber, modelState.selectionStart.endColumn)); const viewSelectionStart = new Range(viewSelectionStart1.lineNumber, viewSelectionStart1.column, viewSelectionStart2.lineNumber, viewSelectionStart2.column); const viewPosition = context.convertModelPositionToViewPosition(modelState.position); - viewState = new SingleCursorState(viewSelectionStart, modelState.selectionStartLeftoverVisibleColumns, viewPosition, modelState.leftoverVisibleColumns); + viewState = new SingleCursorState(viewSelectionStart, modelState.selectionStartLeftoverVisibleColumns, viewPosition, modelState.leftoverVisibleColumns, modelState.isEnd); } else { // Validate new view state const viewSelectionStart = context.validateViewRange(viewState.selectionStart, modelState.selectionStart); const viewPosition = context.validateViewPosition(viewState.position, modelState.position); - viewState = new SingleCursorState(viewSelectionStart, modelState.selectionStartLeftoverVisibleColumns, viewPosition, modelState.leftoverVisibleColumns); + viewState = new SingleCursorState(viewSelectionStart, modelState.selectionStartLeftoverVisibleColumns, viewPosition, modelState.leftoverVisibleColumns, viewState.isEnd); } this.modelState = modelState; diff --git a/yarn.lock b/yarn.lock index 6ef2a9f7c77e3..1e16ef4ba3fda 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3996,6 +3996,14 @@ gulp-azure-storage@^0.10.0: vinyl "^2.2.0" vinyl-fs "^3.0.3" +gulp-bom@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/gulp-bom/-/gulp-bom-3.0.0.tgz#b2f1ab0ef304ff5e593665b776ba517ef7ffb4ad" + integrity sha512-iw/J94F+MVlxG64Q17BSkHsyjpY17qHl3N3A/jDdrL77zQBkhKtTiKLqM4di9CUX/qFToyyeDsOWwH+rESBgmA== + dependencies: + plugin-error "^1.0.1" + through2 "^3.0.1" + gulp-buffer@0.0.2: version "0.0.2" resolved "https://registry.yarnpkg.com/gulp-buffer/-/gulp-buffer-0.0.2.tgz#af81b4346101736b49942ec6c9fa867ffe737036" @@ -8924,6 +8932,13 @@ through2@^3.0.0: readable-stream "2 || 3" xtend "~4.0.1" +through2@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/through2/-/through2-3.0.1.tgz#39276e713c3302edf9e388dd9c812dd3b825bd5a" + integrity sha512-M96dvTalPT3YbYLaKaCuwu+j06D/8Jfib0o/PxbVt6Amhv3dUAtW6rTV1jPgJSBG83I/e04Y6xkVdVhSRhi0ww== + dependencies: + readable-stream "2 || 3" + through2@~0.2.3: version "0.2.3" resolved "https://registry.yarnpkg.com/through2/-/through2-0.2.3.tgz#eb3284da4ea311b6cc8ace3653748a52abf25a3f"