tangled
alpha
login
or
join now
ansxor.ca
/
witchsky.app
forked from
jollywhoppers.com/witchsky.app
1
fork
atom
Bluesky app fork with some witchin' additions 💫
1
fork
atom
overview
issues
pulls
pipelines
fix some auto complete issues
Chenyu Huang
7 months ago
ead6862f
fc2fae42
+8
-5
3 changed files
expand all
collapse all
unified
split
__tests__
lib
strings
mention-manip.test.ts
src
lib
strings
mention-manip.ts
view
com
composer
text-input
TextInput.tsx
+2
__tests__/lib/strings/mention-manip.test.ts
···
32
['@alice hello', 7, undefined],
33
['alice@alice', 0, undefined],
34
['alice@alice', 6, undefined],
0
35
]
36
37
it.each(cases)(
···
72
['@alice hello', 7, '@alice hello'],
73
['alice@alice', 0, 'alice@alice'],
74
['alice@alice', 6, 'alice@alice'],
0
75
]
76
77
it.each(cases)(
···
32
['@alice hello', 7, undefined],
33
['alice@alice', 0, undefined],
34
['alice@alice', 6, undefined],
35
+
['hello @alice-com goodbye', 8, 'alice-com'],
36
]
37
38
it.each(cases)(
···
73
['@alice hello', 7, '@alice hello'],
74
['alice@alice', 0, 'alice@alice'],
75
['alice@alice', 6, 'alice@alice'],
76
+
['hello @alice-com goodbye', 10, 'hello @alice.com goodbye'],
77
]
78
79
it.each(cases)(
+1
-1
src/lib/strings/mention-manip.ts
···
7
text: string,
8
cursorPos: number,
9
): FoundMention | undefined {
10
-
let re = /(^|\s)@([a-z0-9.]*)/gi
11
let match
12
while ((match = re.exec(text))) {
13
const spaceOffset = match[1].length
···
7
text: string,
8
cursorPos: number,
9
): FoundMention | undefined {
10
+
let re = /(^|\s)@([a-z0-9.-]*)/gi
11
let match
12
while ((match = re.exec(text))) {
13
const spaceOffset = match[1].length
+5
-4
src/view/com/composer/text-input/TextInput.tsx
···
96
newRt.detectFacetsWithoutResolution()
97
setRichText(newRt)
98
99
-
const prefix = getMentionAt(
100
-
newText,
101
-
textInputSelection.current?.start || 0,
102
-
)
0
103
if (prefix) {
104
setAutocompletePrefix(prefix.value)
105
} else if (autocompletePrefix) {
···
96
newRt.detectFacetsWithoutResolution()
97
setRichText(newRt)
98
99
+
// NOTE: BinaryFiddler
100
+
// onChangeText happens before onSelectionChange, cursorPos is out of bound if the user deletes characters,
101
+
const cursorPos = textInputSelection.current?.start ?? 0
102
+
const prefix = getMentionAt(newText, Math.min(cursorPos, newText.length))
103
+
104
if (prefix) {
105
setAutocompletePrefix(prefix.value)
106
} else if (autocompletePrefix) {