From 261d075b4cb2391f2fd2a3f2f250a90504857558 Mon Sep 17 00:00:00 2001 From: Henning Dieterichs Date: Fri, 11 Jun 2021 16:06:17 +0200 Subject: [PATCH 01/17] PrefixSumComputer renames. --- .../common/services/editorSimpleWorker.ts | 2 +- .../common/viewModel/prefixSumComputer.ts | 38 +++++----- .../viewModel/prefixSumComputer.test.ts | 74 +++++++++---------- .../api/common/extHostDocumentData.ts | 2 +- .../common/extHostNotebookConcatDocument.ts | 8 +- .../browser/contrib/find/findModel.ts | 2 +- .../browser/diff/diffNestedCellViewModel.ts | 4 +- .../notebook/browser/view/notebookCellList.ts | 16 ++-- .../browser/viewModel/codeCellViewModel.ts | 4 +- 9 files changed, 75 insertions(+), 75 deletions(-) diff --git a/src/vs/editor/common/services/editorSimpleWorker.ts b/src/vs/editor/common/services/editorSimpleWorker.ts index 4ad0c9d316b..e5e93423f69 100644 --- a/src/vs/editor/common/services/editorSimpleWorker.ts +++ b/src/vs/editor/common/services/editorSimpleWorker.ts @@ -235,7 +235,7 @@ class MirrorModel extends BaseMirrorModel implements ICommonModel { public offsetAt(position: IPosition): number { position = this._validatePosition(position); this._ensureLineStarts(); - return this._lineStarts!.getAccumulatedValue(position.lineNumber - 2) + (position.column - 1); + return this._lineStarts!.getPrefixSum(position.lineNumber - 2) + (position.column - 1); } public positionAt(offset: number): IPosition { diff --git a/src/vs/editor/common/viewModel/prefixSumComputer.ts b/src/vs/editor/common/viewModel/prefixSumComputer.ts index 6cb1312c07e..952a810a9d0 100644 --- a/src/vs/editor/common/viewModel/prefixSumComputer.ts +++ b/src/vs/editor/common/viewModel/prefixSumComputer.ts @@ -85,9 +85,9 @@ export class PrefixSumComputer { return true; } - public removeValues(startIndex: number, cnt: number): boolean { + public removeValues(startIndex: number, count: number): boolean { startIndex = toUint32(startIndex); - cnt = toUint32(cnt); + count = toUint32(count); const oldValues = this.values; const oldPrefixSum = this.prefixSum; @@ -96,18 +96,18 @@ export class PrefixSumComputer { return false; } - let maxCnt = oldValues.length - startIndex; - if (cnt >= maxCnt) { - cnt = maxCnt; + let maxCount = oldValues.length - startIndex; + if (count >= maxCount) { + count = maxCount; } - if (cnt === 0) { + if (count === 0) { return false; } - this.values = new Uint32Array(oldValues.length - cnt); + this.values = new Uint32Array(oldValues.length - count); this.values.set(oldValues.subarray(0, startIndex), 0); - this.values.set(oldValues.subarray(startIndex + cnt), startIndex); + this.values.set(oldValues.subarray(startIndex + count), startIndex); this.prefixSum = new Uint32Array(this.values.length); if (startIndex - 1 < this.prefixSumValidIndex[0]) { @@ -119,23 +119,23 @@ export class PrefixSumComputer { return true; } - public getTotalValue(): number { + public getTotalSum(): number { if (this.values.length === 0) { return 0; } - return this._getAccumulatedValue(this.values.length - 1); + return this._getPrefixSum(this.values.length - 1); } - public getAccumulatedValue(index: number): number { + public getPrefixSum(index: number): number { if (index < 0) { return 0; } index = toUint32(index); - return this._getAccumulatedValue(index); + return this._getPrefixSum(index); } - private _getAccumulatedValue(index: number): number { + private _getPrefixSum(index: number): number { if (index <= this.prefixSumValidIndex[0]) { return this.prefixSum[index]; } @@ -157,11 +157,11 @@ export class PrefixSumComputer { return this.prefixSum[index]; } - public getIndexOf(accumulatedValue: number): PrefixSumIndexOfResult { - accumulatedValue = Math.floor(accumulatedValue); //@perf + public getIndexOf(sum: number): PrefixSumIndexOfResult { + sum = Math.floor(sum); //@perf // Compute all sums (to get a fully valid prefixSum) - this.getTotalValue(); + this.getTotalSum(); let low = 0; let high = this.values.length - 1; @@ -175,15 +175,15 @@ export class PrefixSumComputer { midStop = this.prefixSum[mid]; midStart = midStop - this.values[mid]; - if (accumulatedValue < midStart) { + if (sum < midStart) { high = mid - 1; - } else if (accumulatedValue >= midStop) { + } else if (sum >= midStop) { low = mid + 1; } else { break; } } - return new PrefixSumIndexOfResult(mid, accumulatedValue - midStart); + return new PrefixSumIndexOfResult(mid, sum - midStart); } } diff --git a/src/vs/editor/test/common/viewModel/prefixSumComputer.test.ts b/src/vs/editor/test/common/viewModel/prefixSumComputer.test.ts index 80df1a94eb2..0ac5ed2672d 100644 --- a/src/vs/editor/test/common/viewModel/prefixSumComputer.test.ts +++ b/src/vs/editor/test/common/viewModel/prefixSumComputer.test.ts @@ -22,13 +22,13 @@ suite('Editor ViewModel - PrefixSumComputer', () => { let indexOfResult: PrefixSumIndexOfResult; let psc = new PrefixSumComputer(toUint32Array([1, 1, 2, 1, 3])); - assert.strictEqual(psc.getTotalValue(), 8); - assert.strictEqual(psc.getAccumulatedValue(-1), 0); - assert.strictEqual(psc.getAccumulatedValue(0), 1); - assert.strictEqual(psc.getAccumulatedValue(1), 2); - assert.strictEqual(psc.getAccumulatedValue(2), 4); - assert.strictEqual(psc.getAccumulatedValue(3), 5); - assert.strictEqual(psc.getAccumulatedValue(4), 8); + assert.strictEqual(psc.getTotalSum(), 8); + assert.strictEqual(psc.getPrefixSum(-1), 0); + assert.strictEqual(psc.getPrefixSum(0), 1); + assert.strictEqual(psc.getPrefixSum(1), 2); + assert.strictEqual(psc.getPrefixSum(2), 4); + assert.strictEqual(psc.getPrefixSum(3), 5); + assert.strictEqual(psc.getPrefixSum(4), 8); indexOfResult = psc.getIndexOf(0); assert.strictEqual(indexOfResult.index, 0); assert.strictEqual(indexOfResult.remainder, 0); @@ -59,21 +59,21 @@ suite('Editor ViewModel - PrefixSumComputer', () => { // [1, 2, 2, 1, 3] psc.changeValue(1, 2); - assert.strictEqual(psc.getTotalValue(), 9); - assert.strictEqual(psc.getAccumulatedValue(0), 1); - assert.strictEqual(psc.getAccumulatedValue(1), 3); - assert.strictEqual(psc.getAccumulatedValue(2), 5); - assert.strictEqual(psc.getAccumulatedValue(3), 6); - assert.strictEqual(psc.getAccumulatedValue(4), 9); + assert.strictEqual(psc.getTotalSum(), 9); + assert.strictEqual(psc.getPrefixSum(0), 1); + assert.strictEqual(psc.getPrefixSum(1), 3); + assert.strictEqual(psc.getPrefixSum(2), 5); + assert.strictEqual(psc.getPrefixSum(3), 6); + assert.strictEqual(psc.getPrefixSum(4), 9); // [1, 0, 2, 1, 3] psc.changeValue(1, 0); - assert.strictEqual(psc.getTotalValue(), 7); - assert.strictEqual(psc.getAccumulatedValue(0), 1); - assert.strictEqual(psc.getAccumulatedValue(1), 1); - assert.strictEqual(psc.getAccumulatedValue(2), 3); - assert.strictEqual(psc.getAccumulatedValue(3), 4); - assert.strictEqual(psc.getAccumulatedValue(4), 7); + assert.strictEqual(psc.getTotalSum(), 7); + assert.strictEqual(psc.getPrefixSum(0), 1); + assert.strictEqual(psc.getPrefixSum(1), 1); + assert.strictEqual(psc.getPrefixSum(2), 3); + assert.strictEqual(psc.getPrefixSum(3), 4); + assert.strictEqual(psc.getPrefixSum(4), 7); indexOfResult = psc.getIndexOf(0); assert.strictEqual(indexOfResult.index, 0); assert.strictEqual(indexOfResult.remainder, 0); @@ -101,12 +101,12 @@ suite('Editor ViewModel - PrefixSumComputer', () => { // [1, 0, 0, 1, 3] psc.changeValue(2, 0); - assert.strictEqual(psc.getTotalValue(), 5); - assert.strictEqual(psc.getAccumulatedValue(0), 1); - assert.strictEqual(psc.getAccumulatedValue(1), 1); - assert.strictEqual(psc.getAccumulatedValue(2), 1); - assert.strictEqual(psc.getAccumulatedValue(3), 2); - assert.strictEqual(psc.getAccumulatedValue(4), 5); + assert.strictEqual(psc.getTotalSum(), 5); + assert.strictEqual(psc.getPrefixSum(0), 1); + assert.strictEqual(psc.getPrefixSum(1), 1); + assert.strictEqual(psc.getPrefixSum(2), 1); + assert.strictEqual(psc.getPrefixSum(3), 2); + assert.strictEqual(psc.getPrefixSum(4), 5); indexOfResult = psc.getIndexOf(0); assert.strictEqual(indexOfResult.index, 0); assert.strictEqual(indexOfResult.remainder, 0); @@ -128,12 +128,12 @@ suite('Editor ViewModel - PrefixSumComputer', () => { // [1, 0, 0, 0, 3] psc.changeValue(3, 0); - assert.strictEqual(psc.getTotalValue(), 4); - assert.strictEqual(psc.getAccumulatedValue(0), 1); - assert.strictEqual(psc.getAccumulatedValue(1), 1); - assert.strictEqual(psc.getAccumulatedValue(2), 1); - assert.strictEqual(psc.getAccumulatedValue(3), 1); - assert.strictEqual(psc.getAccumulatedValue(4), 4); + assert.strictEqual(psc.getTotalSum(), 4); + assert.strictEqual(psc.getPrefixSum(0), 1); + assert.strictEqual(psc.getPrefixSum(1), 1); + assert.strictEqual(psc.getPrefixSum(2), 1); + assert.strictEqual(psc.getPrefixSum(3), 1); + assert.strictEqual(psc.getPrefixSum(4), 4); indexOfResult = psc.getIndexOf(0); assert.strictEqual(indexOfResult.index, 0); assert.strictEqual(indexOfResult.remainder, 0); @@ -154,12 +154,12 @@ suite('Editor ViewModel - PrefixSumComputer', () => { psc.changeValue(1, 1); psc.changeValue(3, 1); psc.changeValue(4, 1); - assert.strictEqual(psc.getTotalValue(), 4); - assert.strictEqual(psc.getAccumulatedValue(0), 1); - assert.strictEqual(psc.getAccumulatedValue(1), 2); - assert.strictEqual(psc.getAccumulatedValue(2), 2); - assert.strictEqual(psc.getAccumulatedValue(3), 3); - assert.strictEqual(psc.getAccumulatedValue(4), 4); + assert.strictEqual(psc.getTotalSum(), 4); + assert.strictEqual(psc.getPrefixSum(0), 1); + assert.strictEqual(psc.getPrefixSum(1), 2); + assert.strictEqual(psc.getPrefixSum(2), 2); + assert.strictEqual(psc.getPrefixSum(3), 3); + assert.strictEqual(psc.getPrefixSum(4), 4); indexOfResult = psc.getIndexOf(0); assert.strictEqual(indexOfResult.index, 0); assert.strictEqual(indexOfResult.remainder, 0); diff --git a/src/vs/workbench/api/common/extHostDocumentData.ts b/src/vs/workbench/api/common/extHostDocumentData.ts index d244a16b8aa..78e12d7a47c 100644 --- a/src/vs/workbench/api/common/extHostDocumentData.ts +++ b/src/vs/workbench/api/common/extHostDocumentData.ts @@ -143,7 +143,7 @@ export class ExtHostDocumentData extends MirrorTextModel { private _offsetAt(position: vscode.Position): number { position = this._validatePosition(position); this._ensureLineStarts(); - return this._lineStarts!.getAccumulatedValue(position.line - 1) + position.character; + return this._lineStarts!.getPrefixSum(position.line - 1) + position.character; } private _positionAt(offset: number): vscode.Position { diff --git a/src/vs/workbench/api/common/extHostNotebookConcatDocument.ts b/src/vs/workbench/api/common/extHostNotebookConcatDocument.ts index 215975bdfd2..d25c8dfe06d 100644 --- a/src/vs/workbench/api/common/extHostNotebookConcatDocument.ts +++ b/src/vs/workbench/api/common/extHostNotebookConcatDocument.ts @@ -123,7 +123,7 @@ export class ExtHostNotebookConcatDocument implements vscode.NotebookConcatTextD offsetAt(position: vscode.Position): number { const idx = this._cellLines.getIndexOf(position.line); - const offset1 = this._cellLengths.getAccumulatedValue(idx.index - 1); + const offset1 = this._cellLengths.getPrefixSum(idx.index - 1); const offset2 = this._cells[idx.index].document.offsetAt(position.with(idx.remainder)); return offset1 + offset2; } @@ -131,13 +131,13 @@ export class ExtHostNotebookConcatDocument implements vscode.NotebookConcatTextD positionAt(locationOrOffset: vscode.Location | number): vscode.Position { if (typeof locationOrOffset === 'number') { const idx = this._cellLengths.getIndexOf(locationOrOffset); - const lineCount = this._cellLines.getAccumulatedValue(idx.index - 1); + const lineCount = this._cellLines.getPrefixSum(idx.index - 1); return this._cells[idx.index].document.positionAt(idx.remainder).translate(lineCount); } const idx = this._cellUris.get(locationOrOffset.uri); if (idx !== undefined) { - const line = this._cellLines.getAccumulatedValue(idx - 1); + const line = this._cellLines.getPrefixSum(idx - 1); return new types.Position(line + locationOrOffset.range.start.line, locationOrOffset.range.start.character); } // do better? @@ -180,7 +180,7 @@ export class ExtHostNotebookConcatDocument implements vscode.NotebookConcatTextD const cellPosition = new types.Position(startIdx.remainder, position.character); const validCellPosition = this._cells[startIdx.index].document.validatePosition(cellPosition); - const line = this._cellLines.getAccumulatedValue(startIdx.index - 1); + const line = this._cellLines.getPrefixSum(startIdx.index - 1); return new types.Position(line + validCellPosition.line, validCellPosition.character); } } diff --git a/src/vs/workbench/contrib/notebook/browser/contrib/find/findModel.ts b/src/vs/workbench/contrib/notebook/browser/contrib/find/findModel.ts index 3e6d07b7822..99da66dff8e 100644 --- a/src/vs/workbench/contrib/notebook/browser/contrib/find/findModel.ts +++ b/src/vs/workbench/contrib/notebook/browser/contrib/find/findModel.ts @@ -88,7 +88,7 @@ export class FindModel extends Disposable { } else { // const currIndex = this._findMatchesStarts!.getIndexOf(this._currentMatch); // currCell = this._findMatches[currIndex.index].cell; - const totalVal = this._findMatchesStarts.getTotalValue(); + const totalVal = this._findMatchesStarts.getTotalSum(); if (this._currentMatch === -1) { this._currentMatch = previous ? totalVal - 1 : 0; } else { diff --git a/src/vs/workbench/contrib/notebook/browser/diff/diffNestedCellViewModel.ts b/src/vs/workbench/contrib/notebook/browser/diff/diffNestedCellViewModel.ts index 84ef80fbea3..bf8c441d9a5 100644 --- a/src/vs/workbench/contrib/notebook/browser/diff/diffNestedCellViewModel.ts +++ b/src/vs/workbench/contrib/notebook/browser/diff/diffNestedCellViewModel.ts @@ -111,7 +111,7 @@ export class DiffNestedCellViewModel extends Disposable implements IDiffNestedCe throw new Error('Output index out of range!'); } - return this._outputsTop!.getAccumulatedValue(index - 1); + return this._outputsTop!.getPrefixSum(index - 1); } updateOutputHeight(index: number, height: number): void { @@ -129,6 +129,6 @@ export class DiffNestedCellViewModel extends Disposable implements IDiffNestedCe getOutputTotalHeight() { this._ensureOutputsTop(); - return this._outputsTop?.getTotalValue() ?? 0; + return this._outputsTop?.getTotalSum() ?? 0; } } diff --git a/src/vs/workbench/contrib/notebook/browser/view/notebookCellList.ts b/src/vs/workbench/contrib/notebook/browser/view/notebookCellList.ts index 5584ff93977..2d7032b81a4 100644 --- a/src/vs/workbench/contrib/notebook/browser/view/notebookCellList.ts +++ b/src/vs/workbench/contrib/notebook/browser/view/notebookCellList.ts @@ -469,7 +469,7 @@ export class NotebookCellList extends WorkbenchList implements ID return viewIndex; } - const modelIndex = this.hiddenRangesPrefixSum.getAccumulatedValue(viewIndex - 1); + const modelIndex = this.hiddenRangesPrefixSum.getPrefixSum(viewIndex - 1); return modelIndex; } @@ -486,9 +486,9 @@ export class NotebookCellList extends WorkbenchList implements ID const viewIndexInfo = this.hiddenRangesPrefixSum.getIndexOf(modelIndex); if (viewIndexInfo.remainder !== 0) { - if (modelIndex >= this.hiddenRangesPrefixSum.getTotalValue()) { + if (modelIndex >= this.hiddenRangesPrefixSum.getTotalSum()) { // it's already after the last hidden range - return modelIndex - (this.hiddenRangesPrefixSum.getTotalValue() - this.hiddenRangesPrefixSum.getCount()); + return modelIndex - (this.hiddenRangesPrefixSum.getTotalSum() - this.hiddenRangesPrefixSum.getCount()); } return undefined; } else { @@ -504,7 +504,7 @@ export class NotebookCellList extends WorkbenchList implements ID let modelIndex = topModelIndex; while (index <= bottomViewIndex) { - const accu = this.hiddenRangesPrefixSum!.getAccumulatedValue(index); + const accu = this.hiddenRangesPrefixSum!.getPrefixSum(index); if (accu === modelIndex + 1) { // no hidden area after it if (stack.length) { @@ -575,8 +575,8 @@ export class NotebookCellList extends WorkbenchList implements ID const viewIndexInfo = this.hiddenRangesPrefixSum.getIndexOf(modelIndex); if (viewIndexInfo.remainder !== 0) { - if (modelIndex >= this.hiddenRangesPrefixSum.getTotalValue()) { - return modelIndex - (this.hiddenRangesPrefixSum.getTotalValue() - this.hiddenRangesPrefixSum.getCount()); + if (modelIndex >= this.hiddenRangesPrefixSum.getTotalSum()) { + return modelIndex - (this.hiddenRangesPrefixSum.getTotalSum() - this.hiddenRangesPrefixSum.getCount()); } } @@ -591,8 +591,8 @@ export class NotebookCellList extends WorkbenchList implements ID const viewIndexInfo = this.hiddenRangesPrefixSum.getIndexOf(modelIndex); if (viewIndexInfo.remainder !== 0) { - if (modelIndex >= this.hiddenRangesPrefixSum.getTotalValue()) { - return modelIndex - (this.hiddenRangesPrefixSum.getTotalValue() - this.hiddenRangesPrefixSum.getCount()); + if (modelIndex >= this.hiddenRangesPrefixSum.getTotalSum()) { + return modelIndex - (this.hiddenRangesPrefixSum.getTotalSum() - this.hiddenRangesPrefixSum.getCount()); } } diff --git a/src/vs/workbench/contrib/notebook/browser/viewModel/codeCellViewModel.ts b/src/vs/workbench/contrib/notebook/browser/viewModel/codeCellViewModel.ts index c2673fa89ea..83d43339338 100644 --- a/src/vs/workbench/contrib/notebook/browser/viewModel/codeCellViewModel.ts +++ b/src/vs/workbench/contrib/notebook/browser/viewModel/codeCellViewModel.ts @@ -162,7 +162,7 @@ export class CodeCellViewModel extends BaseCellViewModel implements ICellViewMod const notebookLayoutConfiguration = this.viewContext.notebookOptions.getLayoutConfiguration(); const bottomToolbarDimensions = this.viewContext.notebookOptions.computeBottomToolbarDimensions(); const outputShowMoreContainerHeight = state.outputShowMoreContainerHeight ? state.outputShowMoreContainerHeight : this._layoutInfo.outputShowMoreContainerHeight; - let outputTotalHeight = Math.max(this._outputMinHeight, this.metadata.outputCollapsed ? notebookLayoutConfiguration.collapsedIndicatorHeight : this._outputsTop!.getTotalValue()); + let outputTotalHeight = Math.max(this._outputMinHeight, this.metadata.outputCollapsed ? notebookLayoutConfiguration.collapsedIndicatorHeight : this._outputsTop!.getTotalSum()); const originalLayout = this.layoutInfo; if (!this.metadata.inputCollapsed) { @@ -371,7 +371,7 @@ export class CodeCellViewModel extends BaseCellViewModel implements ICellViewMod throw new Error('Output index out of range!'); } - return this._outputsTop!.getAccumulatedValue(index - 1); + return this._outputsTop!.getPrefixSum(index - 1); } getOutputOffset(index: number): number { From 7f93f38f7b71923a6cb1dac5df458c4a4cb0e44a Mon Sep 17 00:00:00 2001 From: Henning Dieterichs Date: Fri, 11 Jun 2021 16:45:23 +0200 Subject: [PATCH 02/17] * Cursor -> CursorsController * OneCursor -> Cursor --- src/vs/editor/browser/widget/codeEditorWidget.ts | 4 ++-- src/vs/editor/common/controller/cursor.ts | 8 ++++---- .../editor/common/controller/cursorCollection.ts | 14 +++++++------- src/vs/editor/common/controller/oneCursor.ts | 5 ++++- src/vs/editor/common/viewModel/viewModelImpl.ts | 6 +++--- 5 files changed, 20 insertions(+), 17 deletions(-) diff --git a/src/vs/editor/browser/widget/codeEditorWidget.ts b/src/vs/editor/browser/widget/codeEditorWidget.ts index 977e55d180b..96d924d2e7c 100644 --- a/src/vs/editor/browser/widget/codeEditorWidget.ts +++ b/src/vs/editor/browser/widget/codeEditorWidget.ts @@ -24,7 +24,7 @@ import { ICommandDelegate } from 'vs/editor/browser/view/viewController'; import { IContentWidgetData, IOverlayWidgetData, View } from 'vs/editor/browser/view/viewImpl'; import { ViewUserInputEvents } from 'vs/editor/browser/view/viewUserInputEvents'; import { ConfigurationChangedEvent, EditorLayoutInfo, IEditorOptions, EditorOption, IComputedEditorOptions, FindComputedEditorOptionValueById, filterValidationDecorations } from 'vs/editor/common/config/editorOptions'; -import { Cursor } from 'vs/editor/common/controller/cursor'; +import { CursorsController } from 'vs/editor/common/controller/cursor'; import { CursorColumns } from 'vs/editor/common/controller/cursorCommon'; import { CursorChangeReason, ICursorPositionChangedEvent, ICursorSelectionChangedEvent } from 'vs/editor/common/controller/cursorEvents'; import { IPosition, Position } from 'vs/editor/common/core/position'; @@ -1540,7 +1540,7 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE break; case OutgoingViewModelEventKind.CursorStateChanged: { if (e.reachedMaxCursorCount) { - this._notificationService.warn(nls.localize('cursors.maximum', "The number of cursors has been limited to {0}.", Cursor.MAX_CURSOR_COUNT)); + this._notificationService.warn(nls.localize('cursors.maximum', "The number of cursors has been limited to {0}.", CursorsController.MAX_CURSOR_COUNT)); } const positions: Position[] = []; diff --git a/src/vs/editor/common/controller/cursor.ts b/src/vs/editor/common/controller/cursor.ts index e2297a6be81..2ec7d252ac2 100644 --- a/src/vs/editor/common/controller/cursor.ts +++ b/src/vs/editor/common/controller/cursor.ts @@ -29,7 +29,7 @@ export class CursorModelState { public readonly modelVersionId: number; public readonly cursorState: CursorState[]; - constructor(model: ITextModel, cursor: Cursor) { + constructor(model: ITextModel, cursor: CursorsController) { this.modelVersionId = model.getVersionId(); this.cursorState = cursor.getCursorStates(); } @@ -119,7 +119,7 @@ class AutoClosedAction { } } -export class Cursor extends Disposable { +export class CursorsController extends Disposable { public static readonly MAX_CURSOR_COUNT = 10000; @@ -216,8 +216,8 @@ export class Cursor extends Disposable { public setStates(eventsCollector: ViewModelEventsCollector, source: string | null | undefined, reason: CursorChangeReason, states: PartialCursorState[] | null): boolean { let reachedMaxCursorCount = false; - if (states !== null && states.length > Cursor.MAX_CURSOR_COUNT) { - states = states.slice(0, Cursor.MAX_CURSOR_COUNT); + if (states !== null && states.length > CursorsController.MAX_CURSOR_COUNT) { + states = states.slice(0, CursorsController.MAX_CURSOR_COUNT); reachedMaxCursorCount = true; } diff --git a/src/vs/editor/common/controller/cursorCollection.ts b/src/vs/editor/common/controller/cursorCollection.ts index 746039533ad..9cc5b6dd40f 100644 --- a/src/vs/editor/common/controller/cursorCollection.ts +++ b/src/vs/editor/common/controller/cursorCollection.ts @@ -4,7 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import { CursorContext, CursorState, PartialCursorState } from 'vs/editor/common/controller/cursorCommon'; -import { OneCursor } from 'vs/editor/common/controller/oneCursor'; +import { Cursor } from 'vs/editor/common/controller/oneCursor'; import { Position } from 'vs/editor/common/core/position'; import { ISelection, Selection } from 'vs/editor/common/core/selection'; @@ -12,15 +12,15 @@ export class CursorCollection { private context: CursorContext; - private primaryCursor: OneCursor; - private secondaryCursors: OneCursor[]; + private primaryCursor: Cursor; + private secondaryCursors: Cursor[]; // An index which identifies the last cursor that was added / moved (think Ctrl+drag) private lastAddedCursorIndex: number; constructor(context: CursorContext) { this.context = context; - this.primaryCursor = new OneCursor(context); + this.primaryCursor = new Cursor(context); this.secondaryCursors = []; this.lastAddedCursorIndex = 0; } @@ -167,7 +167,7 @@ export class CursorCollection { } private _addSecondaryCursor(): void { - this.secondaryCursors.push(new OneCursor(this.context)); + this.secondaryCursors.push(new Cursor(this.context)); this.lastAddedCursorIndex = this.secondaryCursors.length; } @@ -186,8 +186,8 @@ export class CursorCollection { this.secondaryCursors.splice(removeIndex, 1); } - private _getAll(): OneCursor[] { - let result: OneCursor[] = []; + private _getAll(): Cursor[] { + let result: Cursor[] = []; result[0] = this.primaryCursor; for (let i = 0, len = this.secondaryCursors.length; i < len; i++) { result[i + 1] = this.secondaryCursors[i]; diff --git a/src/vs/editor/common/controller/oneCursor.ts b/src/vs/editor/common/controller/oneCursor.ts index f79fafe21ae..f32a1b43c64 100644 --- a/src/vs/editor/common/controller/oneCursor.ts +++ b/src/vs/editor/common/controller/oneCursor.ts @@ -9,7 +9,10 @@ import { Range } from 'vs/editor/common/core/range'; import { Selection, SelectionDirection } from 'vs/editor/common/core/selection'; import { TrackedRangeStickiness } from 'vs/editor/common/model'; -export class OneCursor { +/** + * Represents a single cursor. +*/ +export class Cursor { public modelState!: SingleCursorState; public viewState!: SingleCursorState; diff --git a/src/vs/editor/common/viewModel/viewModelImpl.ts b/src/vs/editor/common/viewModel/viewModelImpl.ts index 2d37d247f66..fd971ba5bf0 100644 --- a/src/vs/editor/common/viewModel/viewModelImpl.ts +++ b/src/vs/editor/common/viewModel/viewModelImpl.ts @@ -26,7 +26,7 @@ import { ViewModelDecorations } from 'vs/editor/common/viewModel/viewModelDecora import { RunOnceScheduler } from 'vs/base/common/async'; import * as platform from 'vs/base/common/platform'; import { EditorTheme } from 'vs/editor/common/view/viewContext'; -import { Cursor } from 'vs/editor/common/controller/cursor'; +import { CursorsController } from 'vs/editor/common/controller/cursor'; import { PartialCursorState, CursorState, IColumnSelectData, EditOperationType, CursorConfiguration } from 'vs/editor/common/controller/cursorCommon'; import { CursorChangeReason } from 'vs/editor/common/controller/cursorEvents'; import { IWhitespaceChangeAccessor } from 'vs/editor/common/viewLayout/linesLayout'; @@ -52,7 +52,7 @@ export class ViewModel extends Disposable implements IViewModel { private readonly _lines: IViewModelLinesCollection; public readonly coordinatesConverter: ICoordinatesConverter; public readonly viewLayout: ViewLayout; - private readonly _cursor: Cursor; + private readonly _cursor: CursorsController; private readonly _decorations: ViewModelDecorations; constructor( @@ -103,7 +103,7 @@ export class ViewModel extends Disposable implements IViewModel { this.coordinatesConverter = this._lines.createCoordinatesConverter(); - this._cursor = this._register(new Cursor(model, this, this.coordinatesConverter, this.cursorConfig)); + this._cursor = this._register(new CursorsController(model, this, this.coordinatesConverter, this.cursorConfig)); this.viewLayout = this._register(new ViewLayout(this._configuration, this.getLineCount(), scheduleAtNextAnimationFrame)); From 5b639e8b22e79c9cdf78891084570c42fb26ae5f Mon Sep 17 00:00:00 2001 From: Matt Bierner Date: Fri, 11 Jun 2021 16:03:59 -0700 Subject: [PATCH 03/17] Also log viewType This is needed for extensions that contribute multiple types of webviews --- src/vs/workbench/api/browser/mainThreadWebviewPanels.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/vs/workbench/api/browser/mainThreadWebviewPanels.ts b/src/vs/workbench/api/browser/mainThreadWebviewPanels.ts index 22bfaff30a5..d50f6fe2550 100644 --- a/src/vs/workbench/api/browser/mainThreadWebviewPanels.ts +++ b/src/vs/workbench/api/browser/mainThreadWebviewPanels.ts @@ -171,10 +171,14 @@ export class MainThreadWebviewPanels extends Disposable implements extHostProtoc /* __GDPR__ "webviews:createWebviewPanel" : { - "extensionId" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" } + "extensionId" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }, + "viewType" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" } } */ - this._telemetryService.publicLog('webviews:createWebviewPanel', { extensionId: extension.id.value }); + this._telemetryService.publicLog('webviews:createWebviewPanel', { + extensionId: extension.id.value, + viewType + }); } public $disposeWebview(handle: extHostProtocol.WebviewHandle): void { From 3c1fa1b286b7f8922213f5d5e04a6633327d652c Mon Sep 17 00:00:00 2001 From: Matt Bierner Date: Fri, 11 Jun 2021 16:22:31 -0700 Subject: [PATCH 04/17] Pass in explicit language mode when converting cell to markdown Fixes #126069 --- .../workbench/contrib/notebook/browser/contrib/coreActions.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vs/workbench/contrib/notebook/browser/contrib/coreActions.ts b/src/vs/workbench/contrib/notebook/browser/contrib/coreActions.ts index bfed6ef00ef..3b0d367feb6 100644 --- a/src/vs/workbench/contrib/notebook/browser/contrib/coreActions.ts +++ b/src/vs/workbench/contrib/notebook/browser/contrib/coreActions.ts @@ -925,7 +925,7 @@ registerAction2(class ChangeCellToMarkdownAction extends NotebookCellAction { } async runWithContext(accessor: ServicesAccessor, context: INotebookCellActionContext): Promise { - await changeCellToKind(CellKind.Markup, context); + await changeCellToKind(CellKind.Markup, context, 'markdown'); } }); From 28f0fc47d0da16e5a5811137280d918d8def7c38 Mon Sep 17 00:00:00 2001 From: Wojciech Nawrocki Date: Fri, 11 Jun 2021 16:27:56 -0700 Subject: [PATCH 05/17] Support Content-Length and Last-Modified for webview local resources (#125994) Closes #125992 --- .../contrib/webview/browser/baseWebviewElement.ts | 2 ++ .../contrib/webview/browser/pre/service-worker.js | 14 ++++++++++---- .../contrib/webview/browser/resourceLoading.ts | 8 +++++--- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/vs/workbench/contrib/webview/browser/baseWebviewElement.ts b/src/vs/workbench/contrib/webview/browser/baseWebviewElement.ts index 05c9310208f..7f97d5592bd 100644 --- a/src/vs/workbench/contrib/webview/browser/baseWebviewElement.ts +++ b/src/vs/workbench/contrib/webview/browser/baseWebviewElement.ts @@ -543,6 +543,7 @@ export abstract class BaseWebview extends Disposable { mime: result.mimeType, data: buffer, etag: result.etag, + mtime: result.mtime }); } case WebviewResourceResponse.Type.NotModified: @@ -552,6 +553,7 @@ export abstract class BaseWebview extends Disposable { status: 304, // not modified path: uri.path, mime: result.mimeType, + mtime: result.mtime }); } case WebviewResourceResponse.Type.AccessDenied: diff --git a/src/vs/workbench/contrib/webview/browser/pre/service-worker.js b/src/vs/workbench/contrib/webview/browser/pre/service-worker.js index 9463b4a7764..dfa0a5e08f7 100644 --- a/src/vs/workbench/contrib/webview/browser/pre/service-worker.js +++ b/src/vs/workbench/contrib/webview/browser/pre/service-worker.js @@ -100,7 +100,9 @@ class RequestStore { /** * Map of requested paths to responses. - * @typedef {{ type: 'response', body: any, mime: string, etag: string | undefined, } | { type: 'not-modified', mime: string } | undefined} ResourceResponse + * @typedef {{ type: 'response', body: Uint8Array, mime: string, etag: string | undefined, mtime: number | undefined } | + * { type: 'not-modified', mime: string, mtime: number | undefined } | + * undefined} ResourceResponse * @type {RequestStore} */ const resourceRequestStore = new RequestStore(); @@ -142,12 +144,12 @@ sw.addEventListener('message', async (event) => { switch (data.status) { case 200: { - response = { type: 'response', body: data.data, mime: data.mime, etag: data.etag }; + response = { type: 'response', body: data.data, mime: data.mime, etag: data.etag, mtime: data.mtime }; break; } case 304: { - response = { type: 'not-modified', mime: data.mime }; + response = { type: 'not-modified', mime: data.mime, mtime: data.mtime }; break; } } @@ -233,15 +235,19 @@ async function processResourceRequest(event, requestUrl) { } } - /** @type {Record} */ + /** @type {Record} */ const headers = { 'Content-Type': entry.mime, + 'Content-Length': entry.body.byteLength.toString(), 'Access-Control-Allow-Origin': '*', }; if (entry.etag) { headers['ETag'] = entry.etag; headers['Cache-Control'] = 'no-cache'; } + if (entry.mtime) { + headers['Last-Modified'] = new Date(entry.mtime).toUTCString(); + } const response = new Response(entry.body, { status: 200, headers diff --git a/src/vs/workbench/contrib/webview/browser/resourceLoading.ts b/src/vs/workbench/contrib/webview/browser/resourceLoading.ts index 5b6ebc58ac2..bba1ae1d6b6 100644 --- a/src/vs/workbench/contrib/webview/browser/resourceLoading.ts +++ b/src/vs/workbench/contrib/webview/browser/resourceLoading.ts @@ -22,6 +22,7 @@ export namespace WebviewResourceResponse { constructor( public readonly stream: VSBufferReadableStream, public readonly etag: string | undefined, + public readonly mtime: number | undefined, public readonly mimeType: string, ) { } } @@ -34,6 +35,7 @@ export namespace WebviewResourceResponse { constructor( public readonly mimeType: string, + public readonly mtime: number | undefined, ) { } } @@ -50,7 +52,7 @@ export async function loadLocalResource( logService: ILogService, token: CancellationToken, ): Promise { - logService.debug(`loadLocalResource - being. requestUri=${requestUri}`); + logService.debug(`loadLocalResource - begin. requestUri=${requestUri}`); const resourceToLoad = getResourceToLoad(requestUri, options.roots); @@ -64,14 +66,14 @@ export async function loadLocalResource( try { const result = await fileService.readFileStream(resourceToLoad, { etag: options.ifNoneMatch }); - return new WebviewResourceResponse.StreamSuccess(result.value, result.etag, mime); + return new WebviewResourceResponse.StreamSuccess(result.value, result.etag, result.mtime, mime); } catch (err) { if (err instanceof FileOperationError) { const result = err.fileOperationResult; // NotModified status is expected and can be handled gracefully if (result === FileOperationResult.FILE_NOT_MODIFIED_SINCE) { - return new WebviewResourceResponse.NotModified(mime); + return new WebviewResourceResponse.NotModified(mime, err.options?.mtime); } } From 53350bc6661449bc097496b04a1d8712474bd301 Mon Sep 17 00:00:00 2001 From: Matt Bierner Date: Fri, 11 Jun 2021 16:45:07 -0700 Subject: [PATCH 06/17] Log exit signal for desktop TS Servers For #125852 --- .../src/tsServer/server.ts | 17 +++++++++++------ .../src/tsServer/serverProcess.browser.ts | 4 ++-- .../src/tsServer/serverProcess.electron.ts | 2 +- .../src/typescriptServiceClient.ts | 13 ++++++++----- 4 files changed, 22 insertions(+), 14 deletions(-) diff --git a/extensions/typescript-language-features/src/tsServer/server.ts b/extensions/typescript-language-features/src/tsServer/server.ts index b97a1a8b73d..c9f05771abe 100644 --- a/extensions/typescript-language-features/src/tsServer/server.ts +++ b/extensions/typescript-language-features/src/tsServer/server.ts @@ -23,9 +23,14 @@ export enum ExecutionTarget { Syntax } +export interface TypeScriptServerExitEvent { + readonly code: number | null; + readonly signal: string | null; +} + export interface ITypeScriptServer { readonly onEvent: vscode.Event; - readonly onExit: vscode.Event; + readonly onExit: vscode.Event; readonly onError: vscode.Event; readonly tsServerLogFile: string | undefined; @@ -66,7 +71,7 @@ export interface TsServerProcess { write(serverRequest: Proto.Request): void; onData(handler: (data: Proto.Response) => void): void; - onExit(handler: (code: number | null) => void): void; + onExit(handler: (code: number | null, signal: string | null) => void): void; onError(handler: (error: Error) => void): void; kill(): void; @@ -93,8 +98,8 @@ export class ProcessBasedTsServer extends Disposable implements ITypeScriptServe this.dispatchMessage(msg); }); - this._process.onExit(code => { - this._onExit.fire(code); + this._process.onExit((code, signal) => { + this._onExit.fire({ code, signal }); this._callbacks.destroy('server exited'); }); @@ -107,7 +112,7 @@ export class ProcessBasedTsServer extends Disposable implements ITypeScriptServe private readonly _onEvent = this._register(new vscode.EventEmitter()); public readonly onEvent = this._onEvent.event; - private readonly _onExit = this._register(new vscode.EventEmitter()); + private readonly _onExit = this._register(new vscode.EventEmitter()); public readonly onExit = this._onExit.event; private readonly _onError = this._register(new vscode.EventEmitter()); @@ -449,7 +454,7 @@ export class GetErrRoutingTsServer extends Disposable implements ITypeScriptServ private readonly _onEvent = this._register(new vscode.EventEmitter()); public readonly onEvent = this._onEvent.event; - private readonly _onExit = this._register(new vscode.EventEmitter()); + private readonly _onExit = this._register(new vscode.EventEmitter()); public readonly onExit = this._onExit.event; private readonly _onError = this._register(new vscode.EventEmitter()); diff --git a/extensions/typescript-language-features/src/tsServer/serverProcess.browser.ts b/extensions/typescript-language-features/src/tsServer/serverProcess.browser.ts index 33845073e0b..9d2f918f05f 100644 --- a/extensions/typescript-language-features/src/tsServer/serverProcess.browser.ts +++ b/extensions/typescript-language-features/src/tsServer/serverProcess.browser.ts @@ -36,7 +36,7 @@ export class WorkerServerProcess implements TsServerProcess { private _onDataHandlers = new Set<(data: Proto.Response) => void>(); private _onErrorHandlers = new Set<(err: Error) => void>(); - private _onExitHandlers = new Set<(code: number | null) => void>(); + private _onExitHandlers = new Set<(code: number | null, signal: string | null) => void>(); public constructor( private readonly worker: Worker, @@ -73,7 +73,7 @@ export class WorkerServerProcess implements TsServerProcess { // Todo: not implemented } - onExit(handler: (code: number | null) => void): void { + onExit(handler: (code: number | null, signal: string | null) => void): void { this._onExitHandlers.add(handler); // Todo: not implemented } diff --git a/extensions/typescript-language-features/src/tsServer/serverProcess.electron.ts b/extensions/typescript-language-features/src/tsServer/serverProcess.electron.ts index c47a75b5e23..ad366f5f347 100644 --- a/extensions/typescript-language-features/src/tsServer/serverProcess.electron.ts +++ b/extensions/typescript-language-features/src/tsServer/serverProcess.electron.ts @@ -226,7 +226,7 @@ export class ChildServerProcess extends Disposable implements TsServerProcess { this._reader.onData(handler); } - onExit(handler: (code: number | null) => void): void { + onExit(handler: (code: number | null, signal: string | null) => void): void { this._process.on('exit', handler); } diff --git a/extensions/typescript-language-features/src/typescriptServiceClient.ts b/extensions/typescript-language-features/src/typescriptServiceClient.ts index 279d0e2d4d8..c6ae3c5b0a0 100644 --- a/extensions/typescript-language-features/src/typescriptServiceClient.ts +++ b/extensions/typescript-language-features/src/typescriptServiceClient.ts @@ -12,7 +12,7 @@ import { EventName } from './protocol.const'; import BufferSyncSupport from './tsServer/bufferSyncSupport'; import { OngoingRequestCancellerFactory } from './tsServer/cancellation'; import { ILogDirectoryProvider } from './tsServer/logDirectoryProvider'; -import { ITypeScriptServer, TsServerProcessFactory } from './tsServer/server'; +import { ITypeScriptServer, TsServerProcessFactory, TypeScriptServerExitEvent } from './tsServer/server'; import { TypeScriptServerError } from './tsServer/serverError'; import { TypeScriptServerSpawner } from './tsServer/spawner'; import { TypeScriptVersionManager } from './tsServer/versionManager'; @@ -432,27 +432,30 @@ export default class TypeScriptServiceClient extends Disposable implements IType this.serviceExited(false); }); - handle.onExit((code: any) => { + handle.onExit((data: TypeScriptServerExitEvent) => { if (this.token !== mytoken) { // this is coming from an old process return; } + const { code, signal } = data; + if (code === null || typeof code === 'undefined') { - this.info('TSServer exited'); + this.info(`TSServer exited. Signal: ${signal}`); } else { // In practice, the exit code is an integer with no ties to any identity, // so it can be classified as SystemMetaData, rather than CallstackOrException. - this.error(`TSServer exited with code: ${code}`); + this.error(`TSServer exited with code: ${code}. Signal: ${signal}`); /* __GDPR__ "tsserver.exitWithCode" : { "code" : { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth" }, + "signal" : { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth" }, "${include}": [ "${TypeScriptCommonProperties}" ] } */ - this.logTelemetry('tsserver.exitWithCode', { code: code }); + this.logTelemetry('tsserver.exitWithCode', { code, signal: signal ?? undefined }); } if (handle.tsServerLogFile) { From 66ecd8f6a8fc78be6e128654687d227b4c9ee855 Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Fri, 11 Jun 2021 17:21:37 -0700 Subject: [PATCH 07/17] make state of trusted extensions correct in storage. Fixes #118486 --- .../api/browser/mainThreadAuthentication.ts | 21 ++- .../api/mainThreadAuthentication.test.ts | 126 ++++++++++++++++++ .../test/common/workbenchTestServices.ts | 19 +++ 3 files changed, 164 insertions(+), 2 deletions(-) create mode 100644 src/vs/workbench/test/browser/api/mainThreadAuthentication.test.ts diff --git a/src/vs/workbench/api/browser/mainThreadAuthentication.ts b/src/vs/workbench/api/browser/mainThreadAuthentication.ts index 797e8c2ba2f..c54c35799ef 100644 --- a/src/vs/workbench/api/browser/mainThreadAuthentication.ts +++ b/src/vs/workbench/api/browser/mainThreadAuthentication.ts @@ -17,6 +17,12 @@ import { INotificationService } from 'vs/platform/notification/common/notificati import { fromNow } from 'vs/base/common/date'; import { ActivationKind, IExtensionService } from 'vs/workbench/services/extensions/common/extensions'; +interface TrustedExtensionsQuickPickItem { + label: string; + description: string; + extension: AllowedExtension; +} + export class MainThreadAuthenticationProvider extends Disposable { constructor( private readonly _proxy: ExtHostAuthenticationShape, @@ -38,7 +44,7 @@ export class MainThreadAuthenticationProvider extends Disposable { return; } - const quickPick = this.quickInputService.createQuickPick<{ label: string, description: string, extension: AllowedExtension }>(); + const quickPick = this.quickInputService.createQuickPick(); quickPick.canSelectMany = true; quickPick.customButton = true; quickPick.customLabel = nls.localize('manageTrustedExtensions.cancel', 'Cancel'); @@ -60,12 +66,23 @@ export class MainThreadAuthenticationProvider extends Disposable { quickPick.placeholder = nls.localize('manageExensions', "Choose which extensions can access this account"); quickPick.onDidAccept(() => { - const updatedAllowedList = quickPick.selectedItems.map(item => item.extension); + const updatedAllowedList = quickPick.items + .map(i => (i as TrustedExtensionsQuickPickItem).extension); this.storageService.store(`${this.id}-${accountName}`, JSON.stringify(updatedAllowedList), StorageScope.GLOBAL, StorageTarget.USER); quickPick.dispose(); }); + quickPick.onDidChangeSelection((changed) => { + quickPick.items.forEach(item => { + if ((item as TrustedExtensionsQuickPickItem).extension) { + (item as TrustedExtensionsQuickPickItem).extension.allowed = false; + } + }); + + changed.forEach((item) => item.extension.allowed = true); + }); + quickPick.onDidHide(() => { quickPick.dispose(); }); diff --git a/src/vs/workbench/test/browser/api/mainThreadAuthentication.test.ts b/src/vs/workbench/test/browser/api/mainThreadAuthentication.test.ts new file mode 100644 index 00000000000..92a924aed86 --- /dev/null +++ b/src/vs/workbench/test/browser/api/mainThreadAuthentication.test.ts @@ -0,0 +1,126 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +import * as assert from 'assert'; +import { AuthenticationProviderInformation } from 'vs/editor/common/modes'; +import { IDialogService } from 'vs/platform/dialogs/common/dialogs'; +import { TestDialogService } from 'vs/platform/dialogs/test/common/testDialogService'; +import { InstantiationService } from 'vs/platform/instantiation/common/instantiationService'; +import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection'; +import { INotificationService } from 'vs/platform/notification/common/notification'; +import { TestNotificationService } from 'vs/platform/notification/test/common/testNotificationService'; +import { IQuickInputHideEvent, IQuickInputService, IQuickPickDidAcceptEvent } from 'vs/platform/quickinput/common/quickInput'; +import { IStorageService } from 'vs/platform/storage/common/storage'; +import { MainThreadAuthentication } from 'vs/workbench/api/browser/mainThreadAuthentication'; +import { IExtHostContext } from 'vs/workbench/api/common/extHost.protocol'; +import { IActivityService } from 'vs/workbench/services/activity/common/activity'; +import { AuthenticationService, IAuthenticationService } from 'vs/workbench/services/authentication/browser/authenticationService'; +import { ExtensionHostKind, IExtensionService } from 'vs/workbench/services/extensions/common/extensions'; +import { IRemoteAgentService } from 'vs/workbench/services/remote/common/remoteAgentService'; +import { TestRemoteAgentService } from 'vs/workbench/services/remote/test/common/testServices'; +import { TestQuickInputService } from 'vs/workbench/test/browser/workbenchTestServices'; +import { TestActivityService, TestExtensionService, TestStorageService } from 'vs/workbench/test/common/workbenchTestServices'; + +function createSession(id: string = '1234', scope: string[] = []) { + return { + accessToken: '1234', + account: { + id: 'test@test.com', + label: 'Test Person' + }, + id: id, + scopes: scope + }; +} + +class AuthQuickPick { + private listener: ((e: IQuickPickDidAcceptEvent) => any) | undefined; + public items = []; + public get selectedItems(): string[] { + return this.items; + } + + onDidAccept(listener: (e: IQuickPickDidAcceptEvent) => any) { + this.listener = listener; + } + onDidHide(listener: (e: IQuickInputHideEvent) => any) { + + } + dispose() { + + } + show() { + this.listener!({ + inBackground: false + }); + } +} +class AuthTestQuickInputService extends TestQuickInputService { + override createQuickPick() { + return new AuthQuickPick(); + } +} + +suite('MainThreadAuthentication', () => { + let mainThreadAuthentication: MainThreadAuthentication; + suiteSetup(async () => { + // extHostContext: IExtHostContext, + const services = new ServiceCollection(); + const dialogService = new TestDialogService(); + const storageService = new TestStorageService(); + const quickInputService = new AuthTestQuickInputService(); + const extensionService = new TestExtensionService(); + + const activityService = new TestActivityService(); + const remoteAgentService = new TestRemoteAgentService(); + + services.set(IDialogService, dialogService); + services.set(IStorageService, storageService); + services.set(INotificationService, new TestNotificationService()); + services.set(IQuickInputService, quickInputService); + services.set(IExtensionService, extensionService); + services.set(IActivityService, activityService); + services.set(IRemoteAgentService, remoteAgentService); + + const instaService = new InstantiationService(services); + services.set(IAuthenticationService, instaService.createInstance(AuthenticationService)); + + mainThreadAuthentication = instaService.createInstance(MainThreadAuthentication, + new class implements IExtHostContext { + remoteAuthority = ''; + extensionHostKind = ExtensionHostKind.LocalProcess; + assertRegistered() { } + set(v: any): any { return null; } + getProxy(): any { + return { + $getSessions(id: string, scopes: string[]) { + return Promise.resolve([createSession(id, scopes)]); + }, + $createSession(id: string, scopes: string[]) { + return Promise.resolve(createSession(id, scopes)); + }, + $removeSession(id: string, sessionId: string) { return Promise.resolve(); }, + $onDidChangeAuthenticationSessions(id: string, label: string) { return Promise.resolve(); }, + $onDidChangeAuthenticationProviders(added: AuthenticationProviderInformation[], removed: AuthenticationProviderInformation[]) { return Promise.resolve(); }, + $setProviders(providers: AuthenticationProviderInformation[]) { return Promise.resolve(); } + }; + } + drain(): any { return null; } + }); + + await mainThreadAuthentication.$registerAuthenticationProvider('test', 'test provider', true); + }); + + suiteTeardown(() => { + mainThreadAuthentication.$unregisterAuthenticationProvider('test'); + mainThreadAuthentication.dispose(); + }); + + test('Can get a session', async () => { + const session = await mainThreadAuthentication.$getSession('test', ['foo'], 'testextension', 'test extension', { createIfNone: true, clearSessionPreference: false }); + assert.strictEqual(session?.id, 'test'); + assert.strictEqual(session?.scopes[0], 'foo'); + }); +}); diff --git a/src/vs/workbench/test/common/workbenchTestServices.ts b/src/vs/workbench/test/common/workbenchTestServices.ts index b2ddf026545..f4450ecfcd5 100644 --- a/src/vs/workbench/test/common/workbenchTestServices.ts +++ b/src/vs/workbench/test/common/workbenchTestServices.ts @@ -22,6 +22,7 @@ import { IFileStatWithMetadata } from 'vs/platform/files/common/files'; import { ISaveOptions, IRevertOptions } from 'vs/workbench/common/editor'; import { CancellationToken } from 'vs/base/common/cancellation'; import product from 'vs/platform/product/common/product'; +import { IActivity, IActivityService } from 'vs/workbench/services/activity/common/activity'; export class TestTextResourcePropertiesService implements ITextResourcePropertiesService { @@ -214,3 +215,21 @@ export interface Ctor { export class TestExtensionService extends NullExtensionService { } export const TestProductService = { _serviceBrand: undefined, ...product }; + +export class TestActivityService implements IActivityService { + _serviceBrand: undefined; + showViewContainerActivity(viewContainerId: string, badge: IActivity): IDisposable { + return this; + } + showViewActivity(viewId: string, badge: IActivity): IDisposable { + return this; + } + showAccountsActivity(activity: IActivity): IDisposable { + return this; + } + showGlobalActivity(activity: IActivity): IDisposable { + return this; + } + + dispose() { } +} From e1161be26874f0d39a5b9cdeb2c5fbfd4f83bb80 Mon Sep 17 00:00:00 2001 From: Ladislau Szomoru <3372902+lszomoru@users.noreply.github.com> Date: Sun, 13 Jun 2021 09:21:25 +0200 Subject: [PATCH 08/17] Method to clear memento static map (#126092) --- src/vs/workbench/common/memento.ts | 13 +++++++++ src/vs/workbench/test/common/memento.test.ts | 28 ++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/src/vs/workbench/common/memento.ts b/src/vs/workbench/common/memento.ts index e9854ff82e2..2d52437793a 100644 --- a/src/vs/workbench/common/memento.ts +++ b/src/vs/workbench/common/memento.ts @@ -59,6 +59,19 @@ export class Memento { globalMemento.save(); } } + + static clear(scope: StorageScope): void { + + // Workspace + if (scope === StorageScope.WORKSPACE) { + Memento.workspaceMementos.clear(); + } + + // Global + if (scope === StorageScope.GLOBAL) { + Memento.globalMementos.clear(); + } + } } class ScopedMemento { diff --git a/src/vs/workbench/test/common/memento.test.ts b/src/vs/workbench/test/common/memento.test.ts index 437688eae1c..46c694b2475 100644 --- a/src/vs/workbench/test/common/memento.test.ts +++ b/src/vs/workbench/test/common/memento.test.ts @@ -14,6 +14,8 @@ suite('Memento', () => { setup(() => { storage = new TestStorageService(); + Memento.clear(StorageScope.GLOBAL); + Memento.clear(StorageScope.WORKSPACE); }); test('Loading and Saving Memento with Scopes', () => { @@ -176,4 +178,30 @@ suite('Memento', () => { memento = myMemento2.getMemento(StorageScope.WORKSPACE, StorageTarget.MACHINE); assert.deepStrictEqual(memento, { foo: 'Hello World', bar: 'Hello World' }); }); + + test('Clear Memento', () => { + let myMemento = new Memento('memento.test', storage); + + // Global + let globalMemento = myMemento.getMemento(StorageScope.GLOBAL, StorageTarget.MACHINE); + globalMemento.foo = 'Hello World'; + + // Workspace + let workspaceMemento = myMemento.getMemento(StorageScope.WORKSPACE, StorageTarget.MACHINE); + workspaceMemento.bar = 'Hello World'; + + myMemento.saveMemento(); + + // Clear + storage = new TestStorageService(); + Memento.clear(StorageScope.GLOBAL); + Memento.clear(StorageScope.WORKSPACE); + + myMemento = new Memento('memento.test', storage); + globalMemento = myMemento.getMemento(StorageScope.GLOBAL, StorageTarget.MACHINE); + workspaceMemento = myMemento.getMemento(StorageScope.WORKSPACE, StorageTarget.MACHINE); + + assert.deepStrictEqual(globalMemento, {}); + assert.deepStrictEqual(workspaceMemento, {}); + }); }); From 3ee7bdd57515c3ffe534d4d3ed7e9e292db15b82 Mon Sep 17 00:00:00 2001 From: Ladislau Szomoru <3372902+lszomoru@users.noreply.github.com> Date: Mon, 14 Jun 2021 10:21:19 +0200 Subject: [PATCH 09/17] #126057 --- .../workspaces/common/workspaceTrust.ts | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/vs/workbench/services/workspaces/common/workspaceTrust.ts b/src/vs/workbench/services/workspaces/common/workspaceTrust.ts index 1dfd7b21b7d..7107899cb20 100644 --- a/src/vs/workbench/services/workspaces/common/workspaceTrust.ts +++ b/src/vs/workbench/services/workspaces/common/workspaceTrust.ts @@ -129,15 +129,17 @@ export class WorkspaceTrustManagementService extends Disposable implements IWork private initializeWorkspaceTrust(): void { // Resolve canonical Uris - this.resolveCanonicalUris().then(async () => { - this._canonicalUrisResolved = true; - await this.updateWorkspaceTrust(); - - this._workspaceResolvedPromiseResolve(); - if (!this.environmentService.remoteAuthority) { - this._workspaceTrustInitializedPromiseResolve(); - } - }); + this.resolveCanonicalUris() + .then(async () => { + this._canonicalUrisResolved = true; + await this.updateWorkspaceTrust(); + }) + .finally(() => { + this._workspaceResolvedPromiseResolve(); + if (!this.environmentService.remoteAuthority) { + this._workspaceTrustInitializedPromiseResolve(); + } + }); // Remote - resolve remote authority if (this.environmentService.remoteAuthority) { @@ -145,7 +147,8 @@ export class WorkspaceTrustManagementService extends Disposable implements IWork .then(async result => { this._remoteAuthority = result; await this.updateWorkspaceTrust(); - + }) + .finally(() => { this._workspaceTrustInitializedPromiseResolve(); }); } From e7cd07f10d5c0f6fea5ad2f8400c80d97a808a37 Mon Sep 17 00:00:00 2001 From: Alex Ross Date: Mon, 14 Jun 2021 11:22:32 +0200 Subject: [PATCH 10/17] Filter canddiate ports to localhost and all interfaces --- src/vs/workbench/api/node/extHostTunnelService.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/vs/workbench/api/node/extHostTunnelService.ts b/src/vs/workbench/api/node/extHostTunnelService.ts index 569e07d7067..d3029087c22 100644 --- a/src/vs/workbench/api/node/extHostTunnelService.ts +++ b/src/vs/workbench/api/node/extHostTunnelService.ts @@ -16,7 +16,7 @@ import * as types from 'vs/workbench/api/common/extHostTypes'; import { isLinux } from 'vs/base/common/platform'; import { IExtHostTunnelService, TunnelDto } from 'vs/workbench/api/common/extHostTunnelService'; import { Event, Emitter } from 'vs/base/common/event'; -import { TunnelOptions, TunnelCreationOptions, ProvidedPortAttributes, ProvidedOnAutoForward } from 'vs/platform/remote/common/tunnel'; +import { TunnelOptions, TunnelCreationOptions, ProvidedPortAttributes, ProvidedOnAutoForward, isLocalhost, isAllInterfaces } from 'vs/platform/remote/common/tunnel'; import { IExtensionDescription } from 'vs/platform/extensions/common/extensions'; import { MovingAverage } from 'vs/base/common/numbers'; import { CandidatePort } from 'vs/workbench/services/remote/common/remoteExplorerService'; @@ -270,7 +270,7 @@ export class ExtHostTunnelService extends Disposable implements IExtHostTunnelSe let oldPorts: { host: string, port: number, detail?: string }[] | undefined = undefined; while (this._candidateFindingEnabled) { const startTime = new Date().getTime(); - const newPorts = await this.findCandidatePorts(); + const newPorts = (await this.findCandidatePorts()).filter(candidate => (isLocalhost(candidate.host) || isAllInterfaces(candidate.host))); this.logService.trace(`ForwardedPorts: (ExtHostTunnelService) found candidate ports ${newPorts.map(port => port.port).join(', ')}`); const timeTaken = new Date().getTime() - startTime; movingAverage.update(timeTaken); From b408a6174701c07f9da9d99ee33b8cc7543095b5 Mon Sep 17 00:00:00 2001 From: Alex Ross Date: Mon, 14 Jun 2021 14:39:05 +0200 Subject: [PATCH 11/17] Check if .. exists before adding to simple file picker Fixes #125055 --- .../services/dialogs/browser/simpleFileDialog.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/vs/workbench/services/dialogs/browser/simpleFileDialog.ts b/src/vs/workbench/services/dialogs/browser/simpleFileDialog.ts index 2954355ce5d..b4c641cd464 100644 --- a/src/vs/workbench/services/dialogs/browser/simpleFileDialog.ts +++ b/src/vs/workbench/services/dialogs/browser/simpleFileDialog.ts @@ -908,20 +908,22 @@ export class SimpleFileDialog { return child.substring(parent.length); } - private createBackItem(currFolder: URI): FileQuickPickItem | null { + private async createBackItem(currFolder: URI): Promise { const fileRepresentationCurr = this.currentFolder.with({ scheme: Schemas.file, authority: '' }); const fileRepresentationParent = resources.dirname(fileRepresentationCurr); if (!resources.isEqual(fileRepresentationCurr, fileRepresentationParent)) { const parentFolder = resources.dirname(currFolder); - return { label: '..', uri: resources.addTrailingPathSeparator(parentFolder, this.separator), isFolder: true }; + if (await this.fileService.exists(parentFolder)) { + return { label: '..', uri: resources.addTrailingPathSeparator(parentFolder, this.separator), isFolder: true }; + } } - return null; + return undefined; } private async createItems(folder: IFileStat | undefined, currentFolder: URI, token: CancellationToken): Promise { const result: FileQuickPickItem[] = []; - const backDir = this.createBackItem(currentFolder); + const backDir = await this.createBackItem(currentFolder); try { if (!folder) { folder = await this.fileService.resolve(currentFolder); From ea7cca2cae5682846151539c9d222f9c7e66d1ae Mon Sep 17 00:00:00 2001 From: Alex Dima Date: Mon, 14 Jun 2021 14:52:56 +0200 Subject: [PATCH 12/17] update distro --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 588861e2012..30f5bacb9a6 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "code-oss-dev", "version": "1.58.0", - "distro": "68c5c22efa9f79309df7a4e7c94b480124a43384", + "distro": "eab7dce58d728b96fec604bb89d25e90c0124e01", "author": { "name": "Microsoft Corporation" }, From 8f1fb8a95e65ab17f1fe32d5411fc8f596f19c0d Mon Sep 17 00:00:00 2001 From: Logan Ramos Date: Mon, 14 Jun 2021 09:31:28 -0400 Subject: [PATCH 13/17] More #124762 --- .../customEditor/browser/customEditors.ts | 4 +-- .../common/contributedCustomEditors.ts | 16 ++++++------ .../customEditor/common/customEditor.ts | 10 +++---- .../notebook/browser/notebookServiceImpl.ts | 16 ++++++------ .../notebook/common/notebookProvider.ts | 6 ++--- .../notebook/test/notebookServiceImpl.test.ts | 6 ++--- .../common/preferencesContribution.ts | 4 +-- .../browser/searchEditor.contribution.ts | 4 +-- .../editor/browser/editorOverrideService.ts | 26 +++++++++---------- .../services/editor/browser/editorService.ts | 4 +-- .../editor/common/editorOverrideService.ts | 18 ++++++------- .../editor/test/browser/editorService.test.ts | 8 +++--- 12 files changed, 61 insertions(+), 61 deletions(-) diff --git a/src/vs/workbench/contrib/customEditor/browser/customEditors.ts b/src/vs/workbench/contrib/customEditor/browser/customEditors.ts index 9c412ac0917..bcf9f1d7adb 100644 --- a/src/vs/workbench/contrib/customEditor/browser/customEditors.ts +++ b/src/vs/workbench/contrib/customEditor/browser/customEditors.ts @@ -23,7 +23,7 @@ import { EditorInput } from 'vs/workbench/common/editor/editorInput'; import { CONTEXT_ACTIVE_CUSTOM_EDITOR_ID, CONTEXT_FOCUSED_CUSTOM_EDITOR_IS_EDITABLE, CustomEditorCapabilities, CustomEditorInfo, CustomEditorInfoCollection, ICustomEditorService } from 'vs/workbench/contrib/customEditor/common/customEditor'; import { CustomEditorModelManager } from 'vs/workbench/contrib/customEditor/common/customEditorModelManager'; import { IEditorGroup, IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService'; -import { ContributedEditorPriority, IEditorOverrideService, IEditorType } from 'vs/workbench/services/editor/common/editorOverrideService'; +import { RegisteredEditorPriority, IEditorOverrideService, IEditorType } from 'vs/workbench/services/editor/common/editorOverrideService'; import { IEditorService } from 'vs/workbench/services/editor/common/editorService'; import { IUriIdentityService } from 'vs/workbench/services/uriIdentity/common/uriIdentity'; import { ContributedCustomEditors } from '../common/contributedCustomEditors'; @@ -213,7 +213,7 @@ export class CustomEditorService extends Disposable implements ICustomEditorServ const possibleEditors = this.getAllCustomEditors(newResource); // See if we have any non-optional custom editor for this resource - if (!possibleEditors.allEditors.some(editor => editor.priority !== ContributedEditorPriority.option)) { + if (!possibleEditors.allEditors.some(editor => editor.priority !== RegisteredEditorPriority.option)) { return; } diff --git a/src/vs/workbench/contrib/customEditor/common/contributedCustomEditors.ts b/src/vs/workbench/contrib/customEditor/common/contributedCustomEditors.ts index 3bf7d2db79b..ea606721b98 100644 --- a/src/vs/workbench/contrib/customEditor/common/contributedCustomEditors.ts +++ b/src/vs/workbench/contrib/customEditor/common/contributedCustomEditors.ts @@ -12,7 +12,7 @@ import { IStorageService, StorageScope, StorageTarget } from 'vs/platform/storag import { Memento } from 'vs/workbench/common/memento'; import { CustomEditorDescriptor, CustomEditorInfo } from 'vs/workbench/contrib/customEditor/common/customEditor'; import { customEditorsExtensionPoint, ICustomEditorsExtensionPoint } from 'vs/workbench/contrib/customEditor/common/extensionPoint'; -import { ContributedEditorPriority } from 'vs/workbench/services/editor/common/editorOverrideService'; +import { RegisteredEditorPriority } from 'vs/workbench/services/editor/common/editorOverrideService'; import { IExtensionPointUser } from 'vs/workbench/services/extensions/common/extensionsRegistry'; export const defaultCustomEditor = new CustomEditorInfo({ @@ -22,7 +22,7 @@ export const defaultCustomEditor = new CustomEditorInfo({ selector: [ { filenamePattern: '*' } ], - priority: ContributedEditorPriority.default, + priority: RegisteredEditorPriority.default, }); export class ContributedCustomEditors extends Disposable { @@ -100,17 +100,17 @@ export class ContributedCustomEditors extends Disposable { function getPriorityFromContribution( contribution: ICustomEditorsExtensionPoint, extension: IExtensionDescription, -): ContributedEditorPriority { +): RegisteredEditorPriority { switch (contribution.priority) { - case ContributedEditorPriority.default: - case ContributedEditorPriority.option: + case RegisteredEditorPriority.default: + case RegisteredEditorPriority.option: return contribution.priority; - case ContributedEditorPriority.builtin: + case RegisteredEditorPriority.builtin: // Builtin is only valid for builtin extensions - return extension.isBuiltin ? ContributedEditorPriority.builtin : ContributedEditorPriority.default; + return extension.isBuiltin ? RegisteredEditorPriority.builtin : RegisteredEditorPriority.default; default: - return ContributedEditorPriority.default; + return RegisteredEditorPriority.default; } } diff --git a/src/vs/workbench/contrib/customEditor/common/customEditor.ts b/src/vs/workbench/contrib/customEditor/common/customEditor.ts index dbd675070a9..21064556bbf 100644 --- a/src/vs/workbench/contrib/customEditor/common/customEditor.ts +++ b/src/vs/workbench/contrib/customEditor/common/customEditor.ts @@ -11,7 +11,7 @@ import { RawContextKey } from 'vs/platform/contextkey/common/contextkey'; import { createDecorator } from 'vs/platform/instantiation/common/instantiation'; import * as nls from 'vs/nls'; import { IRevertOptions, ISaveOptions } from 'vs/workbench/common/editor'; -import { ContributedEditorPriority, globMatchesResource, priorityToRank } from 'vs/workbench/services/editor/common/editorOverrideService'; +import { RegisteredEditorPriority, globMatchesResource, priorityToRank } from 'vs/workbench/services/editor/common/editorOverrideService'; export const ICustomEditorService = createDecorator('customEditorService'); @@ -86,7 +86,7 @@ export interface CustomEditorDescriptor { readonly id: string; readonly displayName: string; readonly providerDisplayName: string; - readonly priority: ContributedEditorPriority; + readonly priority: RegisteredEditorPriority; readonly selector: readonly CustomEditorSelector[]; } @@ -95,7 +95,7 @@ export class CustomEditorInfo implements CustomEditorDescriptor { public readonly id: string; public readonly displayName: string; public readonly providerDisplayName: string; - public readonly priority: ContributedEditorPriority; + public readonly priority: RegisteredEditorPriority; public readonly selector: readonly CustomEditorSelector[]; constructor(descriptor: CustomEditorDescriptor) { @@ -130,8 +130,8 @@ export class CustomEditorInfoCollection { public get defaultEditor(): CustomEditorInfo | undefined { return this.allEditors.find(editor => { switch (editor.priority) { - case ContributedEditorPriority.default: - case ContributedEditorPriority.builtin: + case RegisteredEditorPriority.default: + case RegisteredEditorPriority.builtin: // A default editor must have higher priority than all other contributed editors. return this.allEditors.every(otherEditor => otherEditor === editor || isLowerPriority(otherEditor, editor)); diff --git a/src/vs/workbench/contrib/notebook/browser/notebookServiceImpl.ts b/src/vs/workbench/contrib/notebook/browser/notebookServiceImpl.ts index 599e9ef0214..241ab2f758d 100644 --- a/src/vs/workbench/contrib/notebook/browser/notebookServiceImpl.ts +++ b/src/vs/workbench/contrib/notebook/browser/notebookServiceImpl.ts @@ -37,7 +37,7 @@ import { updateEditorTopPadding } from 'vs/workbench/contrib/notebook/common/not import { NotebookOutputRendererInfo } from 'vs/workbench/contrib/notebook/common/notebookOutputRenderer'; import { NotebookEditorDescriptor, NotebookProviderInfo } from 'vs/workbench/contrib/notebook/common/notebookProvider'; import { ComplexNotebookProviderInfo, INotebookContentProvider, INotebookSerializer, INotebookService, SimpleNotebookProviderInfo } from 'vs/workbench/contrib/notebook/common/notebookService'; -import { ContributedEditorInfo, ContributedEditorPriority, DiffEditorInputFactoryFunction, EditorInputFactoryFunction, IEditorOverrideService, IEditorType } from 'vs/workbench/services/editor/common/editorOverrideService'; +import { RegisteredEditorInfo, RegisteredEditorPriority, DiffEditorInputFactoryFunction, EditorInputFactoryFunction, IEditorOverrideService, IEditorType } from 'vs/workbench/services/editor/common/editorOverrideService'; import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions'; import { IExtensionPointUser } from 'vs/workbench/services/extensions/common/extensionsRegistry'; @@ -124,14 +124,14 @@ export class NotebookProviderInfoStore extends Disposable { private _convertPriority(priority?: string) { if (!priority) { - return ContributedEditorPriority.default; + return RegisteredEditorPriority.default; } if (priority === NotebookEditorPriority.default) { - return ContributedEditorPriority.default; + return RegisteredEditorPriority.default; } - return ContributedEditorPriority.option; + return RegisteredEditorPriority.option; } @@ -141,11 +141,11 @@ export class NotebookProviderInfoStore extends Disposable { for (const selector of notebookProviderInfo.selectors) { const globPattern = (selector as INotebookExclusiveDocumentFilter).include || selector as glob.IRelativePattern | string; - const notebookEditorInfo: ContributedEditorInfo = { + const notebookEditorInfo: RegisteredEditorInfo = { id: notebookProviderInfo.id, label: notebookProviderInfo.displayName, detail: notebookProviderInfo.providerDisplayName, - priority: notebookProviderInfo.exclusive ? ContributedEditorPriority.exclusive : notebookProviderInfo.priority, + priority: notebookProviderInfo.exclusive ? RegisteredEditorPriority.exclusive : notebookProviderInfo.priority, }; const notebookEditorOptions = { canHandleDiff: () => !!this._configurationService.getValue(NotebookTextDiffEditorPreview) && !this._accessibilityService.isScreenReaderOptimized(), @@ -182,7 +182,7 @@ export class NotebookProviderInfoStore extends Disposable { // Then register the schema handler as exclusive for that notebook disposables.add(this._editorOverrideService.registerEditor( `${Schemas.vscodeNotebookCell}:/**/${globPattern}`, - { ...notebookEditorInfo, priority: ContributedEditorPriority.exclusive }, + { ...notebookEditorInfo, priority: RegisteredEditorPriority.exclusive }, notebookEditorOptions, notebookEditorInputFactory, notebookEditorDiffFactory @@ -474,7 +474,7 @@ export class NotebookService extends Disposable implements INotebookService { displayName: data.displayName, providerDisplayName: data.providerDisplayName, exclusive: data.exclusive, - priority: ContributedEditorPriority.default, + priority: RegisteredEditorPriority.default, selectors: [], }); diff --git a/src/vs/workbench/contrib/notebook/common/notebookProvider.ts b/src/vs/workbench/contrib/notebook/common/notebookProvider.ts index fbdce0aebbd..8fa9820c47f 100644 --- a/src/vs/workbench/contrib/notebook/common/notebookProvider.ts +++ b/src/vs/workbench/contrib/notebook/common/notebookProvider.ts @@ -7,7 +7,7 @@ import * as glob from 'vs/base/common/glob'; import { URI } from 'vs/base/common/uri'; import { basename } from 'vs/base/common/path'; import { INotebookExclusiveDocumentFilter, isDocumentExcludePattern, TransientOptions } from 'vs/workbench/contrib/notebook/common/notebookCommon'; -import { ContributedEditorPriority } from 'vs/workbench/services/editor/common/editorOverrideService'; +import { RegisteredEditorPriority } from 'vs/workbench/services/editor/common/editorOverrideService'; import { ExtensionIdentifier } from 'vs/platform/extensions/common/extensions'; type NotebookSelector = string | glob.IRelativePattern | INotebookExclusiveDocumentFilter; @@ -17,7 +17,7 @@ export interface NotebookEditorDescriptor { readonly id: string; readonly displayName: string; readonly selectors: readonly { filenamePattern?: string; excludeFileNamePattern?: string; }[]; - readonly priority: ContributedEditorPriority; + readonly priority: RegisteredEditorPriority; readonly providerDisplayName: string; readonly exclusive: boolean; } @@ -27,7 +27,7 @@ export class NotebookProviderInfo { readonly extension: ExtensionIdentifier; readonly id: string; readonly displayName: string; - readonly priority: ContributedEditorPriority; + readonly priority: RegisteredEditorPriority; readonly providerDisplayName: string; readonly exclusive: boolean; diff --git a/src/vs/workbench/contrib/notebook/test/notebookServiceImpl.test.ts b/src/vs/workbench/contrib/notebook/test/notebookServiceImpl.test.ts index b1ede98b015..3c02d2175f5 100644 --- a/src/vs/workbench/contrib/notebook/test/notebookServiceImpl.test.ts +++ b/src/vs/workbench/contrib/notebook/test/notebookServiceImpl.test.ts @@ -15,7 +15,7 @@ import { IStorageService } from 'vs/platform/storage/common/storage'; import { NotebookProviderInfoStore } from 'vs/workbench/contrib/notebook/browser/notebookServiceImpl'; import { NotebookProviderInfo } from 'vs/workbench/contrib/notebook/common/notebookProvider'; import { EditorOverrideService } from 'vs/workbench/services/editor/browser/editorOverrideService'; -import { ContributedEditorPriority } from 'vs/workbench/services/editor/common/editorOverrideService'; +import { RegisteredEditorPriority } from 'vs/workbench/services/editor/common/editorOverrideService'; import { IExtensionService, nullExtensionDescription } from 'vs/workbench/services/extensions/common/extensions'; import { workbenchInstantiationService } from 'vs/workbench/test/browser/workbenchTestServices'; @@ -52,7 +52,7 @@ suite('NotebookProviderInfoStore', function () { id: 'foo', displayName: 'foo', selectors: [{ filenamePattern: '*.foo' }], - priority: ContributedEditorPriority.default, + priority: RegisteredEditorPriority.default, exclusive: false, providerDisplayName: 'foo', }); @@ -61,7 +61,7 @@ suite('NotebookProviderInfoStore', function () { id: 'bar', displayName: 'bar', selectors: [{ filenamePattern: '*.bar' }], - priority: ContributedEditorPriority.default, + priority: RegisteredEditorPriority.default, exclusive: false, providerDisplayName: 'bar', }); diff --git a/src/vs/workbench/contrib/preferences/common/preferencesContribution.ts b/src/vs/workbench/contrib/preferences/common/preferencesContribution.ts index b653d7b1e56..d42c63be9cc 100644 --- a/src/vs/workbench/contrib/preferences/common/preferencesContribution.ts +++ b/src/vs/workbench/contrib/preferences/common/preferencesContribution.ts @@ -22,7 +22,7 @@ import { workbenchConfigurationNodeBase } from 'vs/workbench/common/configuratio import { IWorkbenchContribution } from 'vs/workbench/common/contributions'; import { IEditorInputWithOptions } from 'vs/workbench/common/editor'; import { IEditorGroup } from 'vs/workbench/services/editor/common/editorGroupsService'; -import { ContributedEditorPriority, IEditorOverrideService } from 'vs/workbench/services/editor/common/editorOverrideService'; +import { RegisteredEditorPriority, IEditorOverrideService } from 'vs/workbench/services/editor/common/editorOverrideService'; import { IEditorService } from 'vs/workbench/services/editor/common/editorService'; import { FOLDER_SETTINGS_PATH, IPreferencesService, USE_SPLIT_JSON_SETTING } from 'vs/workbench/services/preferences/common/preferences'; import { PreferencesEditorInput } from 'vs/workbench/services/preferences/common/preferencesEditorInput'; @@ -67,7 +67,7 @@ export class PreferencesContribution implements IWorkbenchContribution { id: PreferencesEditorInput.ID, detail: 'Split Settings Editor (deprecated)', label: 'label', - priority: ContributedEditorPriority.builtin, + priority: RegisteredEditorPriority.builtin, }, {}, (resource: URI, options: IEditorOptions | undefined, group: IEditorGroup): IEditorInputWithOptions => { diff --git a/src/vs/workbench/contrib/searchEditor/browser/searchEditor.contribution.ts b/src/vs/workbench/contrib/searchEditor/browser/searchEditor.contribution.ts index 79ac2a82104..f3c972bc729 100644 --- a/src/vs/workbench/contrib/searchEditor/browser/searchEditor.contribution.ts +++ b/src/vs/workbench/contrib/searchEditor/browser/searchEditor.contribution.ts @@ -32,7 +32,7 @@ import { createEditorFromSearchResult, modifySearchEditorContextLinesCommand, op import { getOrMakeSearchEditorInput, SearchConfiguration, SearchEditorInput, SEARCH_EDITOR_EXT } from 'vs/workbench/contrib/searchEditor/browser/searchEditorInput'; import { IEditorService } from 'vs/workbench/services/editor/common/editorService'; import { VIEW_ID } from 'vs/workbench/services/search/common/search'; -import { ContributedEditorPriority, DEFAULT_EDITOR_ASSOCIATION, IEditorOverrideService } from 'vs/workbench/services/editor/common/editorOverrideService'; +import { RegisteredEditorPriority, DEFAULT_EDITOR_ASSOCIATION, IEditorOverrideService } from 'vs/workbench/services/editor/common/editorOverrideService'; import { IWorkingCopyEditorService } from 'vs/workbench/services/workingCopy/common/workingCopyEditorService'; import { Disposable } from 'vs/base/common/lifecycle'; @@ -81,7 +81,7 @@ class SearchEditorContribution implements IWorkbenchContribution { id: SearchEditorInput.ID, label: localize('promptOpenWith.searchEditor.displayName', "Search Editor"), detail: DEFAULT_EDITOR_ASSOCIATION.providerDisplayName, - priority: ContributedEditorPriority.default, + priority: RegisteredEditorPriority.default, }, { singlePerResource: true, diff --git a/src/vs/workbench/services/editor/browser/editorOverrideService.ts b/src/vs/workbench/services/editor/browser/editorOverrideService.ts index 23bcfb9096b..35d8235f48e 100644 --- a/src/vs/workbench/services/editor/browser/editorOverrideService.ts +++ b/src/vs/workbench/services/editor/browser/editorOverrideService.ts @@ -13,7 +13,7 @@ import { EditorActivation, EditorOverride, IEditorOptions } from 'vs/platform/ed import { EditorResourceAccessor, IEditorInput, IEditorInputWithOptions, isResourceDiffEditorInput, SideBySideEditor } from 'vs/workbench/common/editor'; import { IEditorGroup, IEditorGroupsService, preferredSideBySideGroupDirection } from 'vs/workbench/services/editor/common/editorGroupsService'; import { Schemas } from 'vs/base/common/network'; -import { ContributedEditorInfo, ContributedEditorPriority, RegisteredEditorOptions, DEFAULT_EDITOR_ASSOCIATION, DiffEditorInputFactoryFunction, EditorAssociation, EditorAssociations, EditorInputFactoryFunction, editorsAssociationsSettingId, globMatchesResource, IEditorOverrideService, priorityToRank, ReturnedOverride, OverrideStatus } from 'vs/workbench/services/editor/common/editorOverrideService'; +import { RegisteredEditorInfo, RegisteredEditorPriority, RegisteredEditorOptions, DEFAULT_EDITOR_ASSOCIATION, DiffEditorInputFactoryFunction, EditorAssociation, EditorAssociations, EditorInputFactoryFunction, editorsAssociationsSettingId, globMatchesResource, IEditorOverrideService, priorityToRank, ReturnedOverride, OverrideStatus } from 'vs/workbench/services/editor/common/editorOverrideService'; import { IKeyMods, IQuickInputService, IQuickPickItem, IQuickPickSeparator } from 'vs/platform/quickinput/common/quickInput'; import { localize } from 'vs/nls'; import { INotificationService, Severity } from 'vs/platform/notification/common/notification'; @@ -23,13 +23,13 @@ import { IStorageService, StorageScope, StorageTarget } from 'vs/platform/storag import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions'; import { IResourceEditorInputType } from 'vs/workbench/services/editor/common/editorService'; -interface IContributedEditorInput extends IEditorInput { +interface IRegisteredEditorInput extends IEditorInput { viewType?: string; } interface RegisteredEditor { globPattern: string | glob.IRelativePattern, - editorInfo: ContributedEditorInfo, + editorInfo: RegisteredEditorInfo, options?: RegisteredEditorOptions, createEditorInput: EditorInputFactoryFunction createDiffEditorInput?: DiffEditorInputFactoryFunction @@ -127,7 +127,7 @@ export class EditorOverrideService extends Disposable implements IEditorOverride const currentEditor = firstOrDefault(group.findEditors(resource)); let currentViewType = undefined; if (currentEditor) { - currentViewType = (currentEditor as IContributedEditorInput).viewType; + currentViewType = (currentEditor as IRegisteredEditorInput).viewType; } if (currentViewType && selectedEditor.editorInfo.id === currentViewType) { return OverrideStatus.ABORT; @@ -148,7 +148,7 @@ export class EditorOverrideService extends Disposable implements IEditorOverride registerEditor( globPattern: string | glob.IRelativePattern, - editorInfo: ContributedEditorInfo, + editorInfo: RegisteredEditorInfo, options: RegisteredEditorOptions, createEditorInput: EditorInputFactoryFunction, createDiffEditorInput?: DiffEditorInputFactoryFunction @@ -273,9 +273,9 @@ export class EditorOverrideService extends Disposable implements IEditorOverride const associationsFromSetting = this.getAssociationsForResource(resource); // We only want built-in+ if no user defined setting is found, else we won't override - const possibleEditors = editors.filter(editor => priorityToRank(editor.editorInfo.priority) >= priorityToRank(ContributedEditorPriority.builtin) && editor.editorInfo.id !== DEFAULT_EDITOR_ASSOCIATION.id); + const possibleEditors = editors.filter(editor => priorityToRank(editor.editorInfo.priority) >= priorityToRank(RegisteredEditorPriority.builtin) && editor.editorInfo.id !== DEFAULT_EDITOR_ASSOCIATION.id); // If the editor is exclusive we use that, else use the user setting, else use the built-in+ editor - const selectedViewType = possibleEditors[0]?.editorInfo.priority === ContributedEditorPriority.exclusive ? + const selectedViewType = possibleEditors[0]?.editorInfo.priority === RegisteredEditorPriority.exclusive ? possibleEditors[0]?.editorInfo.id : associationsFromSetting[0]?.viewType || possibleEditors[0]?.editorInfo.id; @@ -362,7 +362,7 @@ export class EditorOverrideService extends Disposable implements IEditorOverride for (const group of orderedGroups) { for (const editor of group.editors) { - if (isEqual(editor.resource, resource) && (editor as IContributedEditorInput).viewType === viewType) { + if (isEqual(editor.resource, resource) && (editor as IRegisteredEditorInput).viewType === viewType) { out.push({ editor, group }); } } @@ -370,7 +370,7 @@ export class EditorOverrideService extends Disposable implements IEditorOverride return out; } - private async doHandleConflictingDefaults(resource: URI, editorName: string, currentEditor: IContributedEditorInput, options: IEditorOptions | undefined, group: IEditorGroup) { + private async doHandleConflictingDefaults(resource: URI, editorName: string, currentEditor: IRegisteredEditorInput, options: IEditorOptions | undefined, group: IEditorGroup) { type StoredChoice = { [key: string]: string[]; }; @@ -448,7 +448,7 @@ export class EditorOverrideService extends Disposable implements IEditorOverride const currentDefaultAndActiveLabel = localize('promptOpenWith.currentDefaultAndActive', "Active and Default"); // Default order = setting -> highest priority -> text let defaultViewType = defaultSetting; - if (!defaultViewType && registeredEditors.length > 2 && registeredEditors[1]?.editorInfo.priority !== ContributedEditorPriority.option) { + if (!defaultViewType && registeredEditors.length > 2 && registeredEditors[1]?.editorInfo.priority !== RegisteredEditorPriority.option) { defaultViewType = registeredEditors[1]?.editorInfo.id; } if (!defaultViewType) { @@ -456,7 +456,7 @@ export class EditorOverrideService extends Disposable implements IEditorOverride } // Map the editors to quickpick entries registeredEditors.forEach(editor => { - const currentViewType = (currentEditor as IContributedEditorInput).viewType ?? DEFAULT_EDITOR_ASSOCIATION.id; + const currentViewType = (currentEditor as IRegisteredEditorInput).viewType ?? DEFAULT_EDITOR_ASSOCIATION.id; const isActive = currentEditor ? editor.editorInfo.id === currentViewType : false; const isDefault = editor.editorInfo.id === defaultViewType; const quickPickEntry: IQuickPickItem = { @@ -578,7 +578,7 @@ export class EditorOverrideService extends Disposable implements IEditorOverride return undefined; } - private sendOverrideTelemetry(chosenInput: IContributedEditorInput): void { + private sendOverrideTelemetry(chosenInput: IRegisteredEditorInput): void { type editorOverrideClassification = { viewType: { classification: 'PublicNonPersonalData', purpose: 'FeatureInsight' }; }; @@ -596,7 +596,7 @@ export class EditorOverrideService extends Disposable implements IEditorOverride // Store just the relative pattern pieces without any path info for (const [globPattern, contribPoint] of this._editors) { - const nonOptional = !!contribPoint.find(c => c.editorInfo.priority !== ContributedEditorPriority.option && c.editorInfo.id !== DEFAULT_EDITOR_ASSOCIATION.id); + const nonOptional = !!contribPoint.find(c => c.editorInfo.priority !== RegisteredEditorPriority.option && c.editorInfo.id !== DEFAULT_EDITOR_ASSOCIATION.id); // Don't keep a cache of the optional ones as those wouldn't be opened on start anyways if (!nonOptional) { continue; diff --git a/src/vs/workbench/services/editor/browser/editorService.ts b/src/vs/workbench/services/editor/browser/editorService.ts index 73598b51832..29a50ffd767 100644 --- a/src/vs/workbench/services/editor/browser/editorService.ts +++ b/src/vs/workbench/services/editor/browser/editorService.ts @@ -34,7 +34,7 @@ import { Promises, timeout } from 'vs/base/common/async'; import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace'; import { indexOfPath } from 'vs/base/common/extpath'; import { IUriIdentityService } from 'vs/workbench/services/uriIdentity/common/uriIdentity'; -import { ContributedEditorPriority, DEFAULT_EDITOR_ASSOCIATION, IEditorOverrideService, OverrideStatus } from 'vs/workbench/services/editor/common/editorOverrideService'; +import { RegisteredEditorPriority, DEFAULT_EDITOR_ASSOCIATION, IEditorOverrideService, OverrideStatus } from 'vs/workbench/services/editor/common/editorOverrideService'; import { IWorkingCopyService } from 'vs/workbench/services/workingCopy/common/workingCopyService'; import { IWorkspaceTrustRequestService, WorkspaceTrustUriResponse } from 'vs/platform/workspace/common/workspaceTrust'; import { IHostService } from 'vs/workbench/services/host/browser/host'; @@ -121,7 +121,7 @@ export class EditorService extends Disposable implements EditorServiceImpl { id: DEFAULT_EDITOR_ASSOCIATION.id, label: DEFAULT_EDITOR_ASSOCIATION.displayName, detail: DEFAULT_EDITOR_ASSOCIATION.providerDisplayName, - priority: ContributedEditorPriority.builtin + priority: RegisteredEditorPriority.builtin }, {}, resource => ({ editor: this.createEditorInput({ resource }) }), diff --git a/src/vs/workbench/services/editor/common/editorOverrideService.ts b/src/vs/workbench/services/editor/common/editorOverrideService.ts index de5410d5aa2..4dd676549bf 100644 --- a/src/vs/workbench/services/editor/common/editorOverrideService.ts +++ b/src/vs/workbench/services/editor/common/editorOverrideService.ts @@ -64,7 +64,7 @@ configurationRegistry.registerConfiguration(editorAssociationsConfigurationNode) //#endregion //#region EditorOverrideService types -export enum ContributedEditorPriority { +export enum RegisteredEditorPriority { builtin = 'builtin', option = 'option', exclusive = 'exclusive', @@ -100,11 +100,11 @@ export type RegisteredEditorOptions = { canSupportResource?: (resource: URI) => boolean; }; -export type ContributedEditorInfo = { +export type RegisteredEditorInfo = { id: string; label: string; detail?: string; - priority: ContributedEditorPriority; + priority: RegisteredEditorPriority; }; export type EditorInputFactoryFunction = (resource: URI, options: IEditorOptions | undefined, group: IEditorGroup) => IEditorInputWithOptions; @@ -136,7 +136,7 @@ export interface IEditorOverrideService { */ registerEditor( globPattern: string | glob.IRelativePattern, - editorInfo: ContributedEditorInfo, + editorInfo: RegisteredEditorInfo, options: RegisteredEditorOptions, createEditorInput: EditorInputFactoryFunction, createDiffEditorInput?: DiffEditorInputFactoryFunction @@ -162,16 +162,16 @@ export interface IEditorOverrideService { //#endregion //#region Util functions -export function priorityToRank(priority: ContributedEditorPriority): number { +export function priorityToRank(priority: RegisteredEditorPriority): number { switch (priority) { - case ContributedEditorPriority.exclusive: + case RegisteredEditorPriority.exclusive: return 5; - case ContributedEditorPriority.default: + case RegisteredEditorPriority.default: return 4; - case ContributedEditorPriority.builtin: + case RegisteredEditorPriority.builtin: return 3; // Text editor is priority 2 - case ContributedEditorPriority.option: + case RegisteredEditorPriority.option: default: return 1; } diff --git a/src/vs/workbench/services/editor/test/browser/editorService.test.ts b/src/vs/workbench/services/editor/test/browser/editorService.test.ts index 4835c7efe03..4ec713bec82 100644 --- a/src/vs/workbench/services/editor/test/browser/editorService.test.ts +++ b/src/vs/workbench/services/editor/test/browser/editorService.test.ts @@ -30,7 +30,7 @@ import { DiffEditorInput } from 'vs/workbench/common/editor/diffEditorInput'; import { TestStorageService } from 'vs/workbench/test/common/workbenchTestServices'; import { isLinux } from 'vs/base/common/platform'; import { MockScopableContextKeyService } from 'vs/platform/keybinding/test/common/mockKeybindingService'; -import { ContributedEditorPriority } from 'vs/workbench/services/editor/common/editorOverrideService'; +import { RegisteredEditorPriority } from 'vs/workbench/services/editor/common/editorOverrideService'; import { IWorkspaceTrustRequestService, WorkspaceTrustUriResponse } from 'vs/platform/workspace/common/workspaceTrust'; import { TestWorkspaceTrustRequestService } from 'vs/workbench/services/workspaces/test/common/testWorkspaceTrustService'; import { SideBySideEditorInput } from 'vs/workbench/common/editor/sideBySideEditorInput'; @@ -1131,7 +1131,7 @@ suite('EditorService', () => { id: 'TestEditor', label: 'Test Editor', detail: 'Test Editor Provider', - priority: ContributedEditorPriority.builtin + priority: RegisteredEditorPriority.builtin }, {}, (resource) => { @@ -1166,7 +1166,7 @@ suite('EditorService', () => { id: 'TestEditor', label: 'Test Editor', detail: 'Test Editor Provider', - priority: ContributedEditorPriority.builtin + priority: RegisteredEditorPriority.builtin }, {}, (resource) => { @@ -1197,7 +1197,7 @@ suite('EditorService', () => { id: 'TestEditor', label: 'Test Editor', detail: 'Test Editor Provider', - priority: ContributedEditorPriority.builtin + priority: RegisteredEditorPriority.builtin }, {}, (resource) => { From cabbe787a28ad14923b61488c5c4ebe0527db1fe Mon Sep 17 00:00:00 2001 From: Alex Ross Date: Mon, 14 Jun 2021 15:15:37 +0200 Subject: [PATCH 14/17] Don't show tasks error when in a virtual workspace --- src/vs/workbench/contrib/tasks/browser/abstractTaskService.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vs/workbench/contrib/tasks/browser/abstractTaskService.ts b/src/vs/workbench/contrib/tasks/browser/abstractTaskService.ts index 658576a6733..dd82efb25c1 100644 --- a/src/vs/workbench/contrib/tasks/browser/abstractTaskService.ts +++ b/src/vs/workbench/contrib/tasks/browser/abstractTaskService.ts @@ -518,7 +518,7 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer } protected showOutput(runSource: TaskRunSource = TaskRunSource.User): void { - if ((runSource === TaskRunSource.User) || (runSource === TaskRunSource.ConfigurationChange)) { + if (!VirtualWorkspaceContext.getValue(this.contextKeyService) && ((runSource === TaskRunSource.User) || (runSource === TaskRunSource.ConfigurationChange))) { this.notificationService.prompt(Severity.Warning, nls.localize('taskServiceOutputPrompt', 'There are task errors. See the output for details.'), [{ label: nls.localize('showOutput', "Show output"), From f1bbe6611d25359ea6b2e7ad77d643e45b9f627f Mon Sep 17 00:00:00 2001 From: Alex Ross Date: Mon, 14 Jun 2021 15:51:45 +0200 Subject: [PATCH 15/17] Fix workspace folder tasks getting parsed extra times --- .../tasks/browser/abstractTaskService.ts | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/vs/workbench/contrib/tasks/browser/abstractTaskService.ts b/src/vs/workbench/contrib/tasks/browser/abstractTaskService.ts index dd82efb25c1..1e13c2dec11 100644 --- a/src/vs/workbench/contrib/tasks/browser/abstractTaskService.ts +++ b/src/vs/workbench/contrib/tasks/browser/abstractTaskService.ts @@ -2021,7 +2021,8 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer if (this.executionEngine === ExecutionEngine.Process) { return this.emptyWorkspaceTaskResults(workspaceFolder); } - const configuration = this.testParseExternalConfig(this.configurationService.inspect('tasks').workspaceValue, nls.localize('TasksSystem.locationWorkspaceConfig', 'workspace file')); + const workspaceFileConfig = this.getConfiguration(workspaceFolder, TaskSourceKind.WorkspaceFile); + const configuration = this.testParseExternalConfig(workspaceFileConfig.config, nls.localize('TasksSystem.locationWorkspaceConfig', 'workspace file')); let customizedTasks: { byIdentifier: IStringDictionary; } = { byIdentifier: Object.create(null) }; @@ -2040,7 +2041,8 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer if (this.executionEngine === ExecutionEngine.Process) { return this.emptyWorkspaceTaskResults(workspaceFolder); } - const configuration = this.testParseExternalConfig(this.configurationService.inspect('tasks').userValue, nls.localize('TasksSystem.locationUserConfig', 'user settings')); + const userTasksConfig = this.getConfiguration(workspaceFolder, TaskSourceKind.User); + const configuration = this.testParseExternalConfig(userTasksConfig.config, nls.localize('TasksSystem.locationUserConfig', 'user settings')); let customizedTasks: { byIdentifier: IStringDictionary; } = { byIdentifier: Object.create(null) }; @@ -2157,9 +2159,20 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer } else { const wholeConfig = this.configurationService.inspect('tasks', { resource: workspaceFolder.uri }); switch (source) { - case TaskSourceKind.User: result = Objects.deepClone(wholeConfig.userValue); break; + case TaskSourceKind.User: { + if (wholeConfig.userValue !== wholeConfig.workspaceFolderValue) { + result = Objects.deepClone(wholeConfig.userValue); + } + break; + } case TaskSourceKind.Workspace: result = Objects.deepClone(wholeConfig.workspaceFolderValue); break; - case TaskSourceKind.WorkspaceFile: result = Objects.deepClone(wholeConfig.workspaceValue); break; + case TaskSourceKind.WorkspaceFile: { + if ((this.contextService.getWorkbenchState() === WorkbenchState.WORKSPACE) + && (wholeConfig.workspaceFolderValue !== wholeConfig.workspaceValue)) { + result = Objects.deepClone(wholeConfig.workspaceValue); + } + break; + } default: result = Objects.deepClone(wholeConfig.workspaceFolderValue); } } From 59ccce16da6bb5583e0fdf5658993a2714589ad6 Mon Sep 17 00:00:00 2001 From: Logan Ramos Date: Mon, 14 Jun 2021 10:19:05 -0400 Subject: [PATCH 16/17] Better active editor check logic --- .../services/editor/browser/editorOverrideService.ts | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/vs/workbench/services/editor/browser/editorOverrideService.ts b/src/vs/workbench/services/editor/browser/editorOverrideService.ts index 35d8235f48e..53f2f567911 100644 --- a/src/vs/workbench/services/editor/browser/editorOverrideService.ts +++ b/src/vs/workbench/services/editor/browser/editorOverrideService.ts @@ -124,12 +124,9 @@ export class EditorOverrideService extends Disposable implements IEditorOverride } // If it's the currently active editor we shouldn't do anything - const currentEditor = firstOrDefault(group.findEditors(resource)); - let currentViewType = undefined; - if (currentEditor) { - currentViewType = (currentEditor as IRegisteredEditorInput).viewType; - } - if (currentViewType && selectedEditor.editorInfo.id === currentViewType) { + const currentEditors = group.findEditors(resource); + const isActive = currentEditors.find(editor => (editor as IRegisteredEditorInput).viewType === selectedEditor.editorInfo.id); + if (isActive) { return OverrideStatus.ABORT; } const input = await this.doOverrideEditorInput(resource, editor, options, group, selectedEditor); From 8440af2409b34aeaa381bfe3c67565436efc11bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Moreno?= Date: Mon, 14 Jun 2021 16:28:33 +0200 Subject: [PATCH 17/17] share test compilation output across agents --- .../azure-pipelines/darwin/product-build-darwin.yml | 12 ------------ build/azure-pipelines/linux/product-build-linux.yml | 12 ------------ build/azure-pipelines/product-compile.yml | 11 +++++++++-- build/azure-pipelines/win32/product-build-win32.yml | 7 ------- 4 files changed, 9 insertions(+), 33 deletions(-) diff --git a/build/azure-pipelines/darwin/product-build-darwin.yml b/build/azure-pipelines/darwin/product-build-darwin.yml index 566eeb80522..3d7e8c41aa2 100644 --- a/build/azure-pipelines/darwin/product-build-darwin.yml +++ b/build/azure-pipelines/darwin/product-build-darwin.yml @@ -185,12 +185,6 @@ steps: timeoutInMinutes: 7 condition: and(succeeded(), eq(variables['VSCODE_ARCH'], 'x64'), eq(variables['VSCODE_STEP_ON_IT'], 'false')) - - script: | - set -e - yarn --cwd test/integration/browser compile - displayName: Compile integration tests - condition: and(succeeded(), eq(variables['VSCODE_ARCH'], 'x64'), eq(variables['VSCODE_STEP_ON_IT'], 'false')) - - script: | # Figure out the full absolute path of the product we just built # including the remote server and configure the integration tests @@ -224,12 +218,6 @@ steps: timeoutInMinutes: 7 condition: and(succeeded(), eq(variables['VSCODE_ARCH'], 'x64'), eq(variables['VSCODE_STEP_ON_IT'], 'false')) - - script: | - set -e - yarn --cwd test/smoke compile - displayName: Compile smoke tests - condition: and(succeeded(), eq(variables['VSCODE_ARCH'], 'x64'), eq(variables['VSCODE_STEP_ON_IT'], 'false')) - - script: | set -e APP_ROOT=$(agent.builddirectory)/VSCode-darwin-$(VSCODE_ARCH) diff --git a/build/azure-pipelines/linux/product-build-linux.yml b/build/azure-pipelines/linux/product-build-linux.yml index 297c40ac28c..e941a6bb82e 100644 --- a/build/azure-pipelines/linux/product-build-linux.yml +++ b/build/azure-pipelines/linux/product-build-linux.yml @@ -143,12 +143,6 @@ steps: timeoutInMinutes: 7 condition: and(succeeded(), eq(variables['VSCODE_ARCH'], 'x64'), eq(variables['VSCODE_STEP_ON_IT'], 'false')) - - script: | - set -e - yarn --cwd test/integration/browser compile - displayName: Compile integration tests - condition: and(succeeded(), eq(variables['VSCODE_ARCH'], 'x64'), eq(variables['VSCODE_STEP_ON_IT'], 'false')) - - script: | # Figure out the full absolute path of the product we just built # including the remote server and configure the integration tests @@ -184,12 +178,6 @@ steps: timeoutInMinutes: 7 condition: and(succeeded(), eq(variables['VSCODE_ARCH'], 'x64'), eq(variables['VSCODE_STEP_ON_IT'], 'false')) - - script: | - set -e - yarn --cwd test/smoke compile - displayName: Compile smoke tests - condition: and(succeeded(), eq(variables['VSCODE_ARCH'], 'x64'), eq(variables['VSCODE_STEP_ON_IT'], 'false')) - - script: | set -e APP_PATH=$(agent.builddirectory)/VSCode-linux-$(VSCODE_ARCH) diff --git a/build/azure-pipelines/product-compile.yml b/build/azure-pipelines/product-compile.yml index 18c17639b83..7ba1220f040 100644 --- a/build/azure-pipelines/product-compile.yml +++ b/build/azure-pipelines/product-compile.yml @@ -38,7 +38,7 @@ steps: # using `genericNodeModules` instead of `nodeModules` here to avoid sharing the cache with builds running inside containers - task: Cache@2 inputs: - key: 'genericNodeModules | $(Agent.OS) | .build/yarnlockhash' + key: "genericNodeModules | $(Agent.OS) | .build/yarnlockhash" path: .build/node_modules_cache cacheHitVar: NODE_MODULES_RESTORED displayName: Restore node_modules cache @@ -98,6 +98,13 @@ steps: yarn npm-run-all -lp core-ci extensions-ci hygiene eslint valid-layers-check displayName: Compile & Hygiene + - script: | + set -e + yarn --cwd test/smoke compile + yarn --cwd test/integration/browser compile + displayName: Compile test suites + condition: and(succeeded(), eq(variables['VSCODE_STEP_ON_IT'], 'false')) + - script: | set -e AZURE_STORAGE_ACCESS_KEY="$(ticino-storage-key)" \ @@ -121,7 +128,7 @@ steps: # we gotta tarball everything in order to preserve file permissions - script: | set -e - tar -czf $(Build.ArtifactStagingDirectory)/compilation.tar.gz .build out-* + tar -czf $(Build.ArtifactStagingDirectory)/compilation.tar.gz .build out-* test/integration/browser/out test/smoke/out test/automation/out displayName: Compress compilation artifact - task: PublishPipelineArtifact@1 diff --git a/build/azure-pipelines/win32/product-build-win32.yml b/build/azure-pipelines/win32/product-build-win32.yml index 1f8514ae7e3..ba28eedaaaf 100644 --- a/build/azure-pipelines/win32/product-build-win32.yml +++ b/build/azure-pipelines/win32/product-build-win32.yml @@ -154,13 +154,6 @@ steps: timeoutInMinutes: 7 condition: and(succeeded(), eq(variables['VSCODE_STEP_ON_IT'], 'false'), ne(variables['VSCODE_ARCH'], 'arm64')) - - powershell: | - . build/azure-pipelines/win32/exec.ps1 - $ErrorActionPreference = "Stop" - exec { yarn --cwd test/integration/browser compile } - displayName: Compile integration tests - condition: and(succeeded(), eq(variables['VSCODE_STEP_ON_IT'], 'false'), ne(variables['VSCODE_ARCH'], 'arm64')) - - powershell: | # Figure out the full absolute path of the product we just built # including the remote server and configure the integration tests