diff --git a/src/ui/omnibarIntent.js b/src/ui/omnibarIntent.js index e912330a32..2186d59bae 100644 --- a/src/ui/omnibarIntent.js +++ b/src/ui/omnibarIntent.js @@ -292,13 +292,6 @@ export function normalizeLine(text, { isRequest = isPlainRequest } = {}) { /^((?:turn|switch) (?:on|off)|show|hide|remove|enable|disable|clear|go to|fly to)\s+\1\b/i, '$1', ); - // "remove flights from the map", "clear everything except ships from the - // map": the map is where every layer is. Not the verb's own "off" ("turn - // off the screen" is no layer switch). - line = line.replace( - /^((?:turn|switch) (?:on|off)|show|display|add|hide|remove|enable|disable|clear|toggle)\s+(\S.*?)\s+(?:from|off) (?:the )?(?:map|globe|screen|view)$/i, - '$1 $2', - ); // "please" is dropped only around a request: "Please Touch Museum", // "Kindly Lane" and "Pretty Please" are names. const polite = line @@ -306,7 +299,14 @@ export function normalizeLine(text, { isRequest = isPlainRequest } = {}) { .replace(/(?:\s*,\s*|\s+)(?:please|pls|plz)$/i, '') .replace(end, '') .trim(); - return polite !== line && polite && isRequest(polite) ? polite : line; + const read = polite !== line && polite && isRequest(polite) ? polite : line; + // "remove flights from the map", "clear everything except ships from the + // map": the map is where every layer is. Not the verb's own "off" ("turn + // off the screen" is no layer switch). + return read.replace( + /^((?:turn|switch) (?:on|off)|show|display|add|hide|remove|enable|disable|clear|toggle)\s+(\S.*?)\s+(?:from|off) (?:the )?(?:map|globe|screen|view)$/i, + '$1 $2', + ); } /** A request by its own words: a verb starting it, or a real question. */ diff --git a/src/ui/omnibarRows.test.mjs b/src/ui/omnibarRows.test.mjs index d6a7bb6323..b023516182 100644 --- a/src/ui/omnibarRows.test.mjs +++ b/src/ui/omnibarRows.test.mjs @@ -808,6 +808,8 @@ test('"except" leaves Satellites to switch off with Space Missions off', () => { for (const text of [ 'hide everything except flights from the map', 'clear everything except flights from the map', + 'please clear everything except flights from the map', + 'hide everything except flights from the map, please', ]) assert.deepEqual( omnibar.rows(text, { places: [] }).rows[0].steps.map(stepOutcome),