MCPcopy
hub / github.com/kekingcn/kkFileView / extendTo

Function extendTo

server/src/main/resources/static/js/codemirror.js:1597–1604  ·  view source on GitHub ↗
(pos)

Source from the content-addressed store, hash-verified

1595{ourRange=range;}}
1596if(!behavior.addNew){ourIndex=0;setSelection(doc,new Selection([ourRange],0),sel_mouse);startSel=doc.sel;}else if(ourIndex==-1){ourIndex=ranges.length;setSelection(doc,normalizeSelection(cm,ranges.concat([ourRange]),ourIndex),{scroll:false,origin:"*mouse"});}else if(ranges.length>1&&ranges[ourIndex].empty()&&behavior.unit=="char"&&!behavior.extend){setSelection(doc,normalizeSelection(cm,ranges.slice(0,ourIndex).concat(ranges.slice(ourIndex+1)),0),{scroll:false,origin:"*mouse"});startSel=doc.sel;}else{replaceOneSelection(doc,ourIndex,ourRange,sel_mouse);}
1597var lastPos=start;function extendTo(pos){if(cmp(lastPos,pos)==0){return}
1598lastPos=pos;if(behavior.unit=="rectangle"){var ranges=[],tabSize=cm.options.tabSize;var startCol=countColumn(getLine(doc,start.line).text,start.ch,tabSize);var posCol=countColumn(getLine(doc,pos.line).text,pos.ch,tabSize);var left=Math.min(startCol,posCol),right=Math.max(startCol,posCol);for(var line=Math.min(start.line,pos.line),end=Math.min(cm.lastLine(),Math.max(start.line,pos.line));line<=end;line++){var text=getLine(doc,line).text,leftPos=findColumn(text,left,tabSize);if(left==right)
1599{ranges.push(new Range(Pos(line,leftPos),Pos(line,leftPos)));}
1600else if(text.length>leftPos)
1601{ranges.push(new Range(Pos(line,leftPos),Pos(line,findColumn(text,right,tabSize))));}}
1602if(!ranges.length){ranges.push(new Range(start,start));}
1603setSelection(doc,normalizeSelection(cm,startSel.ranges.slice(0,ourIndex).concat(ranges),ourIndex),{origin:"*mouse",scroll:false});cm.scrollIntoView(pos);}else{var oldRange=ourRange;var range=rangeForUnit(cm,pos,behavior.unit);var anchor=oldRange.anchor,head;if(cmp(range.anchor,anchor)>0){head=range.head;anchor=minPos(oldRange.from(),range.anchor);}else{head=range.anchor;anchor=maxPos(oldRange.to(),range.head);}
1604var ranges$1=startSel.ranges.slice(0);ranges$1[ourIndex]=bidiSimplify(cm,new Range(clipPos(doc,anchor),head));setSelection(doc,normalizeSelection(cm,ranges$1,ourIndex),sel_mouse);}}
1605var editorSize=display.wrapper.getBoundingClientRect();var counter=0;function extend(e){var curCount=++counter;var cur=posFromMouse(cm,e,true,behavior.unit=="rectangle");if(!cur){return}
1606if(cmp(cur,lastPos)!=0){cm.curOp.focus=activeElt(root(cm));extendTo(cur);var visible=visibleLines(display,doc);if(cur.line>=visible.to||cur.line<visible.from)
1607{setTimeout(operation(cm,function(){if(counter==curCount){extend(e);}}),150);}}else{var outside=e.clientY<editorSize.top?-20:e.clientY>editorSize.bottom?20:0;if(outside){setTimeout(operation(cm,function(){if(counter!=curCount){return}

Callers 1

extendFunction · 0.85

Calls 15

countColumnFunction · 0.85
findColumnFunction · 0.85
PosFunction · 0.85
normalizeSelectionFunction · 0.85
rangeForUnitFunction · 0.85
minPosFunction · 0.85
maxPosFunction · 0.85
bidiSimplifyFunction · 0.85
clipPosFunction · 0.85
sliceMethod · 0.80
fromMethod · 0.80
toMethod · 0.80

Tested by

no test coverage detected