Merge pull request #255 from DotJoshJohnson/release/2.4.1

Release v2.4.1
This commit is contained in:
Josh Johnson 2019-05-31 22:33:36 -04:00 committed by GitHub
commit c743d032f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -107,11 +107,22 @@ export class XmlTraverser {
columnRange[0] = (columnRange[0] - contextNode.nodeName.length);
}
if (lineNumber === (position.line + 1) && ((position.character + 1) >= columnRange[0] && (position.character + 1) < columnRange[1])) {
if (this._checkRange(lineNumber, position, columnRange)) {
return contextNode;
}
if (this.isElement(contextNode)) {
// if the element contains text, check to see if the cursor is present in the text
const textContent = (contextNode as Element).textContent;
if (textContent) {
columnRange[1] = (columnRange[1] + textContent.length);
if (this._checkRange(lineNumber, position, columnRange)) {
return contextNode;
}
}
const children = [...this.getChildAttributeArray(<Element>contextNode), ...this.getChildElementArray(contextNode)];
let result: Node;
@ -129,6 +140,10 @@ export class XmlTraverser {
return undefined;
}
private _checkRange(lineNumber: number, position: Position, columnRange: number[]): boolean {
return (lineNumber === (position.line + 1) && ((position.character + 1) >= columnRange[0] && (position.character + 1) < columnRange[1]));
}
private _getNodeWidthInCharacters(node: Node) {
if (this.isElement(node)) {
return (node.nodeName.length + 2);