Skip to content

Commit 3784c14

Browse files
committed
Merge branch 'main' into sandy081/profiles-adopt-web-scanner
2 parents 60afef7 + c5a9280 commit 3784c14

File tree

97 files changed

+1062
-2098
lines changed

Some content is hidden

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

97 files changed

+1062
-2098
lines changed

.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:\"June 2022\""
10+
"value": "$repo=repo:microsoft/vscode\n$milestone=milestone:\"July 2022\""
1111
},
1212
{
1313
"kind": 1,

build/.cachesalt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2022-06-10T10:20:54.664Z
1+
2022-07-07T13:42:16.836Z

build/lib/policies.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,8 +452,12 @@ async function getTranslations() {
452452
}
453453
const version = await getLatestStableVersion(updateUrl);
454454
const languageIds = Object.keys(Languages);
455-
return await Promise.all(languageIds.map(languageId => getNLS(resourceUrlTemplate, languageId, version)
455+
const result = await Promise.allSettled(languageIds.map(languageId => getNLS(resourceUrlTemplate, languageId, version)
456+
.catch(err => { console.warn(`Missing translation: ${languageId}@${version}`); return Promise.reject(err); })
456457
.then(languageTranslations => ({ languageId, languageTranslations }))));
458+
return result
459+
.filter((r) => r.status === 'fulfilled')
460+
.map(r => r.value);
457461
}
458462
async function main() {
459463
const [policies, translations] = await Promise.all([parsePolicies(), getTranslations()]);

build/lib/policies.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,8 @@ const Languages = {
585585
};
586586

587587
type LanguageTranslations = { [moduleName: string]: { [nlsKey: string]: string } };
588-
type Translations = { languageId: string; languageTranslations: LanguageTranslations }[];
588+
type Translation = { languageId: string; languageTranslations: LanguageTranslations };
589+
type Translations = Translation[];
589590

590591
async function getLatestStableVersion(updateUrl: string) {
591592
const res = await fetch(`${updateUrl}/api/update/darwin/stable/latest`);
@@ -643,10 +644,15 @@ async function getTranslations(): Promise<Translations> {
643644
const version = await getLatestStableVersion(updateUrl);
644645
const languageIds = Object.keys(Languages);
645646

646-
return await Promise.all(languageIds.map(
647+
const result = await Promise.allSettled(languageIds.map(
647648
languageId => getNLS(resourceUrlTemplate, languageId, version)
649+
.catch(err => { console.warn(`Missing translation: ${languageId}@${version}`); return Promise.reject(err); })
648650
.then(languageTranslations => ({ languageId, languageTranslations }))
649651
));
652+
653+
return result
654+
.filter((r): r is PromiseFulfilledResult<Translation> => r.status === 'fulfilled')
655+
.map(r => r.value);
650656
}
651657

652658
async function main() {

extensions/git/src/actionButton.ts

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

6-
import { Disposable, Event, EventEmitter, SourceControlActionButton, Uri, workspace } from 'vscode';
76
import * as nls from 'vscode-nls';
7+
import { Disposable, Event, EventEmitter, SourceControlActionButton, Uri, workspace } from 'vscode';
8+
import { Branch, Status } from './api/git';
89
import { Repository, Operation } from './repository';
910
import { dispose } from './util';
10-
import { Branch } from './api/git';
1111

1212
const localize = nls.loadMessageBundle();
1313

@@ -16,7 +16,7 @@ interface ActionButtonState {
1616
readonly isCommitInProgress: boolean;
1717
readonly isMergeInProgress: boolean;
1818
readonly isSyncInProgress: boolean;
19-
readonly repositoryHasChanges: boolean;
19+
readonly repositoryHasChangesToCommit: boolean;
2020
}
2121

2222
export class ActionButtonCommand {
@@ -40,19 +40,24 @@ export class ActionButtonCommand {
4040
isCommitInProgress: false,
4141
isMergeInProgress: false,
4242
isSyncInProgress: false,
43-
repositoryHasChanges: false
43+
repositoryHasChangesToCommit: false
4444
};
4545

4646
repository.onDidRunGitStatus(this.onDidRunGitStatus, this, this.disposables);
4747
repository.onDidChangeOperations(this.onDidChangeOperations, this, this.disposables);
4848

4949
const root = Uri.file(repository.root);
5050
this.disposables.push(workspace.onDidChangeConfiguration(e => {
51+
if (e.affectsConfiguration('git.enableSmartCommit', root) ||
52+
e.affectsConfiguration('git.smartCommitChanges', root) ||
53+
e.affectsConfiguration('git.suggestSmartCommit', root)) {
54+
this.onDidChangeSmartCommitSettings();
55+
}
56+
5157
if (e.affectsConfiguration('git.branchProtection', root) ||
5258
e.affectsConfiguration('git.branchProtectionPrompt', root) ||
5359
e.affectsConfiguration('git.postCommitCommand', root) ||
54-
e.affectsConfiguration('git.showActionButton', root)
55-
) {
60+
e.affectsConfiguration('git.showActionButton', root)) {
5661
this._onDidChange.fire();
5762
}
5863
}));
@@ -63,7 +68,7 @@ export class ActionButtonCommand {
6368

6469
let actionButton: SourceControlActionButton | undefined;
6570

66-
if (this.state.repositoryHasChanges) {
71+
if (this.state.repositoryHasChangesToCommit) {
6772
// Commit Changes (enabled)
6873
actionButton = this.getCommitActionButton();
6974
}
@@ -160,7 +165,7 @@ export class ActionButtonCommand {
160165
},
161166
]
162167
],
163-
enabled: this.state.repositoryHasChanges && !this.state.isCommitInProgress && !this.state.isMergeInProgress
168+
enabled: this.state.repositoryHasChangesToCommit && !this.state.isCommitInProgress && !this.state.isMergeInProgress
164169
};
165170
}
166171

@@ -223,19 +228,47 @@ export class ActionButtonCommand {
223228
this.state = { ...this.state, isCommitInProgress, isSyncInProgress };
224229
}
225230

231+
private onDidChangeSmartCommitSettings(): void {
232+
this.state = {
233+
...this.state,
234+
repositoryHasChangesToCommit: this.repositoryHasChangesToCommit()
235+
};
236+
}
237+
226238
private onDidRunGitStatus(): void {
227239
this.state = {
228240
...this.state,
229241
HEAD: this.repository.HEAD,
230-
isMergeInProgress:
231-
this.repository.mergeGroup.resourceStates.length !== 0,
232-
repositoryHasChanges:
233-
this.repository.indexGroup.resourceStates.length !== 0 ||
234-
this.repository.untrackedGroup.resourceStates.length !== 0 ||
235-
this.repository.workingTreeGroup.resourceStates.length !== 0
242+
isMergeInProgress: this.repository.mergeGroup.resourceStates.length !== 0,
243+
repositoryHasChangesToCommit: this.repositoryHasChangesToCommit()
236244
};
237245
}
238246

247+
private repositoryHasChangesToCommit(): boolean {
248+
const config = workspace.getConfiguration('git', Uri.file(this.repository.root));
249+
const enableSmartCommit = config.get<boolean>('enableSmartCommit') === true;
250+
const suggestSmartCommit = config.get<boolean>('suggestSmartCommit') === true;
251+
const smartCommitChanges = config.get<'all' | 'tracked'>('smartCommitChanges', 'all');
252+
253+
const resources = [...this.repository.indexGroup.resourceStates];
254+
255+
if (
256+
// Smart commit enabled (all)
257+
(enableSmartCommit && smartCommitChanges === 'all') ||
258+
// Smart commit disabled, smart suggestion enabled
259+
(!enableSmartCommit && suggestSmartCommit)
260+
) {
261+
resources.push(...this.repository.workingTreeGroup.resourceStates);
262+
}
263+
264+
// Smart commit enabled (tracked only)
265+
if (enableSmartCommit && smartCommitChanges === 'tracked') {
266+
resources.push(...this.repository.workingTreeGroup.resourceStates.filter(r => r.type !== Status.UNTRACKED));
267+
}
268+
269+
return resources.length !== 0;
270+
}
271+
239272
dispose(): void {
240273
this.disposables = dispose(this.disposables);
241274
}

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

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,7 @@
55

66
import { ILogger } from 'vscode-markdown-languageservice';
77

8-
class ConsoleLogger implements ILogger {
9-
10-
public verbose(title: string, message: string, data?: any): void {
11-
this.appendLine(`[Verbose ${ConsoleLogger.now()}] ${title}: ${message}`);
12-
if (data) {
13-
this.appendLine(ConsoleLogger.data2String(data));
14-
}
15-
}
8+
export class LogFunctionLogger implements ILogger {
169

1710
private static now(): string {
1811
const now = new Date();
@@ -21,10 +14,6 @@ class ConsoleLogger implements ILogger {
2114
+ ':' + String(now.getUTCSeconds()).padStart(2, '0') + '.' + String(now.getMilliseconds()).padStart(3, '0');
2215
}
2316

24-
private appendLine(value: string): void {
25-
console.log(value);
26-
}
27-
2817
private static data2String(data: any): string {
2918
if (data instanceof Error) {
3019
if (typeof data.stack === 'string') {
@@ -37,6 +26,21 @@ class ConsoleLogger implements ILogger {
3726
}
3827
return JSON.stringify(data, undefined, 2);
3928
}
29+
30+
constructor(
31+
private readonly _logFn: typeof console.log
32+
) { }
33+
34+
public verbose(title: string, message: string, data?: any): void {
35+
this.appendLine(`[Verbose ${LogFunctionLogger.now()}] ${title}: ${message}`);
36+
if (data) {
37+
this.appendLine(LogFunctionLogger.data2String(data));
38+
}
39+
}
40+
41+
private appendLine(value: string): void {
42+
this._logFn(value);
43+
}
4044
}
4145

42-
export const consoleLogger = new ConsoleLogger();
46+
export const consoleLogger = new LogFunctionLogger(console.log);

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

Lines changed: 33 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55

66
import { Connection, Emitter, Event, InitializeParams, InitializeResult, RequestType, TextDocuments } from 'vscode-languageserver';
77
import { TextDocument } from 'vscode-languageserver-textdocument';
8-
import { DocumentSymbol, Position, Range } from 'vscode-languageserver-types';
8+
import * as lsp from 'vscode-languageserver-types';
99
import * as md from 'vscode-markdown-languageservice';
1010
import { URI } from 'vscode-uri';
11-
import { consoleLogger } from './logging';
11+
import { LogFunctionLogger } from './logging';
1212

1313

1414
const parseRequestType: RequestType<{ uri: string }, md.Token[], any> = new RequestType('markdown/parse');
@@ -31,8 +31,7 @@ class TextDocumentToITextDocumentAdapter implements md.ITextDocument {
3131
}
3232

3333
positionAt(offset: number): md.IPosition {
34-
const pos = this._doc.positionAt(offset);
35-
return md.makePosition(pos.line, pos.character);
34+
return this._doc.positionAt(offset);
3635
}
3736
}
3837

@@ -44,6 +43,8 @@ export function startServer(connection: Connection) {
4443
return {
4544
capabilities: {
4645
documentSymbolProvider: true,
46+
foldingRangeProvider: true,
47+
selectionRangeProvider: true,
4748
}
4849
};
4950
});
@@ -85,48 +86,44 @@ export function startServer(connection: Connection) {
8586
}
8687
};
8788

88-
const provider = md.createLanguageService(workspace, parser, consoleLogger);
89+
const logger = new LogFunctionLogger(connection.console.log.bind(connection.console));
90+
const provider = md.createLanguageService(workspace, parser, logger);
8991

90-
connection.onDocumentSymbol(async (documentSymbolParams, _token): Promise<DocumentSymbol[]> => {
92+
connection.onDocumentSymbol(async (params, token): Promise<lsp.DocumentSymbol[]> => {
9193
try {
92-
const document = documents.get(documentSymbolParams.textDocument.uri) as TextDocument | undefined;
94+
const document = documents.get(params.textDocument.uri);
9395
if (document) {
94-
const response = await provider.provideDocumentSymbols(new TextDocumentToITextDocumentAdapter(document));
95-
// TODO: only required because extra methods returned on positions/ranges
96-
return response.map(symbol => convertDocumentSymbol(symbol));
96+
return await provider.provideDocumentSymbols(new TextDocumentToITextDocumentAdapter(document), token);
9797
}
9898
} catch (e) {
9999
console.error(e.stack);
100100
}
101101
return [];
102102
});
103103

104-
connection.listen();
105-
}
106-
107-
108-
function convertDocumentSymbol(sym: DocumentSymbol): DocumentSymbol {
109-
return {
110-
kind: sym.kind,
111-
name: sym.name,
112-
range: convertRange(sym.range),
113-
selectionRange: convertRange(sym.selectionRange),
114-
children: sym.children?.map(convertDocumentSymbol),
115-
detail: sym.detail,
116-
tags: sym.tags,
117-
};
118-
}
104+
connection.onFoldingRanges(async (params, token): Promise<lsp.FoldingRange[]> => {
105+
try {
106+
const document = documents.get(params.textDocument.uri);
107+
if (document) {
108+
return await provider.provideFoldingRanges(new TextDocumentToITextDocumentAdapter(document), token);
109+
}
110+
} catch (e) {
111+
console.error(e.stack);
112+
}
113+
return [];
114+
});
119115

120-
function convertRange(range: Range): Range {
121-
return {
122-
start: convertPosition(range.start),
123-
end: convertPosition(range.end),
124-
};
125-
}
116+
connection.onSelectionRanges(async (params, token): Promise<lsp.SelectionRange[] | undefined> => {
117+
try {
118+
const document = documents.get(params.textDocument.uri);
119+
if (document) {
120+
return await provider.provideSelectionRanges(new TextDocumentToITextDocumentAdapter(document), params.positions, token);
121+
}
122+
} catch (e) {
123+
console.error(e.stack);
124+
}
125+
return [];
126+
});
126127

127-
function convertPosition(start: Position): Position {
128-
return {
129-
character: start.character,
130-
line: start.line,
131-
};
128+
connection.listen();
132129
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ vscode-languageserver@^8.0.2-next.4:
4343
vscode-languageserver-protocol "3.17.2-next.6"
4444

4545
vscode-markdown-languageservice@mjbvz/vscode-markdown-languageservice:
46-
version "1.0.0"
47-
resolved "https://codeload.github.com/mjbvz/vscode-markdown-languageservice/tar.gz/e410b5df64659fbc186cf0a7a7c882c451e07b8b"
46+
version "0.0.0-alpha.1"
47+
resolved "https://codeload.github.com/mjbvz/vscode-markdown-languageservice/tar.gz/e1a0e00bf6a99cc543da64964cc0995537647d15"
4848
dependencies:
4949
vscode-languageserver-types "^3.17.1"
5050
vscode-uri "^3.0.3"

extensions/markdown-language-features/src/extension.node.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export function activate(context: vscode.ExtensionContext) {
3030
}
3131

3232
async function startServer(context: vscode.ExtensionContext, workspace: IMdWorkspace, parser: IMdParser): Promise<void> {
33-
const clientMain = vscode.extensions.getExtension('vscode.css-language-features')?.packageJSON?.main || '';
33+
const clientMain = vscode.extensions.getExtension('vscode.markdown-language-features')?.packageJSON?.main || '';
3434

3535
const serverMain = `./server/${clientMain.indexOf('/dist/') !== -1 ? 'dist' : 'out'}/node/main`;
3636
const serverModule = context.asAbsolutePath(serverMain);

extensions/markdown-language-features/src/extension.shared.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,9 @@ import { MdLinkProvider, registerDocumentLinkSupport } from './languageFeatures/
1313
import { MdDocumentSymbolProvider } from './languageFeatures/documentSymbols';
1414
import { registerDropIntoEditorSupport } from './languageFeatures/dropIntoEditor';
1515
import { registerFindFileReferenceSupport } from './languageFeatures/fileReferences';
16-
import { registerFoldingSupport } from './languageFeatures/folding';
1716
import { registerPathCompletionSupport } from './languageFeatures/pathCompletions';
1817
import { MdReferencesProvider, registerReferencesSupport } from './languageFeatures/references';
1918
import { registerRenameSupport } from './languageFeatures/rename';
20-
import { registerSmartSelectSupport } from './languageFeatures/smartSelect';
2119
import { registerWorkspaceSymbolSupport } from './languageFeatures/workspaceSymbols';
2220
import { ILogger } from './logging';
2321
import { IMdParser, MarkdownItEngine, MdParsingProvider } from './markdownEngine';
@@ -81,12 +79,10 @@ function registerMarkdownLanguageFeatures(
8179
registerDocumentLinkSupport(selector, linkProvider),
8280
registerDropIntoEditorSupport(selector),
8381
registerFindFileReferenceSupport(commandManager, referencesProvider),
84-
registerFoldingSupport(selector, parser, tocProvider),
8582
registerPasteSupport(selector),
8683
registerPathCompletionSupport(selector, workspace, parser, linkProvider),
8784
registerReferencesSupport(selector, referencesProvider),
8885
registerRenameSupport(selector, workspace, referencesProvider, parser.slugifier),
89-
registerSmartSelectSupport(selector, parser, tocProvider),
9086
registerWorkspaceSymbolSupport(workspace, symbolProvider),
9187
);
9288
}

0 commit comments

Comments
 (0)