Skip to content

Commit 4422cea

Browse files
authored
Merge branch 'main' into extensionCodeblockLangFix
2 parents 5c0a53d + 330ab6c commit 4422cea

File tree

87 files changed

+4109
-321
lines changed

Some content is hidden

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

87 files changed

+4109
-321
lines changed

extensions/git/src/repository.ts

+24-1
Original file line numberDiff line numberDiff line change
@@ -1031,11 +1031,34 @@ export class Repository implements Disposable {
10311031

10321032
// Ignore path that is not inside the current repository
10331033
if (this.repositoryResolver.getRepository(uri) !== this) {
1034+
this.logger.trace(`[Repository][provideOriginalResource] Resource is not part of the repository: ${uri.toString()}`);
10341035
return undefined;
10351036
}
10361037

10371038
// Ignore path that is inside a merge group
1038-
if (this.mergeGroup.resourceStates.some(r => r.resourceUri.path === uri.path)) {
1039+
if (this.mergeGroup.resourceStates.some(r => pathEquals(r.resourceUri.fsPath, uri.fsPath))) {
1040+
this.logger.trace(`[Repository][provideOriginalResource] Resource is part of a merge group: ${uri.toString()}`);
1041+
return undefined;
1042+
}
1043+
1044+
// Ignore path that is untracked
1045+
if (this.untrackedGroup.resourceStates.some(r => pathEquals(r.resourceUri.path, uri.path)) ||
1046+
this.workingTreeGroup.resourceStates.some(r => pathEquals(r.resourceUri.path, uri.path) && r.type === Status.UNTRACKED)) {
1047+
this.logger.trace(`[Repository][provideOriginalResource] Resource is untracked: ${uri.toString()}`);
1048+
return undefined;
1049+
}
1050+
1051+
const activeTabInput = window.tabGroups.activeTabGroup.activeTab?.input;
1052+
1053+
// Ignore file that is on the right-hand side of a diff editor
1054+
if (activeTabInput instanceof TabInputTextDiff && pathEquals(activeTabInput.modified.fsPath, uri.fsPath)) {
1055+
this.logger.trace(`[Repository][provideOriginalResource] Resource is on the right-hand side of a diff editor: ${uri.toString()}`);
1056+
return undefined;
1057+
}
1058+
1059+
// Ignore file that is on the right -hand side of a multi-file diff editor
1060+
if (activeTabInput instanceof TabInputTextMultiDiff && activeTabInput.textDiffs.some(diff => pathEquals(diff.modified.fsPath, uri.fsPath))) {
1061+
this.logger.trace(`[Repository][provideOriginalResource] Resource is on the right-hand side of a multi-file diff editor: ${uri.toString()}`);
10391062
return undefined;
10401063
}
10411064

extensions/json-language-features/server/src/node/jsonServerMain.ts

+13-12
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import { formatError } from '../utils/runner';
88
import { RequestService, RuntimeEnvironment, startServer } from '../jsonServer';
99

1010
import { xhr, XHRResponse, configure as configureHttpRequests, getErrorStatusDescription } from 'request-light';
11-
import { URI as Uri } from 'vscode-uri';
12-
import * as fs from 'fs';
11+
import { promises as fs } from 'fs';
12+
import * as l10n from '@vscode/l10n';
1313

1414
// Create a connection for the server.
1515
const connection: Connection = createConnection();
@@ -36,16 +36,17 @@ function getHTTPRequestService(): RequestService {
3636

3737
function getFileRequestService(): RequestService {
3838
return {
39-
getContent(location: string, encoding?: BufferEncoding) {
40-
return new Promise((c, e) => {
41-
const uri = Uri.parse(location);
42-
fs.readFile(uri.fsPath, encoding, (err, buf) => {
43-
if (err) {
44-
return e(err);
45-
}
46-
c(buf.toString());
47-
});
48-
});
39+
async getContent(location: string, encoding?: BufferEncoding) {
40+
try {
41+
return (await fs.readFile(location, encoding)).toString();
42+
} catch (e) {
43+
if (e.code === 'ENOENT') {
44+
throw new Error(l10n.t('Schema not found: {0}', location));
45+
} else if (e.code === 'EISDIR') {
46+
throw new Error(l10n.t('{0} is a directory, not a file', location));
47+
}
48+
throw e;
49+
}
4950
}
5051
};
5152
}

extensions/terminal-suggest/src/terminalSuggestMain.ts

+32-27
Original file line numberDiff line numberDiff line change
@@ -25,40 +25,44 @@ function getBuiltinCommands(shell: string): string[] | undefined {
2525
}
2626
const filter = (cmd: string) => cmd;
2727
const options: ExecOptionsWithStringEncoding = { encoding: 'utf-8', shell };
28+
let commands: string[] | undefined;
2829
switch (shellType) {
2930
case 'bash': {
3031
const bashOutput = execSync('compgen -b', options);
31-
const bashResult = bashOutput.split('\n').filter(filter);
32-
if (bashResult.length) {
33-
cachedBuiltinCommands?.set(shellType, bashResult);
34-
return bashResult;
35-
}
32+
commands = bashOutput.split('\n').filter(filter);
3633
break;
3734
}
3835
case 'zsh': {
3936
const zshOutput = execSync('printf "%s\\n" ${(k)builtins}', options);
40-
const zshResult = zshOutput.split('\n').filter(filter);
41-
if (zshResult.length) {
42-
cachedBuiltinCommands?.set(shellType, zshResult);
43-
return zshResult;
44-
}
37+
commands = zshOutput.split('\n').filter(filter);
38+
break;
4539
}
4640
case 'fish': {
4741
// TODO: ghost text in the command line prevents
4842
// completions from working ATM for fish
4943
const fishOutput = execSync('functions -n', options);
50-
const fishResult = fishOutput.split(', ').filter(filter);
51-
if (fishResult.length) {
52-
cachedBuiltinCommands?.set(shellType, fishResult);
53-
return fishResult;
54-
}
44+
commands = fishOutput.split(', ').filter(filter);
5545
break;
5646
}
5747
case 'pwsh': {
58-
// native pwsh completions are builtin to vscode
59-
return [];
48+
const output = execSync('Get-Command | Select-Object Name, CommandType, DisplayName | ConvertTo-Json', options);
49+
let json: any;
50+
try {
51+
json = JSON.parse(output);
52+
} catch (e) {
53+
console.error('Error parsing pwsh output:', e);
54+
return [];
55+
}
56+
// TODO: Return a rich type with kind and detail
57+
commands = (json as any[]).map(e => e.Name);
58+
break;
6059
}
6160
}
61+
// TODO: Cache failure results too
62+
if (commands?.length) {
63+
cachedBuiltinCommands?.set(shellType, commands);
64+
return commands;
65+
}
6266
return;
6367

6468
} catch (error) {
@@ -324,16 +328,6 @@ export async function getCompletionItemsFromSpecs(specs: Fig.Spec[], terminalCon
324328
}
325329
}
326330
}
327-
const shouldShowCommands = !terminalContext.commandLine.substring(0, terminalContext.cursorPosition).trimStart().includes(' ');
328-
if (shouldShowCommands && (filesRequested === foldersRequested)) {
329-
// Include builitin/available commands in the results
330-
const labels = new Set(items.map(i => i.label));
331-
for (const command of availableCommands) {
332-
if (!labels.has(command)) {
333-
items.push(createCompletionItem(terminalContext.cursorPosition, prefix, command));
334-
}
335-
}
336-
}
337331

338332
const shouldShowResourceCompletions =
339333
(
@@ -347,6 +341,17 @@ export async function getCompletionItemsFromSpecs(specs: Fig.Spec[], terminalCon
347341
// and neither files nor folders are going to be requested (for a specific spec's argument)
348342
&& (!filesRequested && !foldersRequested);
349343

344+
const shouldShowCommands = !terminalContext.commandLine.substring(0, terminalContext.cursorPosition).trimStart().includes(' ');
345+
if (shouldShowCommands && (filesRequested === foldersRequested)) {
346+
// Include builitin/available commands in the results
347+
const labels = new Set(items.map(i => i.label));
348+
for (const command of availableCommands) {
349+
if (!labels.has(command)) {
350+
items.push(createCompletionItem(terminalContext.cursorPosition, prefix, command));
351+
}
352+
}
353+
}
354+
350355
if (shouldShowResourceCompletions) {
351356
filesRequested = true;
352357
foldersRequested = true;

extensions/theme-defaults/themes/hc_light.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,8 @@
569569
}
570570
],
571571
"colors": {
572-
"actionBar.toggledBackground": "#dddddd"
572+
"actionBar.toggledBackground": "#dddddd",
573+
"statusBarItem.remoteBackground": "#FFFFFF",
574+
"statusBarItem.remoteForeground": "#000000"
573575
}
574576
}

extensions/theme-defaults/themes/light_modern.json

+2
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@
104104
"statusBar.background": "#F8F8F8",
105105
"statusBar.foreground": "#3B3B3B",
106106
"statusBar.border": "#E5E5E5",
107+
"statusBarItem.hoverBackground": "#B8B8B850",
108+
"statusBarItem.compactHoverBackground": "#CCCCCC",
107109
"statusBar.debuggingBackground": "#FD716C",
108110
"statusBar.debuggingForeground": "#000000",
109111
"statusBar.focusBorder": "#005FB8",

extensions/typescript-language-features/src/typescriptServiceClient.ts

+18-30
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { Schemes } from './configuration/schemes';
1212
import { IExperimentationTelemetryReporter } from './experimentTelemetryReporter';
1313
import { DiagnosticKind, DiagnosticsManager } from './languageFeatures/diagnostics';
1414
import { Logger } from './logging/logger';
15-
import { TelemetryProperties, TelemetryReporter, VSCodeTelemetryReporter } from './logging/telemetry';
15+
import { TelemetryReporter, VSCodeTelemetryReporter } from './logging/telemetry';
1616
import Tracer from './logging/tracer';
1717
import { ProjectType, inferredProjectCompilerOptions } from './tsconfig';
1818
import { API } from './tsServer/api';
@@ -319,7 +319,7 @@ export default class TypeScriptServiceClient extends Disposable implements IType
319319

320320
public restartTsServer(fromUserAction = false): void {
321321
if (this.serverState.type === ServerState.Type.Running) {
322-
this.info('Killing TS Server');
322+
this.logger.info('Killing TS Server');
323323
this.isRestarting = true;
324324
this.serverState.server.kill();
325325
}
@@ -372,18 +372,6 @@ export default class TypeScriptServiceClient extends Disposable implements IType
372372
return this._onReady!.promise.then(f);
373373
}
374374

375-
private info(message: string, ...data: any[]): void {
376-
this.logger.info(message, ...data);
377-
}
378-
379-
private error(message: string, ...data: any[]): void {
380-
this.logger.error(message, ...data);
381-
}
382-
383-
private logTelemetry(eventName: string, properties?: TelemetryProperties) {
384-
this.telemetryReporter.logTelemetry(eventName, properties);
385-
}
386-
387375
public ensureServiceStarted() {
388376
if (this.serverState.type !== ServerState.Type.Running) {
389377
this.startService();
@@ -392,15 +380,15 @@ export default class TypeScriptServiceClient extends Disposable implements IType
392380

393381
private token: number = 0;
394382
private startService(resendModels: boolean = false): ServerState.State {
395-
this.info(`Starting TS Server`);
383+
this.logger.info(`Starting TS Server`);
396384

397385
if (this.isDisposed) {
398-
this.info(`Not starting server: disposed`);
386+
this.logger.info(`Not starting server: disposed`);
399387
return ServerState.None;
400388
}
401389

402390
if (this.hasServerFatallyCrashedTooManyTimes) {
403-
this.info(`Not starting server: too many crashes`);
391+
this.logger.info(`Not starting server: too many crashes`);
404392
return ServerState.None;
405393
}
406394

@@ -412,10 +400,10 @@ export default class TypeScriptServiceClient extends Disposable implements IType
412400
version = this._versionManager.currentVersion;
413401
}
414402

415-
this.info(`Using tsserver from: ${version.path}`);
403+
this.logger.info(`Using tsserver from: ${version.path}`);
416404
const nodePath = this._nodeVersionManager.currentVersion;
417405
if (nodePath) {
418-
this.info(`Using Node installation from ${nodePath} to run TS Server`);
406+
this.logger.info(`Using Node installation from ${nodePath} to run TS Server`);
419407
}
420408

421409
this.resetWatchers();
@@ -451,7 +439,7 @@ export default class TypeScriptServiceClient extends Disposable implements IType
451439
"typeScriptVersionSource": { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
452440
}
453441
*/
454-
this.logTelemetry('tsserver.spawned', {
442+
this.telemetryReporter.logTelemetry('tsserver.spawned', {
455443
...typeScriptServerEnvCommonProperties,
456444
localTypeScriptVersion: this.versionProvider.localVersion ? this.versionProvider.localVersion.displayName : '',
457445
typeScriptVersionSource: version.source,
@@ -468,9 +456,9 @@ export default class TypeScriptServiceClient extends Disposable implements IType
468456
}
469457

470458
this.serverState = new ServerState.Errored(err, handle.tsServerLog);
471-
this.error('TSServer errored with error.', err);
459+
this.logger.error('TSServer errored with error.', err);
472460
if (handle.tsServerLog?.type === 'file') {
473-
this.error(`TSServer log file: ${handle.tsServerLog.uri.fsPath}`);
461+
this.logger.error(`TSServer log file: ${handle.tsServerLog.uri.fsPath}`);
474462
}
475463

476464
/* __GDPR__
@@ -482,15 +470,15 @@ export default class TypeScriptServiceClient extends Disposable implements IType
482470
]
483471
}
484472
*/
485-
this.logTelemetry('tsserver.error', {
473+
this.telemetryReporter.logTelemetry('tsserver.error', {
486474
...typeScriptServerEnvCommonProperties
487475
});
488476
this.serviceExited(false, apiVersion);
489477
});
490478

491479
handle.onExit((data: TypeScriptServerExitEvent) => {
492480
const { code, signal } = data;
493-
this.error(`TSServer exited. Code: ${code}. Signal: ${signal}`);
481+
this.logger.error(`TSServer exited. Code: ${code}. Signal: ${signal}`);
494482

495483
// In practice, the exit code is an integer with no ties to any identity,
496484
// so it can be classified as SystemMetaData, rather than CallstackOrException.
@@ -505,7 +493,7 @@ export default class TypeScriptServiceClient extends Disposable implements IType
505493
"signal" : { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth" }
506494
}
507495
*/
508-
this.logTelemetry('tsserver.exitWithCode', {
496+
this.telemetryReporter.logTelemetry('tsserver.exitWithCode', {
509497
...typeScriptServerEnvCommonProperties,
510498
code: code ?? undefined,
511499
signal: signal ?? undefined,
@@ -517,7 +505,7 @@ export default class TypeScriptServiceClient extends Disposable implements IType
517505
}
518506

519507
if (handle.tsServerLog?.type === 'file') {
520-
this.info(`TSServer log file: ${handle.tsServerLog.uri.fsPath}`);
508+
this.logger.info(`TSServer log file: ${handle.tsServerLog.uri.fsPath}`);
521509
}
522510
this.serviceExited(!this.isRestarting, apiVersion);
523511
this.isRestarting = false;
@@ -678,7 +666,7 @@ export default class TypeScriptServiceClient extends Disposable implements IType
678666
]
679667
}
680668
*/
681-
this.logTelemetry('serviceExited');
669+
this.telemetryReporter.logTelemetry('serviceExited');
682670
} else if (diff < 60 * 1000 * 5 /* 5 Minutes */) {
683671
this.lastStart = Date.now();
684672
if (!this._isPromptingAfterCrash) {
@@ -956,14 +944,14 @@ export default class TypeScriptServiceClient extends Disposable implements IType
956944
"command" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
957945
}
958946
*/
959-
this.logTelemetry('fatalError', { ...(error instanceof TypeScriptServerError ? error.telemetry : { command }) });
947+
this.telemetryReporter.logTelemetry('fatalError', { ...(error instanceof TypeScriptServerError ? error.telemetry : { command }) });
960948
console.error(`A non-recoverable error occurred while executing tsserver command: ${command}`);
961949
if (error instanceof TypeScriptServerError && error.serverErrorText) {
962950
console.error(error.serverErrorText);
963951
}
964952

965953
if (this.serverState.type === ServerState.Type.Running) {
966-
this.info('Killing TS Server');
954+
this.logger.info('Killing TS Server');
967955
const logfile = this.serverState.server.tsServerLog;
968956
this.serverState.server.kill();
969957
if (error instanceof TypeScriptServerError) {
@@ -1235,7 +1223,7 @@ export default class TypeScriptServiceClient extends Disposable implements IType
12351223
}
12361224
*/
12371225
// __GDPR__COMMENT__: Other events are defined by TypeScript.
1238-
this.logTelemetry(telemetryData.telemetryEventName, properties);
1226+
this.telemetryReporter.logTelemetry(telemetryData.telemetryEventName, properties);
12391227
}
12401228

12411229
private configurePlugin(pluginName: string, configuration: {}): any {

0 commit comments

Comments
 (0)