Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
ea3a0d3e
Commit
ea3a0d3e
authored
Apr 15, 2018
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove v-html & use vdom instead
parent
0281fbc1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
18 deletions
+31
-18
app/assets/javascripts/ide/components/file_finder/item.vue
app/assets/javascripts/ide/components/file_finder/item.vue
+31
-18
No files found.
app/assets/javascripts/ide/components/file_finder/item.vue
View file @
ea3a0d3e
...
...
@@ -29,6 +29,19 @@ export default {
required
:
true
,
},
},
computed
:
{
pathWithEllipsis
()
{
return
this
.
file
.
path
.
length
<
MAX_PATH_LENGTH
||
!
addEllipsis
?
this
.
file
.
path
:
`...
${
this
.
file
.
path
.
substr
(
this
.
file
.
path
.
length
-
MAX_PATH_LENGTH
)}
`
;
},
nameSearchTextOccurences
()
{
return
fuzzaldrinPlus
.
match
(
this
.
file
.
name
,
this
.
searchText
);
},
pathSearchTextOccurences
()
{
return
fuzzaldrinPlus
.
match
(
this
.
pathWithEllipsis
,
this
.
searchText
);
},
},
methods
:
{
clickRow
()
{
this
.
$emit
(
'
click
'
,
this
.
file
);
...
...
@@ -36,22 +49,6 @@ export default {
mouseOverRow
()
{
this
.
$emit
(
'
mouseover
'
,
this
.
index
);
},
highlightText
(
text
,
addEllipsis
)
{
const
escapedText
=
escape
(
text
);
const
maxText
=
escapedText
.
length
<
MAX_PATH_LENGTH
||
!
addEllipsis
?
escapedText
:
`...
${
escapedText
.
substr
(
escapedText
.
length
-
MAX_PATH_LENGTH
)}
`
;
const
occurrences
=
fuzzaldrinPlus
.
match
(
maxText
,
this
.
searchText
);
return
maxText
.
split
(
''
)
.
map
(
(
char
,
i
)
=>
`<span class="
${
occurrences
.
indexOf
(
i
)
>=
0
?
'
highlighted
'
:
''
}
">
${
char
}
</span>`
,
)
.
join
(
''
);
},
},
};
</
script
>
...
...
@@ -74,13 +71,29 @@ export default {
<span
class=
"diff-changed-file-content append-right-8"
>
<strong
class=
"diff-changed-file-name"
v-html=
"highlightText(file.name, false)"
>
<span
v-for=
"(char, index) in file.name.split('')"
:key=
"index + char"
:class=
"
{
highlighted: nameSearchTextOccurences.indexOf(index) >= 0,
}"
v-text="char"
>
</span>
</strong>
<span
class=
"diff-changed-file-path prepend-top-5"
v-html=
"highlightText(file.path, true)"
>
<span
v-for=
"(char, index) in pathWithEllipsis.split('')"
:key=
"index + char"
:class=
"
{
highlighted: pathSearchTextOccurences.indexOf(index) >= 0,
}"
v-text="char"
>
</span>
</span>
</span>
<span
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment