Closed user3323 closed 7 years ago
The highlights are the occurences that our language server identifies for the file (in this case JavaScript).
Yes this is as-designed. JS tries to mark all references to a given symbol instead of just text occurrences. If it is not finding references correctly, please share some minimal code that demonstrates the problem and we can look into it
@mjbvz, ok, here is a code from the GIF, that I showed you:
Try it by yourself.
var DragManager = new function() {
var dragObject = {};
var self = this;
function onMouseDown(e) {
if (e.which != 1) return;
var elem = e.target.closest('.draggable');
if (!elem) return;
dragObject.elem = elem;
dragObject.downX = e.pageX;
dragObject.downY = e.pageY;
return false;
}
function onMouseMove(e) {
if (!dragObject.elem) return;
if (!dragObject.avatar) {
var moveX = e.pageX - dragObject.downX;
var moveY = e.pageY - dragObject.downY;
if (Math.abs(moveX) < 3 && Math.abs(moveY) < 3) {
return;
}
dragObject.avatar = createAvatar(e);
if (!dragObject.avatar) {
dragObject = {};
return;
}
var coords = getCoords(dragObject.avatar);
dragObject.shiftX = dragObject.downX - coords.left;
dragObject.shiftY = dragObject.downY - coords.top;
startDrag(e);
}
dragObject.avatar.style.left = e.pageX - dragObject.shiftX + 'px';
dragObject.avatar.style.top = e.pageY - dragObject.shiftY + 'px';
return false;
}
function onMouseUp(e) {
if (dragObject.avatar) {
finishDrag(e);
}
dragObject = {};
}
function finishDrag(e) {
var dropElem = findDroppable(e);
if (!dropElem) {
self.onDragCancel(dragObject);
} else {
self.onDragEnd(dragObject, dropElem);
}
}
function createAvatar(e) {
var avatar = dragObject.elem;
var old = {
parent: avatar.parentNode,
nextSibling: avatar.nextSibling,
position: avatar.position || '',
left: avatar.left || '',
top: avatar.top || '',
zIndex: avatar.zIndex || ''
};
avatar.rollback = function() {
old.parent.insertBefore(avatar, old.nextSibling);
avatar.style.position = old.position;
avatar.style.left = old.left;
avatar.style.top = old.top;
avatar.style.zIndex = old.zIndex
};
return avatar;
}
function startDrag(e) {
var avatar = dragObject.avatar;
document.body.appendChild(avatar);
avatar.style.zIndex = 9999;
avatar.style.position = 'absolute';
}
function findDroppable(event) {
dragObject.avatar.hidden = true;
var elem = document.elementFromPoint(event.clientX, event.clientY);
dragObject.avatar.hidden = false;
if (elem == null) {
return null;
}
return elem.closest('.droppable');
}
document.onmousemove = onMouseMove;
document.onmouseup = onMouseUp;
document.onmousedown = onMouseDown;
this.onDragEnd = function(dragObject, dropElem) {};
this.onDragCancel = function(dragObject) {};
};
function getCoords(elem) {
var box = elem.getBoundingClientRect();
return {
top: box.top + pageYOffset,
left: box.left + pageXOffset
};
}
Thanks. The root cause of the issue appears to be https://github.com/Microsoft/TypeScript/issues/18171
Highlighting of the variables in scroll area works by weird selective algorithm and totally unefficient.
I see that it's trying to be "smart" highlighting, but in fact - it's not.
Just to understand what I mean, you better see the GIF:
You mark up "onDragCancel" in one area of the code - no highlighting in scroll area. You mark up the same "onDragCancel" in another area - and one more appear in the bottom of the code.
Then you mark up "dragObject" that has been put as an argument (20+ times written in the code) - and NO highlighting at all.
Should be fixed.