Third try for Add Em Dash PR (#5564)
This commit is contained in:
parent
53890c8d32
commit
ca4840a3eb
1 changed files with 14 additions and 1 deletions
|
|
@ -263,6 +263,15 @@ export class ParsedCommand {
|
|||
this.i++;
|
||||
break;
|
||||
}
|
||||
case '—': {
|
||||
// Em dash, introduced when two '-' are set in iOS. Will be considered as such.
|
||||
this.state = ParseState.Flag;
|
||||
this.i++;
|
||||
this.incomplete = '';
|
||||
this.incompleteStart = this.i;
|
||||
flagEqualsUsed = false;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
// Positional parameter.
|
||||
this.position++;
|
||||
|
|
@ -1093,10 +1102,14 @@ export class AppCommandParser {
|
|||
}
|
||||
|
||||
// There have been 0 to 2 dashes in the command prior to this call, adjust.
|
||||
const prevCharIndex = parsed.incompleteStart - 1;
|
||||
let prefix = '--';
|
||||
for (let i = parsed.incompleteStart - 1; i > 0 && i >= parsed.incompleteStart - 2 && parsed.command[i] === '-'; i--) {
|
||||
for (let i = prevCharIndex; i > 0 && i >= parsed.incompleteStart - 2 && parsed.command[i] === '-'; i--) {
|
||||
prefix = prefix.substring(1);
|
||||
}
|
||||
if (prevCharIndex > 0 && parsed.command[prevCharIndex] === '—') {
|
||||
prefix = '';
|
||||
}
|
||||
|
||||
const applicable = parsed.form.fields.filter((field) => field.label && field.label.toLowerCase().startsWith(parsed.incomplete.toLowerCase()) && !parsed.values[field.name]);
|
||||
if (applicable) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue