Skip to content

Commit

Permalink
Add commandsToSkipShell preference for plugin support (#15099)
Browse files Browse the repository at this point in the history
  • Loading branch information
msujew authored Mar 3, 2025
1 parent 3982113 commit 65f542c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

const levenshtein = require('js-levenshtein');

// eslint-disable-next-line import/no-extraneous-dependencies
const metadata = require('@theia/core/src/common/i18n/nls.metadata.json');
const messages = new Set(Object.values(metadata.messages)
.reduceRight((prev, curr) => prev.concat(curr), [])
Expand All @@ -39,7 +40,7 @@ module.exports = {
return;
}
const { value, byDefault, node: localizeNode } = evaluateLocalize(node);
if (value !== undefined) {
if (value !== undefined && localizeNode) {
if (byDefault && !messages.has(value)) {
let lowestDistance = Number.MAX_VALUE;
let lowestMessage = '';
Expand All @@ -51,12 +52,12 @@ module.exports = {
}
}
if (lowestMessage) {
const replacementValue = `'${lowestMessage.replace(/'/g, "\\'").replace(/\n/g, '\\n')}'`;
context.report({
node: localizeNode,
message: `'${value}' is not a valid default value. Did you mean '${lowestMessage}'?`,
message: `'${value}' is not a valid default value. Did you mean ${replacementValue}?`,
fix: function (fixer) {
const updatedCall = `'${lowestMessage.replace(/'/g, "\\'")}'`;
return fixer.replaceText(localizeNode, updatedCall);
return fixer.replaceText(localizeNode, replacementValue);
}
});
} else {
Expand Down
9 changes: 9 additions & 0 deletions packages/terminal/src/browser/terminal-preferences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,15 @@ export const TerminalConfigSchema: PreferenceSchema = {
default: [],
deprecationMessage: shellArgsDeprecatedMessage(OS.Type.Linux),
},
// TODO: This preference currently features no implementation but is only available for plugins to use.
'terminal.integrated.commandsToSkipShell': {
type: 'array',
markdownDescription: nls.localizeByDefault('A set of command IDs whose keybindings will not be sent to the shell but instead always be handled by VS Code. This allows keybindings that would normally be consumed by the shell to act instead the same as when the terminal is not focused, for example `Ctrl+P` to launch Quick Open.\n\n \n\nMany commands are skipped by default. To override a default and pass that command\'s keybinding to the shell instead, add the command prefixed with the `-` character. For example add `-workbench.action.quickOpen` to allow `Ctrl+P` to reach the shell.\n\n \n\nThe following list of default skipped commands is truncated when viewed in Settings Editor. To see the full list, {1} and search for the first command from the list below.\n\n \n\nDefault Skipped Commands:\n\n{0}'),
items: {
type: 'string'
},
default: []
},
'terminal.integrated.confirmOnExit': {
type: 'string',
description: nls.localizeByDefault('Controls whether to confirm when the window closes if there are active terminal sessions.'),
Expand Down

0 comments on commit 65f542c

Please sign in to comment.