Keep plans for places that begin with a kind of place, and keep Satellites with Space Missions only while missions are on

A keyword is read as the start of a name only when what follows is one
word for a kind of place alone ("Radio City", "Traffic Island"), so
"traffic city hall" and "earthquakes valley forge" keep their plans.
"except space missions" keeps Satellites only while Space Missions is
on, and "from the map" is read before "except".

Co-authored-by: Manjunath Paparaju <[email protected]>
This commit is contained in:
Sameh KhamisandManjunath Paparaju committed 2026-11-18 18:36:26 -08:00
1 parent 859aa172e7
commit 81192cfa50
3 files changed
+53 -27

No files matched your search

+6 -7
View File
@@ -7974,8 +7974,8 @@ Tokyo. "hide everything except flights" (or "all but", "other than", with
"turn off", "clear" or "remove") switches off every layer that is on but
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.
Space Missions and Satellites are kept together, since Space Missions draws
through Satellites. "remove flights from the
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
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
@@ -8007,11 +8007,10 @@ flights"), or a comma part that is exactly a style, map, camera move or
layer ("go to Tokyo, north up"). A line with one keyword and no verb beside
the rest of a name ("Tilt Cove", "tokyo traffic", "Hurricane, Utah") offers
the whole line as a place first and the plan second. When that keyword
starts the line with no comma after it and the rest starts with a word for
a kind of place written after a name ("Fire Island", "Radio City Music
Hall"; not "Lake Tahoe" or "Mount Fuji"), it begins the
name: the place and the layer are offered, and no plan goes to the rest
("earthquakes japan" keeps its plan). Further places joined
starts the line with no comma after it and the rest is only a word for a
kind of place ("Fire Island", "Radio City"), it begins the name: the place
and the layer are offered, and no plan goes to the rest ("earthquakes
japan" and "traffic city hall" keep their plans). Further places joined
with "and" are offered as their own rows. Things loaded on the map that
match the line are offered too: a callsign, tail number or transponder
code puts them first, and otherwise the place row keeps the top, so
+15 -14
View File
@@ -154,12 +154,12 @@ const SWITCH =
/^(turn on|switch on|enable|show|display|add|turn off|switch off|disable|hide|remove|toggle)(?:\s+(.*))?$/;
const SWITCH_OFF = /^(turn off|switch off|disable|hide|remove)\b/;
/**
* A word for a kind of place written after the name it ends ("Fire
* Island", "Ship Bottom", "Radio City"), not one written before it ("Lake
* Tahoe", "Mount Fuji", "Tower Bridge", "Park City").
* A word for a kind of place, alone: after a keyword it ends a name ("Fire
* Island", "Ship Bottom", "Radio City"), and is no place to go to by itself.
* Followed by more words it may begin one ("City Hall", "Peak District").
*/
const NAME_TAIL =
/^(?:islands?|isle|city|hall|bottom|beach|station|street|road|hills?|valley|falls|springs?|creek|county|town|village|harbou?r|cove|canyon|center|centre|square|bridge|ridge|peak)\b(?!\s+of\b)/i;
/^(?:islands?|isle|city|hall|bottom|beach|station|street|road|hills?|valley|falls|springs?|creek|county|town|village|harbou?r|cove|canyon|center|centre|square|bridge|ridge|peak)$/i;
/**
* A layer that shows itself through another, which must stay on with it:
@@ -958,11 +958,12 @@ export function createOmnibar({ layers = [], isEntity = () => false } = {}) {
if (!kept.length) return null;
if (!kept.every(named)) return [ask];
const keptIds = new Set(kept.map((layer) => layer.id));
// Keeping either of a pair keeps both: switching one off would take the
// other with it ("except space missions", "except satellites").
// Keeping either of a pair keeps both while the first is on: switching
// one off would take the other with it ("except space missions",
// "except satellites").
for (const [layer, through] of SHOWN_THROUGH) {
const on = all().find((entry) => entry.id === layer)?.enabled;
if (keptIds.has(layer) || (on && through.some((id) => keptIds.has(id))))
if (on && (keptIds.has(layer) || through.some((id) => keptIds.has(id))))
for (const id of [layer, ...through]) keptIds.add(id);
}
const steps = all()
@@ -1001,8 +1002,6 @@ export function createOmnibar({ layers = [], isEntity = () => false } = {}) {
* ("Show Low, AZ").
*/
function switchRows(line, ask) {
const excepted = exceptRows(line, ask);
if (excepted) return excepted;
// "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(
@@ -1010,6 +1009,8 @@ export function createOmnibar({ layers = [], isEntity = () => false } = {}) {
'',
);
if (bare !== line && SWITCH.test(bare.toLowerCase())) line = bare;
const excepted = exceptRows(line, ask);
if (excepted) return excepted;
const switching = line.toLowerCase().match(SWITCH);
if (
!switching ||
@@ -1358,11 +1359,11 @@ export function createOmnibar({ layers = [], isEntity = () => false } = {}) {
// without a verb may be part of the place's name, so the whole line as a
// place comes first and the plan second. After "go to …" with a request
// peeled off, the place is the one read ("go to London with flights").
// A keyword ahead of the rest of a name ("Fire Island", "Ship Bottom",
// "Radio City Music Hall") begins that name when what is left starts
// with a word for a kind of place: a fragment, not a place, so no plan
// goes there. "earthquakes japan", "tokyo traffic" and "Thermal,
// California" (a comma parts them) keep their plans.
// A keyword ahead of the rest of a name ("Fire Island", "Ship Bottom")
// begins that name when what is left is only a word for a kind of
// place: a fragment, not a place, so no plan goes there. "earthquakes
// japan", "traffic city hall", "tokyo traffic" and "Thermal, California"
// (a comma parts them) keep their plans.
const lower = text.toLowerCase();
const fragment =
ambiguous &&
+32 -6
View File
@@ -744,11 +744,7 @@ test('a grid reference after "near" is the place', () => {
test('a keyword that begins a name offers no plan to the rest of it', () => {
const omnibar = createOmnibar({ layers: layers() });
for (const text of [
'Radio City Music Hall',
'Traffic Island',
'radio island',
]) {
for (const text of ['Radio City', 'Traffic Island', 'radio island']) {
const { rows } = omnibar.rows(text, { places: [] });
assert.equal(rows[0].kind, 'place', text);
assert.ok(!rows.some((row) => row.kind === 'plan'), text);
@@ -759,7 +755,15 @@ test('a keyword that begins a name offers no plan to the rest of it', () => {
}
// A keyword after the place, or before a place that is no name's
// fragment, still offers its plan.
for (const text of ['tokyo traffic', 'earthquakes japan', 'radio London']) {
for (const text of [
'tokyo traffic',
'earthquakes japan',
'radio London',
'traffic city hall',
'traffic county cork',
'earthquakes valley forge',
'traffic road to hana',
]) {
const { rows } = omnibar.rows(text, { places: [] });
assert.ok(
rows.some((row) => row.kind === 'plan'),
@@ -787,6 +791,28 @@ test('"except" keeps a layer and the one it shows through together', () => {
);
});
test('"except" leaves Satellites to switch off with Space Missions off', () => {
const omnibar = createOmnibar({
layers: [
{ id: 'flights', name: 'Live Flights', enabled: true },
{ id: 'satellites', name: 'Satellites', enabled: true },
{ id: 'rocket-launches', name: 'Space Missions', enabled: false },
],
});
assert.deepEqual(
omnibar
.rows('hide everything except space missions', { places: [] })
.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)'],
);
});
test('"turn off the screen" is no layer switch and no place', () => {
for (const text of ['turn off the screen', 'switch off the map'])
assert.equal(outcome(text, { on: ['flights'] }), 'nothing', text);