Skip to content

Commit

Permalink
Document how to unset auto reply, support null explicitly
Browse files Browse the repository at this point in the history
Fixes #141456
  • Loading branch information
Tyriar committed Jan 25, 2022
1 parent c89f347 commit a30e4b2
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
12 changes: 10 additions & 2 deletions src/vs/workbench/contrib/terminal/browser/remoteTerminalBackend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,23 @@ class RemoteTerminalBackend extends BaseTerminalBackend implements ITerminalBack
// Listen for config changes
const initialConfig = this._configurationService.getValue<ITerminalConfiguration>(TERMINAL_CONFIG_SECTION);
for (const match of Object.keys(initialConfig.autoReplies)) {
this._remoteTerminalChannel.installAutoReply(match, initialConfig.autoReplies[match]);
// Ensure the value is truthy
const reply = initialConfig.autoReplies[match];
if (reply) {
this._remoteTerminalChannel.installAutoReply(match, reply);
}
}
// TODO: Could simplify update to a single call
this._register(this._configurationService.onDidChangeConfiguration(async e => {
if (e.affectsConfiguration(TerminalSettingId.AutoReplies)) {
this._remoteTerminalChannel.uninstallAllAutoReplies();
const config = this._configurationService.getValue<ITerminalConfiguration>(TERMINAL_CONFIG_SECTION);
for (const match of Object.keys(config.autoReplies)) {
await this._remoteTerminalChannel.installAutoReply(match, config.autoReplies[match]);
// Ensure the value is truthy
const reply = config.autoReplies[match];
if (reply) {
await this._remoteTerminalChannel.installAutoReply(match, reply);
}
}
}
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ const terminalConfiguration: IConfigurationNode = {
default: true
},
[TerminalSettingId.AutoReplies]: {
description: localize('terminal.integrated.autoReplies', "A set of messages that when encountered in the terminal will be automatically responded to. Provided the message is specific enough, this can help automate away common responses. Note that the message includes escape sequences so the reply might not happen with styled text. Each reply can only happen once every second."),
markdownDescription: localize('terminal.integrated.autoReplies', "A set of messages that when encountered in the terminal will be automatically responded to. Provided the message is specific enough, this can help automate away common responses. Note that the message includes escape sequences so the reply might not happen with styled text. Each reply can only happen once every second.\n\nTo unset a default key, set the value to null."),
type: 'object',
additionalProperties: {
type: 'string',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,23 @@ class LocalTerminalBackend extends BaseTerminalBackend implements ITerminalBacke
// Listen for config changes
const initialConfig = configurationService.getValue<ITerminalConfiguration>(TERMINAL_CONFIG_SECTION);
for (const match of Object.keys(initialConfig.autoReplies)) {
this._localPtyService.installAutoReply(match, initialConfig.autoReplies[match]);
// Ensure the reply is value
const reply = initialConfig.autoReplies[match] as string | null;
if (reply) {
this._localPtyService.installAutoReply(match, reply);
}
}
// TODO: Could simplify update to a single call
this._register(configurationService.onDidChangeConfiguration(async e => {
if (e.affectsConfiguration(TerminalSettingId.AutoReplies)) {
this._localPtyService.uninstallAllAutoReplies();
const config = configurationService.getValue<ITerminalConfiguration>(TERMINAL_CONFIG_SECTION);
for (const match of Object.keys(config.autoReplies)) {
await this._localPtyService.installAutoReply(match, config.autoReplies[match]);
// Ensure the reply is value
const reply = config.autoReplies[match] as string | null;
if (reply) {
await this._localPtyService.installAutoReply(match, reply);
}
}
}
}));
Expand Down

0 comments on commit a30e4b2

Please sign in to comment.