-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Fix for Issue 3339 #3340
Fix for Issue 3339 #3340
Changes from 4 commits
990fe39
edab6b8
5ae84c4
087fa43
b200259
cd9004a
e63ec5f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -92,11 +92,7 @@ define(function (require, exports, module) { | |
|
||
var query = this._getQuery(); | ||
|
||
if (implicitChar === null) { | ||
return query !== null; | ||
} | ||
|
||
return implicitChar === "&" || query !== null; | ||
return query !== null; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Original comment seemed to be buried in a hidden "Outdated Diff", so adding again. Sorry for the dupe. Don't need query var, so this can be simplified more:
|
||
}; | ||
|
||
/** | ||
|
@@ -120,7 +116,7 @@ define(function (require, exports, module) { | |
var query, | ||
result; | ||
|
||
if (this.primaryTriggerKeys.indexOf(implicitChar) !== -1 || implicitChar === null) { | ||
if (implicitChar === null || this.primaryTriggerKeys.indexOf(implicitChar) !== -1) { | ||
this.currentQuery = query = this._getQuery(); | ||
result = $.map(specialChars, function (value, index) { | ||
if (value.indexOf(query) === 0) { | ||
|
@@ -129,7 +125,10 @@ define(function (require, exports, module) { | |
} | ||
}).sort(this._internalSort); | ||
|
||
query = _encodeValue(query); | ||
if (query !== null) { | ||
query = _encodeValue(query); | ||
} | ||
|
||
return { | ||
hints: result, | ||
match: query, | ||
|
@@ -173,26 +172,29 @@ define(function (require, exports, module) { | |
var query, | ||
lineContent, | ||
startChar, | ||
endChar; | ||
endChar, | ||
cursor = this.editor.getCursorPos(); | ||
|
||
query = "&"; | ||
if (HTMLUtils.getTagInfo(this.editor, cursor).tagName !== "") { | ||
return null; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The variable name There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed. |
||
} | ||
|
||
lineContent = this.editor.document.getRange({ | ||
line: this.editor.getCursorPos().line, | ||
line: cursor.line, | ||
ch: 0 | ||
}, this.editor.getCursorPos()); | ||
}, cursor); | ||
|
||
startChar = lineContent.lastIndexOf("&"); | ||
endChar = lineContent.lastIndexOf(";"); | ||
|
||
if (endChar < startChar) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The logic here needs some cleanup:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you're right thats much more understandable. |
||
query = this.editor.document.getRange({ | ||
line: this.editor.getCursorPos().line, | ||
line: cursor.line, | ||
ch: startChar | ||
}, this.editor.getCursorPos()); | ||
}, cursor); | ||
} | ||
|
||
if (startChar !== -1 && HTMLUtils.getTagInfo(this.editor, this.editor.getCursorPos()).tagName === "") { | ||
if (endChar < startChar) { | ||
return query; | ||
} | ||
|
||
|
@@ -212,11 +214,19 @@ define(function (require, exports, module) { | |
SpecialCharHints.prototype.insertHint = function (completion) { | ||
var start = {line: -1, ch: -1}, | ||
end = {line: -1, ch: -1}, | ||
cursor = this.editor.getCursorPos(); | ||
cursor = this.editor.getCursorPos(), | ||
match; | ||
|
||
end.line = start.line = cursor.line; | ||
start.ch = cursor.ch - this.currentQuery.length; | ||
match = this.editor.document.getLine(cursor.line).slice(cursor.ch); | ||
end.ch = start.ch + this.currentQuery.length; | ||
|
||
if (match.indexOf(";") !== -1 && /^(#*[0-9]+)|([a-zA-Z]+)$/.test(match.slice(0, match.indexOf(";")))) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
console.log("In Entity"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove this |
||
end.ch = this.editor.document.getLine(cursor.line).indexOf(";", start.ch) + 1; | ||
} | ||
|
||
completion = completion.slice(0, completion.indexOf(" ")); | ||
completion = _decodeValue(completion); | ||
if (start.ch !== end.ch) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method now returns
query !== null
in all cases, so remove this block:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, but now that you made that change, I can see that you don't need query var, and this can simply be: