@optique/core 1.0.15-dev.2792 → 1.0.15-dev.2812
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/completion.cjs +15 -17
- package/dist/completion.js +15 -17
- package/package.json +1 -1
package/dist/completion.cjs
CHANGED
|
@@ -913,6 +913,16 @@ complete -c ${programName} -f -a '(${functionName})'
|
|
|
913
913
|
}
|
|
914
914
|
};
|
|
915
915
|
/**
|
|
916
|
+
* Quotes a string as a Nushell string literal. Nushell single-quoted strings
|
|
917
|
+
* have no escape sequences, so a value containing an apostrophe is written as
|
|
918
|
+
* a double-quoted string, in which only backslashes and double quotes need
|
|
919
|
+
* escaping.
|
|
920
|
+
*/
|
|
921
|
+
function quoteNuString(value) {
|
|
922
|
+
if (!value.includes("'")) return `'${value}'`;
|
|
923
|
+
return `"${value.replace(/["\\]/g, "\\$&")}"`;
|
|
924
|
+
}
|
|
925
|
+
/**
|
|
916
926
|
* The Nushell completion generator.
|
|
917
927
|
* @since 0.6.0
|
|
918
928
|
*/
|
|
@@ -920,7 +930,7 @@ const nu = {
|
|
|
920
930
|
name: "nu",
|
|
921
931
|
generateScript(programName, args = []) {
|
|
922
932
|
validateProgramName(programName);
|
|
923
|
-
const escapedArgs = args.map(
|
|
933
|
+
const escapedArgs = args.map(quoteNuString).join(" ");
|
|
924
934
|
const safeName = programName.replace(/[^a-zA-Z0-9]+/g, "-");
|
|
925
935
|
const functionName = `nu-complete-${safeName}`;
|
|
926
936
|
return `
|
|
@@ -1269,23 +1279,11 @@ Register-ArgumentCompleter -Native -CommandName ${programName} -ScriptBlock {
|
|
|
1269
1279
|
\$arguments = @()
|
|
1270
1280
|
\$commandElements = \$commandAst.CommandElements
|
|
1271
1281
|
|
|
1272
|
-
#
|
|
1273
|
-
#
|
|
1274
|
-
\$
|
|
1275
|
-
if (\$commandElements.Count -gt 1) {
|
|
1276
|
-
\$lastElement = \$commandElements[\$commandElements.Count - 1]
|
|
1277
|
-
\$lastText = if (\$lastElement -is [System.Management.Automation.Language.StringConstantExpressionAst]) {
|
|
1278
|
-
\$lastElement.Value
|
|
1279
|
-
} else {
|
|
1280
|
-
\$lastElement.Extent.Text
|
|
1281
|
-
}
|
|
1282
|
-
if (\$lastText -eq \$wordToComplete) {
|
|
1283
|
-
\$maxIndex = \$commandElements.Count - 2
|
|
1284
|
-
}
|
|
1285
|
-
}
|
|
1286
|
-
|
|
1287
|
-
for (\$i = 1; \$i -le \$maxIndex; \$i++) {
|
|
1282
|
+
# Keep only complete arguments before the cursor. The current word
|
|
1283
|
+
# (including a token ending exactly at the cursor) is appended below.
|
|
1284
|
+
for (\$i = 1; \$i -lt \$commandElements.Count; \$i++) {
|
|
1288
1285
|
\$element = \$commandElements[\$i]
|
|
1286
|
+
if (\$element.Extent.EndOffset -ge \$cursorPosition) { break }
|
|
1289
1287
|
|
|
1290
1288
|
if (\$element -is [System.Management.Automation.Language.StringConstantExpressionAst]) {
|
|
1291
1289
|
\$arguments += \$element.Value
|
package/dist/completion.js
CHANGED
|
@@ -913,6 +913,16 @@ complete -c ${programName} -f -a '(${functionName})'
|
|
|
913
913
|
}
|
|
914
914
|
};
|
|
915
915
|
/**
|
|
916
|
+
* Quotes a string as a Nushell string literal. Nushell single-quoted strings
|
|
917
|
+
* have no escape sequences, so a value containing an apostrophe is written as
|
|
918
|
+
* a double-quoted string, in which only backslashes and double quotes need
|
|
919
|
+
* escaping.
|
|
920
|
+
*/
|
|
921
|
+
function quoteNuString(value) {
|
|
922
|
+
if (!value.includes("'")) return `'${value}'`;
|
|
923
|
+
return `"${value.replace(/["\\]/g, "\\$&")}"`;
|
|
924
|
+
}
|
|
925
|
+
/**
|
|
916
926
|
* The Nushell completion generator.
|
|
917
927
|
* @since 0.6.0
|
|
918
928
|
*/
|
|
@@ -920,7 +930,7 @@ const nu = {
|
|
|
920
930
|
name: "nu",
|
|
921
931
|
generateScript(programName, args = []) {
|
|
922
932
|
validateProgramName(programName);
|
|
923
|
-
const escapedArgs = args.map(
|
|
933
|
+
const escapedArgs = args.map(quoteNuString).join(" ");
|
|
924
934
|
const safeName = programName.replace(/[^a-zA-Z0-9]+/g, "-");
|
|
925
935
|
const functionName = `nu-complete-${safeName}`;
|
|
926
936
|
return `
|
|
@@ -1269,23 +1279,11 @@ Register-ArgumentCompleter -Native -CommandName ${programName} -ScriptBlock {
|
|
|
1269
1279
|
\$arguments = @()
|
|
1270
1280
|
\$commandElements = \$commandAst.CommandElements
|
|
1271
1281
|
|
|
1272
|
-
#
|
|
1273
|
-
#
|
|
1274
|
-
\$
|
|
1275
|
-
if (\$commandElements.Count -gt 1) {
|
|
1276
|
-
\$lastElement = \$commandElements[\$commandElements.Count - 1]
|
|
1277
|
-
\$lastText = if (\$lastElement -is [System.Management.Automation.Language.StringConstantExpressionAst]) {
|
|
1278
|
-
\$lastElement.Value
|
|
1279
|
-
} else {
|
|
1280
|
-
\$lastElement.Extent.Text
|
|
1281
|
-
}
|
|
1282
|
-
if (\$lastText -eq \$wordToComplete) {
|
|
1283
|
-
\$maxIndex = \$commandElements.Count - 2
|
|
1284
|
-
}
|
|
1285
|
-
}
|
|
1286
|
-
|
|
1287
|
-
for (\$i = 1; \$i -le \$maxIndex; \$i++) {
|
|
1282
|
+
# Keep only complete arguments before the cursor. The current word
|
|
1283
|
+
# (including a token ending exactly at the cursor) is appended below.
|
|
1284
|
+
for (\$i = 1; \$i -lt \$commandElements.Count; \$i++) {
|
|
1288
1285
|
\$element = \$commandElements[\$i]
|
|
1286
|
+
if (\$element.Extent.EndOffset -ge \$cursorPosition) { break }
|
|
1289
1287
|
|
|
1290
1288
|
if (\$element -is [System.Management.Automation.Language.StringConstantExpressionAst]) {
|
|
1291
1289
|
\$arguments += \$element.Value
|