Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
matrix-react-sdk
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
GitHub Mirror
Matrix.org
matrix-react-sdk
Commits
42479cf0
Commit
42479cf0
authored
9 years ago
by
Matthew Hodgson
Browse files
Options
Downloads
Patches
Plain Diff
PR feedback
parent
4a90f262
Branches
matthew/fix-zero-length-tab-complete
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/TabComplete.js
+30
-33
30 additions, 33 deletions
src/TabComplete.js
with
30 additions
and
33 deletions
src/TabComplete.js
+
30
−
33
View file @
42479cf0
...
...
@@ -84,9 +84,38 @@ class TabComplete {
}
startTabCompleting
(
passive
)
{
this
.
originalText
=
this
.
textArea
.
value
;
// cache starting text
// grab the partial word from the text which we'll be tab-completing
var
res
=
MATCH_REGEX
.
exec
(
this
.
originalText
);
if
(
!
res
)
{
this
.
matchedList
=
[];
return
;
}
// ES6 destructuring; ignore first element (the complete match)
var
[
,
boundaryGroup
,
partialGroup
]
=
res
;
if
(
partialGroup
.
length
===
0
&&
passive
)
{
return
;
}
this
.
isFirstWord
=
partialGroup
.
length
===
this
.
originalText
.
length
;
this
.
completing
=
true
;
this
.
currentIndex
=
0
;
this
.
_calculateCompletions
(
passive
);
this
.
matchedList
=
[
new
Entry
(
partialGroup
)
// first entry is always the original partial
];
// find matching entries in the set of entries given to us
this
.
list
.
forEach
((
entry
)
=>
{
if
(
entry
.
text
.
toLowerCase
().
indexOf
(
partialGroup
.
toLowerCase
())
===
0
)
{
this
.
matchedList
.
push
(
entry
);
}
});
// console.log("calculated completions => %s", JSON.stringify(this.matchedList));
}
/**
...
...
@@ -270,38 +299,6 @@ class TabComplete {
});
}
_calculateCompletions
(
passive
)
{
this
.
originalText
=
this
.
textArea
.
value
;
// cache starting text
// grab the partial word from the text which we'll be tab-completing
var
res
=
MATCH_REGEX
.
exec
(
this
.
originalText
);
if
(
!
res
)
{
this
.
matchedList
=
[];
return
;
}
// ES6 destructuring; ignore first element (the complete match)
var
[
,
boundaryGroup
,
partialGroup
]
=
res
;
this
.
isFirstWord
=
partialGroup
.
length
===
this
.
originalText
.
length
;
if
(
partialGroup
.
length
===
0
&&
passive
)
{
this
.
stopTabCompleting
();
return
;
}
this
.
matchedList
=
[
new
Entry
(
partialGroup
)
// first entry is always the original partial
];
// find matching entries in the set of entries given to us
this
.
list
.
forEach
((
entry
)
=>
{
if
(
entry
.
text
.
toLowerCase
().
indexOf
(
partialGroup
.
toLowerCase
())
===
0
)
{
this
.
matchedList
.
push
(
entry
);
}
});
// console.log("_calculateCompletions => %s", JSON.stringify(this.matchedList));
}
_notifyStateChange
()
{
if
(
this
.
opts
.
onStateChange
)
{
this
.
opts
.
onStateChange
(
this
.
completing
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment