Repository navigation
Commit efdd2a5
committed
fix(web/shell): #107 review — Tab no longer completes to another file's name, misreads where a command starts, or leaves a stray quote
The five findings of the review on completion.js, each reproduced against the real modules first. Every new test
fails on e93bc09 and passes here.
1. A name with a character the editor does not type (U+200B and the rest of cleanText's invisible list) was offered:
`rm a` + Tab gave `rm ab.txt ` for `a<ZWSP>b.txt`, another file's name, with only a dim note under the line. The
completer now drops a candidate whose written-back text cleanText would change (completion.js createCompleter).
Names whose invisible characters the editor keeps (an emoji's selector, a ZWJ family, a Persian ZWNJ) are offered
as before.
2. A line end that is not quoted or escaped was read as a blank, so in a pasted `echo hi\ngre` the word `gre` asked
for paths. A line end now ends a command, as `;` does (wordAt).
3. A leading assignment took the command position: `LC_ALL=C gre` asked for paths. A word that is `NAME=`, `NAME+=`
or `NAME[i]=`, judged on the raw token so the name has to be unquoted as bash requires (`"LC_ALL"=C` is a
command word), keeps the command position (wordAt, ASSIGNMENT).
4. A word written against `<` or `>` was dropped without ending the command position: `cat>out sr` asked for commands.
The word now ends there like any other unless it is all digits (the `2` of `2>err`). `>&`, `<&` and `>|` (an `&`
or `|` right after the operator) and `&>`, `&>>` are read as redirections, not as a list or a pipe: `2>&1 gre`
and `>|out gre` complete commands, `cat &>out sr` a file. Every row of the new table was checked with `bash -xc`
(bash 3.2, the only bash on this machine: Docker was down, so not the golden suite's 5.1).
5. Tab just before a closing quote left the quote behind: `cat "my fi|"` became `cat "my file.txt" "`, an open quote,
and the line was held for more. GNU readline does no better (`cat "my file.txt""`), so bash is not the model here.
wordAt now also returns where the word ends after the cursor and what it holds there. The completer offers only
names that end with that rest (any name when the rest is empty) and gives each such candidate an `end`. The
editor's `_replace` replaces through that end, so the closing quote and the tail of a name typed earlier are
consumed, never split off. A folder at the end of a word still keeps its quote open, with the cursor before the
quote that is there. In the editor (line-editor.js `_complete`), too: a file gets no blank when one follows already;
a common part that is a whole candidate (`'it'` of `it` and `it's`) takes that candidate's end (`cat 'i|'` gave
`cat 'it''`); an `end` before the cursor or past the line completes nothing. A cursor at the start of a word still
inserts a word of its own (`cat |foo` gives `cat x.txt foo`, as before).
NOTES.md: the completion section says what counts as a command position and what Tab inside a word does, and no
longer that a name it cannot type "is typed without" the character.1 parent 4a9803f commit efdd2a5
5 files changed
Lines changed: 307 additions & 39 deletions
File tree
- web
- shell/src/terminal
- test/unit
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
109 | 109 | | |
110 | 110 | | |
111 | 111 | | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
117 | 129 | | |
118 | 130 | | |
119 | 131 | | |
| |||
419 | 431 | | |
420 | 432 | | |
421 | 433 | | |
422 | | - | |
| 434 | + | |
423 | 435 | | |
424 | 436 | | |
425 | 437 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
| 9 | + | |
8 | 10 | | |
9 | 11 | | |
10 | 12 | | |
| 13 | + | |
| 14 | + | |
11 | 15 | | |
12 | 16 | | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
13 | 23 | | |
14 | 24 | | |
15 | 25 | | |
16 | 26 | | |
17 | 27 | | |
18 | 28 | | |
19 | 29 | | |
20 | | - | |
| 30 | + | |
21 | 31 | | |
22 | 32 | | |
23 | | - | |
| 33 | + | |
| 34 | + | |
24 | 35 | | |
25 | 36 | | |
26 | | - | |
| 37 | + | |
| 38 | + | |
27 | 39 | | |
28 | 40 | | |
29 | 41 | | |
30 | 42 | | |
31 | 43 | | |
| 44 | + | |
32 | 45 | | |
33 | 46 | | |
| 47 | + | |
34 | 48 | | |
35 | 49 | | |
36 | 50 | | |
37 | 51 | | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
38 | 62 | | |
39 | 63 | | |
40 | 64 | | |
| |||
48 | 72 | | |
49 | 73 | | |
50 | 74 | | |
51 | | - | |
| 75 | + | |
52 | 76 | | |
53 | 77 | | |
54 | 78 | | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
65 | 84 | | |
66 | 85 | | |
67 | 86 | | |
68 | 87 | | |
69 | 88 | | |
70 | 89 | | |
71 | 90 | | |
72 | | - | |
73 | | - | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
74 | 97 | | |
| 98 | + | |
75 | 99 | | |
76 | 100 | | |
77 | 101 | | |
78 | 102 | | |
79 | 103 | | |
80 | 104 | | |
81 | 105 | | |
82 | | - | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
83 | 143 | | |
84 | 144 | | |
85 | 145 | | |
| |||
104 | 164 | | |
105 | 165 | | |
106 | 166 | | |
107 | | - | |
| 167 | + | |
| 168 | + | |
108 | 169 | | |
109 | 170 | | |
110 | 171 | | |
| |||
117 | 178 | | |
118 | 179 | | |
119 | 180 | | |
120 | | - | |
121 | | - | |
| 181 | + | |
| 182 | + | |
122 | 183 | | |
123 | 184 | | |
124 | | - | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
125 | 196 | | |
126 | 197 | | |
127 | 198 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
118 | 118 | | |
119 | 119 | | |
120 | 120 | | |
121 | | - | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
122 | 124 | | |
123 | 125 | | |
124 | 126 | | |
| |||
1069 | 1071 | | |
1070 | 1072 | | |
1071 | 1073 | | |
| 1074 | + | |
| 1075 | + | |
1072 | 1076 | | |
1073 | 1077 | | |
1074 | | - | |
| 1078 | + | |
| 1079 | + | |
| 1080 | + | |
| 1081 | + | |
1075 | 1082 | | |
1076 | 1083 | | |
1077 | 1084 | | |
| |||
1081 | 1088 | | |
1082 | 1089 | | |
1083 | 1090 | | |
1084 | | - | |
| 1091 | + | |
| 1092 | + | |
| 1093 | + | |
1085 | 1094 | | |
1086 | 1095 | | |
1087 | 1096 | | |
1088 | 1097 | | |
1089 | 1098 | | |
1090 | 1099 | | |
1091 | 1100 | | |
1092 | | - | |
1093 | | - | |
1094 | | - | |
1095 | | - | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
1096 | 1105 | | |
1097 | 1106 | | |
1098 | 1107 | | |
| |||
0 commit comments