Skip to content

Commit 95205a3

Browse files
committed
Merge branch 'main' into joh/swc
2 parents 872e9df + dffbdeb commit 95205a3

File tree

191 files changed

+1536
-1251
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

191 files changed

+1536
-1251
lines changed

.mailmap

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
Eric Amodio <[email protected]> Eric Amodio <[email protected]>
2-
Eric Amodio <[email protected]> Eric Amodio <[email protected]>
31
Daniel Imms <[email protected]> Daniel Imms <[email protected]>
4-
Tanha Kabir <[email protected]> Tanha Kabir <[email protected]>
52
Raymond Zhao <[email protected]>
63
Tyler Leonhardt <[email protected]> Tyler Leonhardt <[email protected]>
4+
João Moreno <[email protected]> João Moreno <[email protected]>

.vscode/notebooks/api.github-issues

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
{
88
"kind": 2,
99
"language": "github-issues",
10-
"value": "$repo=repo:microsoft/vscode\n$milestone=milestone:\"August 2022\""
10+
"value": "$repo=repo:microsoft/vscode\n$milestone=milestone:\"September 2022\""
1111
},
1212
{
1313
"kind": 1,

extensions/git/src/commands.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ export class CommandCenter {
457457
);
458458
}
459459

460-
async cloneRepository(url?: string, parentPath?: string, options: { recursive?: boolean } = {}): Promise<void> {
460+
async cloneRepository(url?: string, parentPath?: string, options: { recursive?: boolean; ref?: string } = {}): Promise<void> {
461461
if (!url || typeof url !== 'string') {
462462
url = await pickRemoteSource({
463463
providerLabel: provider => localize('clonefrom', "Clone from {0}", provider.name),
@@ -519,6 +519,11 @@ export class CommandCenter {
519519
(progress, token) => this.git.clone(url!, { parentPath: parentPath!, progress, recursive: options.recursive }, token)
520520
);
521521

522+
if (options.ref !== undefined) {
523+
const repository = this.model.getRepository(Uri.file(repositoryPath));
524+
await repository?.checkout(options.ref);
525+
}
526+
522527
const config = workspace.getConfiguration('git');
523528
const openAfterClone = config.get<'always' | 'alwaysNewWindow' | 'whenNoFolderOpen' | 'prompt'>('openAfterClone');
524529

@@ -596,8 +601,8 @@ export class CommandCenter {
596601
}
597602

598603
@command('git.clone')
599-
async clone(url?: string, parentPath?: string): Promise<void> {
600-
await this.cloneRepository(url, parentPath);
604+
async clone(url?: string, parentPath?: string, options?: { ref?: string }): Promise<void> {
605+
await this.cloneRepository(url, parentPath, options);
601606
}
602607

603608
@command('git.cloneRecursive')

extensions/git/src/protocolHandler.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export class GitProtocolHandler implements UriHandler {
2525

2626
private clone(uri: Uri): void {
2727
const data = querystring.parse(uri.query);
28+
const ref = data.ref;
2829

2930
if (!data.url) {
3031
console.warn('Failed to open URI:', uri);
@@ -36,6 +37,11 @@ export class GitProtocolHandler implements UriHandler {
3637
return;
3738
}
3839

40+
if (ref !== undefined && typeof ref !== 'string') {
41+
console.warn('Failed to open URI:', uri);
42+
return;
43+
}
44+
3945
let cloneUri: Uri;
4046
try {
4147
let rawUri = Array.isArray(data.url) ? data.url[0] : data.url;
@@ -56,7 +62,7 @@ export class GitProtocolHandler implements UriHandler {
5662
return;
5763
}
5864

59-
commands.executeCommand('git.clone', cloneUri.toString(true));
65+
commands.executeCommand('git.clone', cloneUri.toString(true), undefined, { ref: ref });
6066
}
6167

6268
dispose(): void {

extensions/ipynb/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
"vscode": "^1.57.0"
1010
},
1111
"enabledApiProposals": [
12-
"notebookWorkspaceEdit",
1312
"documentPaste"
1413
],
1514
"activationEvents": [

extensions/ipynb/tsconfig.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
"include": [
1010
"src/**/*",
1111
"../../src/vscode-dts/vscode.d.ts",
12-
"../../src/vscode-dts/vscode.proposed.notebookWorkspaceEdit.d.ts",
1312
"../../src/vscode-dts/vscode.proposed.documentPaste.d.ts"
1413
]
1514
}

extensions/markdown-language-features/server/README.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,20 @@ This server uses the [Markdown Language Service](https://github.com/microsoft/vs
2323

2424
- [Find all references](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_references) to headers and links across all Markdown files in the workspace.
2525

26+
- [Go to definition](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_definition) from links to headers or link definitions.
27+
2628
- [Rename](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_rename) of headers and links across all Markdown files in the workspace.
2729

28-
- [Go to definition](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_definition) from links to headers or link definitions.
30+
- Find all references to a file. Uses a custom `markdown/getReferencesToFileInWorkspace` message.
2931

30-
- (experimental) [Pull diagnostics (validation)](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_pullDiagnostics) for links.
32+
- [Code Actions](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_codeAction)
3133

34+
- Organize link definitions source action.
35+
- Extract link to definition refactoring.
36+
37+
- (experimental) Updating links when a file is moved / renamed. Uses a custom `markdown/getEditForFileRenames` message.
38+
39+
- (experimental) [Pull diagnostics (validation)](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_pullDiagnostics) for links.
3240

3341

3442
## Client requirements

extensions/markdown-language-features/server/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
"vscode-languageserver": "^8.0.2",
1414
"vscode-languageserver-textdocument": "^1.0.5",
1515
"vscode-languageserver-types": "^3.17.1",
16-
"vscode-markdown-languageservice": "^0.0.1",
16+
"vscode-markdown-languageservice": "^0.1.0-alpha.1",
17+
"vscode-nls": "^5.0.1",
1718
"vscode-uri": "^3.0.3"
1819
},
1920
"devDependencies": {

extensions/markdown-language-features/server/src/server.ts

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { CancellationToken, Connection, InitializeParams, InitializeResult, Note
77
import { TextDocument } from 'vscode-languageserver-textdocument';
88
import * as lsp from 'vscode-languageserver-types';
99
import * as md from 'vscode-markdown-languageservice';
10+
import * as nls from 'vscode-nls';
1011
import { URI } from 'vscode-uri';
1112
import { getLsConfiguration, LsConfiguration } from './config';
1213
import { ConfigurationManager } from './configuration';
@@ -16,8 +17,11 @@ import * as protocol from './protocol';
1617
import { IDisposable } from './util/dispose';
1718
import { VsCodeClientWorkspace } from './workspace';
1819

20+
const localize = nls.loadMessageBundle();
21+
1922
interface MdServerInitializationOptions extends LsConfiguration { }
2023

24+
const organizeLinkDefKind = 'source.organizeLinkDefinitions';
2125
export async function startServer(connection: Connection) {
2226
const documents = new TextDocuments(TextDocument);
2327
const notebooks = new NotebookDocuments(documents);
@@ -61,6 +65,7 @@ export async function startServer(connection: Connection) {
6165
interFileDependencies: true,
6266
workspaceDiagnostics: false,
6367
},
68+
codeActionProvider: { resolveProvider: true },
6469
completionProvider: { triggerCharacters: ['.', '/', '#'] },
6570
definitionProvider: true,
6671
documentLinkProvider: { resolveProvider: true },
@@ -97,7 +102,7 @@ export async function startServer(connection: Connection) {
97102
if (!document) {
98103
return [];
99104
}
100-
return mdLs!.getDocumentSymbols(document, token);
105+
return mdLs!.getDocumentSymbols(document, { includeLinkDefinitions: true }, token);
101106
});
102107

103108
connection.onFoldingRanges(async (params, token): Promise<lsp.FoldingRange[]> => {
@@ -152,6 +157,48 @@ export async function startServer(connection: Connection) {
152157
return mdLs!.getRenameEdit(document, params.position, params.newName, token);
153158
});
154159

160+
interface OrganizeLinkActionData {
161+
readonly uri: string;
162+
}
163+
164+
connection.onCodeAction(async (params, token) => {
165+
const document = documents.get(params.textDocument.uri);
166+
if (!document) {
167+
return undefined;
168+
}
169+
170+
if (params.context.only?.some(kind => kind === 'source' || kind.startsWith('source.'))) {
171+
const action: lsp.CodeAction = {
172+
title: localize('organizeLinkDefAction.title', "Organize link definitions"),
173+
kind: organizeLinkDefKind,
174+
data: <OrganizeLinkActionData>{ uri: document.uri }
175+
};
176+
return [action];
177+
}
178+
179+
return mdLs!.getCodeActions(document, params.range, params.context, token);
180+
});
181+
182+
connection.onCodeActionResolve(async (codeAction, token) => {
183+
if (codeAction.kind === organizeLinkDefKind) {
184+
const data = codeAction.data as OrganizeLinkActionData;
185+
const document = documents.get(data.uri);
186+
if (!document) {
187+
return codeAction;
188+
}
189+
190+
const edits = (await mdLs?.organizeLinkDefinitions(document, { removeUnused: true }, token)) || [];
191+
codeAction.edit = {
192+
changes: {
193+
[data.uri]: edits
194+
}
195+
};
196+
return codeAction;
197+
}
198+
199+
return codeAction;
200+
});
201+
155202
connection.onRequest(protocol.getReferencesToFileInWorkspace, (async (params: { uri: string }, token: CancellationToken) => {
156203
return mdLs!.getFileReferences(URI.parse(params.uri), token);
157204
}));

extensions/markdown-language-features/server/src/util/dispose.ts

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,6 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
export class MultiDisposeError extends Error {
7-
constructor(
8-
public readonly errors: any[]
9-
) {
10-
super(`Encountered errors while disposing of store. Errors: [${errors.join(', ')}]`);
11-
}
12-
}
13-
146
export function disposeAll(disposables: Iterable<IDisposable>) {
157
const errors: any[] = [];
168

@@ -25,7 +17,7 @@ export function disposeAll(disposables: Iterable<IDisposable>) {
2517
if (errors.length === 1) {
2618
throw errors[0];
2719
} else if (errors.length > 1) {
28-
throw new MultiDisposeError(errors);
20+
throw new AggregateError(errors, 'Encountered errors while disposing of store');
2921
}
3022
}
3123

@@ -60,21 +52,3 @@ export abstract class Disposable {
6052
}
6153
}
6254

63-
export class DisposableStore extends Disposable {
64-
private readonly items = new Set<IDisposable>();
65-
66-
public override dispose() {
67-
super.dispose();
68-
disposeAll(this.items);
69-
this.items.clear();
70-
}
71-
72-
public add<T extends IDisposable>(item: T): T {
73-
if (this.isDisposed) {
74-
console.warn('Adding to disposed store. Item will be leaked');
75-
}
76-
77-
this.items.add(item);
78-
return item;
79-
}
80-
}

0 commit comments

Comments
 (0)