diff --git a/docs/CURRENT-STATE.md b/docs/CURRENT-STATE.md index 531fc1c8ea..810afb174c 100644 --- a/docs/CURRENT-STATE.md +++ b/docs/CURRENT-STATE.md @@ -7976,7 +7976,8 @@ the ones named, on Enter, or says no other layers are on; with a layer to keep that is not read, nothing is switched off and only Ask GEV is offered. While Space Missions is on, keeping either it or Satellites keeps both, since Space Missions draws through Satellites. "remove flights from the -map" is "remove flights", a doubled verb ("hide hide everything") is read +map" is "remove flights", after any switch or clear verb ("clear everything +except flights from the map", "hide everything from the map"), a doubled verb ("hide hide everything") is read once, and a grid reference after "near" is the place ("flights near 14R PU 2090 4906"). Following needs a callsign or ICAO address (letters and a digit), a nine-digit MMSI or the name of something loaded on the map, so "Track diff --git a/src/ui/omnibarIntent.js b/src/ui/omnibarIntent.js index e9a2ebfd7b..e912330a32 100644 --- a/src/ui/omnibarIntent.js +++ b/src/ui/omnibarIntent.js @@ -292,6 +292,13 @@ 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 diff --git a/src/ui/omnibarRows.js b/src/ui/omnibarRows.js index 51f50211f7..dd300fda51 100644 --- a/src/ui/omnibarRows.js +++ b/src/ui/omnibarRows.js @@ -1002,13 +1002,6 @@ export function createOmnibar({ layers = [], isEntity = () => false } = {}) { * ("Show Low, AZ"). */ function switchRows(line, ask) { - // "remove flights from the map": the map is where every layer is. Not - // the verb's own "off" ("turn off the screen" is no layer switch). - const bare = line.replace( - /\s+(?:from|off) (?:the )?(?:map|globe|screen|view)$/i, - '', - ); - if (bare !== line && SWITCH.test(bare.toLowerCase())) line = bare; const excepted = exceptRows(line, ask); if (excepted) return excepted; const switching = line.toLowerCase().match(SWITCH); diff --git a/src/ui/omnibarRows.test.mjs b/src/ui/omnibarRows.test.mjs index 4333363bbe..d6a7bb6323 100644 --- a/src/ui/omnibarRows.test.mjs +++ b/src/ui/omnibarRows.test.mjs @@ -805,12 +805,24 @@ test('"except" leaves Satellites to switch off with Space Missions off', () => { .rows[0].steps.map(stepOutcome), ['layer(flights,off)', 'layer(satellites,off)'], ); - assert.deepEqual( - omnibar - .rows('hide everything except flights from the map', { places: [] }) - .rows[0].steps.map(stepOutcome), - ['layer(satellites,off)'], - ); + for (const text of [ + 'hide everything except flights from the map', + 'clear everything except flights from the map', + ]) + assert.deepEqual( + omnibar.rows(text, { places: [] }).rows[0].steps.map(stepOutcome), + ['layer(satellites,off)'], + text, + ); + // The whole map cleared "from the map" is the same plan, not a place. + for (const text of [ + 'hide everything from the map', + 'remove all layers from the map', + ]) { + const { rows } = omnibar.rows(text, { places: [] }); + assert.equal(rows[0].kind, 'plan', text); + assert.ok(!rows.some((row) => row.kind === 'place'), text); + } }); test('"turn off the screen" is no layer switch and no place', () => {