mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-27 12:04:04 +01:00
Merge remote-tracking branch 'origin/master' into 46192_terminal_renderer
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
'use strict';
|
||||
|
||||
import { Disposable, IDisposable, dispose } from 'vs/base/common/lifecycle';
|
||||
import { ICodeEditor, getCodeEditor } from 'vs/editor/browser/editorBrowser';
|
||||
import { ICodeEditor, isCodeEditor, isDiffEditor, IDiffEditor } from 'vs/editor/browser/editorBrowser';
|
||||
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
|
||||
import * as modes from 'vs/editor/common/modes';
|
||||
import { extHostNamedCustomer } from 'vs/workbench/api/electron-browser/extHostCustomers';
|
||||
@@ -37,23 +37,25 @@ export class MainThreadComments extends Disposable implements MainThreadComments
|
||||
this._disposables = [];
|
||||
this._proxy = extHostContext.getProxy(ExtHostContext.ExtHostComments);
|
||||
this._disposables.push(this._editorService.onDidActiveEditorChange(e => {
|
||||
const outerEditor = this.getFocusedEditor();
|
||||
if (!outerEditor) {
|
||||
const editors = this.getFocusedEditors();
|
||||
if (!editors || !editors.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
const controller = ReviewController.get(outerEditor);
|
||||
if (!controller) {
|
||||
return;
|
||||
}
|
||||
editors.forEach(editor => {
|
||||
const controller = ReviewController.get(editor);
|
||||
if (!controller) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!outerEditor.getModel()) {
|
||||
return;
|
||||
}
|
||||
if (!editor.getModel()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const outerEditorURI = outerEditor.getModel().uri;
|
||||
this.provideDocumentComments(outerEditorURI).then(commentInfos => {
|
||||
this._commentService.setDocumentComments(outerEditorURI, commentInfos.filter(info => info !== null));
|
||||
const outerEditorURI = editor.getModel().uri;
|
||||
this.provideDocumentComments(outerEditorURI).then(commentInfos => {
|
||||
this._commentService.setDocumentComments(outerEditorURI, commentInfos.filter(info => info !== null));
|
||||
});
|
||||
});
|
||||
}));
|
||||
}
|
||||
@@ -115,8 +117,25 @@ export class MainThreadComments extends Disposable implements MainThreadComments
|
||||
this._documentProviders.clear();
|
||||
}
|
||||
|
||||
getFocusedEditor(): ICodeEditor {
|
||||
return this._codeEditorService.getFocusedCodeEditor() || getCodeEditor(this._editorService.activeControl);
|
||||
getFocusedEditors(): ICodeEditor[] {
|
||||
let activeControl = this._editorService.activeControl;
|
||||
if (activeControl) {
|
||||
if (isCodeEditor(activeControl.getControl())) {
|
||||
return [this._editorService.activeControl.getControl() as ICodeEditor];
|
||||
}
|
||||
|
||||
if (isDiffEditor(activeControl.getControl())) {
|
||||
let diffEditor = activeControl.getControl() as IDiffEditor;
|
||||
return [diffEditor.getOriginalEditor(), diffEditor.getModifiedEditor()];
|
||||
}
|
||||
}
|
||||
|
||||
let editor = this._codeEditorService.getFocusedCodeEditor();
|
||||
|
||||
if (editor) {
|
||||
return [editor];
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
async provideWorkspaceComments(): Promise<modes.CommentThread[]> {
|
||||
|
||||
@@ -19,6 +19,7 @@ import { IEditorService } from 'vs/workbench/services/editor/common/editorServic
|
||||
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
|
||||
import { IEditorGroupsService } from 'vs/workbench/services/group/common/editorGroupsService';
|
||||
import { extHostNamedCustomer } from './extHostCustomers';
|
||||
import * as vscode from 'vscode';
|
||||
|
||||
@extHostNamedCustomer(MainContext.MainThreadWebviews)
|
||||
export class MainThreadWebviews implements MainThreadWebviewsShape, WebviewReviver {
|
||||
@@ -105,6 +106,14 @@ export class MainThreadWebviews implements MainThreadWebviewsShape, WebviewReviv
|
||||
webview.html = value;
|
||||
}
|
||||
|
||||
$setOptions(handle: WebviewPanelHandle, options: vscode.WebviewOptions): void {
|
||||
const webview = this.getWebview(handle);
|
||||
webview.setOptions({
|
||||
...options,
|
||||
localResourceRoots: Array.isArray(options.localResourceRoots) ? options.localResourceRoots.map(URI.revive) : undefined
|
||||
});
|
||||
}
|
||||
|
||||
$reveal(handle: WebviewPanelHandle, viewColumn: EditorViewColumn | null, preserveFocus: boolean): void {
|
||||
const webview = this.getWebview(handle);
|
||||
if (webview.isDisposed()) {
|
||||
|
||||
@@ -430,6 +430,7 @@ export interface MainThreadWebviewsShape extends IDisposable {
|
||||
$reveal(handle: WebviewPanelHandle, viewColumn: EditorViewColumn | null, preserveFocus: boolean): void;
|
||||
$setTitle(handle: WebviewPanelHandle, value: string): void;
|
||||
$setHtml(handle: WebviewPanelHandle, value: string): void;
|
||||
$setOptions(handle: WebviewPanelHandle, options: vscode.WebviewOptions): void;
|
||||
$postMessage(handle: WebviewPanelHandle, value: any): Thenable<boolean>;
|
||||
|
||||
$registerSerializer(viewType: string): void;
|
||||
@@ -855,7 +856,7 @@ export interface ExtHostTaskShape {
|
||||
$onDidStartTaskProcess(value: TaskProcessStartedDTO): void;
|
||||
$onDidEndTaskProcess(value: TaskProcessEndedDTO): void;
|
||||
$OnDidEndTask(execution: TaskExecutionDTO): void;
|
||||
$resolveVariables(workspaceFolder: URI, variables: string[]): TPromise<any>;
|
||||
$resolveVariables(workspaceFolder: UriComponents, variables: string[]): TPromise<any>;
|
||||
}
|
||||
|
||||
export interface IBreakpointDto {
|
||||
|
||||
@@ -874,8 +874,9 @@ export class ExtHostTask implements ExtHostTaskShape {
|
||||
});
|
||||
}
|
||||
|
||||
public $resolveVariables(uri: URI, variables: string[]): any {
|
||||
let result = Object.create(null);
|
||||
public $resolveVariables(uriComponents: UriComponents, variables: string[]): any {
|
||||
let uri: URI = URI.revive(uriComponents);
|
||||
let result: { [key: string]: string; } = Object.create(null);
|
||||
let workspaceFolder = this._workspaceService.resolveWorkspaceFolder(uri);
|
||||
let resolver = new ExtHostVariableResolverService(this._workspaceService, this._editorService, this._configurationService);
|
||||
let ws: IWorkspaceFolder = {
|
||||
@@ -887,7 +888,7 @@ export class ExtHostTask implements ExtHostTaskShape {
|
||||
}
|
||||
};
|
||||
for (let variable of variables) {
|
||||
result.push(variable, resolver.resolve(ws, variable));
|
||||
result[variable] = resolver.resolve(ws, variable);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ export class ExtHostWebview implements vscode.Webview {
|
||||
private _options: vscode.WebviewOptions;
|
||||
private _isDisposed: boolean = false;
|
||||
|
||||
readonly _onMessageEmitter = new Emitter<any>();
|
||||
public readonly _onMessageEmitter = new Emitter<any>();
|
||||
public readonly onDidReceiveMessage: Event<any> = this._onMessageEmitter.event;
|
||||
|
||||
constructor(
|
||||
@@ -32,16 +32,16 @@ export class ExtHostWebview implements vscode.Webview {
|
||||
this._options = options;
|
||||
}
|
||||
|
||||
dispose() {
|
||||
public dispose() {
|
||||
this._onMessageEmitter.dispose();
|
||||
}
|
||||
|
||||
get html(): string {
|
||||
public get html(): string {
|
||||
this.assertNotDisposed();
|
||||
return this._html;
|
||||
}
|
||||
|
||||
set html(value: string) {
|
||||
public set html(value: string) {
|
||||
this.assertNotDisposed();
|
||||
if (this._html !== value) {
|
||||
this._html = value;
|
||||
@@ -49,11 +49,17 @@ export class ExtHostWebview implements vscode.Webview {
|
||||
}
|
||||
}
|
||||
|
||||
get options(): vscode.WebviewOptions {
|
||||
public get options(): vscode.WebviewOptions {
|
||||
this.assertNotDisposed();
|
||||
return this._options;
|
||||
}
|
||||
|
||||
public set options(newOptions: vscode.WebviewOptions) {
|
||||
this.assertNotDisposed();
|
||||
this._proxy.$setOptions(this._handle, newOptions);
|
||||
this._options = newOptions;
|
||||
}
|
||||
|
||||
public postMessage(message: any): Thenable<boolean> {
|
||||
this.assertNotDisposed();
|
||||
return this._proxy.$postMessage(this._handle, message);
|
||||
|
||||
Reference in New Issue
Block a user