Merge branch 'master' into joh/extpack

This commit is contained in:
Johannes Rieken 2018-08-16 12:48:07 +02:00
commit 7c9b48b5a7
5 changed files with 87 additions and 27 deletions

58
src/vs/vscode.d.ts vendored
View file

@ -1231,24 +1231,41 @@ declare module 'vscode' {
*/
export class Uri {
/**
* Create an URI from a string, e.g. `http://www.msft.com/some/path`,
* `file:///usr/home`, or `scheme:with/path`.
*
* @see [Uri.toString](#Uri.toString)
* @param value The string value of an Uri.
* @return A new Uri instance.
*/
static parse(value: string): Uri;
/**
* Create an URI from a file system path. The [scheme](#Uri.scheme)
* will be `file`.
*
* The *difference* between `Uri#parse` and `Uri#file` is that the latter treats the argument
* as path, not as stringified-uri. E.g. `Uri.file(path)` is *not* the same as
* `Uri.parse('file://' + path)` because the path might contain characters that are
* interpreted (# and ?). See the following sample:
* ```ts
const good = URI.file('/coding/c#/project1');
good.scheme === 'file';
good.path === '/coding/c#/project1';
good.fragment === '';
const bad = URI.parse('file://' + '/coding/c#/project1');
bad.scheme === 'file';
bad.path === '/coding/c'; // path is now broken
bad.fragment === '/project1';
```
*
* @param path A file system or UNC path.
* @return A new Uri instance.
*/
static file(path: string): Uri;
/**
* Create an URI from a string. Will throw if the given value is not
* valid.
*
* @param value The string value of an Uri.
* @return A new Uri instance.
*/
static parse(value: string): Uri;
/**
* Use the `file` and `parse` factory functions to create new `Uri` objects.
*/
@ -1285,8 +1302,21 @@ declare module 'vscode' {
* The string representing the corresponding file system path of this Uri.
*
* Will handle UNC paths and normalize windows drive letters to lower-case. Also
* uses the platform specific path separator. Will *not* validate the path for
* invalid characters and semantics. Will *not* look at the scheme of this Uri.
* uses the platform specific path separator.
*
* * Will *not* validate the path for invalid characters and semantics.
* * Will *not* look at the scheme of this Uri.
* * The resulting string shall *not* be used for display purposes but
* for disk operations, like `readFile` et al.
*
* The *difference* to the [`path`](#Uri.path)-property is the use of the platform specific
* path separator and the handling of UNC paths. The sample below outlines the difference:
* ```ts
const u = URI.parse('file://server/c$/folder/file.txt')
u.authority === 'server'
u.path === '/shares/c$/file.txt'
u.fsPath === '\\server\c$\folder\file.txt'
```
*/
readonly fsPath: string;
@ -1308,8 +1338,10 @@ declare module 'vscode' {
/**
* Returns a string representation of this Uri. The representation and normalization
* of a URI depends on the scheme. The resulting string can be safely used with
* [Uri.parse](#Uri.parse).
* of a URI depends on the scheme.
*
* * The resulting string can be safely used with [Uri.parse](#Uri.parse).
* * The resulting string shall *not* be used for display purposes.
*
* @param skipEncoding Do not percentage-encode the result, defaults to `false`. Note that
* the `#` and `?` characters occurring in the path will always be encoded.

View file

@ -140,7 +140,6 @@ export class BreadcrumbsControl {
readonly domNode: HTMLDivElement;
private readonly _widget: BreadcrumbsWidget;
private _dimension: dom.Dimension;
private _disposables = new Array<IDisposable>();
private _breadcrumbsDisposables = new Array<IDisposable>();
@ -191,7 +190,6 @@ export class BreadcrumbsControl {
}
layout(dim: dom.Dimension): void {
this._dimension = dim;
this._widget.layout(dim);
}
@ -296,7 +294,7 @@ export class BreadcrumbsControl {
getAnchor: () => {
let pickerHeight = 330;
let pickerWidth = Math.max(this._dimension.width / 2.59, dom.getTotalWidth(event.node));
let pickerWidth = Math.max(window.innerWidth / 4.17, dom.getTotalWidth(event.node));
let pickerArrowSize = 8;
let pickerArrowOffset: number;

View file

@ -15,10 +15,10 @@ import { groupBy, isFalsyOrEmpty, flatten } from 'vs/base/common/arrays';
import { values } from 'vs/base/common/map';
import * as glob from 'vs/base/common/glob';
import * as strings from 'vs/base/common/strings';
import { ITextModelService } from 'vs/editor/common/services/resolverService';
import { CodeAction } from 'vs/editor/common/modes';
import { getCodeActions } from 'vs/editor/contrib/codeAction/codeAction';
import { CodeActionKind } from 'vs/editor/contrib/codeAction/codeActionTrigger';
import { IModelService } from 'vs/editor/common/services/modelService';
function compareUris(a: URI, b: URI) {
if (a.toString() < b.toString()) {
@ -48,7 +48,7 @@ export class ResourceMarkers extends NodeWithId {
constructor(
readonly uri: URI,
private textModelService: ITextModelService
private modelService: IModelService
) {
super(uri.toString());
}
@ -72,6 +72,10 @@ export class ResourceMarkers extends NodeWithId {
}
public async hasFixes(marker: Marker): Promise<boolean> {
if (!this.modelService.getModel(this.uri)) {
// Return early, If the model is not yet created
return false;
}
if (!this._allFixesPromise) {
this._allFixesPromise = this._getFixes();
}
@ -88,11 +92,9 @@ export class ResourceMarkers extends NodeWithId {
}
private async _getFixes(range?: Range): Promise<CodeAction[]> {
const modelReference = await this.textModelService.createModelReference(this.uri);
if (modelReference) {
const model = modelReference.object.textEditorModel;
const model = this.modelService.getModel(this.uri);
if (model) {
const codeActions = await getCodeActions(model, range ? range : model.getFullModelRange(), { type: 'manual', filter: { kind: CodeActionKind.QuickFix } });
modelReference.dispose();
return codeActions;
}
return [];
@ -225,7 +227,7 @@ export class MarkersModel {
constructor(
markers: IMarker[] = [],
@ITextModelService private textModelService: ITextModelService
@IModelService private modelService: IModelService
) {
this._markersByResource = new Map<string, ResourceMarkers>();
this._filterOptions = new FilterOptions();
@ -311,7 +313,7 @@ export class MarkersModel {
private createResource(uri: URI, rawMarkers: IMarker[]): ResourceMarkers {
const markers: Marker[] = [];
const resource = new ResourceMarkers(uri, this.textModelService);
const resource = new ResourceMarkers(uri, this.modelService);
this.updateResource(resource);
rawMarkers.forEach((rawMarker, index) => {

View file

@ -23,7 +23,7 @@ import { IThemeService } from 'vs/platform/theme/common/themeService';
import { attachInputBoxStyler, attachStylerCallback, attachCheckboxStyler } from 'vs/platform/theme/common/styler';
import { IMarkersWorkbenchService } from 'vs/workbench/parts/markers/electron-browser/markers';
import { Event, Emitter } from 'vs/base/common/event';
import { IDisposable } from 'vs/base/common/lifecycle';
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import { BaseActionItem, ActionItem } from 'vs/base/browser/ui/actionbar/actionbar';
import { badgeBackground, contrastBorder } from 'vs/platform/theme/common/colorRegistry';
import { localize } from 'vs/nls';
@ -35,6 +35,8 @@ import { applyCodeAction } from 'vs/editor/contrib/codeAction/codeActionCommands
import { IBulkEditService } from 'vs/editor/browser/services/bulkEditService';
import { ICommandService } from 'vs/platform/commands/common/commands';
import { IEditorService, ACTIVE_GROUP } from 'vs/workbench/services/editor/common/editorService';
import { IModelService } from 'vs/editor/common/services/modelService';
import { isEqual, hasToIgnoreCase } from 'vs/base/common/resources';
export class ToggleMarkersPanelAction extends TogglePanelAction {
@ -280,14 +282,34 @@ export class QuickFixAction extends Action {
public static readonly ID: string = 'workbench.actions.problems.quickfix';
private updated: boolean = false;
private disposables: IDisposable[] = [];
constructor(
readonly marker: Marker,
@IBulkEditService private bulkEditService: IBulkEditService,
@ICommandService private commandService: ICommandService,
@IEditorService private editorService: IEditorService
@IEditorService private editorService: IEditorService,
@IModelService modelService: IModelService
) {
super(QuickFixAction.ID, Messages.MARKERS_PANEL_ACTION_TOOLTIP_QUICKFIX, 'markers-panel-action-quickfix', false);
marker.resourceMarkers.hasFixes(marker).then(hasFixes => this.enabled = hasFixes);
if (modelService.getModel(this.marker.resourceMarkers.uri)) {
this.update();
} else {
modelService.onModelAdded(model => {
if (isEqual(model.uri, marker.resource, hasToIgnoreCase(model.uri))) {
this.update();
}
}, this, this.disposables);
}
}
private update(): void {
if (!this.updated) {
this.marker.resourceMarkers.hasFixes(this.marker).then(hasFixes => this.enabled = hasFixes);
this.updated = true;
}
}
async getQuickFixActions(): Promise<IAction[]> {
@ -315,6 +337,11 @@ export class QuickFixAction extends Action {
},
}, ACTIVE_GROUP).then(() => null);
}
dispose(): void {
dispose(this.disposables);
super.dispose();
}
}
export class QuickFixActionItem extends ActionItem {

View file

@ -261,6 +261,7 @@ export class Renderer implements IRenderer {
} else if (templateId === Renderer.MARKER_TEMPLATE_ID) {
(<IMarkerTemplateData>templateData).description.dispose();
(<IMarkerTemplateData>templateData).source.dispose();
(<IMarkerTemplateData>templateData).actionBar.dispose();
} else if (templateId === Renderer.RELATED_INFO_TEMPLATE_ID) {
(<IRelatedInformationTemplateData>templateData).description.dispose();
(<IRelatedInformationTemplateData>templateData).resourceLabel.dispose();