diff --git a/src/vs/vscode.d.ts b/src/vs/vscode.d.ts index 330f4dca769..fb2b77f36b7 100644 --- a/src/vs/vscode.d.ts +++ b/src/vs/vscode.d.ts @@ -3588,14 +3588,15 @@ declare namespace vscode { export enum TextDocumentSaveReason { /** - * Explicitly triggered, e.g. by the user pressing save or by an API call. + * Manually triggered, e.g. by the user pressing save, by starting debugging, + * or by an API call. */ - Explicit = 1, + Manual = 1, /** * Automatic after a delay. */ - Auto = 2, + AfterDelay = 2, /** * When the editor lost focus. diff --git a/src/vs/workbench/api/node/extHostTypeConverters.ts b/src/vs/workbench/api/node/extHostTypeConverters.ts index 01a9145f80c..9aebafecfb2 100644 --- a/src/vs/workbench/api/node/extHostTypeConverters.ts +++ b/src/vs/workbench/api/node/extHostTypeConverters.ts @@ -4,16 +4,16 @@ *--------------------------------------------------------------------------------------------*/ 'use strict'; -import {ExtHostCommands} from 'vs/workbench/api/node/extHostCommands'; +import { ExtHostCommands } from 'vs/workbench/api/node/extHostCommands'; import Severity from 'vs/base/common/severity'; -import {isFalsyOrEmpty} from 'vs/base/common/arrays'; -import {IDisposable} from 'vs/base/common/lifecycle'; -import {stringDiff} from 'vs/base/common/diff/diff'; +import { isFalsyOrEmpty } from 'vs/base/common/arrays'; +import { IDisposable } from 'vs/base/common/lifecycle'; +import { stringDiff } from 'vs/base/common/diff/diff'; import * as modes from 'vs/editor/common/modes'; import * as types from './extHostTypes'; -import {Position as EditorPosition} from 'vs/platform/editor/common/editor'; -import {IPosition, ISelection, IRange, IDecorationOptions, ISingleEditOperation} from 'vs/editor/common/editorCommon'; -import {IWorkspaceSymbol} from 'vs/workbench/parts/search/common/search'; +import { Position as EditorPosition } from 'vs/platform/editor/common/editor'; +import { IPosition, ISelection, IRange, IDecorationOptions, ISingleEditOperation } from 'vs/editor/common/editorCommon'; +import { IWorkspaceSymbol } from 'vs/workbench/parts/search/common/search'; import * as vscode from 'vscode'; import URI from 'vs/base/common/uri'; import { SaveReason } from 'vs/workbench/parts/files/common/files'; @@ -69,8 +69,8 @@ export function toPosition(position: IPosition): types.Position { return new types.Position(position.lineNumber - 1, position.column - 1); } -export function fromPosition(position: types.Position):IPosition { - return { lineNumber: position.line + 1, column: position.character + 1}; +export function fromPosition(position: types.Position): IPosition { + return { lineNumber: position.line + 1, column: position.character + 1 }; } export function fromDiagnosticSeverity(value: number): Severity { @@ -118,11 +118,11 @@ export function toViewColumn(position?: EditorPosition): vscode.ViewColumn { return; } if (position === EditorPosition.LEFT) { - return types.ViewColumn.One; + return types.ViewColumn.One; } else if (position === EditorPosition.CENTER) { - return types.ViewColumn.Two; + return types.ViewColumn.Two; } else if (position === EditorPosition.RIGHT) { - return types.ViewColumn.Three; + return types.ViewColumn.Three; } } @@ -130,14 +130,14 @@ function isDecorationOptions(something: any): something is vscode.DecorationOpti return (typeof something.range !== 'undefined'); } -function isDecorationOptionsArr(something: vscode.Range[]|vscode.DecorationOptions[]): something is vscode.DecorationOptions[] { +function isDecorationOptionsArr(something: vscode.Range[] | vscode.DecorationOptions[]): something is vscode.DecorationOptions[] { if (something.length === 0) { return true; } return isDecorationOptions(something[0]) ? true : false; } -export function fromRangeOrRangeWithMessage(ranges:vscode.Range[]|vscode.DecorationOptions[]): IDecorationOptions[] { +export function fromRangeOrRangeWithMessage(ranges: vscode.Range[] | vscode.DecorationOptions[]): IDecorationOptions[] { if (isDecorationOptionsArr(ranges)) { return ranges.map((r): IDecorationOptions => { return { @@ -182,8 +182,8 @@ export const TextEdit = { for (let j = 0; j < changes.length; j++) { const {originalStart, originalLength, modifiedStart, modifiedLength} = changes[j]; - const start = fromPosition( document.positionAt(editOffset + originalStart)); - const end = fromPosition( document.positionAt(editOffset + originalStart + originalLength)); + const start = fromPosition(document.positionAt(editOffset + originalStart)); + const end = fromPosition(document.positionAt(editOffset + originalStart + originalLength)); result.push({ text: modified.substr(modifiedStart, modifiedLength), @@ -195,7 +195,7 @@ export const TextEdit = { return result; }, - from(edit: vscode.TextEdit): ISingleEditOperation{ + from(edit: vscode.TextEdit): ISingleEditOperation { return { text: edit.newText, range: fromRange(edit.range) @@ -443,9 +443,9 @@ export namespace TextDocumentSaveReason { export function to(reason: SaveReason): vscode.TextDocumentSaveReason { switch (reason) { case SaveReason.AUTO: - return types.TextDocumentSaveReason.Auto; + return types.TextDocumentSaveReason.AfterDelay; case SaveReason.EXPLICIT: - return types.TextDocumentSaveReason.Explicit; + return types.TextDocumentSaveReason.Manual; case SaveReason.FOCUS_CHANGE: case SaveReason.WINDOW_CHANGE: return types.TextDocumentSaveReason.FocusOut; diff --git a/src/vs/workbench/api/node/extHostTypes.ts b/src/vs/workbench/api/node/extHostTypes.ts index a1ce182b039..988810919c3 100644 --- a/src/vs/workbench/api/node/extHostTypes.ts +++ b/src/vs/workbench/api/node/extHostTypes.ts @@ -5,7 +5,7 @@ 'use strict'; import URI from 'vs/base/common/uri'; -import {illegalArgument} from 'vs/base/common/errors'; +import { illegalArgument } from 'vs/base/common/errors'; export class Disposable { @@ -149,7 +149,7 @@ export class Position { } } - translate(change: { lineDelta?: number; characterDelta?: number;}): Position; + translate(change: { lineDelta?: number; characterDelta?: number; }): Position; translate(lineDelta?: number, characterDelta?: number): Position; translate(lineDeltaOrChange: number | { lineDelta?: number; characterDelta?: number; }, characterDelta: number = 0): Position { @@ -230,7 +230,7 @@ export class Range { constructor(start: Position, end: Position); constructor(startLine: number, startColumn: number, endLine: number, endColumn: number); - constructor(startLineOrStart: number|Position, startColumnOrEnd: number|Position, endLine?: number, endColumn?: number) { + constructor(startLineOrStart: number | Position, startColumnOrEnd: number | Position, endLine?: number, endColumn?: number) { let start: Position; let end: Position; @@ -367,7 +367,7 @@ export class Selection extends Range { constructor(anchor: Position, active: Position); constructor(anchorLine: number, anchorColumn: number, activeLine: number, activeColumn: number); - constructor(anchorLineOrAnchor: number|Position, anchorColumnOrActive: number|Position, activeLine?: number, activeColumn?: number) { + constructor(anchorLineOrAnchor: number | Position, anchorColumnOrActive: number | Position, activeLine?: number, activeColumn?: number) { let anchor: Position; let active: Position; @@ -679,7 +679,7 @@ export class SymbolInformation { if (locationOrUri instanceof Location) { this.location = locationOrUri; } else if (rangeOrContainer instanceof Range) { - this.location = new Location( locationOrUri, rangeOrContainer); + this.location = new Location(locationOrUri, rangeOrContainer); } } @@ -832,8 +832,8 @@ export enum TextEditorLineNumbersStyle { } export enum TextDocumentSaveReason { - Explicit = 1, - Auto = 2, + Manual = 1, + AfterDelay = 2, FocusOut = 3 } diff --git a/src/vs/workbench/test/node/api/extHostDocumentSaveParticipant.test.ts b/src/vs/workbench/test/node/api/extHostDocumentSaveParticipant.test.ts index de00812a88f..d8ddd22601e 100644 --- a/src/vs/workbench/test/node/api/extHostDocumentSaveParticipant.test.ts +++ b/src/vs/workbench/test/node/api/extHostDocumentSaveParticipant.test.ts @@ -6,14 +6,14 @@ import * as assert from 'assert'; import URI from 'vs/base/common/uri'; -import {TPromise} from 'vs/base/common/winjs.base'; -import {ExtHostDocuments} from 'vs/workbench/api/node/extHostDocuments'; -import {TextDocumentSaveReason, TextEdit, Position} from 'vs/workbench/api/node/extHostTypes'; -import {MainThreadWorkspaceShape} from 'vs/workbench/api/node/extHost.protocol'; -import {ExtHostDocumentSaveParticipant} from 'vs/workbench/api/node/extHostDocumentSaveParticipant'; -import {OneGetThreadService} from './testThreadService'; +import { TPromise } from 'vs/base/common/winjs.base'; +import { ExtHostDocuments } from 'vs/workbench/api/node/extHostDocuments'; +import { TextDocumentSaveReason, TextEdit, Position } from 'vs/workbench/api/node/extHostTypes'; +import { MainThreadWorkspaceShape } from 'vs/workbench/api/node/extHost.protocol'; +import { ExtHostDocumentSaveParticipant } from 'vs/workbench/api/node/extHostDocumentSaveParticipant'; +import { OneGetThreadService } from './testThreadService'; import * as EditorCommon from 'vs/editor/common/editorCommon'; -import {IResourceEdit} from 'vs/editor/common/services/bulkEdit'; +import { IResourceEdit } from 'vs/editor/common/services/bulkEdit'; import { SaveReason } from 'vs/workbench/parts/files/common/files'; suite('ExtHostDocumentSaveParticipant', () => { @@ -62,7 +62,7 @@ suite('ExtHostDocumentSaveParticipant', () => { sub.dispose(); assert.ok(event); - assert.equal(event.reason, TextDocumentSaveReason.Explicit); + assert.equal(event.reason, TextDocumentSaveReason.Manual); assert.equal(typeof event.waitUntil, 'function'); }); });