diff --git a/extensions/typescript/src/features/bufferSyncSupport.ts b/extensions/typescript/src/features/bufferSyncSupport.ts index 4a3c929bdce4068e2885633853f50707fa843465..b2d41eb4759052ffaebbd2124756c2e536f529c0 100644 --- a/extensions/typescript/src/features/bufferSyncSupport.ts +++ b/extensions/typescript/src/features/bufferSyncSupport.ts @@ -21,8 +21,8 @@ class SyncedBuffer { private diagnosticRequestor: IDiagnosticRequestor; private client: ITypescriptServiceClient; - constructor(model: TextDocument, filepath: string, diagnosticRequestor: IDiagnosticRequestor, client: ITypescriptServiceClient) { - this.document = model; + constructor(document: TextDocument, filepath: string, diagnosticRequestor: IDiagnosticRequestor, client: ITypescriptServiceClient) { + this.document = document; this.filepath = filepath; this.diagnosticRequestor = diagnosticRequestor; this.client = client; @@ -30,26 +30,10 @@ class SyncedBuffer { public open(): void { let args: Proto.OpenRequestArgs = { - file: this.filepath + file: this.filepath, + fileContent: this.document.getText() }; this.client.execute('open', args, false); - // The last line never has a new line character at the end. So we use range. - // Sending a replace doesn't work if the buffer is newer then on disk and - // if changes are on the last line. In this case the tsserver has less characters - // which makes the tsserver bail since the range is invalid - /* - let lastLineRange = this.document.lineAt(this.document.lineCount - 1).range; - let text = this.document.getText(); - let changeArgs: Proto.ChangeRequestArgs = { - file: this.filepath, - line: 1, - offset: 1, - endLine: lastLineRange.end.line + 1, - endOffset: lastLineRange.end.character + 1, - insertString: text - } - this.client.execute('change', changeArgs, false); - */ } public close(): void { diff --git a/extensions/typescript/src/protocol.d.ts b/extensions/typescript/src/protocol.d.ts index 2eee75e8cab8c0ac64c68e1937be1381fdbae308..aabef0c9ab754c0c31fdf13caf4d6b17ecc04a85 100644 --- a/extensions/typescript/src/protocol.d.ts +++ b/extensions/typescript/src/protocol.d.ts @@ -4,251 +4,251 @@ * ------------------------------------------------------------------------------------------ */ /** - * A TypeScript Server message - */ + * A TypeScript Server message + */ export interface Message { /** - * Sequence number of the message - */ + * Sequence number of the message + */ seq: number; /** - * One of "request", "response", or "event" - */ + * One of "request", "response", or "event" + */ type: string; } /** - * Client-initiated request message - */ + * Client-initiated request message + */ export interface Request extends Message { /** - * The command to execute - */ + * The command to execute + */ command: string; /** - * Object containing arguments for the command - */ + * Object containing arguments for the command + */ arguments?: any; } /** - * Request to reload the project structure for all the opened files - */ + * Request to reload the project structure for all the opened files + */ export interface ReloadProjectsRequest extends Message { } /** - * Server-initiated event message - */ + * Server-initiated event message + */ export interface Event extends Message { /** - * Name of event - */ + * Name of event + */ event: string; /** - * Event-specific information - */ + * Event-specific information + */ body?: any; } /** - * Response by server to client request message. - */ + * Response by server to client request message. + */ export interface Response extends Message { /** - * Sequence number of the request message. - */ + * Sequence number of the request message. + */ request_seq: number; /** - * Outcome of the request. - */ + * Outcome of the request. + */ success: boolean; /** - * The command requested. - */ + * The command requested. + */ command: string; /** - * Contains error message if success === false. - */ + * Contains error message if success === false. + */ message?: string; /** - * Contains message body if success === true. - */ + * Contains message body if success === true. + */ body?: any; } /** - * Arguments for FileRequest messages. - */ + * Arguments for FileRequest messages. + */ export interface FileRequestArgs { /** - * The file for the request (absolute pathname required). - */ + * The file for the request (absolute pathname required). + */ file: string; } /** - * Arguments for ProjectInfoRequest request. - */ + * Arguments for ProjectInfoRequest request. + */ export interface ProjectInfoRequestArgs extends FileRequestArgs { /** - * Indicate if the file name list of the project is needed - */ + * Indicate if the file name list of the project is needed + */ needFileNameList: boolean; } /** - * A request to get the project information of the current file - */ + * A request to get the project information of the current file + */ export interface ProjectInfoRequest extends Request { arguments: ProjectInfoRequestArgs } /** - * Response message body for "projectInfo" request - */ + * Response message body for "projectInfo" request + */ export interface ProjectInfo { /** - * For configured project, this is the normalized path of the 'tsconfig.json' file - * For inferred project, this is undefined - */ + * For configured project, this is the normalized path of the 'tsconfig.json' file + * For inferred project, this is undefined + */ configFileName: string; /** - * The list of normalized file name in the project, including 'lib.d.ts' - */ + * The list of normalized file name in the project, including 'lib.d.ts' + */ fileNames?: string[]; } /** - * Response message for "projectInfo" request - */ + * Response message for "projectInfo" request + */ export interface ProjectInfoResponse extends Response { body?: ProjectInfo; } /** - * Request whose sole parameter is a file name. - */ + * Request whose sole parameter is a file name. + */ export interface FileRequest extends Request { arguments: FileRequestArgs; } /** - * Instances of this interface specify a location in a source file: - * (file, line, character offset), where line and character offset are 1-based. - */ + * Instances of this interface specify a location in a source file: + * (file, line, character offset), where line and character offset are 1-based. + */ export interface FileLocationRequestArgs extends FileRequestArgs { /** - * The line number for the request (1-based). - */ + * The line number for the request (1-based). + */ line: number; /** - * The character offset (on the line) for the request (1-based). - */ + * The character offset (on the line) for the request (1-based). + */ offset: number; } /** - * A request whose arguments specify a file location (file, line, col). - */ + * A request whose arguments specify a file location (file, line, col). + */ export interface FileLocationRequest extends FileRequest { arguments: FileLocationRequestArgs; } /** - * Arguments in document highlight request; include: filesToSearch, file, - * line, offset. - */ + * Arguments in document highlight request; include: filesToSearch, file, + * line, offset. + */ export interface DocumentHighlightsRequestArgs extends FileLocationRequestArgs { /** - * List of files to search for document highlights. - */ + * List of files to search for document highlights. + */ filesToSearch: string[]; } /** - * Go to definition request; value of command field is - * "definition". Return response giving the file locations that - * define the symbol found in file at location line, col. - */ + * Go to definition request; value of command field is + * "definition". Return response giving the file locations that + * define the symbol found in file at location line, col. + */ export interface DefinitionRequest extends FileLocationRequest { } /** - * Go to type request; value of command field is - * "typeDefinition". Return response giving the file locations that - * define the type for the symbol found in file at location line, col. - */ + * Go to type request; value of command field is + * "typeDefinition". Return response giving the file locations that + * define the type for the symbol found in file at location line, col. + */ export interface TypeDefinitionRequest extends FileLocationRequest { } /** - * Location in source code expressed as (one-based) line and character offset. - */ + * Location in source code expressed as (one-based) line and character offset. + */ export interface Location { line: number; offset: number; } /** - * Object found in response messages defining a span of text in source code. - */ + * Object found in response messages defining a span of text in source code. + */ export interface TextSpan { /** - * First character of the definition. - */ + * First character of the definition. + */ start: Location; /** - * One character past last character of the definition. - */ + * One character past last character of the definition. + */ end: Location; } /** - * Object found in response messages defining a span of text in a specific source file. - */ + * Object found in response messages defining a span of text in a specific source file. + */ export interface FileSpan extends TextSpan { /** - * File containing text span. - */ + * File containing text span. + */ file: string; } /** - * Definition response message. Gives text range for definition. - */ + * Definition response message. Gives text range for definition. + */ export interface DefinitionResponse extends Response { body?: FileSpan[]; } /** - * Definition response message. Gives text range for definition. - */ + * Definition response message. Gives text range for definition. + */ export interface TypeDefinitionResponse extends Response { body?: FileSpan[]; } /** - * Get occurrences request; value of command field is - * "occurrences". Return response giving spans that are relevant - * in the file at a given line and column. - */ + * Get occurrences request; value of command field is + * "occurrences". Return response giving spans that are relevant + * in the file at a given line and column. + */ export interface OccurrencesRequest extends FileLocationRequest { } export interface OccurrencesResponseItem extends FileSpan { /** - * True if the occurrence is a write location, false otherwise. - */ + * True if the occurrence is a write location, false otherwise. + */ isWriteAccess: boolean; } @@ -257,10 +257,10 @@ export interface OccurrencesResponse extends Response { } /** - * Get document highlights request; value of command field is - * "documentHighlights". Return response giving spans that are relevant - * in the file at a given line and column. - */ + * Get document highlights request; value of command field is + * "documentHighlights". Return response giving spans that are relevant + * in the file at a given line and column. + */ export interface DocumentHighlightsRequest extends FileLocationRequest { arguments: DocumentHighlightsRequestArgs } @@ -271,13 +271,13 @@ export interface HighlightSpan extends TextSpan { export interface DocumentHighlightsItem { /** - * File containing highlight spans. - */ + * File containing highlight spans. + */ file: string, /** - * Spans to highlight in file. - */ + * Spans to highlight in file. + */ highlightSpans: HighlightSpan[]; } @@ -286,55 +286,55 @@ export interface DocumentHighlightsResponse extends Response { } /** - * Find references request; value of command field is - * "references". Return response giving the file locations that - * reference the symbol found in file at location line, col. - */ + * Find references request; value of command field is + * "references". Return response giving the file locations that + * reference the symbol found in file at location line, col. + */ export interface ReferencesRequest extends FileLocationRequest { } export interface ReferencesResponseItem extends FileSpan { /** Text of line containing the reference. Including this - * with the response avoids latency of editor loading files - * to show text of reference line (the server already has - * loaded the referencing files). - */ + * with the response avoids latency of editor loading files + * to show text of reference line (the server already has + * loaded the referencing files). + */ lineText: string; /** - * True if reference is a write location, false otherwise. - */ + * True if reference is a write location, false otherwise. + */ isWriteAccess: boolean; } /** - * The body of a "references" response message. - */ + * The body of a "references" response message. + */ export interface ReferencesResponseBody { /** - * The file locations referencing the symbol. - */ + * The file locations referencing the symbol. + */ refs: ReferencesResponseItem[]; /** - * The name of the symbol. - */ + * The name of the symbol. + */ symbolName: string; /** - * The start character offset of the symbol (on the line provided by the references request). - */ + * The start character offset of the symbol (on the line provided by the references request). + */ symbolStartOffset: number; /** - * The full display name of the symbol. - */ + * The full display name of the symbol. + */ symbolDisplayString: string; } /** - * Response to "references" request. - */ + * Response to "references" request. + */ export interface ReferencesResponse extends Response { body?: ReferencesResponseBody; } @@ -346,53 +346,53 @@ export interface RenameRequestArgs extends FileLocationRequestArgs { /** - * Rename request; value of command field is "rename". Return - * response giving the file locations that reference the symbol - * found in file at location line, col. Also return full display - * name of the symbol so that client can print it unambiguously. - */ + * Rename request; value of command field is "rename". Return + * response giving the file locations that reference the symbol + * found in file at location line, col. Also return full display + * name of the symbol so that client can print it unambiguously. + */ export interface RenameRequest extends FileLocationRequest { arguments: RenameRequestArgs; } /** - * Information about the item to be renamed. - */ + * Information about the item to be renamed. + */ export interface RenameInfo { /** - * True if item can be renamed. - */ + * True if item can be renamed. + */ canRename: boolean; /** - * Error message if item can not be renamed. - */ + * Error message if item can not be renamed. + */ localizedErrorMessage?: string; /** - * Display name of the item to be renamed. - */ + * Display name of the item to be renamed. + */ displayName: string; /** - * Full display name of item to be renamed. - */ + * Full display name of item to be renamed. + */ fullDisplayName: string; /** - * The items's kind (such as 'className' or 'parameterName' or plain 'text'). - */ + * The items's kind (such as 'className' or 'parameterName' or plain 'text'). + */ kind: string; /** - * Optional modifiers for the kind (such as 'public'). - */ + * Optional modifiers for the kind (such as 'public'). + */ kindModifiers: string; } /** - * A group of text spans, all in 'file'. - */ + * A group of text spans, all in 'file'. + */ export interface SpanGroup { /** The file to which the spans apply */ file: string; @@ -402,26 +402,26 @@ export interface SpanGroup { export interface RenameResponseBody { /** - * Information about the item to be renamed. - */ + * Information about the item to be renamed. + */ info: RenameInfo; /** - * An array of span groups (one per file) that refer to the item to be renamed. - */ + * An array of span groups (one per file) that refer to the item to be renamed. + */ locs: SpanGroup[]; } /** - * Rename response message. - */ + * Rename response message. + */ export interface RenameResponse extends Response { body?: RenameResponseBody; } /** - * Editor options - */ + * Editor options + */ export interface EditorOptions { /** Number of spaces for each tab. Default value is 4. */ @@ -438,8 +438,8 @@ export interface EditorOptions { } /** - * Format options - */ + * Format options + */ export interface FormatOptions extends EditorOptions { /** Defines space handling after a comma delimiter. Default value is true. */ @@ -474,310 +474,315 @@ export interface FormatOptions extends EditorOptions { } /** - * Information found in a configure request. - */ + * Information found in a configure request. + */ export interface ConfigureRequestArguments { /** - * Information about the host, for example 'Emacs 24.4' or - * 'Sublime Text version 3075' - */ + * Information about the host, for example 'Emacs 24.4' or + * 'Sublime Text version 3075' + */ hostInfo?: string; /** - * If present, tab settings apply only to this file. - */ + * If present, tab settings apply only to this file. + */ file?: string; /** - * The format options to use during formatting and other code editing features. - */ + * The format options to use during formatting and other code editing features. + */ formatOptions?: FormatOptions; } /** - * Configure request; value of command field is "configure". Specifies - * host information, such as host type, tab size, and indent size. - */ + * Configure request; value of command field is "configure". Specifies + * host information, such as host type, tab size, and indent size. + */ export interface ConfigureRequest extends Request { arguments: ConfigureRequestArguments; } /** - * Response to "configure" request. This is just an acknowledgement, so - * no body field is required. - */ + * Response to "configure" request. This is just an acknowledgement, so + * no body field is required. + */ export interface ConfigureResponse extends Response { } /** - * Information found in an "open" request. - */ + * Information found in an "open" request. + */ export interface OpenRequestArgs extends FileRequestArgs { + /** + * Used when a version of the file content is known to be more up to date than the one on disk. + * Then the known content will be used upon opening instead of the disk copy + */ + fileContent?: string; } /** - * Open request; value of command field is "open". Notify the - * server that the client has file open. The server will not - * monitor the filesystem for changes in this file and will assume - * that the client is updating the server (using the change and/or - * reload messages) when the file changes. Server does not currently - * send a response to an open request. - */ + * Open request; value of command field is "open". Notify the + * server that the client has file open. The server will not + * monitor the filesystem for changes in this file and will assume + * that the client is updating the server (using the change and/or + * reload messages) when the file changes. Server does not currently + * send a response to an open request. + */ export interface OpenRequest extends Request { arguments: OpenRequestArgs; } /** - * Exit request; value of command field is "exit". Ask the server process - * to exit. - */ + * Exit request; value of command field is "exit". Ask the server process + * to exit. + */ export interface ExitRequest extends Request { } /** - * Close request; value of command field is "close". Notify the - * server that the client has closed a previously open file. If - * file is still referenced by open files, the server will resume - * monitoring the filesystem for changes to file. Server does not - * currently send a response to a close request. - */ + * Close request; value of command field is "close". Notify the + * server that the client has closed a previously open file. If + * file is still referenced by open files, the server will resume + * monitoring the filesystem for changes to file. Server does not + * currently send a response to a close request. + */ export interface CloseRequest extends FileRequest { } /** - * Quickinfo request; value of command field is - * "quickinfo". Return response giving a quick type and - * documentation string for the symbol found in file at location - * line, col. - */ + * Quickinfo request; value of command field is + * "quickinfo". Return response giving a quick type and + * documentation string for the symbol found in file at location + * line, col. + */ export interface QuickInfoRequest extends FileLocationRequest { } /** - * Body of QuickInfoResponse. - */ + * Body of QuickInfoResponse. + */ export interface QuickInfoResponseBody { /** - * The symbol's kind (such as 'className' or 'parameterName' or plain 'text'). - */ + * The symbol's kind (such as 'className' or 'parameterName' or plain 'text'). + */ kind: string; /** - * Optional modifiers for the kind (such as 'public'). - */ + * Optional modifiers for the kind (such as 'public'). + */ kindModifiers: string; /** - * Starting file location of symbol. - */ + * Starting file location of symbol. + */ start: Location; /** - * One past last character of symbol. - */ + * One past last character of symbol. + */ end: Location; /** - * Type and kind of symbol. - */ + * Type and kind of symbol. + */ displayString: string; /** - * Documentation associated with symbol. - */ + * Documentation associated with symbol. + */ documentation: string; } /** - * Quickinfo response message. - */ + * Quickinfo response message. + */ export interface QuickInfoResponse extends Response { body?: QuickInfoResponseBody; } /** - * Arguments for format messages. - */ + * Arguments for format messages. + */ export interface FormatRequestArgs extends FileLocationRequestArgs { /** - * Last line of range for which to format text in file. - */ + * Last line of range for which to format text in file. + */ endLine: number; /** - * Character offset on last line of range for which to format text in file. - */ + * Character offset on last line of range for which to format text in file. + */ endOffset: number; } /** - * Format request; value of command field is "format". Return - * response giving zero or more edit instructions. The edit - * instructions will be sorted in file order. Applying the edit - * instructions in reverse to file will result in correctly - * reformatted text. - */ + * Format request; value of command field is "format". Return + * response giving zero or more edit instructions. The edit + * instructions will be sorted in file order. Applying the edit + * instructions in reverse to file will result in correctly + * reformatted text. + */ export interface FormatRequest extends FileLocationRequest { arguments: FormatRequestArgs; } /** - * Object found in response messages defining an editing - * instruction for a span of text in source code. The effect of - * this instruction is to replace the text starting at start and - * ending one character before end with newText. For an insertion, - * the text span is empty. For a deletion, newText is empty. - */ + * Object found in response messages defining an editing + * instruction for a span of text in source code. The effect of + * this instruction is to replace the text starting at start and + * ending one character before end with newText. For an insertion, + * the text span is empty. For a deletion, newText is empty. + */ export interface CodeEdit { /** - * First character of the text span to edit. - */ + * First character of the text span to edit. + */ start: Location; /** - * One character past last character of the text span to edit. - */ + * One character past last character of the text span to edit. + */ end: Location; /** - * Replace the span defined above with this string (may be - * the empty string). - */ + * Replace the span defined above with this string (may be + * the empty string). + */ newText: string; } /** - * Format and format on key response message. - */ + * Format and format on key response message. + */ export interface FormatResponse extends Response { body?: CodeEdit[]; } /** - * Arguments for format on key messages. - */ + * Arguments for format on key messages. + */ export interface FormatOnKeyRequestArgs extends FileLocationRequestArgs { /** - * Key pressed (';', '\n', or '}'). - */ + * Key pressed (';', '\n', or '}'). + */ key: string; } /** - * Format on key request; value of command field is - * "formatonkey". Given file location and key typed (as string), - * return response giving zero or more edit instructions. The - * edit instructions will be sorted in file order. Applying the - * edit instructions in reverse to file will result in correctly - * reformatted text. - */ + * Format on key request; value of command field is + * "formatonkey". Given file location and key typed (as string), + * return response giving zero or more edit instructions. The + * edit instructions will be sorted in file order. Applying the + * edit instructions in reverse to file will result in correctly + * reformatted text. + */ export interface FormatOnKeyRequest extends FileLocationRequest { arguments: FormatOnKeyRequestArgs; } /** - * Arguments for completions messages. - */ + * Arguments for completions messages. + */ export interface CompletionsRequestArgs extends FileLocationRequestArgs { /** - * Optional prefix to apply to possible completions. - */ + * Optional prefix to apply to possible completions. + */ prefix?: string; } /** - * Completions request; value of command field is "completions". - * Given a file location (file, line, col) and a prefix (which may - * be the empty string), return the possible completions that - * begin with prefix. - */ + * Completions request; value of command field is "completions". + * Given a file location (file, line, col) and a prefix (which may + * be the empty string), return the possible completions that + * begin with prefix. + */ export interface CompletionsRequest extends FileLocationRequest { arguments: CompletionsRequestArgs; } /** - * Arguments for completion details request. - */ + * Arguments for completion details request. + */ export interface CompletionDetailsRequestArgs extends FileLocationRequestArgs { /** - * Names of one or more entries for which to obtain details. - */ + * Names of one or more entries for which to obtain details. + */ entryNames: string[]; } /** - * Completion entry details request; value of command field is - * "completionEntryDetails". Given a file location (file, line, - * col) and an array of completion entry names return more - * detailed information for each completion entry. - */ + * Completion entry details request; value of command field is + * "completionEntryDetails". Given a file location (file, line, + * col) and an array of completion entry names return more + * detailed information for each completion entry. + */ export interface CompletionDetailsRequest extends FileLocationRequest { arguments: CompletionDetailsRequestArgs; } /** - * Part of a symbol description. - */ + * Part of a symbol description. + */ export interface SymbolDisplayPart { /** - * Text of an item describing the symbol. - */ + * Text of an item describing the symbol. + */ text: string; /** - * The symbol's kind (such as 'className' or 'parameterName' or plain 'text'). - */ + * The symbol's kind (such as 'className' or 'parameterName' or plain 'text'). + */ kind: string; } /** - * An item found in a completion response. - */ + * An item found in a completion response. + */ export interface CompletionEntry { /** - * The symbol's name. - */ + * The symbol's name. + */ name: string; /** - * The symbol's kind (such as 'className' or 'parameterName'). - */ + * The symbol's kind (such as 'className' or 'parameterName'). + */ kind: string; /** - * Optional modifiers for the kind (such as 'public'). - */ + * Optional modifiers for the kind (such as 'public'). + */ kindModifiers: string; /** - * A string that is used for comparing completion items so that they can be ordered. This - * is often the same as the name but may be different in certain circumstances. - */ + * A string that is used for comparing completion items so that they can be ordered. This + * is often the same as the name but may be different in certain circumstances. + */ sortText: string; } /** - * Additional completion entry details, available on demand - */ + * Additional completion entry details, available on demand + */ export interface CompletionEntryDetails { /** - * The symbol's name. - */ + * The symbol's name. + */ name: string; /** - * The symbol's kind (such as 'className' or 'parameterName'). - */ + * The symbol's kind (such as 'className' or 'parameterName'). + */ kind: string; /** - * Optional modifiers for the kind (such as 'public'). - */ + * Optional modifiers for the kind (such as 'public'). + */ kindModifiers: string; /** - * Display parts of the symbol (similar to quick info). - */ + * Display parts of the symbol (similar to quick info). + */ displayParts: SymbolDisplayPart[]; /** - * Documentation strings for the symbol. - */ + * Documentation strings for the symbol. + */ documentation: SymbolDisplayPart[]; } @@ -790,422 +795,422 @@ export interface CompletionDetailsResponse extends Response { } /** - * Signature help information for a single parameter - */ + * Signature help information for a single parameter + */ export interface SignatureHelpParameter { /** - * The parameter's name - */ + * The parameter's name + */ name: string; /** - * Documentation of the parameter. - */ + * Documentation of the parameter. + */ documentation: SymbolDisplayPart[]; /** - * Display parts of the parameter. - */ + * Display parts of the parameter. + */ displayParts: SymbolDisplayPart[]; /** - * Whether the parameter is optional or not. - */ + * Whether the parameter is optional or not. + */ isOptional: boolean; } /** - * Represents a single signature to show in signature help. - */ + * Represents a single signature to show in signature help. + */ export interface SignatureHelpItem { /** - * Whether the signature accepts a variable number of arguments. - */ + * Whether the signature accepts a variable number of arguments. + */ isVariadic: boolean; /** - * The prefix display parts. - */ + * The prefix display parts. + */ prefixDisplayParts: SymbolDisplayPart[]; /** - * The suffix disaply parts. - */ + * The suffix disaply parts. + */ suffixDisplayParts: SymbolDisplayPart[]; /** - * The separator display parts. - */ + * The separator display parts. + */ separatorDisplayParts: SymbolDisplayPart[]; /** - * The signature helps items for the parameters. - */ + * The signature helps items for the parameters. + */ parameters: SignatureHelpParameter[]; /** - * The signature's documentation - */ + * The signature's documentation + */ documentation: SymbolDisplayPart[]; } /** - * Signature help items found in the response of a signature help request. - */ + * Signature help items found in the response of a signature help request. + */ export interface SignatureHelpItems { /** - * The signature help items. - */ + * The signature help items. + */ items: SignatureHelpItem[]; /** - * The span for which signature help should appear on a signature - */ + * The span for which signature help should appear on a signature + */ applicableSpan: TextSpan; /** - * The item selected in the set of available help items. - */ + * The item selected in the set of available help items. + */ selectedItemIndex: number; /** - * The argument selected in the set of parameters. - */ + * The argument selected in the set of parameters. + */ argumentIndex: number; /** - * The argument count - */ + * The argument count + */ argumentCount: number; } /** - * Arguments of a signature help request. - */ + * Arguments of a signature help request. + */ export interface SignatureHelpRequestArgs extends FileLocationRequestArgs { } /** - * Signature help request; value of command field is "signatureHelp". - * Given a file location (file, line, col), return the signature - * help. - */ + * Signature help request; value of command field is "signatureHelp". + * Given a file location (file, line, col), return the signature + * help. + */ export interface SignatureHelpRequest extends FileLocationRequest { arguments: SignatureHelpRequestArgs; } /** - * Repsonse object for a SignatureHelpRequest. - */ + * Repsonse object for a SignatureHelpRequest. + */ export interface SignatureHelpResponse extends Response { body?: SignatureHelpItems; } /** - * Arguments for GeterrForProject request. - */ +* Arguments for GeterrForProject request. +*/ export interface GeterrForProjectRequestArgs { /** - * the file requesting project error list - */ + * the file requesting project error list + */ file: string; /** - * Delay in milliseconds to wait before starting to compute - * errors for the files in the file list - */ + * Delay in milliseconds to wait before starting to compute + * errors for the files in the file list + */ delay: number; } /** - * GeterrForProjectRequest request; value of command field is - * "geterrForProject". It works similarly with 'Geterr', only - * it request for every file in this project. - */ + * GeterrForProjectRequest request; value of command field is + * "geterrForProject". It works similarly with 'Geterr', only + * it request for every file in this project. + */ export interface GeterrForProjectRequest extends Request { arguments: GeterrForProjectRequestArgs } /** - * Arguments for geterr messages. - */ + * Arguments for geterr messages. + */ export interface GeterrRequestArgs { /** - * List of file names for which to compute compiler errors. - * The files will be checked in list order. - */ + * List of file names for which to compute compiler errors. + * The files will be checked in list order. + */ files: string[]; /** - * Delay in milliseconds to wait before starting to compute - * errors for the files in the file list - */ + * Delay in milliseconds to wait before starting to compute + * errors for the files in the file list + */ delay: number; } /** - * Geterr request; value of command field is "geterr". Wait for - * delay milliseconds and then, if during the wait no change or - * reload messages have arrived for the first file in the files - * list, get the syntactic errors for the file, field requests, - * and then get the semantic errors for the file. Repeat with a - * smaller delay for each subsequent file on the files list. Best - * practice for an editor is to send a file list containing each - * file that is currently visible, in most-recently-used order. - */ + * Geterr request; value of command field is "geterr". Wait for + * delay milliseconds and then, if during the wait no change or + * reload messages have arrived for the first file in the files + * list, get the syntactic errors for the file, field requests, + * and then get the semantic errors for the file. Repeat with a + * smaller delay for each subsequent file on the files list. Best + * practice for an editor is to send a file list containing each + * file that is currently visible, in most-recently-used order. + */ export interface GeterrRequest extends Request { arguments: GeterrRequestArgs; } /** - * Item of diagnostic information found in a DiagnosticEvent message. - */ + * Item of diagnostic information found in a DiagnosticEvent message. + */ export interface Diagnostic { /** - * Starting file location at which text appies. - */ + * Starting file location at which text appies. + */ start: Location; /** - * The last file location at which the text applies. - */ + * The last file location at which the text applies. + */ end: Location; /** - * Text of diagnostic message. - */ + * Text of diagnostic message. + */ text: string; } export interface DiagnosticEventBody { /** - * The file for which diagnostic information is reported. - */ + * The file for which diagnostic information is reported. + */ file: string; /** - * An array of diagnostic information items. - */ + * An array of diagnostic information items. + */ diagnostics: Diagnostic[]; } /** - * Event message for "syntaxDiag" and "semanticDiag" event types. - * These events provide syntactic and semantic errors for a file. - */ + * Event message for "syntaxDiag" and "semanticDiag" event types. + * These events provide syntactic and semantic errors for a file. + */ export interface DiagnosticEvent extends Event { body?: DiagnosticEventBody; } /** - * Arguments for reload request. - */ + * Arguments for reload request. + */ export interface ReloadRequestArgs extends FileRequestArgs { /** - * Name of temporary file from which to reload file - * contents. May be same as file. - */ + * Name of temporary file from which to reload file + * contents. May be same as file. + */ tmpfile: string; } /** - * Reload request message; value of command field is "reload". - * Reload contents of file with name given by the 'file' argument - * from temporary file with name given by the 'tmpfile' argument. - * The two names can be identical. - */ + * Reload request message; value of command field is "reload". + * Reload contents of file with name given by the 'file' argument + * from temporary file with name given by the 'tmpfile' argument. + * The two names can be identical. + */ export interface ReloadRequest extends FileRequest { arguments: ReloadRequestArgs; } /** - * Response to "reload" request. This is just an acknowledgement, so - * no body field is required. - */ + * Response to "reload" request. This is just an acknowledgement, so + * no body field is required. + */ export interface ReloadResponse extends Response { } /** - * Arguments for saveto request. - */ + * Arguments for saveto request. + */ export interface SavetoRequestArgs extends FileRequestArgs { /** - * Name of temporary file into which to save server's view of - * file contents. - */ + * Name of temporary file into which to save server's view of + * file contents. + */ tmpfile: string; } /** - * Saveto request message; value of command field is "saveto". - * For debugging purposes, save to a temporaryfile (named by - * argument 'tmpfile') the contents of file named by argument - * 'file'. The server does not currently send a response to a - * "saveto" request. - */ + * Saveto request message; value of command field is "saveto". + * For debugging purposes, save to a temporaryfile (named by + * argument 'tmpfile') the contents of file named by argument + * 'file'. The server does not currently send a response to a + * "saveto" request. + */ export interface SavetoRequest extends FileRequest { arguments: SavetoRequestArgs; } /** - * Arguments for navto request message. - */ + * Arguments for navto request message. + */ export interface NavtoRequestArgs extends FileRequestArgs { /** - * Search term to navigate to from current location; term can - * be '.*' or an identifier prefix. - */ + * Search term to navigate to from current location; term can + * be '.*' or an identifier prefix. + */ searchValue: string; /** - * Optional limit on the number of items to return. - */ + * Optional limit on the number of items to return. + */ maxResultCount?: number; } /** - * Navto request message; value of command field is "navto". - * Return list of objects giving file locations and symbols that - * match the search term given in argument 'searchTerm'. The - * context for the search is given by the named file. - */ + * Navto request message; value of command field is "navto". + * Return list of objects giving file locations and symbols that + * match the search term given in argument 'searchTerm'. The + * context for the search is given by the named file. + */ export interface NavtoRequest extends FileRequest { arguments: NavtoRequestArgs; } /** - * An item found in a navto response. - */ + * An item found in a navto response. + */ export interface NavtoItem { /** - * The symbol's name. - */ + * The symbol's name. + */ name: string; /** - * The symbol's kind (such as 'className' or 'parameterName'). - */ + * The symbol's kind (such as 'className' or 'parameterName'). + */ kind: string; /** - * exact, substring, or prefix. - */ + * exact, substring, or prefix. + */ matchKind?: string; /** - * If this was a case sensitive or insensitive match. - */ + * If this was a case sensitive or insensitive match. + */ isCaseSensitive?: boolean; /** - * Optional modifiers for the kind (such as 'public'). - */ + * Optional modifiers for the kind (such as 'public'). + */ kindModifiers?: string; /** - * The file in which the symbol is found. - */ + * The file in which the symbol is found. + */ file: string; /** - * The location within file at which the symbol is found. - */ + * The location within file at which the symbol is found. + */ start: Location; /** - * One past the last character of the symbol. - */ + * One past the last character of the symbol. + */ end: Location; /** - * Name of symbol's container symbol (if any); for example, - * the class name if symbol is a class member. - */ + * Name of symbol's container symbol (if any); for example, + * the class name if symbol is a class member. + */ containerName?: string; /** - * Kind of symbol's container symbol (if any). - */ + * Kind of symbol's container symbol (if any). + */ containerKind?: string; } /** - * Navto response message. Body is an array of navto items. Each - * item gives a symbol that matched the search term. - */ + * Navto response message. Body is an array of navto items. Each + * item gives a symbol that matched the search term. + */ export interface NavtoResponse extends Response { body?: NavtoItem[]; } /** - * Arguments for change request message. - */ + * Arguments for change request message. + */ export interface ChangeRequestArgs extends FormatRequestArgs { /** - * Optional string to insert at location (file, line, offset). - */ + * Optional string to insert at location (file, line, offset). + */ insertString?: string; } /** - * Change request message; value of command field is "change". - * Update the server's view of the file named by argument 'file'. - * Server does not currently send a response to a change request. - */ + * Change request message; value of command field is "change". + * Update the server's view of the file named by argument 'file'. + * Server does not currently send a response to a change request. + */ export interface ChangeRequest extends FileLocationRequest { arguments: ChangeRequestArgs; } /** - * Response to "brace" request. - */ + * Response to "brace" request. + */ export interface BraceResponse extends Response { body?: TextSpan[]; } /** - * Brace matching request; value of command field is "brace". - * Return response giving the file locations of matching braces - * found in file at location line, offset. - */ + * Brace matching request; value of command field is "brace". + * Return response giving the file locations of matching braces + * found in file at location line, offset. + */ export interface BraceRequest extends FileLocationRequest { } /** - * NavBar itesm request; value of command field is "navbar". - * Return response giving the list of navigation bar entries - * extracted from the requested file. - */ + * NavBar itesm request; value of command field is "navbar". + * Return response giving the list of navigation bar entries + * extracted from the requested file. + */ export interface NavBarRequest extends FileRequest { } export interface NavigationBarItem { /** - * The item's display text. - */ + * The item's display text. + */ text: string; /** - * The symbol's kind (such as 'className' or 'parameterName'). - */ + * The symbol's kind (such as 'className' or 'parameterName'). + */ kind: string; /** - * Optional modifiers for the kind (such as 'public'). - */ + * Optional modifiers for the kind (such as 'public'). + */ kindModifiers?: string; /** - * The definition locations of the item. - */ + * The definition locations of the item. + */ spans: TextSpan[]; /** - * Optional children. - */ + * Optional children. + */ childItems?: NavigationBarItem[]; } diff --git a/extensions/typescript/src/typescriptServiceClient.ts b/extensions/typescript/src/typescriptServiceClient.ts index aba7e657c0dba8ef6b86751426790996363ffa0b..cd370db7f3783751e8523029f69cdafab6fce50e 100644 --- a/extensions/typescript/src/typescriptServiceClient.ts +++ b/extensions/typescript/src/typescriptServiceClient.ts @@ -40,7 +40,7 @@ interface RequestItem { export default class TypeScriptServiceClient implements ITypescriptServiceClient { - public static Trace: boolean = false; + public static Trace: boolean = process.env.TSS_TRACE || false; private host: ITypescriptServiceClientHost; private pathSeparator: string; diff --git a/src/vs/platform/keybinding/common/commands.ts b/src/vs/platform/keybinding/common/commands.ts new file mode 100644 index 0000000000000000000000000000000000000000..d3bfa2c93a76ee09fb0d7f93c9f5bbc538eba8f7 --- /dev/null +++ b/src/vs/platform/keybinding/common/commands.ts @@ -0,0 +1,37 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +'use strict'; + +import {IDisposable} from 'vs/base/common/lifecycle'; +import Event, {Emitter} from 'vs/base/common/event'; + + +export class ApiCommands { + + static Instance = new ApiCommands(); + + private _commands: { [id: string]: [(...args: any[]) => any, any] } = Object.create(null); + private _onDidAddCommand = new Emitter<{ id: string; handler: (...args: any[]) => any; thisArg?: any }>(); + + add(id: string, handler: (...args: any[]) => any, thisArg?: any) { + if (this._commands[id]) { + throw new Error(); + } + this._commands[id] = [handler, thisArg]; + this._onDidAddCommand.fire({ id, handler, thisArg }); + } + + track(callback: (event: { id: string; handler: (...args: any[]) => any; thisArg?: any }) => any): IDisposable { + for (let id in this._commands) { + let [handler, thisArg] = this._commands[id]; + callback({ id, handler, thisArg }); + } + return this._onDidAddCommand.event(callback); + } +} + +export function addApiCommand(id: string, handler: (...args: any[]) => any, thisArg?: any) { + ApiCommands.Instance.add(id, handler, thisArg); +} \ No newline at end of file diff --git a/src/vs/platform/keybinding/common/keybindingsRegistry.ts b/src/vs/platform/keybinding/common/keybindingsRegistry.ts index 65ac634a595b0a29e9e5f73b3363a8078e16ecc4..7275deb876ecfa698b7936849f0fdf83c907a94d 100644 --- a/src/vs/platform/keybinding/common/keybindingsRegistry.ts +++ b/src/vs/platform/keybinding/common/keybindingsRegistry.ts @@ -8,6 +8,7 @@ import {Registry} from 'vs/platform/platform'; import {ICommandHandler, ICommandsMap, IKeybindingItem, IKeybindings, IKeybindingContextRule} from 'vs/platform/keybinding/common/keybindingService'; import {KeybindingsUtils} from 'vs/platform/keybinding/common/keybindingsUtils'; import {KeyMod, KeyCode, BinaryKeybindings} from 'vs/base/common/keyCodes'; +import {ApiCommands} from 'vs/platform/keybinding/common/commands'; import Platform = require('vs/base/common/platform'); export interface ICommandRule extends IKeybindings { @@ -67,6 +68,17 @@ class KeybindingsRegistryImpl implements IKeybindingsRegistry { constructor() { this._keybindings = []; this._commands = Object.create(null); + ApiCommands.Instance.track(event => { + this.registerCommandDesc({ + id: event.id, + handler: function(accessor, args) { + event.handler.apply(event.thisArg, args); + }, + weight: this.WEIGHT.externalExtension(0), + context: undefined, + primary: undefined + }); + }); } public registerCommandRule(rule:ICommandRule): void { diff --git a/src/vs/workbench/api/common/extHostLanguageFeatureCommands.ts b/src/vs/workbench/api/common/extHostLanguageFeatureCommands.ts index 9c8b5e5469353595ce015c7eb37d59e2f777fbe7..260dc0aaae63a0ebb83059ede675bc6efb3b8dc4 100644 --- a/src/vs/workbench/api/common/extHostLanguageFeatureCommands.ts +++ b/src/vs/workbench/api/common/extHostLanguageFeatureCommands.ts @@ -35,6 +35,7 @@ import {NavigateTypesSupportRegistry, INavigateTypesSupport, ITypeBearing} from import {RenameRegistry} from 'vs/editor/contrib/rename/common/rename'; import {FormatRegistry, FormatOnTypeRegistry} from 'vs/editor/contrib/format/common/format'; import {ICodeLensData} from 'vs/editor/contrib/codelens/common/codelens'; +import {addApiCommand} from 'vs/platform/keybinding/common/commands'; export class ExtHostLanguageFeatureCommands { @@ -44,28 +45,30 @@ export class ExtHostLanguageFeatureCommands { constructor(commands: PluginHostCommands) { this._commands = commands; - this._register('vscode.executeWorkspaceSymbolProvider', this._executeWorkspaceSymbolProvider); - this._register('vscode.executeDefinitionProvider', this._executeDefinitionProvider); - this._register('vscode.executeHoverProvider', this._executeHoverProvider); - this._register('vscode.executeDocumentHighlights', this._executeDocumentHighlights); - this._register('vscode.executeReferenceProvider', this._executeReferenceProvider); - this._register('vscode.executeDocumentRenameProvider', this._executeDocumentRenameProvider); - this._register('vscode.executeSignatureHelpProvider', this._executeSignatureHelpProvider); - this._register('vscode.executeDocumentSymbolProvider', this._executeDocumentSymbolProvider); - this._register('vscode.executeCompletionItemProvider', this._executeCompletionItemProvider); - this._register('vscode.executeCodeActionProvider', this._executeCodeActionProvider); - this._register('vscode.executeCodeLensProvider', this._executeCodeLensProvider); - this._register('vscode.executeFormatDocumentProvider', this._executeFormatDocumentProvider); - this._register('vscode.executeFormatRangeProvider', this._executeFormatRangeProvider); - this._register('vscode.executeFormatOnTypeProvider', this._executeFormatOnTypeProvider); - } - - private _register(id: string, callback: (...args: any[]) => any): void { - this._disposables.push(this._commands.registerCommand(id, callback, this)); + addApiCommand('vscode.executeWorkspaceSymbolProvider', this._executeWorkspaceSymbolProvider, this); + addApiCommand('vscode.executeDefinitionProvider', this._executeDefinitionProvider, this); + addApiCommand('vscode.executeHoverProvider', this._executeHoverProvider, this); + addApiCommand('vscode.executeDocumentHighlights', this._executeDocumentHighlights, this); + addApiCommand('vscode.executeReferenceProvider', this._executeReferenceProvider, this); + addApiCommand('vscode.executeDocumentRenameProvider', this._executeDocumentRenameProvider, this); + addApiCommand('vscode.executeSignatureHelpProvider', this._executeSignatureHelpProvider, this); + addApiCommand('vscode.executeDocumentSymbolProvider', this._executeDocumentSymbolProvider, this); + addApiCommand('vscode.executeCompletionItemProvider', this._executeCompletionItemProvider, this); + addApiCommand('vscode.executeCodeActionProvider', this._executeCodeActionProvider, this); + addApiCommand('vscode.executeCodeLensProvider', this._executeCodeLensProvider, this); + addApiCommand('vscode.executeFormatDocumentProvider', this._executeFormatDocumentProvider, this); + addApiCommand('vscode.executeFormatRangeProvider', this._executeFormatRangeProvider, this); + addApiCommand('vscode.executeFormatOnTypeProvider', this._executeFormatOnTypeProvider, this); } // --- command impl + /** + * Execute workspace symbol provider. + * + * @param query Search string to match query symbol names + * @return A promise that resolves to an array of symbol information. + */ private _executeWorkspaceSymbolProvider(query: string): Thenable { return this._commands.executeCommand('_executeWorkspaceSymbolProvider', { query }).then(value => { if (Array.isArray(value)) { diff --git a/src/vs/workbench/api/common/pluginHostCommands.ts b/src/vs/workbench/api/common/pluginHostCommands.ts index bc57ffe399258c63f60d40397bd3af88571bc5a0..4c9defc22c5a1cf4ce326d592109fa0d333e3150 100644 --- a/src/vs/workbench/api/common/pluginHostCommands.ts +++ b/src/vs/workbench/api/common/pluginHostCommands.ts @@ -15,6 +15,7 @@ import {PluginHostEditors} from 'vs/workbench/api/common/pluginHostEditors'; import {IMessageService, Severity} from 'vs/platform/message/common/message'; import {canSerialize} from 'vs/base/common/marshalling'; import {toErrorMessage} from 'vs/base/common/errors'; +import {ApiCommands} from 'vs/platform/keybinding/common/commands'; import * as vscode from 'vscode'; @Remotable.PluginHostContext('PluginHostCommands') @@ -27,6 +28,11 @@ export class PluginHostCommands { constructor(@IThreadService threadService: IThreadService) { this._pluginHostEditors = threadService.getRemotable(PluginHostEditors); this._proxy = threadService.getRemotable(MainThreadCommands); + + ApiCommands.Instance.track(event => { + let {id, handler, thisArg} = event; + this.registerCommand(id, handler, thisArg); + }); } registerCommand(id: string, command: (...args: any[]) => T | Thenable, thisArgs?: any): vscode.Disposable { diff --git a/src/vs/workbench/electron-browser/main.contribution.ts b/src/vs/workbench/electron-browser/main.contribution.ts index b9b510ba41916f376e7f1e6cb72eba4d43592681..57f23a42a93ffea886414963b47809f3ddd41a4b 100644 --- a/src/vs/workbench/electron-browser/main.contribution.ts +++ b/src/vs/workbench/electron-browser/main.contribution.ts @@ -16,12 +16,13 @@ import {CloseEditorAction, ReloadWindowAction, ShowStartupPerformance, ZoomReset // Contribute Global Actions const viewCategory = nls.localize('view', "View"); -const developerCategory = nls.localize('developerCat', "Developer"); +const developerCategory = nls.localize('developer', "Developer"); +const fileCategory = nls.localize('file', "File"); const workbenchActionsRegistry = Registry.as(Extensions.WorkbenchActions); workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(NewWindowAction, NewWindowAction.ID, NewWindowAction.LABEL, { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_N })); workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(CloseWindowAction, CloseWindowAction.ID, CloseWindowAction.LABEL, { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_W })); -workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(CloseFolderAction, CloseFolderAction.ID, CloseFolderAction.LABEL, { primary: KeyMod.chord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyCode.KEY_F) }), nls.localize('file', "File")); -workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(OpenRecentAction, OpenRecentAction.ID, OpenRecentAction.LABEL), nls.localize('file', "File")); +workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(CloseFolderAction, CloseFolderAction.ID, CloseFolderAction.LABEL, { primary: KeyMod.chord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyCode.KEY_F) }), fileCategory); +workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(OpenRecentAction, OpenRecentAction.ID, OpenRecentAction.LABEL), fileCategory); workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(ToggleDevToolsAction, ToggleDevToolsAction.ID, ToggleDevToolsAction.LABEL), developerCategory); workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(ZoomInAction, ZoomInAction.ID, ZoomInAction.LABEL, { primary: KeyMod.CtrlCmd | KeyCode.US_EQUAL }), viewCategory); workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(ZoomOutAction, ZoomOutAction.ID, ZoomOutAction.LABEL, { primary: KeyMod.CtrlCmd | KeyCode.US_MINUS }), viewCategory); @@ -29,18 +30,11 @@ workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(ZoomRe workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(ShowStartupPerformance, ShowStartupPerformance.ID, ShowStartupPerformance.LABEL), developerCategory); workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(ReloadWindowAction, ReloadWindowAction.ID, ReloadWindowAction.LABEL)); workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(CloseMessagesAction, CloseMessagesAction.ID, CloseMessagesAction.LABEL, { primary: KeyCode.Escape }, [{ key: WorkbenchMessageService.GLOBAL_MESSAGES_SHOWING_CONTEXT }])); -workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(CloseEditorAction, CloseEditorAction.ID, CloseEditorAction.LABEL, { - primary: KeyMod.CtrlCmd | KeyCode.KEY_W, - win: { primary: KeyMod.CtrlCmd | KeyCode.F4, secondary: [KeyMod.CtrlCmd | KeyCode.KEY_W] } -}), viewCategory); -workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(ToggleFullScreenAction, ToggleFullScreenAction.ID, ToggleFullScreenAction.LABEL, { - primary: KeyCode.F11, - mac: { primary: KeyMod.CtrlCmd | KeyMod.WinCtrl | KeyCode.KEY_F } -}), viewCategory); +workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(CloseEditorAction, CloseEditorAction.ID, CloseEditorAction.LABEL, { primary: KeyMod.CtrlCmd | KeyCode.KEY_W, win: { primary: KeyMod.CtrlCmd | KeyCode.F4, secondary: [KeyMod.CtrlCmd | KeyCode.KEY_W] } }), viewCategory); +workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(ToggleFullScreenAction, ToggleFullScreenAction.ID, ToggleFullScreenAction.LABEL, { primary: KeyCode.F11, mac: { primary: KeyMod.CtrlCmd | KeyMod.WinCtrl | KeyCode.KEY_F } }), viewCategory); +// Configuration: Window const configurationRegistry = Registry.as(ConfigurationExtensions.Configuration); - -// Window Configuration configurationRegistry.registerConfiguration({ 'id': 'window', 'order': 6, @@ -66,7 +60,7 @@ configurationRegistry.registerConfiguration({ } }); -// Update Configuration +// Configuration: Update configurationRegistry.registerConfiguration({ 'id': 'update', 'order': 10, @@ -77,7 +71,7 @@ configurationRegistry.registerConfiguration({ 'type': 'string', 'default': 'stable', 'description': nls.localize('updateChannel', "Configure the update channel to receive updates from. Requires a restart after change.") - }, + } } }); diff --git a/src/vs/workbench/parts/debug/browser/media/repl.css b/src/vs/workbench/parts/debug/browser/media/repl.css index 4df1ad880f3e52915efec75bc66935448e1f297d..155d6987ec8251ee2aa52a12faec0cbf59f28fbe 100644 --- a/src/vs/workbench/parts/debug/browser/media/repl.css +++ b/src/vs/workbench/parts/debug/browser/media/repl.css @@ -15,8 +15,19 @@ height: calc(100% - 24px); } +.monaco-workbench .repl .surveyor { + font-family: Monaco, Menlo, Consolas, "Droid Sans Mono", "Inconsolata", "Courier New", monospace, "Droid Sans Fallback"; + position: absolute; + display: inline-block; + width : auto; + top: 0; + left: 0; + visibility: hidden; +} + .monaco-workbench .repl .repl-tree .monaco-tree .monaco-tree-row > .content { line-height: 24px; + word-wrap: break-word; -webkit-user-select: initial; } diff --git a/src/vs/workbench/parts/debug/browser/replEditor.ts b/src/vs/workbench/parts/debug/browser/replEditor.ts index b98b4ecf830b1ff6223cd464651341377c08e3c9..49b6229e8e15d99f16e41a6dae21799ecb7ba48d 100644 --- a/src/vs/workbench/parts/debug/browser/replEditor.ts +++ b/src/vs/workbench/parts/debug/browser/replEditor.ts @@ -48,6 +48,8 @@ export class Repl extends baseeditor.BaseEditor { private toDispose: lifecycle.IDisposable[]; private tree: tree.ITree; + private renderer: viewer.ReplExpressionsRenderer; + private characterWidthSurveyor: HTMLElement; private treeContainer: HTMLElement; private replInput: HTMLInputElement; private refreshTimeoutHandle: number; @@ -121,9 +123,17 @@ export class Repl extends baseeditor.BaseEditor { } }); + this.characterWidthSurveyor = dom.append(container, $('.surveyor')); + this.characterWidthSurveyor.textContent = 'a'; + for (let i = 0; i < 10; i++) { + this.characterWidthSurveyor.textContent += this.characterWidthSurveyor.textContent; + } + this.characterWidthSurveyor.style.fontSize = platform.isMacintosh ? '12px' : '14px'; + + this.renderer = this.instantiationService.createInstance(viewer.ReplExpressionsRenderer); this.tree = new treeimpl.Tree(this.treeContainer, { dataSource: new viewer.ReplExpressionsDataSource(this.debugService), - renderer: this.instantiationService.createInstance(viewer.ReplExpressionsRenderer), + renderer: this.renderer, controller: new viewer.ReplExpressionsController(this.debugService, this.contextMenuService, new viewer.ReplExpressionsActionProvider(this.instantiationService), this.replInput, false) }, replTreeOptions); @@ -146,7 +156,9 @@ export class Repl extends baseeditor.BaseEditor { public layout(dimension: builder.Dimension): void { if (this.tree) { + this.renderer.setWidth(dimension.width - 20, this.characterWidthSurveyor.clientWidth / this.characterWidthSurveyor.textContent.length); this.tree.layout(this.treeContainer.clientHeight); + this.tree.refresh().done(null, errors.onUnexpectedError); } } diff --git a/src/vs/workbench/parts/debug/browser/replViewer.ts b/src/vs/workbench/parts/debug/browser/replViewer.ts index e91cbf19d5b33a3c38cc95886269538662f8cf05..87816d05d95a29438ab0431a3768cb599eaeae47 100644 --- a/src/vs/workbench/parts/debug/browser/replViewer.ts +++ b/src/vs/workbench/parts/debug/browser/replViewer.ts @@ -107,6 +107,9 @@ export class ReplExpressionsRenderer implements tree.IRenderer { /((\/|[a-zA-Z]:\\)[^\(\)<>\'\"\[\]]+):(\d+):(\d+)/ ] + private width: number; + private characterWidth: number; + constructor( @debug.IDebugService private debugService: debug.IDebugService, @IWorkbenchEditorService private editorService: IWorkbenchEditorService, @@ -116,7 +119,20 @@ export class ReplExpressionsRenderer implements tree.IRenderer { } public getHeight(tree:tree.ITree, element:any): number { - return element instanceof model.Expression ? 48 : 24; + return this.getHeightForString(element.value) + (element instanceof model.Expression ? this.getHeightForString(element.name) : 0); + } + + private getHeightForString(s: string): number { + if (!s || !s.length || this.width <= 0 || this.characterWidth <= 0) { + return 24; + } + + return 24 * Math.ceil(s.length * this.characterWidth / this.width); + } + + public setWidth(fullWidth: number, characterWidth: number): void { + this.width = fullWidth; + this.characterWidth = characterWidth; } public getTemplateId(tree: tree.ITree, element: any): string { diff --git a/src/vs/workbench/parts/tasks/common/problemCollectors.ts b/src/vs/workbench/parts/tasks/common/problemCollectors.ts index bc2db5ae711c2d305e6708a2b6c7e3a1fa507876..042f3bdf6c87e73f5954111e895b372340029f7f 100644 --- a/src/vs/workbench/parts/tasks/common/problemCollectors.ts +++ b/src/vs/workbench/parts/tasks/common/problemCollectors.ts @@ -257,7 +257,7 @@ export class WatchingProblemCollector extends AbstractProblemCollector implement private markers: IStringDictionary; // Cleaning state - private ignoreOpenByOwner: IStringDictionary; + private ignoreOpenResourcesByOwner: IStringDictionary; private resourcesToClean: IStringDictionary>; constructor(problemMatchers: ProblemMatcher[], markerService: IMarkerService, modelService: IModelService) { @@ -266,7 +266,7 @@ export class WatchingProblemCollector extends AbstractProblemCollector implement this.markerService = markerService; this.resetCurrentResource(); this.resourcesToClean = Object.create(null); - this.ignoreOpenByOwner = Object.create(null); + this.ignoreOpenResourcesByOwner = Object.create(null); this.watchingBeginsPatterns = []; this.watchingEndsPatterns = []; this.problemMatchers.forEach(matcher => { @@ -283,13 +283,13 @@ export class WatchingProblemCollector extends AbstractProblemCollector implement this.emit(ProblemCollectorEvents.WatchingBeginDetected, {}); this.recordResourcesToClean(matcher.owner); } - let value: boolean = this.ignoreOpenByOwner[matcher.owner]; + let value: boolean = this.ignoreOpenResourcesByOwner[matcher.owner]; if (!value) { - this.ignoreOpenByOwner[matcher.owner] = (matcher.applyTo === ApplyToKind.closedDocuments); + this.ignoreOpenResourcesByOwner[matcher.owner] = (matcher.applyTo === ApplyToKind.closedDocuments); } else { let newValue = value && (matcher.applyTo === ApplyToKind.closedDocuments); if (newValue != value) { - this.ignoreOpenByOwner[matcher.owner] = newValue; + this.ignoreOpenResourcesByOwner[matcher.owner] = newValue; } } }) @@ -395,7 +395,8 @@ export class WatchingProblemCollector extends AbstractProblemCollector implement let resourceSet = this.resourcesToClean[owner]; if (resourceSet) { let toClean = Object.keys(resourceSet).map(key => resourceSet[key]).filter(resource => { - return this.ignoreOpenByOwner[owner] && !this.isOpen(resource); + // Check whether we need to ignore open documents for this owner. + return this.ignoreOpenResourcesByOwner[owner] ? !this.isOpen(resource) : true; }); this.markerService.remove(owner, toClean); if (remove) { diff --git a/src/vs/workbench/workbench.main.js b/src/vs/workbench/workbench.main.js index 54d4f319ecb343038d4581389d5ec9330149623b..4544520d105f5cdcca72e2502bc66dc0b853d221 100644 --- a/src/vs/workbench/workbench.main.js +++ b/src/vs/workbench/workbench.main.js @@ -30,6 +30,7 @@ define([ 'vs/workbench/browser/actions/triggerEditorActions', 'vs/workbench/browser/actions/triggerNavigation', 'vs/workbench/browser/actions/showPerformanceBox', + 'vs/workbench/browser/actions/openSettings', 'vs/workbench/parts/quickopen/browser/quickopen.contribution', @@ -56,7 +57,6 @@ define([ 'vs/workbench/parts/markdown/browser/markdownActions.contribution', 'vs/workbench/browser/workbench', - 'vs/workbench/browser/actions/openSettings', 'vs/workbench/parts/tasks/electron-browser/task.contribution',