Skip to content

Commit 831e530

Browse files
committed
Merge remote-tracking branch 'origin/main' into pr/r3m0t/181949
2 parents 761a1d3 + 4c45cff commit 831e530

File tree

113 files changed

+1896
-586
lines changed

Some content is hidden

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

113 files changed

+1896
-586
lines changed

.github/workflows/rich-navigation.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
name: "Rich Navigation Indexing"
22
on:
33
workflow_dispatch:
4-
pull_request:
54
push:
65
branches:
76
- main

.vscode/settings.json

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
},
1818
"search.exclude": {
1919
"**/node_modules": true,
20-
"**/bower_components": true,
2120
"cli/target/**": true,
2221
".build/**": true,
2322
"out/**": true,
@@ -34,6 +33,18 @@
3433
"src/vs/workbench/api/test/browser/extHostDocumentData.test.perf-data.ts": true,
3534
"src/vs/editor/test/node/diffing/fixtures/**": true,
3635
},
36+
"files.readonlyInclude": {
37+
"**/node_modules/**": true,
38+
"out/**": true,
39+
"out-build/**": true,
40+
"out-vscode/**": true,
41+
"out-vscode-reh/**": true,
42+
"extensions/**/dist/**": true,
43+
"extensions/**/out/**": true,
44+
"test/smoke/out/**": true,
45+
"test/automation/out/**": true,
46+
"test/integration/browser/out/**": true,
47+
},
3748
"lcov.path": [
3849
"./.build/coverage/lcov.info",
3950
"./.build/coverage-single/lcov.info"

build/lib/electron.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/lib/electron.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ function darwinBundleDocumentTypes(types: { [name: string]: string | string[] },
9191
}
9292

9393
export const config = {
94-
version: product.electronRepository ? '22.5.1' : util.getElectronVersion(),
94+
version: product.electronRepository ? '22.5.2' : util.getElectronVersion(),
9595
productAppName: product.nameLong,
9696
companyName: 'Microsoft Corporation',
9797
copyright: 'Copyright (C) 2023 Microsoft. All rights reserved',
@@ -212,7 +212,7 @@ function getElectron(arch: string): () => NodeJS.ReadWriteStream {
212212
}
213213

214214
async function main(arch = process.arch): Promise<void> {
215-
const version = product.electronRepository ? '22.5.1' : util.getElectronVersion();
215+
const version = product.electronRepository ? '22.5.2' : util.getElectronVersion();
216216
const electronPath = path.join(root, '.build', 'electron');
217217
const versionFile = path.join(electronPath, 'version');
218218
const isUpToDate = fs.existsSync(versionFile) && fs.readFileSync(versionFile, 'utf8') === `${version}`;

extensions/github/src/auth.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ export function getOctokit(): Promise<Octokit> {
5959

6060
let _octokitGraphql: Promise<graphql> | undefined;
6161

62-
export async function getOctokitGraphql(): Promise<graphql> {
62+
export async function getOctokitGraphql(silent = false): Promise<graphql> {
6363
if (!_octokitGraphql) {
6464
try {
65-
const session = await authentication.getSession('github', scopes, { createIfNone: false });
65+
const session = await authentication.getSession('github', scopes, { silent });
6666

6767
if (!session) {
6868
throw new AuthenticationError('No GitHub authentication session available.');

extensions/github/src/branchProtection.ts

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -114,25 +114,32 @@ export class GithubBranchProtectionProvider implements BranchProtectionProvider
114114
// Restore branch protection from global state
115115
this.branchProtection = this.globalState.get<BranchProtection[]>(this.globalStateKey, []);
116116

117-
repository.status().then(() => this.updateRepositoryBranchProtection());
117+
repository.status().then(() => {
118+
authentication.onDidChangeSessions(e => {
119+
if (e.provider.id === 'github') {
120+
this.updateRepositoryBranchProtection(true);
121+
}
122+
});
123+
this.updateRepositoryBranchProtection();
124+
});
118125
}
119126

120127
provideBranchProtection(): BranchProtection[] {
121128
return this.branchProtection;
122129
}
123130

124-
private async getRepositoryDetails(owner: string, repo: string): Promise<GitHubRepository> {
125-
const graphql = await getOctokitGraphql();
131+
private async getRepositoryDetails(owner: string, repo: string, silent: boolean): Promise<GitHubRepository> {
132+
const graphql = await getOctokitGraphql(silent);
126133
const { repository } = await graphql<{ repository: GitHubRepository }>(REPOSITORY_QUERY, { owner, repo });
127134

128135
return repository;
129136
}
130137

131-
private async getRepositoryRulesets(owner: string, repo: string): Promise<RepositoryRuleset[]> {
138+
private async getRepositoryRulesets(owner: string, repo: string, silent: boolean): Promise<RepositoryRuleset[]> {
132139
const rulesets: RepositoryRuleset[] = [];
133140

134141
let cursor: string | undefined = undefined;
135-
const graphql = await getOctokitGraphql();
142+
const graphql = await getOctokitGraphql(silent);
136143

137144
while (true) {
138145
const { repository } = await graphql<{ repository: GitHubRepository }>(REPOSITORY_RULESETS_QUERY, { owner, repo, cursor });
@@ -151,10 +158,10 @@ export class GithubBranchProtectionProvider implements BranchProtectionProvider
151158
return rulesets;
152159
}
153160

154-
private async updateRepositoryBranchProtection(): Promise<void> {
155-
try {
156-
const branchProtection: BranchProtection[] = [];
161+
private async updateRepositoryBranchProtection(silent = false): Promise<void> {
162+
const branchProtection: BranchProtection[] = [];
157163

164+
try {
158165
for (const remote of this.repository.state.remotes) {
159166
const repository = getRepositoryFromUrl(remote.pushUrl ?? remote.fetchUrl ?? '');
160167

@@ -164,7 +171,7 @@ export class GithubBranchProtectionProvider implements BranchProtectionProvider
164171

165172
// Repository details
166173
this.logger.trace(`Fetching repository details for "${repository.owner}/${repository.repo}".`);
167-
const repositoryDetails = await this.getRepositoryDetails(repository.owner, repository.repo);
174+
const repositoryDetails = await this.getRepositoryDetails(repository.owner, repository.repo, silent);
168175

169176
// Check repository write permission
170177
if (repositoryDetails.viewerPermission !== 'ADMIN' && repositoryDetails.viewerPermission !== 'MAINTAIN' && repositoryDetails.viewerPermission !== 'WRITE') {
@@ -174,7 +181,7 @@ export class GithubBranchProtectionProvider implements BranchProtectionProvider
174181

175182
// Get repository rulesets
176183
const branchProtectionRules: BranchProtectionRule[] = [];
177-
const repositoryRulesets = await this.getRepositoryRulesets(repository.owner, repository.repo);
184+
const repositoryRulesets = await this.getRepositoryRulesets(repository.owner, repository.repo, silent);
178185

179186
for (const ruleset of repositoryRulesets) {
180187
branchProtectionRules.push({
@@ -193,19 +200,17 @@ export class GithubBranchProtectionProvider implements BranchProtectionProvider
193200
await this.globalState.update(this.globalStateKey, branchProtection);
194201
this.logger.trace(`Branch protection for "${this.repository.rootUri.toString()}": ${JSON.stringify(branchProtection)}.`);
195202
} catch (err) {
203+
this.logger.warn(`Failed to update repository branch protection: ${err.message}`);
204+
196205
if (err instanceof AuthenticationError) {
197-
// Since there is no GitHub authentication session available we need to wait
198-
// until the user signs in with their GitHub account so that we can query the
199-
// repository rulesets
200-
const disposable = authentication.onDidChangeSessions(e => {
201-
if (e.provider.id === 'github') {
202-
disposable.dispose();
203-
this.updateRepositoryBranchProtection();
204-
}
205-
});
206-
}
206+
// A GitHub authentication session could be missing if the user has not yet
207+
// signed in with their GitHub account or they have signed out. In this case
208+
// we have to clear the branch protection information.
209+
this.branchProtection = branchProtection;
210+
this._onDidChangeBranchProtection.fire(this.repository.rootUri);
207211

208-
this.logger.warn(`Failed to update repository branch protection: ${err.message}`);
212+
await this.globalState.update(this.globalStateKey, undefined);
213+
}
209214
}
210215
}
211216

extensions/ipynb/src/notebookImagePaste.ts

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,16 @@ enum MimeType {
1818
uriList = 'text/uri-list',
1919
}
2020

21+
const imageMimeTypes: ReadonlySet<string> = new Set<string>([
22+
MimeType.bmp,
23+
MimeType.gif,
24+
MimeType.ico,
25+
MimeType.jpeg,
26+
MimeType.png,
27+
MimeType.tiff,
28+
MimeType.webp,
29+
]);
30+
2131
const imageExtToMime: ReadonlyMap<string, string> = new Map<string, string>([
2232
['.bmp', MimeType.bmp],
2333
['.gif', MimeType.gif],
@@ -35,6 +45,7 @@ function getImageMimeType(uri: vscode.Uri): string | undefined {
3545
return imageExtToMime.get(extname(uri.fsPath).toLowerCase());
3646
}
3747

48+
const id = 'insertAttachment';
3849
class CopyPasteEditProvider implements vscode.DocumentPasteEditProvider {
3950

4051
async provideDocumentPasteEdits(
@@ -43,7 +54,7 @@ class CopyPasteEditProvider implements vscode.DocumentPasteEditProvider {
4354
dataTransfer: vscode.DataTransfer,
4455
token: vscode.CancellationToken,
4556
): Promise<vscode.DocumentPasteEdit | undefined> {
46-
const enabled = vscode.workspace.getConfiguration('ipynb', document).get('pasteImagesAsAttachments.enabled', false);
57+
const enabled = vscode.workspace.getConfiguration('ipynb', document).get('pasteImagesAsAttachments.enabled', true);
4758
if (!enabled) {
4859
return;
4960
}
@@ -53,7 +64,7 @@ class CopyPasteEditProvider implements vscode.DocumentPasteEditProvider {
5364
return;
5465
}
5566

56-
const pasteEdit = new vscode.DocumentPasteEdit(insert.insertText, vscode.l10n.t('Insert Image as Attachment'));
67+
const pasteEdit = new vscode.DocumentPasteEdit(insert.insertText, id, vscode.l10n.t('Insert Image as Attachment'));
5768
pasteEdit.additionalEdit = insert.additionalEdit;
5869
return pasteEdit;
5970
}
@@ -73,6 +84,7 @@ class DropEditProvider implements vscode.DocumentDropEditProvider {
7384
}
7485

7586
const dropEdit = new vscode.DocumentDropEdit(insert.insertText);
87+
dropEdit.id = id;
7688
dropEdit.additionalEdit = insert.additionalEdit;
7789
dropEdit.label = vscode.l10n.t('Insert Image as Attachment');
7890
return dropEdit;
@@ -126,16 +138,21 @@ async function getDroppedImageData(
126138
): Promise<readonly ImageAttachmentData[]> {
127139

128140
// Prefer using image data in the clipboard
129-
// TODO: dataTransfer.get() limits to one image pasted. Should we support multiple?
130-
const pngDataItem = dataTransfer.get(MimeType.png);
131-
if (pngDataItem) {
132-
const fileItem = pngDataItem.asFile();
133-
if (!fileItem) {
134-
return [];
141+
const files = coalesce(await Promise.all(Array.from(dataTransfer, async ([mimeType, item]): Promise<ImageAttachmentData | undefined> => {
142+
if (!imageMimeTypes.has(mimeType)) {
143+
return;
144+
}
145+
146+
const file = item.asFile();
147+
if (!file) {
148+
return;
135149
}
136150

137-
const data = await fileItem.data();
138-
return [{ fileName: fileItem.name, mimeType: MimeType.png, data }];
151+
const data = await file.data();
152+
return { fileName: file.name, mimeType, data };
153+
})));
154+
if (files.length) {
155+
return files;
139156
}
140157

141158
// Then fallback to image files in the uri-list
@@ -287,7 +304,6 @@ export function notebookImagePasteSetup(): vscode.Disposable {
287304
],
288305
}),
289306
vscode.languages.registerDocumentDropEditProvider(JUPYTER_NOTEBOOK_MARKDOWN_SELECTOR, new DropEditProvider(), {
290-
id: 'imageAttachment',
291307
dropMimeTypes: [
292308
...Object.values(imageExtToMime),
293309
MimeType.uriList,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"@vscode/l10n": "^0.0.13",
1616
"jsonc-parser": "^3.2.0",
1717
"request-light": "^0.7.0",
18-
"vscode-json-languageservice": "^5.3.4",
18+
"vscode-json-languageservice": "^5.3.5",
1919
"vscode-languageserver": "^8.2.0-next.0",
2020
"vscode-uri": "^3.0.7"
2121
},

extensions/json-language-features/server/yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ request-light@^0.7.0:
2727
resolved "https://registry.yarnpkg.com/request-light/-/request-light-0.7.0.tgz#885628bb2f8040c26401ebf258ec51c4ae98ac2a"
2828
integrity sha512-lMbBMrDoxgsyO+yB3sDcrDuX85yYt7sS8BfQd11jtbW/z5ZWgLZRcEGLsLoYw7I0WSUGQBs8CC8ScIxkTX1+6Q==
2929

30-
vscode-json-languageservice@^5.3.4:
31-
version "5.3.4"
32-
resolved "https://registry.yarnpkg.com/vscode-json-languageservice/-/vscode-json-languageservice-5.3.4.tgz#a37c8443ab458e0141d83bb080ce9c363b0fed8b"
33-
integrity sha512-GSsHCrv1XBXJDI5DrCi8adEjv+yqZi21TsWs1pJo0cIEmiSVnf3V+v/kiVt0DHvSm9MuRYNjvMfDTW8m5Zpi8Q==
30+
vscode-json-languageservice@^5.3.5:
31+
version "5.3.5"
32+
resolved "https://registry.yarnpkg.com/vscode-json-languageservice/-/vscode-json-languageservice-5.3.5.tgz#20acd827e13ea4bdeb9976df84ec2bfbb2452c73"
33+
integrity sha512-DasT+bKtpaS2rTPEB4VMROnvO1WES2KD8RZZxXbumnk9sk5wco10VdB6sJgTlsKQN14tHQLZDXuHnSoSAlE8LQ==
3434
dependencies:
3535
"@vscode/l10n" "^0.0.13"
3636
jsonc-parser "^3.2.0"

extensions/markdown-language-features/src/languageFeatures/copyFiles/copyFiles.ts

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,42 @@ import * as vscode from 'vscode';
88
import { Utils } from 'vscode-uri';
99
import { getParentDocumentUri } from './dropIntoEditor';
1010

11+
export class NewFilePathGenerator {
1112

12-
export async function getNewFileName(document: vscode.TextDocument, file: vscode.DataTransferFile): Promise<vscode.Uri> {
13-
const desiredPath = getDesiredNewFilePath(document, file);
14-
15-
const root = Utils.dirname(desiredPath);
16-
const ext = path.extname(file.name);
17-
const baseName = path.basename(file.name, ext);
18-
for (let i = 0; ; ++i) {
19-
const name = i === 0 ? baseName : `${baseName}-${i}`;
20-
const uri = vscode.Uri.joinPath(root, `${name}${ext}`);
21-
try {
22-
await vscode.workspace.fs.stat(uri);
23-
} catch {
24-
// Does not exist
25-
return uri;
13+
private readonly _usedPaths = new Set<string>();
14+
15+
async getNewFilePath(document: vscode.TextDocument, file: vscode.DataTransferFile, token: vscode.CancellationToken): Promise<vscode.Uri | undefined> {
16+
const desiredPath = getDesiredNewFilePath(document, file);
17+
18+
const root = Utils.dirname(desiredPath);
19+
const ext = path.extname(file.name);
20+
const baseName = path.basename(file.name, ext);
21+
for (let i = 0; ; ++i) {
22+
if (token.isCancellationRequested) {
23+
return undefined;
24+
}
25+
26+
const name = i === 0 ? baseName : `${baseName}-${i}`;
27+
const uri = vscode.Uri.joinPath(root, name + ext);
28+
if (this._wasPathAlreadyUsed(uri)) {
29+
continue;
30+
}
31+
32+
try {
33+
await vscode.workspace.fs.stat(uri);
34+
} catch {
35+
if (!this._wasPathAlreadyUsed(uri)) {
36+
// Does not exist
37+
this._usedPaths.add(uri.toString());
38+
return uri;
39+
}
40+
}
2641
}
2742
}
43+
44+
private _wasPathAlreadyUsed(uri: vscode.Uri) {
45+
return this._usedPaths.has(uri.toString());
46+
}
2847
}
2948

3049
function getDesiredNewFilePath(document: vscode.TextDocument, file: vscode.DataTransferFile): vscode.Uri {

0 commit comments

Comments
 (0)