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
eb993dc5
Commit
eb993dc5
authored
Jan 20, 2017
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed bug with hint not showing when in middle of text
parent
1980403c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
22 deletions
+16
-22
app/assets/javascripts/filtered_search/dropdown_hint.js.es6
app/assets/javascripts/filtered_search/dropdown_hint.js.es6
+1
-1
app/assets/javascripts/filtered_search/dropdown_user.js.es6
app/assets/javascripts/filtered_search/dropdown_user.js.es6
+1
-1
app/assets/javascripts/filtered_search/dropdown_utils.js.es6
app/assets/javascripts/filtered_search/dropdown_utils.js.es6
+12
-9
app/assets/javascripts/filtered_search/filtered_search_dropdown_manager.js.es6
...s/filtered_search/filtered_search_dropdown_manager.js.es6
+2
-11
No files found.
app/assets/javascripts/filtered_search/dropdown_hint.js.es6
View file @
eb993dc5
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
this.config = {
this.config = {
droplabFilter: {
droplabFilter: {
template: 'hint',
template: 'hint',
filterFunction: gl.DropdownUtils.filterHint,
filterFunction: gl.DropdownUtils.filterHint
.bind(null, input)
,
},
},
};
};
}
}
...
...
app/assets/javascripts/filtered_search/dropdown_user.js.es6
View file @
eb993dc5
...
@@ -37,7 +37,7 @@
...
@@ -37,7 +37,7 @@
}
}
getSearchInput() {
getSearchInput() {
const query = gl.DropdownUtils.getSearchInput(this.input)
.trim()
;
const query = gl.DropdownUtils.getSearchInput(this.input);
const { lastToken } = gl.FilteredSearchTokenizer.processTokens(query);
const { lastToken } = gl.FilteredSearchTokenizer.processTokens(query);
return lastToken.value || '';
return lastToken.value || '';
...
...
app/assets/javascripts/filtered_search/dropdown_utils.js.es6
View file @
eb993dc5
...
@@ -22,7 +22,7 @@
...
@@ -22,7 +22,7 @@
static filterWithSymbol(filterSymbol, input, item) {
static filterWithSymbol(filterSymbol, input, item) {
const updatedItem = item;
const updatedItem = item;
const query = gl.DropdownUtils.getSearchInput(input)
.trim()
;
const query = gl.DropdownUtils.getSearchInput(input);
const { lastToken, searchToken } = gl.FilteredSearchTokenizer.processTokens(query);
const { lastToken, searchToken } = gl.FilteredSearchTokenizer.processTokens(query);
if (lastToken !== searchToken) {
if (lastToken !== searchToken) {
...
@@ -45,8 +45,9 @@
...
@@ -45,8 +45,9 @@
return updatedItem;
return updatedItem;
}
}
static filterHint(i
tem, query
) {
static filterHint(i
nput, item
) {
const updatedItem = item;
const updatedItem = item;
const query = gl.DropdownUtils.getSearchInput(input);
let { lastToken } = gl.FilteredSearchTokenizer.processTokens(query);
let { lastToken } = gl.FilteredSearchTokenizer.processTokens(query);
lastToken = lastToken.key || lastToken || '';
lastToken = lastToken.key || lastToken || '';
...
@@ -79,32 +80,34 @@
...
@@ -79,32 +80,34 @@
const inputValue = filteredSearchInput.value;
const inputValue = filteredSearchInput.value;
const { right } = gl.DropdownUtils.getInputSelectionPosition(filteredSearchInput);
const { right } = gl.DropdownUtils.getInputSelectionPosition(filteredSearchInput);
if (right < 0) {
return inputValue.slice(0, right);
return inputValue;
}
return inputValue.slice(0, right + 1).trim();
}
}
static getInputSelectionPosition(input) {
static getInputSelectionPosition(input) {
const selectionStart = input.selectionStart;
let inputValue = input.value;
let inputValue = input.value;
// Replace all spaces inside quote marks with underscores
// Replace all spaces inside quote marks with underscores
// This helps with matching the beginning & end of a token:key
// This helps with matching the beginning & end of a token:key
inputValue = inputValue.replace(/"(.*?)"/g, str => str.replace(/\s/g, '_') );
inputValue = inputValue.replace(/"(.*?)"/g, str => str.replace(/\s/g, '_') );
const selectionStart = input.selectionStart;
// Get the right position for the word selected
let right = inputValue.slice(selectionStart).search(/\s/);
let right = inputValue.slice(selectionStart).search(/\s/);
if (right >= 0) {
if (right >= 0) {
right += selectionStart;
right += selectionStart;
} else if (right < 0) {
right = inputValue.length;
}
}
let left = inputValue.slice(0, selectionStart + 1).search(/\S+$/);
// Get the left position for the word selected
let left = inputValue.slice(0, right).search(/\S+$/);
if (selectionStart === 0) {
if (selectionStart === 0) {
left = 0;
left = 0;
} else if (selectionStart === inputValue.length && left < 0) {
} else if (selectionStart === inputValue.length && left < 0) {
left = inputValue.length;
left = inputValue.length;
} else if (left < 0) {
left = selectionStart;
}
}
return {
return {
...
...
app/assets/javascripts/filtered_search/filtered_search_dropdown_manager.js.es6
View file @
eb993dc5
...
@@ -62,12 +62,7 @@
...
@@ -62,12 +62,7 @@
// Get the string to replace
// Get the string to replace
const selectionStart = input.selectionStart;
const selectionStart = input.selectionStart;
const { left } = gl.DropdownUtils.getInputSelectionPosition(input);
const { left, right } = gl.DropdownUtils.getInputSelectionPosition(input);
let { right } = gl.DropdownUtils.getInputSelectionPosition(input);
if (right < 0) {
right = inputValue.length;
}
input.value = `${inputValue.substr(0, left)}${word}${inputValue.substr(right)}`;
input.value = `${inputValue.substr(0, left)}${word}${inputValue.substr(right)}`;
gl.FilteredSearchDropdownManager.updateInputCaretPosition(selectionStart, input);
gl.FilteredSearchDropdownManager.updateInputCaretPosition(selectionStart, input);
...
@@ -79,11 +74,7 @@
...
@@ -79,11 +74,7 @@
input.setSelectionRange(selectionStart, selectionStart);
input.setSelectionRange(selectionStart, selectionStart);
const inputValue = input.value;
const inputValue = input.value;
let { right } = gl.DropdownUtils.getInputSelectionPosition(input);
const { right } = gl.DropdownUtils.getInputSelectionPosition(input);
if (right < 0) {
right = inputValue.length;
}
input.setSelectionRange(right, right);
input.setSelectionRange(right, right);
}
}
...
...
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