Merge branch 'master' into feature/themes

This commit is contained in:
Seivan Heidari 2019-12-23 15:35:31 +01:00
commit b21d9337d9
233 changed files with 14900 additions and 10781 deletions

View file

@ -14,6 +14,13 @@ export interface CargoWatchOptions {
command: string;
trace: CargoWatchTraceOptions;
ignore: string[];
allTargets: boolean;
}
export interface CargoFeatures {
noDefaultFeatures: boolean;
allFeatures: boolean;
features: string[];
}
export class Config {
@ -25,21 +32,30 @@ export class Config {
public displayInlayHints = true;
public maxInlayHintLength: null | number = null;
public excludeGlobs = [];
public useClientWatching = false;
public useClientWatching = true;
public featureFlags = {};
// for internal use
public withSysroot: null | boolean = null;
public cargoWatchOptions: CargoWatchOptions = {
enableOnStartup: 'ask',
trace: 'off',
arguments: '',
command: '',
ignore: []
ignore: [],
allTargets: true,
};
public cargoFeatures: CargoFeatures = {
noDefaultFeatures: false,
allFeatures: true,
features: [],
};
private prevEnhancedTyping: null | boolean = null;
private prevCargoFeatures: null | CargoFeatures = null;
constructor() {
vscode.workspace.onDidChangeConfiguration(_ =>
this.userConfigChanged()
this.userConfigChanged(),
);
this.userConfigChanged();
}
@ -49,6 +65,8 @@ export class Config {
Server.highlighter.removeHighlights();
let requireReloadMessage = null;
if (config.has('highlightingOn')) {
this.highlightingOn = config.get('highlightingOn') as boolean;
if (this.highlightingOn) {
@ -59,13 +77,13 @@ export class Config {
if (config.has('rainbowHighlightingOn')) {
this.rainbowHighlightingOn = config.get(
'rainbowHighlightingOn'
'rainbowHighlightingOn',
) as boolean;
}
if (config.has('enableEnhancedTyping')) {
this.enableEnhancedTyping = config.get(
'enableEnhancedTyping'
'enableEnhancedTyping',
) as boolean;
if (this.prevEnhancedTyping === null) {
@ -76,19 +94,8 @@ export class Config {
}
if (this.prevEnhancedTyping !== this.enableEnhancedTyping) {
const reloadAction = 'Reload now';
vscode.window
.showInformationMessage(
'Changing enhanced typing setting requires a reload',
reloadAction
)
.then(selectedAction => {
if (selectedAction === reloadAction) {
vscode.commands.executeCommand(
'workbench.action.reloadWindow'
);
}
});
requireReloadMessage =
'Changing enhanced typing setting requires a reload';
this.prevEnhancedTyping = this.enableEnhancedTyping;
}
@ -106,28 +113,35 @@ export class Config {
if (config.has('trace.cargo-watch')) {
this.cargoWatchOptions.trace = config.get<CargoWatchTraceOptions>(
'trace.cargo-watch',
'off'
'off',
);
}
if (config.has('cargo-watch.arguments')) {
this.cargoWatchOptions.arguments = config.get<string>(
'cargo-watch.arguments',
''
'',
);
}
if (config.has('cargo-watch.command')) {
this.cargoWatchOptions.command = config.get<string>(
'cargo-watch.command',
''
'',
);
}
if (config.has('cargo-watch.ignore')) {
this.cargoWatchOptions.ignore = config.get<string[]>(
'cargo-watch.ignore',
[]
[],
);
}
if (config.has('cargo-watch.allTargets')) {
this.cargoWatchOptions.allTargets = config.get<boolean>(
'cargo-watch.allTargets',
true,
);
}
@ -140,17 +154,68 @@ export class Config {
}
if (config.has('maxInlayHintLength')) {
this.maxInlayHintLength = config.get(
'maxInlayHintLength'
'maxInlayHintLength',
) as number;
}
if (config.has('excludeGlobs')) {
this.excludeGlobs = config.get('excludeGlobs') || [];
}
if (config.has('useClientWatching')) {
this.useClientWatching = config.get('useClientWatching') || false;
this.useClientWatching = config.get('useClientWatching') || true;
}
if (config.has('featureFlags')) {
this.featureFlags = config.get('featureFlags') || {};
}
if (config.has('withSysroot')) {
this.withSysroot = config.get('withSysroot') || false;
}
if (config.has('cargoFeatures.noDefaultFeatures')) {
this.cargoFeatures.noDefaultFeatures = config.get(
'cargoFeatures.noDefaultFeatures',
false,
);
}
if (config.has('cargoFeatures.allFeatures')) {
this.cargoFeatures.allFeatures = config.get(
'cargoFeatures.allFeatures',
true,
);
}
if (config.has('cargoFeatures.features')) {
this.cargoFeatures.features = config.get(
'cargoFeatures.features',
[],
);
}
if (
this.prevCargoFeatures !== null &&
(this.cargoFeatures.allFeatures !==
this.prevCargoFeatures.allFeatures ||
this.cargoFeatures.noDefaultFeatures !==
this.prevCargoFeatures.noDefaultFeatures ||
this.cargoFeatures.features.length !==
this.prevCargoFeatures.features.length ||
this.cargoFeatures.features.some(
(v, i) => v !== this.prevCargoFeatures!.features[i],
))
) {
requireReloadMessage = 'Changing cargo features requires a reload';
}
this.prevCargoFeatures = { ...this.cargoFeatures };
if (requireReloadMessage !== null) {
const reloadAction = 'Reload now';
vscode.window
.showInformationMessage(requireReloadMessage, reloadAction)
.then(selectedAction => {
if (selectedAction === reloadAction) {
vscode.commands.executeCommand(
'workbench.action.reloadWindow',
);
}
});
}
}
}