Search is not available for this dataset
query
stringlengths
7
355k
document
stringlengths
9
341k
metadata
dict
negatives
listlengths
0
101
negative_scores
listlengths
0
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
Compute the character length of a line, taking into account collapsed ranges (see markText) that might hide parts, and join other lines onto it.
function lineLength(line) { if (line.height == 0) { return 0 } var len = line.text.length, merged, cur = line; while (merged = collapsedSpanAtStart(cur)) { var found = merged.find(0, true); cur = found.from.line; len += found.from.ch - found.to.ch; } cur = line; while (merged = collapsedSpanAtEnd(cur)) { var found$1 = merged.find(0, true); len -= cur.text.length - found$1.from.ch; cur = found$1.to.line; len += cur.text.length - found$1.to.ch; } return len }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function lineLength(line) {\n if (line.height == 0) return 0;\n var len = line.text.length, merged, cur = line;\n while (merged = collapsedSpanAtStart(cur)) {\n var found = merged.find(0, true);\n cur = found.from.line;\n len += found.from.ch - found.to.ch;\n }\n cur = line;\n whil...
[ "0.76744145", "0.76744145", "0.76744145", "0.76744145", "0.76744145", "0.76744145", "0.76744145", "0.76744145", "0.7654427", "0.76487726", "0.7636767", "0.7626715", "0.7626715", "0.7623724", "0.76186347", "0.76186347", "0.76186347", "0.76186347", "0.76186347", "0.76186347", "...
0.76794684
16
Find the longest line in the document.
function findMaxLine(cm) { var d = cm.display, doc = cm.doc; d.maxLine = getLine(doc, doc.first); d.maxLineLength = lineLength(d.maxLine); d.maxLineChanged = true; doc.iter(function (line) { var len = lineLength(line); if (len > d.maxLineLength) { d.maxLineLength = len; d.maxLine = line; } }); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function findMaxLine(cm) {\n var d = cm.display, doc = cm.doc;\n d.maxLine = getLine(doc, doc.first);\n d.maxLineLength = lineLength(d.maxLine);\n d.maxLineChanged = true;\n doc.iter(function(line) {\n var len = lineLength(line);\n if (len > d.maxLineLength) {\n d.maxLineLength = le...
[ "0.7557767", "0.7557767", "0.7557767", "0.7557767", "0.7557767", "0.7557767", "0.7557767", "0.7557767", "0.75130606", "0.75130606", "0.75036013", "0.7496651", "0.7496651", "0.7496651", "0.7496651", "0.7496651", "0.7496651", "0.7496651", "0.7496651", "0.7496651", "0.7496651", ...
0.75558054
23
Change the content (text, markers) of a line. Automatically invalidates cached information and tries to reestimate the line's height.
function updateLine(line, text, markedSpans, estimateHeight) { line.text = text; if (line.stateAfter) { line.stateAfter = null; } if (line.styles) { line.styles = null; } if (line.order != null) { line.order = null; } detachMarkedSpans(line); attachMarkedSpans(line, markedSpans); var estHeight = estimateHeight ? estimateHeight(line) : 1; if (estHeight != line.height) { updateLineHeight(line, estHeight); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function updateLine(line, text, markedSpans, estimateHeight) {\n line.text = text;\n\n if (line.stateAfter) {\n line.stateAfter = null;\n }\n\n if (line.styles) {\n line.styles = null;\n }\n\n if (line.order != null) {\n line.order = null;\n }\n\n detachMarkedSpans(line);\n ...
[ "0.7491608", "0.7394629", "0.73894763", "0.73894763", "0.73894763", "0.73894763", "0.73894763", "0.73894763", "0.73894763", "0.7387523", "0.7345274", "0.7345274", "0.7345274", "0.7339563", "0.7339563", "0.7328437", "0.73019385", "0.72927153", "0.72927153", "0.72927153", "0.72...
0.7390273
17
Detach a line from the document tree and its markers.
function cleanUpLine(line) { line.parent = null; detachMarkedSpans(line); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function detachMarkedSpans(line) {\n var spans = line.markedSpans\n if (!spans) { return }\n for (var i = 0; i < spans.length; ++i)\n { spans[i].marker.detachLine(line) }\n line.markedSpans = null\n}", "function detachMarkedSpans(line) {\n var spans = line.markedSpans\n if (!spans) { return }\n for (va...
[ "0.7419141", "0.7419141", "0.7408427", "0.7399212", "0.7399212", "0.73966587", "0.7390764", "0.7388641", "0.7385563", "0.738401", "0.738401", "0.738401", "0.738401", "0.738401", "0.738401", "0.738401", "0.738401", "0.738401", "0.738401", "0.738401", "0.738401", "0.738401", ...
0.7264013
76
Render the DOM representation of the text of a line. Also builds up a 'line map', which points at the DOM nodes that represent specific stretches of text, and is used by the measuring code. The returned object contains the DOM node, this map, and information about linewide styles that were set by the mode.
function buildLineContent(cm, lineView) { // The padding-right forces the element to have a 'border', which // is needed on Webkit to be able to get line-level bounding // rectangles for it (in measureChar). var content = eltP("span", null, null, webkit ? "padding-right: .1px" : null); var builder = {pre: eltP("pre", [content], "CodeMirror-line"), content: content, col: 0, pos: 0, cm: cm, trailingSpace: false, splitSpaces: cm.getOption("lineWrapping")}; lineView.measure = {}; // Iterate over the logical lines that make up this visual line. for (var i = 0; i <= (lineView.rest ? lineView.rest.length : 0); i++) { var line = i ? lineView.rest[i - 1] : lineView.line, order = (void 0); builder.pos = 0; builder.addToken = buildToken; // Optionally wire in some hacks into the token-rendering // algorithm, to deal with browser quirks. if (hasBadBidiRects(cm.display.measure) && (order = getOrder(line, cm.doc.direction))) { builder.addToken = buildTokenBadBidi(builder.addToken, order); } builder.map = []; var allowFrontierUpdate = lineView != cm.display.externalMeasured && lineNo(line); insertLineContent(line, builder, getLineStyles(cm, line, allowFrontierUpdate)); if (line.styleClasses) { if (line.styleClasses.bgClass) { builder.bgClass = joinClasses(line.styleClasses.bgClass, builder.bgClass || ""); } if (line.styleClasses.textClass) { builder.textClass = joinClasses(line.styleClasses.textClass, builder.textClass || ""); } } // Ensure at least a single node is present, for measuring. if (builder.map.length == 0) { builder.map.push(0, 0, builder.content.appendChild(zeroWidthElement(cm.display.measure))); } // Store the map and a cache object for the current logical line if (i == 0) { lineView.measure.map = builder.map; lineView.measure.cache = {}; } else { (lineView.measure.maps || (lineView.measure.maps = [])).push(builder.map) ;(lineView.measure.caches || (lineView.measure.caches = [])).push({}); } } // See issue #2901 if (webkit) { var last = builder.content.lastChild; if (/\bcm-tab\b/.test(last.className) || (last.querySelector && last.querySelector(".cm-tab"))) { builder.content.className = "cm-tab-wrap-hack"; } } signal(cm, "renderLine", cm, lineView.line, builder.pre); if (builder.pre.className) { builder.textClass = joinClasses(builder.pre.className, builder.textClass || ""); } return builder }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function buildLineContent(cm, lineView) {\r\n // The padding-right forces the element to have a 'border', which\r\n // is needed on Webkit to be able to get line-level bounding\r\n // rectangles for it (in measureChar).\r\n var content = elt(\"span\", null, null, webkit ? \"padding-right: .1px\" : null...
[ "0.7296825", "0.7259922", "0.7259922", "0.7194069", "0.7194069", "0.7194069", "0.70309806", "0.7024098", "0.7003542", "0.7000183", "0.69872445", "0.69866264", "0.69771665", "0.69638944", "0.6954674", "0.6933167", "0.6933167", "0.6933167", "0.6933167", "0.6933167", "0.6933167"...
0.69485915
26
Build up the DOM representation for a single token, and add it to the line map. Takes care to render special characters separately.
function buildToken(builder, text, style, startStyle, endStyle, css, attributes) { if (!text) { return } var displayText = builder.splitSpaces ? splitSpaces(text, builder.trailingSpace) : text; var special = builder.cm.state.specialChars, mustWrap = false; var content; if (!special.test(text)) { builder.col += text.length; content = document.createTextNode(displayText); builder.map.push(builder.pos, builder.pos + text.length, content); if (ie && ie_version < 9) { mustWrap = true; } builder.pos += text.length; } else { content = document.createDocumentFragment(); var pos = 0; while (true) { special.lastIndex = pos; var m = special.exec(text); var skipped = m ? m.index - pos : text.length - pos; if (skipped) { var txt = document.createTextNode(displayText.slice(pos, pos + skipped)); if (ie && ie_version < 9) { content.appendChild(elt("span", [txt])); } else { content.appendChild(txt); } builder.map.push(builder.pos, builder.pos + skipped, txt); builder.col += skipped; builder.pos += skipped; } if (!m) { break } pos += skipped + 1; var txt$1 = (void 0); if (m[0] == "\t") { var tabSize = builder.cm.options.tabSize, tabWidth = tabSize - builder.col % tabSize; txt$1 = content.appendChild(elt("span", spaceStr(tabWidth), "cm-tab")); txt$1.setAttribute("role", "presentation"); txt$1.setAttribute("cm-text", "\t"); builder.col += tabWidth; } else if (m[0] == "\r" || m[0] == "\n") { txt$1 = content.appendChild(elt("span", m[0] == "\r" ? "\u240d" : "\u2424", "cm-invalidchar")); txt$1.setAttribute("cm-text", m[0]); builder.col += 1; } else { txt$1 = builder.cm.options.specialCharPlaceholder(m[0]); txt$1.setAttribute("cm-text", m[0]); if (ie && ie_version < 9) { content.appendChild(elt("span", [txt$1])); } else { content.appendChild(txt$1); } builder.col += 1; } builder.map.push(builder.pos, builder.pos + 1, txt$1); builder.pos++; } } builder.trailingSpace = displayText.charCodeAt(text.length - 1) == 32; if (style || startStyle || endStyle || mustWrap || css) { var fullStyle = style || ""; if (startStyle) { fullStyle += startStyle; } if (endStyle) { fullStyle += endStyle; } var token = elt("span", [content], fullStyle, css); if (attributes) { for (var attr in attributes) { if (attributes.hasOwnProperty(attr) && attr != "style" && attr != "class") { token.setAttribute(attr, attributes[attr]); } } } return builder.content.appendChild(token) } builder.content.appendChild(content); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "drawHTMLToken() {\n const tokenContainer = document.createElement('div');\n const gameBoardUnderlay = document.getElementById('game-board-underlay');\n gameBoardUnderlay.appendChild(tokenContainer);\n tokenContainer.setAttribute(\"id\", this.id);\n tokenContainer.setAttribute(\"c...
[ "0.63364595", "0.6152449", "0.611563", "0.6113837", "0.6113837", "0.6113837", "0.6104204", "0.60897434", "0.604226", "0.60420346", "0.6017149", "0.6017149", "0.6017149", "0.6017149", "0.6017149", "0.6017149", "0.6008158", "0.6008158", "0.5997036", "0.5991892", "0.59615743", ...
0.6017149
20
Change some spaces to NBSP to prevent the browser from collapsing trailing spaces at the end of a line when rendering text (issue 1362).
function splitSpaces(text, trailingBefore) { if (text.length > 1 && !/ /.test(text)) { return text } var spaceBefore = trailingBefore, result = ""; for (var i = 0; i < text.length; i++) { var ch = text.charAt(i); if (ch == " " && spaceBefore && (i == text.length - 1 || text.charCodeAt(i + 1) == 32)) { ch = "\u00a0"; } result += ch; spaceBefore = ch == " "; } return result }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function String_SpaceToNonBreakingSpace()\n{\n\t//replace them\n\treturn this.replace(/\\b {2}/g, \" &nbsp;\").replace(/ {2}\\b/g, \"&nbsp; \").replace(/ {2}/g, \"&nbsp;&nbsp;\");\n}", "function normalizeSpaces(text)\n{\n // IE has already done this conversion, so doing it again will remove multiple nbsp\n ...
[ "0.7739919", "0.75860053", "0.72711277", "0.7261996", "0.7015653", "0.69172597", "0.67173624", "0.66479915", "0.659467", "0.65831417", "0.6578782", "0.6573841", "0.6523409", "0.64220226", "0.64159256", "0.64096767", "0.64095", "0.6408991", "0.6408991", "0.63840115", "0.636956...
0.65678304
24
Work around nonsense dimensions being reported for stretches of righttoleft text.
function buildTokenBadBidi(inner, order) { return function (builder, text, style, startStyle, endStyle, css, attributes) { style = style ? style + " cm-force-border" : "cm-force-border"; var start = builder.pos, end = start + text.length; for (;;) { // Find the part that overlaps with the start of this text var part = (void 0); for (var i = 0; i < order.length; i++) { part = order[i]; if (part.to > start && part.from <= start) { break } } if (part.to >= end) { return inner(builder, text, style, startStyle, endStyle, css, attributes) } inner(builder, text.slice(0, part.to - start), style, startStyle, null, css, attributes); startStyle = null; text = text.slice(part.to - start); start = part.to; } } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function textResize(elt, d) {\n\n var textWidth = elt.getComputedTextLength();\n var arrayBro = elt.parentNode.childNodes;\n var len = arrayBro.length;\n var i = len / 2;\n\n if (arrayBro[i].firstChild === null || elt.firstChild === null)\n return null;\n\n while (arrayBro[i].firstChild.no...
[ "0.6419615", "0.62969416", "0.6237837", "0.60760343", "0.6073828", "0.5946762", "0.592194", "0.58706087", "0.585344", "0.57196945", "0.57196945", "0.5669483", "0.5669483", "0.56625825", "0.56436014", "0.56314695", "0.5612791", "0.55979156", "0.55979156", "0.55979156", "0.5593...
0.0
-1
Outputs a number of spans to make up a line, taking highlighting and marked text into account.
function insertLineContent(line, builder, styles) { var spans = line.markedSpans, allText = line.text, at = 0; if (!spans) { for (var i$1 = 1; i$1 < styles.length; i$1+=2) { builder.addToken(builder, allText.slice(at, at = styles[i$1]), interpretTokenStyle(styles[i$1+1], builder.cm.options)); } return } var len = allText.length, pos = 0, i = 1, text = "", style, css; var nextChange = 0, spanStyle, spanEndStyle, spanStartStyle, collapsed, attributes; for (;;) { if (nextChange == pos) { // Update current marker set spanStyle = spanEndStyle = spanStartStyle = css = ""; attributes = null; collapsed = null; nextChange = Infinity; var foundBookmarks = [], endStyles = (void 0); for (var j = 0; j < spans.length; ++j) { var sp = spans[j], m = sp.marker; if (m.type == "bookmark" && sp.from == pos && m.widgetNode) { foundBookmarks.push(m); } else if (sp.from <= pos && (sp.to == null || sp.to > pos || m.collapsed && sp.to == pos && sp.from == pos)) { if (sp.to != null && sp.to != pos && nextChange > sp.to) { nextChange = sp.to; spanEndStyle = ""; } if (m.className) { spanStyle += " " + m.className; } if (m.css) { css = (css ? css + ";" : "") + m.css; } if (m.startStyle && sp.from == pos) { spanStartStyle += " " + m.startStyle; } if (m.endStyle && sp.to == nextChange) { (endStyles || (endStyles = [])).push(m.endStyle, sp.to); } // support for the old title property // https://github.com/codemirror/CodeMirror/pull/5673 if (m.title) { (attributes || (attributes = {})).title = m.title; } if (m.attributes) { for (var attr in m.attributes) { (attributes || (attributes = {}))[attr] = m.attributes[attr]; } } if (m.collapsed && (!collapsed || compareCollapsedMarkers(collapsed.marker, m) < 0)) { collapsed = sp; } } else if (sp.from > pos && nextChange > sp.from) { nextChange = sp.from; } } if (endStyles) { for (var j$1 = 0; j$1 < endStyles.length; j$1 += 2) { if (endStyles[j$1 + 1] == nextChange) { spanEndStyle += " " + endStyles[j$1]; } } } if (!collapsed || collapsed.from == pos) { for (var j$2 = 0; j$2 < foundBookmarks.length; ++j$2) { buildCollapsedSpan(builder, 0, foundBookmarks[j$2]); } } if (collapsed && (collapsed.from || 0) == pos) { buildCollapsedSpan(builder, (collapsed.to == null ? len + 1 : collapsed.to) - pos, collapsed.marker, collapsed.from == null); if (collapsed.to == null) { return } if (collapsed.to == pos) { collapsed = false; } } } if (pos >= len) { break } var upto = Math.min(len, nextChange); while (true) { if (text) { var end = pos + text.length; if (!collapsed) { var tokenText = end > upto ? text.slice(0, upto - pos) : text; builder.addToken(builder, tokenText, style ? style + spanStyle : spanStyle, spanStartStyle, pos + tokenText.length == nextChange ? spanEndStyle : "", css, attributes); } if (end >= upto) {text = text.slice(upto - pos); pos = upto; break} pos = end; spanStartStyle = ""; } text = allText.slice(at, at = styles[i++]); style = interpretTokenStyle(styles[i++], builder.cm.options); } } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function insertLineContent(line, builder, styles) {\n\t var spans = line.markedSpans, allText = line.text, at = 0;\n\t if (!spans) {\n\t for (var i = 1; i < styles.length; i+=2)\n\t builder.addToken(builder, allText.slice(at, at = styles[i]), interpretTokenStyle(styles[i+1], builder.cm.options));...
[ "0.6612778", "0.66099524", "0.6578742", "0.6569854", "0.6564896", "0.6564896", "0.6545556", "0.6532712", "0.65212727", "0.65170527", "0.65070033", "0.6499207", "0.6499207", "0.649153", "0.649153", "0.649153", "0.6460711", "0.6460711", "0.6460711", "0.6459593", "0.6459526", ...
0.64115644
52
These objects are used to represent the visible (currently drawn) part of the document. A LineView may correspond to multiple logical lines, if those are connected by collapsed ranges.
function LineView(doc, line, lineN) { // The starting line this.line = line; // Continuing lines, if any this.rest = visualLineContinued(line); // Number of logical lines in this visual line this.size = this.rest ? lineNo(lst(this.rest)) - lineN + 1 : 1; this.node = this.text = null; this.hidden = lineIsHidden(doc, line); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function LineView(doc, line, lineN) {\n // The starting line\n this.line = line; // Continuing lines, if any\n\n this.rest = visualLineContinued(line); // Number of logical lines in this visual line\n\n this.size = this.rest ? lineNo(lst(this.rest)) - lineN + 1 : 1;\n this.node = this.text = null;\n...
[ "0.77587694", "0.7355294", "0.7355294", "0.73397183", "0.73397183", "0.73397183", "0.73397183", "0.73397183", "0.73397183", "0.73397183", "0.73397183", "0.73397183", "0.73397183", "0.73397183", "0.73043203", "0.7289012", "0.7289012", "0.728781", "0.7266966", "0.7266966", "0.7...
0.7326388
31
Create a range of LineView objects for the given lines.
function buildViewArray(cm, from, to) { var array = [], nextPos; for (var pos = from; pos < to; pos = nextPos) { var view = new LineView(cm.doc, getLine(cm.doc, pos), pos); nextPos = pos + view.size; array.push(view); } return array }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function LineView(doc, line, lineN) {\n // The starting line\n this.line = line; // Continuing lines, if any\n\n this.rest = visualLineContinued(line); // Number of logical lines in this visual line\n\n this.size = this.rest ? lineNo(lst(this.rest)) - lineN + 1 : 1;\n this.node = this.text = null;\n...
[ "0.77182955", "0.66010743", "0.66010743", "0.66010743", "0.66010743", "0.66010743", "0.66010743", "0.66010743", "0.66010743", "0.65827054", "0.65815836", "0.6575943", "0.6561047", "0.6553308", "0.6553308", "0.6537662", "0.6537662", "0.6537662", "0.6534156", "0.65170366", "0.6...
0.65894336
20
Often, we want to signal events at a point where we are in the middle of some work, but don't want the handler to start calling other methods on the editor, which might be in an inconsistent state or simply not expect any other events to happen. signalLater looks whether there are any handlers, and schedules them to be executed when the last operation ends, or, if no operation is active, when a timeout fires.
function signalLater(emitter, type /*, values...*/) { var arr = getHandlers(emitter, type); if (!arr.length) { return } var args = Array.prototype.slice.call(arguments, 2), list; if (operationGroup) { list = operationGroup.delayedCallbacks; } else if (orphanDelayedCallbacks) { list = orphanDelayedCallbacks; } else { list = orphanDelayedCallbacks = []; setTimeout(fireOrphanDelayed, 0); } var loop = function ( i ) { list.push(function () { return arr[i].apply(null, args); }); }; for (var i = 0; i < arr.length; ++i) loop( i ); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function signalLater(emitter, type /*, values...*/) {\n\t\t var arr = getHandlers(emitter, type, false)\n\t\t if (!arr.length) return;\n\t\t var args = Array.prototype.slice.call(arguments, 2), list;\n\t\t if (operationGroup) {\n\t\t list = operationGroup.delayedCallbacks;\n\t\t } else if (orph...
[ "0.6554211", "0.64453864", "0.64453864", "0.64453864", "0.6413596", "0.64093375", "0.62302804", "0.6220109", "0.6220109", "0.6220109", "0.6220109", "0.6220109", "0.6048615", "0.60203564", "0.6013591", "0.6013591", "0.6013591", "0.6013591", "0.6013591", "0.6013591", "0.6013591...
0.615517
26
When an aspect of a line changes, a string is added to lineView.changes. This updates the relevant part of the line's DOM structure.
function updateLineForChanges(cm, lineView, lineN, dims) { for (var j = 0; j < lineView.changes.length; j++) { var type = lineView.changes[j]; if (type == "text") { updateLineText(cm, lineView); } else if (type == "gutter") { updateLineGutter(cm, lineView, lineN, dims); } else if (type == "class") { updateLineClasses(cm, lineView); } else if (type == "widget") { updateLineWidgets(cm, lineView, dims); } } lineView.changes = null; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function updateLineForChanges(cm, lineView, lineN, dims) {\n\t\t for (var j = 0; j < lineView.changes.length; j++) {\n\t\t var type = lineView.changes[j];\n\t\t if (type == \"text\") updateLineText(cm, lineView);\n\t\t else if (type == \"gutter\") updateLineGutter(cm, lineView, lineN, dims);\n\t\...
[ "0.7633977", "0.7631411", "0.7612085", "0.7612085", "0.7612085", "0.760189", "0.760189", "0.760189", "0.760189", "0.760189", "0.760189", "0.7598171", "0.7597313", "0.7597313", "0.75850314", "0.7557656", "0.7553357", "0.7506481", "0.7506481", "0.7506481", "0.7506481", "0.750...
0.75903237
26
Lines with gutter elements, widgets or a background class need to be wrapped, and have the extra elements added to the wrapper div
function ensureLineWrapped(lineView) { if (lineView.node == lineView.text) { lineView.node = elt("div", null, null, "position: relative"); if (lineView.text.parentNode) { lineView.text.parentNode.replaceChild(lineView.node, lineView.text); } lineView.node.appendChild(lineView.text); if (ie && ie_version < 8) { lineView.node.style.zIndex = 2; } } return lineView.node }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function wa(e){for(var t=e.display,a={},n={},r=t.gutters.clientLeft,f=t.gutters.firstChild,o=0;f;f=f.nextSibling,++o)a[e.options.gutters[o]]=f.offsetLeft+f.clientLeft+r,n[e.options.gutters[o]]=f.clientWidth;return{fixedPos:xa(t),gutterTotalWidth:t.gutters.offsetWidth,gutterLeft:a,gutterWidth:n,wrapperWidth:t.wrapp...
[ "0.63652897", "0.6070703", "0.57518905", "0.56793195", "0.5650686", "0.5588701", "0.55632764", "0.55362713", "0.55177873", "0.5483235", "0.54808384", "0.54808384", "0.5474382", "0.54581654", "0.5456185", "0.54484624", "0.54248106", "0.5405661", "0.5405661", "0.5405661", "0.54...
0.0
-1
Wrapper around buildLineContent which will reuse the structure in display.externalMeasured when possible.
function getLineContent(cm, lineView) { var ext = cm.display.externalMeasured; if (ext && ext.line == lineView.line) { cm.display.externalMeasured = null; lineView.measure = ext.measure; return ext.built } return buildLineContent(cm, lineView) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function getLineContent(cm, lineView) {\n\t\t var ext = cm.display.externalMeasured;\n\t\t if (ext && ext.line == lineView.line) {\n\t\t cm.display.externalMeasured = null;\n\t\t lineView.measure = ext.measure;\n\t\t return ext.built\n\t\t }\n\t\t return buildLineContent(cm, lineView)\n\...
[ "0.7480917", "0.7473227", "0.7392253", "0.7392253", "0.7392253", "0.7392253", "0.7392253", "0.7392253", "0.7392253", "0.7392253", "0.7390707", "0.7390707", "0.7390707", "0.73619705", "0.72684866", "0.72610617", "0.7257943", "0.72563297", "0.7244617", "0.7222567", "0.7222567",...
0.7383554
25
Redraw the line's text. Interacts with the background and text classes because the mode may output tokens that influence these classes.
function updateLineText(cm, lineView) { var cls = lineView.text.className; var built = getLineContent(cm, lineView); if (lineView.text == lineView.node) { lineView.node = built.pre; } lineView.text.parentNode.replaceChild(built.pre, lineView.text); lineView.text = built.pre; if (built.bgClass != lineView.bgClass || built.textClass != lineView.textClass) { lineView.bgClass = built.bgClass; lineView.textClass = built.textClass; updateLineClasses(cm, lineView); } else if (cls) { lineView.text.className = cls; } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function updateLineText(cm, lineView) {\n\t\t var cls = lineView.text.className;\n\t\t var built = getLineContent(cm, lineView);\n\t\t if (lineView.text == lineView.node) lineView.node = built.pre;\n\t\t lineView.text.parentNode.replaceChild(built.pre, lineView.text);\n\t\t lineView.text = built.pre...
[ "0.74870175", "0.7475659", "0.74642247", "0.74642247", "0.74642247", "0.74642247", "0.74642247", "0.74642247", "0.74642247", "0.74642247", "0.74571306", "0.74571306", "0.74571306", "0.74498487", "0.7411686", "0.7344041", "0.732451", "0.732451", "0.732451", "0.732451", "0.7324...
0.74458647
27
Build a line's DOM representation from scratch
function buildLineElement(cm, lineView, lineN, dims) { var built = getLineContent(cm, lineView); lineView.text = lineView.node = built.pre; if (built.bgClass) { lineView.bgClass = built.bgClass; } if (built.textClass) { lineView.textClass = built.textClass; } updateLineClasses(cm, lineView); updateLineGutter(cm, lineView, lineN, dims); insertLineWidgets(cm, lineView, dims); return lineView.node }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function buildLineElement(cm, lineView, lineN, dims) {\n\t\t var built = getLineContent(cm, lineView);\n\t\t lineView.text = lineView.node = built.pre;\n\t\t if (built.bgClass) { lineView.bgClass = built.bgClass; }\n\t\t if (built.textClass) { lineView.textClass = built.textClass; }\n\n\t\t updateLi...
[ "0.7639888", "0.75955623", "0.75483197", "0.7539128", "0.7539128", "0.7481602", "0.7481602", "0.7476351", "0.7471293", "0.7471293", "0.7471293", "0.7471293", "0.7471293", "0.7471293", "0.74629945", "0.7421916", "0.7421916", "0.7421916", "0.7421916", "0.7421916", "0.7421916", ...
0.7545719
14
A lineView may contain multiple logical lines (when merged by collapsed spans). The widgets for all of them need to be drawn.
function insertLineWidgets(cm, lineView, dims) { insertLineWidgetsFor(cm, lineView.line, lineView, dims, true); if (lineView.rest) { for (var i = 0; i < lineView.rest.length; i++) { insertLineWidgetsFor(cm, lineView.rest[i], lineView, dims, false); } } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function insertLineWidgets(lineView, dims) {\n insertLineWidgetsFor(lineView.line, lineView, dims, true);\n if (lineView.rest) for (var i = 0; i < lineView.rest.length; i++)\n insertLineWidgetsFor(lineView.rest[i], lineView, dims, false);\n }", "function insertLineWidgets(lineView, dims) {\n inser...
[ "0.7027548", "0.7027548", "0.7027548", "0.7027548", "0.7027548", "0.7027548", "0.70150566", "0.69329065", "0.6855795", "0.68497884", "0.6844549", "0.6844549", "0.68330497", "0.68330497", "0.68291104", "0.68127936", "0.67902917", "0.67902917", "0.67902917", "0.67902917", "0.67...
0.68482625
24
Return true when the given mouse event happened in a widget
function eventInWidget(display, e) { for (var n = e_target(e); n != display.wrapper; n = n.parentNode) { if (!n || (n.nodeType == 1 && n.getAttribute("cm-ignore-events") == "true") || (n.parentNode == display.sizer && n != display.mover)) { return true } } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function mouseClicked() {\n // If it has been clicked return true\n return true;\n }", "mouseClicked(){\n //If we are highlighted and we clicked, return true\n if(this.highlighted){\n return true\n }\n //Else return false\n return false;\n }", "hovered(){\n //if mouse i...
[ "0.7194196", "0.7059485", "0.68766373", "0.6852455", "0.6758913", "0.67542046", "0.6751924", "0.66846025", "0.6671108", "0.664715", "0.6614089", "0.6614089", "0.6614089", "0.6614089", "0.6591147", "0.6567154", "0.65445554", "0.6489968", "0.64857376", "0.64652973", "0.646091",...
0.6431442
40
Ensure the lineView.wrapping.heights array is populated. This is an array of bottom offsets for the lines that make up a drawn line. When lineWrapping is on, there might be more than one height.
function ensureLineHeights(cm, lineView, rect) { var wrapping = cm.options.lineWrapping; var curWidth = wrapping && displayWidth(cm); if (!lineView.measure.heights || wrapping && lineView.measure.width != curWidth) { var heights = lineView.measure.heights = []; if (wrapping) { lineView.measure.width = curWidth; var rects = lineView.text.firstChild.getClientRects(); for (var i = 0; i < rects.length - 1; i++) { var cur = rects[i], next = rects[i + 1]; if (Math.abs(cur.bottom - next.bottom) > 2) { heights.push((cur.bottom + next.top) / 2 - rect.top); } } } heights.push(rect.bottom - rect.top); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function ensureLineHeights(cm, lineView, rect) {\n var wrapping = cm.options.lineWrapping;\n var curWidth = wrapping && cm.display.scroller.clientWidth;\n if (!lineView.measure.heights || wrapping && lineView.measure.width != curWidth) {\n var heights = lineView.measure.heights = [];\n if (wrapp...
[ "0.7546182", "0.7546182", "0.7546182", "0.7546182", "0.7498462", "0.73648065", "0.73648065", "0.73648065", "0.73648065", "0.7262307", "0.7261923", "0.72531855", "0.72531855", "0.72531855", "0.72389436", "0.72389436", "0.71971226", "0.71971226", "0.71971226", "0.71971226", "0....
0.7377386
20
Find a line map (mapping character offsets to text nodes) and a measurement cache for the given line number. (A line view might contain multiple lines when collapsed ranges are present.)
function mapFromLineView(lineView, line, lineN) { if (lineView.line == line) { return {map: lineView.measure.map, cache: lineView.measure.cache} } for (var i = 0; i < lineView.rest.length; i++) { if (lineView.rest[i] == line) { return {map: lineView.measure.maps[i], cache: lineView.measure.caches[i]} } } for (var i$1 = 0; i$1 < lineView.rest.length; i$1++) { if (lineNo(lineView.rest[i$1]) > lineN) { return {map: lineView.measure.maps[i$1], cache: lineView.measure.caches[i$1], before: true} } } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function mapFromLineView(lineView, line, lineN) {\n if (lineView.line == line) {\n return {\n map: lineView.measure.map,\n cache: lineView.measure.cache\n };\n }\n\n for (var i = 0; i < lineView.rest.length; i++) {\n if (lineView.rest[i] == line) {\n return {\n ...
[ "0.75483626", "0.7491622", "0.74201775", "0.74201775", "0.74123937", "0.74108994", "0.7395338", "0.7395338", "0.7395338", "0.7395338", "0.7395338", "0.7395338", "0.7395338", "0.7395338", "0.73932946", "0.73932946", "0.73932946", "0.73932946", "0.73932946", "0.73932946", "0.73...
0.7439926
11
Render a line into the hidden node display.externalMeasured. Used when measurement is needed for a line that's not in the viewport.
function updateExternalMeasurement(cm, line) { line = visualLine(line); var lineN = lineNo(line); var view = cm.display.externalMeasured = new LineView(cm.doc, line, lineN); view.lineN = lineN; var built = view.built = buildLineContent(cm, view); view.text = built.pre; removeChildrenAndAdd(cm.display.lineMeasure, built.pre); return view }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function updateExternalMeasurement(cm, line) {\n line = visualLine(line);\n var lineN = lineNo(line);\n var view = cm.display.externalMeasured = new LineView(cm.doc, line, lineN);\n view.lineN = lineN;\n var built = view.built = buildLineContent(cm, view);\n view.text = built.pre;\n removeChil...
[ "0.75342", "0.7487335", "0.7484259", "0.74745804", "0.74694103", "0.74694103", "0.74694103", "0.74694103", "0.74694103", "0.74694103", "0.74694103", "0.74694103", "0.74650806", "0.7460484", "0.7460484", "0.7460484", "0.7459808", "0.7459808", "0.74311703", "0.74311703", "0.743...
0.7475978
14
Find a line view that corresponds to the given line number.
function findViewForLine(cm, lineN) { if (lineN >= cm.display.viewFrom && lineN < cm.display.viewTo) { return cm.display.view[findViewIndex(cm, lineN)] } var ext = cm.display.externalMeasured; if (ext && lineN >= ext.lineN && lineN < ext.lineN + ext.size) { return ext } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function findViewForLine(cm, lineN) {\n if (lineN >= cm.display.viewFrom && lineN < cm.display.viewTo)\n return cm.display.view[findViewIndex(cm, lineN)];\n var ext = cm.display.externalMeasured;\n if (ext && lineN >= ext.lineN && lineN < ext.lineN + ext.size)\n return ext;\n }", "function fi...
[ "0.7489299", "0.7489299", "0.7489299", "0.7489299", "0.7489299", "0.7489299", "0.7489299", "0.7489299", "0.74819213", "0.74819213", "0.74819213", "0.74819213", "0.74819213", "0.74819213", "0.74819213", "0.74819213", "0.74819213", "0.74819213", "0.74819213", "0.7480697", "0.74...
0.7497042
11
Measurement can be split in two steps, the setup work that applies to the whole line, and the measurement of the actual character. Functions like coordsChar, that need to do a lot of measurements in a row, can thus ensure that the setup work is only done once.
function prepareMeasureForLine(cm, line) { var lineN = lineNo(line); var view = findViewForLine(cm, lineN); if (view && !view.text) { view = null; } else if (view && view.changes) { updateLineForChanges(cm, view, lineN, getDimensions(cm)); cm.curOp.forceUpdate = true; } if (!view) { view = updateExternalMeasurement(cm, line); } var info = mapFromLineView(view, line, lineN); return { line: line, view: view, rect: null, map: info.map, cache: info.cache, before: info.before, hasHeights: false } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function prepareMeasureForLine(cm, line) {\n var lineN = lineNo(line);\n var view = findViewForLine(cm, lineN);\n\n if (view && !view.text) {\n view = null;\n } else if (view && view.changes) {\n updateLineForChanges(cm, view, lineN, getDimensions(cm));\n cm.curOp.forceUpdate = true;\n ...
[ "0.61007935", "0.6079905", "0.60480803", "0.5923985", "0.5918367", "0.5918367", "0.589796", "0.589796", "0.5888241", "0.5888241", "0.5888241", "0.5888241", "0.5888241", "0.5888241", "0.5888241", "0.5888241", "0.5888241", "0.5888241", "0.5888241", "0.5875767", "0.5873418", "...
0.5901451
17
Given a prepared measurement object, measures the position of an actual character (or fetches it from the cache).
function measureCharPrepared(cm, prepared, ch, bias, varHeight) { if (prepared.before) { ch = -1; } var key = ch + (bias || ""), found; if (prepared.cache.hasOwnProperty(key)) { found = prepared.cache[key]; } else { if (!prepared.rect) { prepared.rect = prepared.view.text.getBoundingClientRect(); } if (!prepared.hasHeights) { ensureLineHeights(cm, prepared.view, prepared.rect); prepared.hasHeights = true; } found = measureCharInner(cm, prepared, ch, bias); if (!found.bogus) { prepared.cache[key] = found; } } return {left: found.left, right: found.right, top: varHeight ? found.rtop : found.top, bottom: varHeight ? found.rbottom : found.bottom} }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function measureCharPrepared(cm, prepared, ch, bias, varHeight) {\n if (prepared.before) ch = -1;\n var key = ch + (bias || \"\"), found;\n if (prepared.cache.hasOwnProperty(key)) {\n found = prepared.cache[key];\n } else {\n if (!prepared.rect)\n prepared.rect = prepared.view.text.get...
[ "0.6956434", "0.6956434", "0.6956434", "0.6956434", "0.6956434", "0.6956434", "0.6956434", "0.6956434", "0.6944827", "0.6935705", "0.69277096", "0.6926043", "0.69001466", "0.6898976", "0.6898976", "0.6890307", "0.6890307", "0.6890307", "0.68885005", "0.68885005", "0.68885005"...
0.6947927
23
Work around problem with bounding client rects on ranges being returned incorrectly when zoomed on IE10 and below.
function maybeUpdateRectForZooming(measure, rect) { if (!window.screen || screen.logicalXDPI == null || screen.logicalXDPI == screen.deviceXDPI || !hasBadZoomedRects(measure)) { return rect } var scaleX = screen.logicalXDPI / screen.deviceXDPI; var scaleY = screen.logicalYDPI / screen.deviceYDPI; return {left: rect.left * scaleX, right: rect.right * scaleX, top: rect.top * scaleY, bottom: rect.bottom * scaleY} }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function getRangeBoundingClientRect(range){// \"Return a DOMRect object describing the smallest rectangle that includes\r\n\t// the first rectangle in list and all of the remaining rectangles of which\r\n\t// the height or width is not zero.\"\r\n\t// http://www.w3.org/TR/cssom-view/#dom-range-getboundingclientrec...
[ "0.6960293", "0.68528867", "0.67470604", "0.6737133", "0.6737133", "0.6730641", "0.6730641", "0.6730641", "0.6730641", "0.6730641", "0.6730641", "0.6730641", "0.6730641", "0.6730641", "0.6724661", "0.6724661", "0.6669039", "0.6669039", "0.66471195", "0.6547397", "0.65430623",...
0.0
-1
Coverts a box from "div" coords to another coordinate system. Context may be "window", "page", "div", or "local"./null.
function fromCoordSystem(cm, coords, context) { if (context == "div") { return coords } var left = coords.left, top = coords.top; // First move into "page" coordinate system if (context == "page") { left -= pageScrollX(); top -= pageScrollY(); } else if (context == "local" || !context) { var localBox = cm.display.sizer.getBoundingClientRect(); left += localBox.left; top += localBox.top; } var lineSpaceBox = cm.display.lineSpace.getBoundingClientRect(); return {left: left - lineSpaceBox.left, top: top - lineSpaceBox.top} }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function fromCoordSystem(cm, coords, context) {\n if (context == \"div\") return coords;\n var left = coords.left, top = coords.top;\n // First move into \"page\" coordinate system\n if (context == \"page\") {\n left -= pageScrollX();\n top -= pageScrollY();\n } else if (context == \"local...
[ "0.6558659", "0.6558659", "0.6558659", "0.6558659", "0.64615387", "0.6410469", "0.6360999", "0.63595706", "0.63595706", "0.63595706", "0.63595706", "0.63595706", "0.63595706", "0.63595706", "0.63595706", "0.63592327", "0.6344733", "0.63308084", "0.63308084", "0.6330061", "0.6...
0.633558
31
Returns a box for a given cursor position, which may have an 'other' property containing the position of the secondary cursor on a bidi boundary. A cursor Pos(line, char, "before") is on the same visual line as `char 1` and after `char 1` in writing order of `char 1` A cursor Pos(line, char, "after") is on the same visual line as `char` and before `char` in writing order of `char` Examples (uppercase letters are RTL, lowercase are LTR): Pos(0, 1, ...) before after ab a|b a|b aB a|B aB| Ab |Ab A|b AB B|A B|A Every position after the last character on a line is considered to stick to the last character on the line.
function cursorCoords(cm, pos, context, lineObj, preparedMeasure, varHeight) { lineObj = lineObj || getLine(cm.doc, pos.line); if (!preparedMeasure) { preparedMeasure = prepareMeasureForLine(cm, lineObj); } function get(ch, right) { var m = measureCharPrepared(cm, preparedMeasure, ch, right ? "right" : "left", varHeight); if (right) { m.left = m.right; } else { m.right = m.left; } return intoCoordSystem(cm, lineObj, m, context) } var order = getOrder(lineObj, cm.doc.direction), ch = pos.ch, sticky = pos.sticky; if (ch >= lineObj.text.length) { ch = lineObj.text.length; sticky = "before"; } else if (ch <= 0) { ch = 0; sticky = "after"; } if (!order) { return get(sticky == "before" ? ch - 1 : ch, sticky == "before") } function getBidi(ch, partPos, invert) { var part = order[partPos], right = part.level == 1; return get(invert ? ch - 1 : ch, right != invert) } var partPos = getBidiPartAt(order, ch, sticky); var other = bidiOther; var val = getBidi(ch, partPos, sticky == "before"); if (other != null) { val.other = getBidi(ch, other, sticky != "before"); } return val }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function cursorCoords(cm, pos, context, lineObj, preparedMeasure, varHeight) {\n lineObj = lineObj || getLine(cm.doc, pos.line);\n if (!preparedMeasure) { preparedMeasure = prepareMeasureForLine(cm, lineObj); }\n function get(ch, right) {\n var m = measureCharPrepared(cm, preparedMeasure, ch, right ? \"right...
[ "0.61579114", "0.61579114", "0.61579114", "0.61579114", "0.61579114", "0.61579114", "0.61579114", "0.61579114", "0.61579114", "0.61579114", "0.61518496", "0.6137645", "0.6125479", "0.609435", "0.6078191", "0.6078191", "0.6078191", "0.6078191", "0.6078191", "0.6078191", "0.607...
0.6194518
11
Used to cheaply estimate the coordinates for a position. Used for intermediate scroll updates.
function estimateCoords(cm, pos) { var left = 0; pos = clipPos(cm.doc, pos); if (!cm.options.lineWrapping) { left = charWidth(cm.display) * pos.ch; } var lineObj = getLine(cm.doc, pos.line); var top = heightAtLine(lineObj) + paddingTop(cm.display); return {left: left, right: left, top: top, bottom: top + lineObj.height} }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function calculate_coordinates () {\n\t }", "coordinates () {\n return this._position.coordinates()\n }", "function calcPos() {\n\t\t// Current coordinates\n\t\tvar coords = sphoords.getCoordinates();\n\t\tvar coords_deg = sphoords.getCoordinatesInDegrees();\n\n\t\t// Corresponding position on the sphere\n...
[ "0.69225216", "0.6853562", "0.6800712", "0.670349", "0.670349", "0.670349", "0.6692505", "0.6686151", "0.6673038", "0.6643865", "0.66430914", "0.6631961", "0.6619071", "0.6619071", "0.6619071", "0.6619071", "0.6619071", "0.6619071", "0.6619071", "0.6619071", "0.66069835", "...
0.660359
34
Positions returned by coordsChar contain some extra information. xRel is the relative x position of the input coordinates compared to the found position (so xRel > 0 means the coordinates are to the right of the character position, for example). When outside is true, that means the coordinates lie outside the line's vertical range.
function PosWithInfo(line, ch, sticky, outside, xRel) { var pos = Pos(line, ch, sticky); pos.xRel = xRel; if (outside) { pos.outside = outside; } return pos }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function PosWithInfo(line, ch, sticky, outside, xRel) {\n var pos = Pos(line, ch, sticky);\n pos.xRel = xRel;\n\n if (outside) {\n pos.outside = outside;\n }\n\n return pos;\n } // Compute the character position closest to the given coordinates.", "function coordsChar(cm, x, y) {\n var do...
[ "0.6486872", "0.6368994", "0.6368994", "0.6368994", "0.6334459", "0.63261276", "0.63261276", "0.63261276", "0.63261276", "0.63261276", "0.63261276", "0.63261276", "0.63261276", "0.6316018", "0.6310313", "0.6298065", "0.6298065", "0.6298065", "0.6298065", "0.6284752", "0.62847...
0.0
-1
Compute the character position closest to the given coordinates. Input must be lineSpacelocal ("div" coordinate system).
function coordsChar(cm, x, y) { var doc = cm.doc; y += cm.display.viewOffset; if (y < 0) { return PosWithInfo(doc.first, 0, null, -1, -1) } var lineN = lineAtHeight(doc, y), last = doc.first + doc.size - 1; if (lineN > last) { return PosWithInfo(doc.first + doc.size - 1, getLine(doc, last).text.length, null, 1, 1) } if (x < 0) { x = 0; } var lineObj = getLine(doc, lineN); for (;;) { var found = coordsCharInner(cm, lineObj, lineN, x, y); var collapsed = collapsedSpanAround(lineObj, found.ch + (found.xRel > 0 || found.outside > 0 ? 1 : 0)); if (!collapsed) { return found } var rangeEnd = collapsed.find(1); if (rangeEnd.line == lineN) { return rangeEnd } lineObj = getLine(doc, lineN = rangeEnd.line); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function PosWithInfo(line, ch, sticky, outside, xRel) {\n var pos = Pos(line, ch, sticky);\n pos.xRel = xRel;\n\n if (outside) {\n pos.outside = outside;\n }\n\n return pos;\n } // Compute the character position closest to the given coordinates.", "function coordsChar(cm, x, y) {\n var do...
[ "0.71382034", "0.6260421", "0.6260421", "0.6260421", "0.6260421", "0.62046796", "0.62046796", "0.62046796", "0.62046796", "0.62046796", "0.62046796", "0.62046796", "0.62046796", "0.61931807", "0.61761427", "0.6175584", "0.6170042", "0.6170042", "0.6162834", "0.6151725", "0.61...
0.60480213
48
Returns true if the given side of a box is after the given coordinates, in toptobottom, lefttoright order.
function boxIsAfter(box, x, y, left) { return box.bottom <= y ? false : box.top > y ? true : (left ? box.left : box.right) > x }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function boxIsAfter(box, x, y, left) {\n\t\t return box.bottom <= y ? false : box.top > y ? true : (left ? box.left : box.right) > x\n\t\t }", "function boxIsAfter(box, x, y, left) {\n return box.bottom <= y ? false : box.top > y ? true : (left ? box.left : box.right) > x;\n }", "function boxIsAfter(bo...
[ "0.80230653", "0.7990573", "0.7967614", "0.7967614", "0.7967614", "0.7967614", "0.7967614", "0.7967614", "0.7967614", "0.7967614", "0.7967614", "0.7967614", "0.79146224", "0.62625074", "0.62625074", "0.6129979", "0.605716", "0.5878628", "0.5862407", "0.5801529", "0.57982314",...
0.8012587
12
Compute the default text height.
function textHeight(display) { if (display.cachedTextHeight != null) { return display.cachedTextHeight } if (measureText == null) { measureText = elt("pre", null, "CodeMirror-line-like"); // Measure a bunch of lines, for browsers that compute // fractional heights. for (var i = 0; i < 49; ++i) { measureText.appendChild(document.createTextNode("x")); measureText.appendChild(elt("br")); } measureText.appendChild(document.createTextNode("x")); } removeChildrenAndAdd(display.measure, measureText); var height = measureText.offsetHeight / 50; if (height > 3) { display.cachedTextHeight = height; } removeChildren(display.measure); return height || 1 }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function textHeight(display) {\n if (display.cachedTextHeight != null) {\n return display.cachedTextHeight;\n }\n\n if (measureText == null) {\n measureText = elt(\"pre\", null, \"CodeMirror-line-like\"); // Measure a bunch of lines, for browsers that compute\n // fractional heights.\n\n ...
[ "0.7177307", "0.69143856", "0.6897133", "0.68873185", "0.68799967", "0.6806309", "0.6806309", "0.6806309", "0.6806309", "0.6806309", "0.6793898", "0.6793898", "0.6793898", "0.6793898", "0.6793898", "0.6793898", "0.6793898", "0.6793898", "0.6777712", "0.672439", "0.67172724", ...
0.68935585
12
Compute the default character width.
function charWidth(display) { if (display.cachedCharWidth != null) { return display.cachedCharWidth } var anchor = elt("span", "xxxxxxxxxx"); var pre = elt("pre", [anchor], "CodeMirror-line-like"); removeChildrenAndAdd(display.measure, pre); var rect = anchor.getBoundingClientRect(), width = (rect.right - rect.left) / 10; if (width > 2) { display.cachedCharWidth = width; } return width || 10 }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "get defaultCharacterWidth() { return this.viewState.heightOracle.charWidth; }", "function charWidth(display) {\n\t\t if (display.cachedCharWidth != null) return display.cachedCharWidth;\n\t\t var anchor = elt(\"span\", \"xxxxxxxxxx\");\n\t\t var pre = elt(\"pre\", [anchor]);\n\t\t removeChildrenAndAd...
[ "0.7920131", "0.7037969", "0.7021818", "0.7021073", "0.7021073", "0.7021073", "0.70129645", "0.70129645", "0.70129645", "0.70129645", "0.70129645", "0.7000035", "0.7000035", "0.7000035", "0.7000035", "0.7000035", "0.7000035", "0.7000035", "0.7000035", "0.6951675", "0.686542",...
0.6948909
29
Do a bulkread of the DOM positions and sizes needed to draw the view, so that we don't interleave reading and writing to the DOM.
function getDimensions(cm) { var d = cm.display, left = {}, width = {}; var gutterLeft = d.gutters.clientLeft; for (var n = d.gutters.firstChild, i = 0; n; n = n.nextSibling, ++i) { var id = cm.display.gutterSpecs[i].className; left[id] = n.offsetLeft + n.clientLeft + gutterLeft; width[id] = n.clientWidth; } return {fixedPos: compensateForHScroll(d), gutterTotalWidth: d.gutters.offsetWidth, gutterLeft: left, gutterWidth: width, wrapperWidth: d.wrapper.clientWidth} }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "_updateRendering() {\n this._domElement.style.width = this._width + 'px'\n this._domElement.style.height = this._height + 'px'\n this._adjustAll()\n }", "draw() {\n if (this._page !== currentPage) {\n return;\n }\n this.drawRectangles();\n if (!isReady) {\n ...
[ "0.5897446", "0.58449394", "0.57988375", "0.5757708", "0.57276994", "0.5712541", "0.5673291", "0.5610675", "0.5602419", "0.5594531", "0.5583795", "0.54926413", "0.5485577", "0.5463084", "0.54616827", "0.54176617", "0.54121333", "0.537817", "0.53698725", "0.53656584", "0.53627...
0.0
-1
Computes display.scroller.scrollLeft + display.gutters.offsetWidth, but using getBoundingClientRect to get a subpixelaccurate result.
function compensateForHScroll(display) { return display.scroller.getBoundingClientRect().left - display.sizer.getBoundingClientRect().left }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "get getBoundingClientRects() {\n if (!this._boundingClientRects) {\n const innerBox = this._innerBoxHelper.nativeElement.getBoundingClientRect();\n const clientRect = this.element.getBoundingClientRect();\n this._boundingClientRects = {\n clientRect,\n ...
[ "0.6243216", "0.6220974", "0.6219117", "0.6219117", "0.6219117", "0.6219117", "0.6219117", "0.6219117", "0.6219117", "0.6219117", "0.6219117", "0.6219117", "0.6219117", "0.6219117", "0.6219117", "0.6184225", "0.6179456", "0.6166653", "0.6166653", "0.6166653", "0.6166653", "...
0.62709266
11
Returns a function that estimates the height of a line, to use as first approximation until the line becomes visible (and is thus properly measurable).
function estimateHeight(cm) { var th = textHeight(cm.display), wrapping = cm.options.lineWrapping; var perLine = wrapping && Math.max(5, cm.display.scroller.clientWidth / charWidth(cm.display) - 3); return function (line) { if (lineIsHidden(cm.doc, line)) { return 0 } var widgetsHeight = 0; if (line.widgets) { for (var i = 0; i < line.widgets.length; i++) { if (line.widgets[i].height) { widgetsHeight += line.widgets[i].height; } } } if (wrapping) { return widgetsHeight + (Math.ceil(line.text.length / perLine) || 1) * th } else { return widgetsHeight + th } } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function heightAtLine(lineObj) {\n\t\t lineObj = visualLine(lineObj);\n\n\t\t var h = 0, chunk = lineObj.parent;\n\t\t for (var i = 0; i < chunk.lines.length; ++i) {\n\t\t var line = chunk.lines[i];\n\t\t if (line == lineObj) { break }\n\t\t else { h += line.height; }\n\t\t }\n\t\t fo...
[ "0.75962454", "0.75941265", "0.7518054", "0.7507497", "0.7507497", "0.74446887", "0.74446887", "0.74446887", "0.74446887", "0.74446887", "0.74446887", "0.74446887", "0.74446887", "0.74446887", "0.74446887", "0.74446887", "0.74446887", "0.74446887", "0.74446887", "0.74446887", ...
0.7124381
72
Given a mouse event, find the corresponding position. If liberal is false, it checks whether a gutter or scrollbar was clicked, and returns null if it was. forRect is used by rectangular selections, and tries to estimate a character position even for coordinates beyond the right of the text.
function posFromMouse(cm, e, liberal, forRect) { var display = cm.display; if (!liberal && e_target(e).getAttribute("cm-not-content") == "true") { return null } var x, y, space = display.lineSpace.getBoundingClientRect(); // Fails unpredictably on IE[67] when mouse is dragged around quickly. try { x = e.clientX - space.left; y = e.clientY - space.top; } catch (e$1) { return null } var coords = coordsChar(cm, x, y), line; if (forRect && coords.xRel > 0 && (line = getLine(cm.doc, coords.line).text).length == coords.ch) { var colDiff = countColumn(line, line.length, cm.options.tabSize) - line.length; coords = Pos(coords.line, Math.max(0, Math.round((x - paddingH(cm.display).left) / charWidth(cm.display)) - colDiff)); } return coords }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function posFromMouse(cm, e, liberal, forRect) {\n var display = cm.display;\n if (!liberal) {\n var target = e_target(e);\n if (target == display.scrollbarH || target == display.scrollbarV ||\n target == display.scrollbarFiller || target == display.gutterFiller) return null;\n }\n v...
[ "0.77090347", "0.77090347", "0.77090347", "0.77090347", "0.76392555", "0.75154114", "0.75154114", "0.74738806", "0.74738806", "0.74582624", "0.74582624", "0.7457641", "0.7457641", "0.7457641", "0.7457641", "0.7457641", "0.7457641", "0.7457641", "0.7457641", "0.7455493", "0.74...
0.7435852
39
Find the view element corresponding to a given line. Return null when the line isn't visible.
function findViewIndex(cm, n) { if (n >= cm.display.viewTo) { return null } n -= cm.display.viewFrom; if (n < 0) { return null } var view = cm.display.view; for (var i = 0; i < view.length; i++) { n -= view[i].size; if (n < 0) { return i } } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function findViewForLine(cm, lineN) {\n if (lineN >= cm.display.viewFrom && lineN < cm.display.viewTo)\n { return cm.display.view[findViewIndex(cm, lineN)] }\n var ext = cm.display.externalMeasured;\n if (ext && lineN >= ext.lineN && lineN < ext.lineN + ext.size)\n { return ext }\n }", "funct...
[ "0.700917", "0.700917", "0.700917", "0.700917", "0.700917", "0.700917", "0.700917", "0.700917", "0.700917", "0.700917", "0.700917", "0.700917", "0.700917", "0.700917", "0.700917", "0.700917", "0.700917", "0.6991396", "0.6991396", "0.6991396", "0.6991396", "0.6991396", "0....
0.0
-1
Updates the display.view data structure for a given change to the document. From and to are in prechange coordinates. Lendiff is the amount of lines added or subtracted by the change. This is used for changes that span multiple lines, or change the way lines are divided into visual lines. regLineChange (below) registers singleline changes.
function regChange(cm, from, to, lendiff) { if (from == null) { from = cm.doc.first; } if (to == null) { to = cm.doc.first + cm.doc.size; } if (!lendiff) { lendiff = 0; } var display = cm.display; if (lendiff && to < display.viewTo && (display.updateLineNumbers == null || display.updateLineNumbers > from)) { display.updateLineNumbers = from; } cm.curOp.viewChanged = true; if (from >= display.viewTo) { // Change after if (sawCollapsedSpans && visualLineNo(cm.doc, from) < display.viewTo) { resetView(cm); } } else if (to <= display.viewFrom) { // Change before if (sawCollapsedSpans && visualLineEndNo(cm.doc, to + lendiff) > display.viewFrom) { resetView(cm); } else { display.viewFrom += lendiff; display.viewTo += lendiff; } } else if (from <= display.viewFrom && to >= display.viewTo) { // Full overlap resetView(cm); } else if (from <= display.viewFrom) { // Top overlap var cut = viewCuttingPoint(cm, to, to + lendiff, 1); if (cut) { display.view = display.view.slice(cut.index); display.viewFrom = cut.lineN; display.viewTo += lendiff; } else { resetView(cm); } } else if (to >= display.viewTo) { // Bottom overlap var cut$1 = viewCuttingPoint(cm, from, from, -1); if (cut$1) { display.view = display.view.slice(0, cut$1.index); display.viewTo = cut$1.lineN; } else { resetView(cm); } } else { // Gap in the middle var cutTop = viewCuttingPoint(cm, from, from, -1); var cutBot = viewCuttingPoint(cm, to, to + lendiff, 1); if (cutTop && cutBot) { display.view = display.view.slice(0, cutTop.index) .concat(buildViewArray(cm, cutTop.lineN, cutBot.lineN)) .concat(display.view.slice(cutBot.index)); display.viewTo += lendiff; } else { resetView(cm); } } var ext = display.externalMeasured; if (ext) { if (to < ext.lineN) { ext.lineN += lendiff; } else if (from < ext.lineN + ext.size) { display.externalMeasured = null; } } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function regChange(cm, from, to, lendiff) {\n if (from == null) {\n from = cm.doc.first;\n }\n\n if (to == null) {\n to = cm.doc.first + cm.doc.size;\n }\n\n if (!lendiff) {\n lendiff = 0;\n }\n\n var display = cm.display;\n\n if (lendiff && to < display.viewTo && (display.up...
[ "0.7041917", "0.70200956", "0.7002636", "0.7002636", "0.6970039", "0.6949149", "0.6944299", "0.6944299", "0.6944299", "0.6944299", "0.6944299", "0.6944299", "0.6944299", "0.6944299", "0.69192004", "0.6917124", "0.6862251", "0.6862251", "0.6862251", "0.6862251", "0.6862251", ...
0.6954716
16
Register a change to a single line. Type must be one of "text", "gutter", "class", "widget"
function regLineChange(cm, line, type) { cm.curOp.viewChanged = true; var display = cm.display, ext = cm.display.externalMeasured; if (ext && line >= ext.lineN && line < ext.lineN + ext.size) { display.externalMeasured = null; } if (line < display.viewFrom || line >= display.viewTo) { return } var lineView = display.view[findViewIndex(cm, line)]; if (lineView.node == null) { return } var arr = lineView.changes || (lineView.changes = []); if (indexOf(arr, type) == -1) { arr.push(type); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function LineChange (type, text) {\n this.type = type // ADDED, REMOVED, UNMODIFIED\n this.text = text\n}", "function regLineChange(cm, line, type) {\n cm.curOp.viewChanged = true\n var display = cm.display, ext = cm.display.externalMeasured\n if (ext && line >= ext.lineN && line < ext.lineN + ext.siz...
[ "0.7580796", "0.7120189", "0.7120189", "0.7101667", "0.7101667", "0.7101667", "0.7101667", "0.7101667", "0.7101667", "0.7101667", "0.7101667", "0.7101667", "0.7101667", "0.7101667", "0.7096139", "0.7096139", "0.7096139", "0.7096139", "0.7096139", "0.7096139", "0.7096139", "...
0.70884424
37
Force the view to cover a given range, adding empty view element or clipping off existing ones as needed.
function adjustView(cm, from, to) { var display = cm.display, view = display.view; if (view.length == 0 || from >= display.viewTo || to <= display.viewFrom) { display.view = buildViewArray(cm, from, to); display.viewFrom = from; } else { if (display.viewFrom > from) { display.view = buildViewArray(cm, from, display.viewFrom).concat(display.view); } else if (display.viewFrom < from) { display.view = display.view.slice(findViewIndex(cm, from)); } display.viewFrom = from; if (display.viewTo < to) { display.view = display.view.concat(buildViewArray(cm, display.viewTo, to)); } else if (display.viewTo > to) { display.view = display.view.slice(0, findViewIndex(cm, to)); } } display.viewTo = to; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "constructor(viewOf, qmin, qmax) {\n super(viewOf, (field, colLabel, colSchema, colData, df) =>\n _clipAnnoMatrix(field, colLabel, colSchema, colData, df, qmin, qmax)\n );\n this.isClipped = true;\n this.clipRange = [qmin, qmax];\n Object.seal(this);\n }", "setRenderedRange(range) {\n if (...
[ "0.5556946", "0.5472256", "0.5384595", "0.537245", "0.5349878", "0.53442", "0.53263646", "0.5308165", "0.52663255", "0.52513677", "0.52321917", "0.5231704", "0.52292764", "0.5206579", "0.5195497", "0.5195497", "0.5187255", "0.5187255", "0.5183682", "0.5183682", "0.51568943", ...
0.46898982
72
Count the number of lines in the view whose DOM representation is out of date (or nonexistent).
function countDirtyView(cm) { var view = cm.display.view, dirty = 0; for (var i = 0; i < view.length; i++) { var lineView = view[i]; if (!lineView.hidden && (!lineView.node || lineView.changes)) { ++dirty; } } return dirty }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function countLines() {\n let page = document.getElementsByClassName(\"kix-zoomdocumentplugin-outer\")[0];\n if (page == null) {\n return (\"Element does not exist on the document.\")\n }\n let lineCount = 0;\n const pageText = page.innerText;\n\n for (let i = 0; i < pageText.length; i++) ...
[ "0.64792055", "0.639454", "0.639454", "0.639454", "0.639454", "0.639454", "0.639454", "0.639454", "0.639454", "0.63799185", "0.6371316", "0.636951", "0.6367281", "0.6367281", "0.636076", "0.636076", "0.636076", "0.636076", "0.636076", "0.636076", "0.636076", "0.636076", "...
0.6395247
14
Draws a cursor for the given range
function drawSelectionCursor(cm, head, output) { var pos = cursorCoords(cm, head, "div", null, null, !cm.options.singleCursorHeightPerLine); var cursor = output.appendChild(elt("div", "\u00a0", "CodeMirror-cursor")); cursor.style.left = pos.left + "px"; cursor.style.top = pos.top + "px"; cursor.style.height = Math.max(0, pos.bottom - pos.top) * cm.options.cursorHeight + "px"; if (pos.other) { // Secondary cursor, shown when on a 'jump' in bi-directional text var otherCursor = output.appendChild(elt("div", "\u00a0", "CodeMirror-cursor CodeMirror-secondarycursor")); otherCursor.style.display = ""; otherCursor.style.left = pos.other.left + "px"; otherCursor.style.top = pos.other.top + "px"; otherCursor.style.height = (pos.other.bottom - pos.other.top) * .85 + "px"; } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function drawSelectionCursor(cm, range, output) {\n var pos = cursorCoords(cm, range.head, \"div\", null, null, !cm.options.singleCursorHeightPerLine);\n\n var cursor = output.appendChild(elt(\"div\", \"\\u00a0\", \"CodeMirror-cursor\"));\n cursor.style.left = pos.left + \"px\";\n cursor.style.top = po...
[ "0.69801736", "0.69801736", "0.69801736", "0.69801736", "0.69801736", "0.69801736", "0.69801736", "0.6950206", "0.68451244", "0.6837227", "0.6837227", "0.6837227", "0.6837227", "0.6835953", "0.6835953", "0.6835953", "0.6835953", "0.68251777", "0.68251777", "0.6819444", "0.680...
0.6168477
75
Draws the given range as a highlighted selection
function drawSelectionRange(cm, range, output) { var display = cm.display, doc = cm.doc; var fragment = document.createDocumentFragment(); var padding = paddingH(cm.display), leftSide = padding.left; var rightSide = Math.max(display.sizerWidth, displayWidth(cm) - display.sizer.offsetLeft) - padding.right; var docLTR = doc.direction == "ltr"; function add(left, top, width, bottom) { if (top < 0) { top = 0; } top = Math.round(top); bottom = Math.round(bottom); fragment.appendChild(elt("div", null, "CodeMirror-selected", ("position: absolute; left: " + left + "px;\n top: " + top + "px; width: " + (width == null ? rightSide - left : width) + "px;\n height: " + (bottom - top) + "px"))); } function drawForLine(line, fromArg, toArg) { var lineObj = getLine(doc, line); var lineLen = lineObj.text.length; var start, end; function coords(ch, bias) { return charCoords(cm, Pos(line, ch), "div", lineObj, bias) } function wrapX(pos, dir, side) { var extent = wrappedLineExtentChar(cm, lineObj, null, pos); var prop = (dir == "ltr") == (side == "after") ? "left" : "right"; var ch = side == "after" ? extent.begin : extent.end - (/\s/.test(lineObj.text.charAt(extent.end - 1)) ? 2 : 1); return coords(ch, prop)[prop] } var order = getOrder(lineObj, doc.direction); iterateBidiSections(order, fromArg || 0, toArg == null ? lineLen : toArg, function (from, to, dir, i) { var ltr = dir == "ltr"; var fromPos = coords(from, ltr ? "left" : "right"); var toPos = coords(to - 1, ltr ? "right" : "left"); var openStart = fromArg == null && from == 0, openEnd = toArg == null && to == lineLen; var first = i == 0, last = !order || i == order.length - 1; if (toPos.top - fromPos.top <= 3) { // Single line var openLeft = (docLTR ? openStart : openEnd) && first; var openRight = (docLTR ? openEnd : openStart) && last; var left = openLeft ? leftSide : (ltr ? fromPos : toPos).left; var right = openRight ? rightSide : (ltr ? toPos : fromPos).right; add(left, fromPos.top, right - left, fromPos.bottom); } else { // Multiple lines var topLeft, topRight, botLeft, botRight; if (ltr) { topLeft = docLTR && openStart && first ? leftSide : fromPos.left; topRight = docLTR ? rightSide : wrapX(from, dir, "before"); botLeft = docLTR ? leftSide : wrapX(to, dir, "after"); botRight = docLTR && openEnd && last ? rightSide : toPos.right; } else { topLeft = !docLTR ? leftSide : wrapX(from, dir, "before"); topRight = !docLTR && openStart && first ? rightSide : fromPos.right; botLeft = !docLTR && openEnd && last ? leftSide : toPos.left; botRight = !docLTR ? rightSide : wrapX(to, dir, "after"); } add(topLeft, fromPos.top, topRight - topLeft, fromPos.bottom); if (fromPos.bottom < toPos.top) { add(leftSide, fromPos.bottom, null, toPos.top); } add(botLeft, toPos.top, botRight - botLeft, toPos.bottom); } if (!start || cmpCoords(fromPos, start) < 0) { start = fromPos; } if (cmpCoords(toPos, start) < 0) { start = toPos; } if (!end || cmpCoords(fromPos, end) < 0) { end = fromPos; } if (cmpCoords(toPos, end) < 0) { end = toPos; } }); return {start: start, end: end} } var sFrom = range.from(), sTo = range.to(); if (sFrom.line == sTo.line) { drawForLine(sFrom.line, sFrom.ch, sTo.ch); } else { var fromLine = getLine(doc, sFrom.line), toLine = getLine(doc, sTo.line); var singleVLine = visualLine(fromLine) == visualLine(toLine); var leftEnd = drawForLine(sFrom.line, sFrom.ch, singleVLine ? fromLine.text.length + 1 : null).end; var rightStart = drawForLine(sTo.line, singleVLine ? 0 : null, sTo.ch).start; if (singleVLine) { if (leftEnd.top < rightStart.top - 2) { add(leftEnd.right, leftEnd.top, null, leftEnd.bottom); add(leftSide, rightStart.top, rightStart.left, rightStart.bottom); } else { add(leftEnd.right, leftEnd.top, rightStart.left - leftEnd.right, leftEnd.bottom); } } if (leftEnd.bottom < rightStart.top) { add(leftSide, leftEnd.bottom, null, rightStart.top); } } output.appendChild(fragment); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function drawSelectionRange(cm, range, output) {\n\t\t var display = cm.display, doc = cm.doc;\n\t\t var fragment = document.createDocumentFragment();\n\t\t var padding = paddingH(cm.display), leftSide = padding.left;\n\t\t var rightSide = Math.max(display.sizerWidth, displayWidth(cm) - display.sizer.o...
[ "0.75184023", "0.75181", "0.75181", "0.75181", "0.75181", "0.7513441", "0.74920034", "0.74920034", "0.74920034", "0.74920034", "0.7467525", "0.74552387", "0.7454378", "0.7444069", "0.7444069", "0.7443119", "0.7443119", "0.7443119", "0.7443119", "0.7443119", "0.7443119", "0....
0.74210626
43
Read the actual heights of the rendered lines, and update their stored heights to match.
function updateHeightsInViewport(cm) { var display = cm.display; var prevBottom = display.lineDiv.offsetTop; for (var i = 0; i < display.view.length; i++) { var cur = display.view[i], wrapping = cm.options.lineWrapping; var height = (void 0), width = 0; if (cur.hidden) { continue } if (ie && ie_version < 8) { var bot = cur.node.offsetTop + cur.node.offsetHeight; height = bot - prevBottom; prevBottom = bot; } else { var box = cur.node.getBoundingClientRect(); height = box.bottom - box.top; // Check that lines don't extend past the right of the current // editor width if (!wrapping && cur.text.firstChild) { width = cur.text.firstChild.getBoundingClientRect().right - box.left - 1; } } var diff = cur.line.height - height; if (diff > .005 || diff < -.005) { updateLineHeight(cur.line, height); updateWidgetHeight(cur.line); if (cur.rest) { for (var j = 0; j < cur.rest.length; j++) { updateWidgetHeight(cur.rest[j]); } } } if (width > cm.display.sizerWidth) { var chWidth = Math.ceil(width / charWidth(cm.display)); if (chWidth > cm.display.maxLineLength) { cm.display.maxLineLength = chWidth; cm.display.maxLine = cur.line; cm.display.maxLineChanged = true; } } } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function lineHeight(){\n\t\thistoryLine.each(function(index, element){\n\t\t\tif(index == $('.line').length - 1){\n\t\t\t\treturn false;\n\t\t\t} else{\n\t\t\t\tvar thisBlock = $(this).closest('.history-item').height()/2;\n\t\t\t\tvar nextBlock = $(this).closest('.history-item').next().height()/2;\n\t\t\t\tvar h =...
[ "0.6847615", "0.6575622", "0.6532162", "0.6532162", "0.6532162", "0.6532162", "0.6532162", "0.6532162", "0.6532162", "0.6520374", "0.6517116", "0.6517116", "0.6511045", "0.6511045", "0.6511045", "0.6507662", "0.64917886", "0.64917886", "0.64917886", "0.6491407", "0.64767325",...
0.0
-1
Read and store the height of line widgets associated with the given line.
function updateWidgetHeight(line) { if (line.widgets) { for (var i = 0; i < line.widgets.length; ++i) { var w = line.widgets[i], parent = w.node.parentNode; if (parent) { w.height = parent.offsetHeight; } } } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function updateWidgetHeight(line) {\n if (line.widgets) for (var i = 0; i < line.widgets.length; ++i)\n line.widgets[i].height = line.widgets[i].node.offsetHeight;\n }", "function updateWidgetHeight(line) {\n if (line.widgets) for (var i = 0; i < line.widgets.length; ++i)\n line.widgets[i].heigh...
[ "0.79593384", "0.79593384", "0.79593384", "0.79593384", "0.79593384", "0.79593384", "0.79593384", "0.795811", "0.79317176", "0.79317176", "0.7928275", "0.7913349", "0.7913349", "0.7913349", "0.7899005", "0.7899005", "0.7899005", "0.7899005", "0.7899005", "0.7899005", "0.78990...
0.7864872
39
Compute the lines that are visible in a given viewport (defaults the the current scroll position). viewport may contain top, height, and ensure (see op.scrollToPos) properties.
function visibleLines(display, doc, viewport) { var top = viewport && viewport.top != null ? Math.max(0, viewport.top) : display.scroller.scrollTop; top = Math.floor(top - paddingTop(display)); var bottom = viewport && viewport.bottom != null ? viewport.bottom : top + display.wrapper.clientHeight; var from = lineAtHeight(doc, top), to = lineAtHeight(doc, bottom); // Ensure is a {from: {line, ch}, to: {line, ch}} object, and // forces those lines into the viewport (if possible). if (viewport && viewport.ensure) { var ensureFrom = viewport.ensure.from.line, ensureTo = viewport.ensure.to.line; if (ensureFrom < from) { from = ensureFrom; to = lineAtHeight(doc, heightAtLine(getLine(doc, ensureFrom)) + display.wrapper.clientHeight); } else if (Math.min(ensureTo, doc.lastLine()) >= to) { from = lineAtHeight(doc, heightAtLine(getLine(doc, ensureTo)) - display.wrapper.clientHeight); to = ensureTo; } } return {from: from, to: Math.max(to, from + 1)} }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function visibleLines(display, doc, viewport) {\n\t var top = viewport && viewport.top != null ? Math.max(0, viewport.top) : display.scroller.scrollTop;\n\t top = Math.floor(top - paddingTop(display));\n\t var bottom = viewport && viewport.bottom != null ? viewport.bottom : top + display.wrapper.clientHei...
[ "0.74272996", "0.74230975", "0.74230975", "0.7401155", "0.73803174", "0.7377409", "0.7353546", "0.7353546", "0.7353546", "0.7353546", "0.731544", "0.7312608", "0.7312608", "0.7312608", "0.7312608", "0.7312608", "0.7312608", "0.7312608", "0.7312608", "0.7312608", "0.7312608", ...
0.7355309
22
SCROLLING THINGS INTO VIEW If an editor sits on the top or bottom of the window, partially scrolled out of view, this ensures that the cursor is visible.
function maybeScrollWindow(cm, rect) { if (signalDOMEvent(cm, "scrollCursorIntoView")) { return } var display = cm.display, box = display.sizer.getBoundingClientRect(), doScroll = null; if (rect.top + box.top < 0) { doScroll = true; } else if (rect.bottom + box.top > (window.innerHeight || document.documentElement.clientHeight)) { doScroll = false; } if (doScroll != null && !phantom) { var scrollNode = elt("div", "\u200b", null, ("position: absolute;\n top: " + (rect.top - display.viewOffset - paddingTop(cm.display)) + "px;\n height: " + (rect.bottom - rect.top + scrollGap(cm) + display.barHeight) + "px;\n left: " + (rect.left) + "px; width: " + (Math.max(2, rect.right - rect.left)) + "px;")); cm.display.lineSpace.appendChild(scrollNode); scrollNode.scrollIntoView(doScroll); cm.display.lineSpace.removeChild(scrollNode); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "updateView(selection, editor) {\n let path = editor.getPath();\n let i = 0;\n // We check that the selection is actually a point\n // We use selection because for the moment we think it's better not to update the view when the user selects a large part of text\n if (\n selection.newScreenRange....
[ "0.6382399", "0.62962425", "0.61368537", "0.6136764", "0.60798055", "0.6077412", "0.6056208", "0.60094726", "0.60094726", "0.60094726", "0.6004994", "0.5907688", "0.5907688", "0.5907688", "0.5907688", "0.5907688", "0.5907688", "0.5907688", "0.59062874", "0.5891157", "0.589115...
0.5791165
66
Scroll a given position into view (immediately), verifying that it actually became visible (as line heights are accurately measured, the position of something may 'drift' during drawing).
function scrollPosIntoView(cm, pos, end, margin) { if (margin == null) { margin = 0; } var rect; if (!cm.options.lineWrapping && pos == end) { // Set pos and end to the cursor positions around the character pos sticks to // If pos.sticky == "before", that is around pos.ch - 1, otherwise around pos.ch // If pos == Pos(_, 0, "before"), pos and end are unchanged pos = pos.ch ? Pos(pos.line, pos.sticky == "before" ? pos.ch - 1 : pos.ch, "after") : pos; end = pos.sticky == "before" ? Pos(pos.line, pos.ch + 1, "before") : pos; } for (var limit = 0; limit < 5; limit++) { var changed = false; var coords = cursorCoords(cm, pos); var endCoords = !end || end == pos ? coords : cursorCoords(cm, end); rect = {left: Math.min(coords.left, endCoords.left), top: Math.min(coords.top, endCoords.top) - margin, right: Math.max(coords.left, endCoords.left), bottom: Math.max(coords.bottom, endCoords.bottom) + margin}; var scrollPos = calculateScrollPos(cm, rect); var startTop = cm.doc.scrollTop, startLeft = cm.doc.scrollLeft; if (scrollPos.scrollTop != null) { updateScrollTop(cm, scrollPos.scrollTop); if (Math.abs(cm.doc.scrollTop - startTop) > 1) { changed = true; } } if (scrollPos.scrollLeft != null) { setScrollLeft(cm, scrollPos.scrollLeft); if (Math.abs(cm.doc.scrollLeft - startLeft) > 1) { changed = true; } } if (!changed) { break } } return rect }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function ifVisible(pos) {\n var bottomLine = html.clientHeight + html.scrollTop;\n\n if (pos < bottomLine) {\n return true;\n }\n }", "_checkScrollPosition() {\n\n var isVisible = this._isVisible;\n var isAtBottom = this._isAtBottom;\n var scrollTop = typeof window.scrollY !== 'undefined'...
[ "0.6941846", "0.6569337", "0.62933385", "0.61800575", "0.61191726", "0.6019441", "0.59948593", "0.597039", "0.5944806", "0.58684546", "0.58561337", "0.5852364", "0.58486384", "0.58313596", "0.5824516", "0.5813296", "0.5812549", "0.57976955", "0.57970214", "0.5781929", "0.5778...
0.0
-1
Scroll a given set of coordinates into view (immediately).
function scrollIntoView(cm, rect) { var scrollPos = calculateScrollPos(cm, rect); if (scrollPos.scrollTop != null) { updateScrollTop(cm, scrollPos.scrollTop); } if (scrollPos.scrollLeft != null) { setScrollLeft(cm, scrollPos.scrollLeft); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function scrollIntoView(cm, x1, y1, x2, y2) {\n\t\t var scrollPos = calculateScrollPos(cm, x1, y1, x2, y2);\n\t\t if (scrollPos.scrollTop != null) setScrollTop(cm, scrollPos.scrollTop);\n\t\t if (scrollPos.scrollLeft != null) setScrollLeft(cm, scrollPos.scrollLeft);\n\t\t }", "function scrollIntoView(c...
[ "0.6669822", "0.6622224", "0.6622224", "0.6622224", "0.65621066", "0.65621066", "0.65621066", "0.65621066", "0.65621066", "0.65621066", "0.65621066", "0.6510055", "0.64823157", "0.61906785", "0.61906785", "0.61906785", "0.61906785", "0.6184818", "0.61735964", "0.6156998", "0....
0.5908387
39
Calculate a new scroll position needed to scroll the given rectangle into view. Returns an object with scrollTop and scrollLeft properties. When these are undefined, the vertical/horizontal position does not need to be adjusted.
function calculateScrollPos(cm, rect) { var display = cm.display, snapMargin = textHeight(cm.display); if (rect.top < 0) { rect.top = 0; } var screentop = cm.curOp && cm.curOp.scrollTop != null ? cm.curOp.scrollTop : display.scroller.scrollTop; var screen = displayHeight(cm), result = {}; if (rect.bottom - rect.top > screen) { rect.bottom = rect.top + screen; } var docBottom = cm.doc.height + paddingVert(display); var atTop = rect.top < snapMargin, atBottom = rect.bottom > docBottom - snapMargin; if (rect.top < screentop) { result.scrollTop = atTop ? 0 : rect.top; } else if (rect.bottom > screentop + screen) { var newTop = Math.min(rect.top, (atBottom ? docBottom : rect.bottom) - screen); if (newTop != screentop) { result.scrollTop = newTop; } } var screenleft = cm.curOp && cm.curOp.scrollLeft != null ? cm.curOp.scrollLeft : display.scroller.scrollLeft; var screenw = displayWidth(cm) - (cm.options.fixedGutter ? display.gutters.offsetWidth : 0); var tooWide = rect.right - rect.left > screenw; if (tooWide) { rect.right = rect.left + screenw; } if (rect.left < 10) { result.scrollLeft = 0; } else if (rect.left < screenleft) { result.scrollLeft = Math.max(0, rect.left - (tooWide ? 0 : 10)); } else if (rect.right > screenw + screenleft - 3) { result.scrollLeft = rect.right + (tooWide ? 0 : 10) - screenw; } return result }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function getPosition(rect) {\r\n return {\r\n \"top\" : window.scrollY + Math.round(rect.top),\r\n \"right\" : Math.round(rect.left + rect.width),\r\n \"bottom\" : window.scrollY + Math.round(rect.top + rect.height),\r\n \"left\" ...
[ "0.65926", "0.6490647", "0.6490647", "0.6490647", "0.6490647", "0.6490647", "0.6490647", "0.64872724", "0.6467502", "0.6460425", "0.6447043", "0.64178056", "0.64178056", "0.64178056", "0.64178056", "0.64178056", "0.64178056", "0.64178056", "0.64178056", "0.64178056", "0.64178...
0.6590855
10
Store a relative adjustment to the scroll position in the current operation (to be applied when the operation finishes).
function addToScrollTop(cm, top) { if (top == null) { return } resolveScrollToPos(cm); cm.curOp.scrollTop = (cm.curOp.scrollTop == null ? cm.doc.scrollTop : cm.curOp.scrollTop) + top; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "saveScrollPosition({ commit }, value) {\n commit('setScrollPosition', value)\n }", "function addToScrollPos(cm, left, top) {\n\t if (left != null || top != null) resolveScrollToPos(cm);\n\t if (left != null)\n\t cm.curOp.scrollLeft = (cm.curOp.scrollLeft == null ? cm.doc.scrollLeft : cm.curOp.scro...
[ "0.6434745", "0.6315518", "0.6315518", "0.6315518", "0.6271345", "0.6246111", "0.6246111", "0.6246111", "0.6246111", "0.6246111", "0.6246111", "0.6246111", "0.6217396", "0.6204886", "0.6168477", "0.6106627", "0.60856074", "0.60713035", "0.60713035", "0.60713035", "0.606473", ...
0.0
-1
Make sure that at the end of the operation the current cursor is shown.
function ensureCursorVisible(cm) { resolveScrollToPos(cm); var cur = cm.getCursor(); cm.curOp.scrollToPos = {from: cur, to: cur, margin: cm.options.cursorScrollMargin}; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function EmptyCursor () {}", "_showCursor() {\n if (!this._coreService.isCursorInitialized) {\n this._coreService.isCursorInitialized = true;\n this.refresh(this.buffer.y, this.buffer.y);\n }\n }", "checkForCursorVisibility() {\n this.showCaret();\n }", "endDr...
[ "0.71896726", "0.70795476", "0.70729387", "0.667339", "0.6522092", "0.6430521", "0.6329043", "0.62736994", "0.622839", "0.6224282", "0.6167339", "0.61538243", "0.61226624", "0.6042317", "0.6026656", "0.6026656", "0.6026656", "0.6026656", "0.60073024", "0.60073024", "0.6007302...
0.58007646
46
When an operation has its scrollToPos property set, and another scroll action is applied before the end of the operation, this 'simulates' scrolling that position into view in a cheap way, so that the effect of intermediate scroll commands is not ignored.
function resolveScrollToPos(cm) { var range = cm.curOp.scrollToPos; if (range) { cm.curOp.scrollToPos = null; var from = estimateCoords(cm, range.from), to = estimateCoords(cm, range.to); scrollToCoordsRange(cm, from, to, range.margin); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "scrollBehavior (to, from, savedPosition) {\n if (savedPosition) {\n console.log(\"后退\")\n return savedPosition\n } else {\n console.log(\"前进\")\n return {x: 0, y: 0}\n }\n }", "scrollBehavior (to, from, savedPosition) {\n return new Promi...
[ "0.6445942", "0.64281124", "0.6380104", "0.6374943", "0.63135195", "0.63110936", "0.6300032", "0.6285562", "0.62773645", "0.62624735", "0.6240491", "0.6235333", "0.6234318", "0.6229291", "0.6197611", "0.61976075", "0.6192568", "0.6169131", "0.6149815", "0.61469245", "0.614692...
0.61753
23
Sync the scrollable area and scrollbars, ensure the viewport covers the visible area.
function updateScrollTop(cm, val) { if (Math.abs(cm.doc.scrollTop - val) < 2) { return } if (!gecko) { updateDisplaySimple(cm, {top: val}); } setScrollTop(cm, val, true); if (gecko) { updateDisplaySimple(cm); } startWorker(cm, 100); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "_setScrollBars() {\r\n const that = this;\r\n\r\n if (!that._scrollView) {\r\n that._scrollView = new LW.Utilities.Scroll(that.$.timeline, that.$.horizontalScrollBar, that.$.verticalScrollBar);\r\n }\r\n\r\n const vScrollBar = that._scrollView.vScrollBar,\r\n hScro...
[ "0.63104016", "0.6014229", "0.597583", "0.59733564", "0.59518754", "0.5943817", "0.59371865", "0.59174764", "0.59174764", "0.59174764", "0.58966506", "0.5860512", "0.58578753", "0.58413035", "0.5810574", "0.57836545", "0.57833326", "0.5774653", "0.57643884", "0.5733071", "0.5...
0.0
-1
Sync scroller and scrollbar, ensure the gutter elements are aligned.
function setScrollLeft(cm, val, isScroller, forceScroll) { val = Math.max(0, Math.min(val, cm.display.scroller.scrollWidth - cm.display.scroller.clientWidth)); if ((isScroller ? val == cm.doc.scrollLeft : Math.abs(cm.doc.scrollLeft - val) < 2) && !forceScroll) { return } cm.doc.scrollLeft = val; alignHorizontally(cm); if (cm.display.scroller.scrollLeft != val) { cm.display.scroller.scrollLeft = val; } cm.display.scrollbars.setScrollLeft(val); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function updateScrollbars(cm) {\n var d = cm.display, docHeight = cm.doc.height;\n var totalHeight = docHeight + paddingVert(d);\n d.sizer.style.minHeight = d.heightForcer.style.top = totalHeight + \"px\";\n d.gutters.style.height = Math.max(totalHeight, d.scroller.clientHeight - scrollerCutOff) + \"px...
[ "0.7326363", "0.7248495", "0.7248495", "0.7248495", "0.6466243", "0.6466243", "0.6466243", "0.6408239", "0.6333963", "0.6333963", "0.6333963", "0.6333963", "0.63296926", "0.63296926", "0.63296926", "0.63296926", "0.63296926", "0.63296926", "0.63296926", "0.63296926", "0.63296...
0.0
-1
SCROLLBARS Prepare DOM reads needed to update the scrollbars. Done in one shot to minimize update/measure roundtrips.
function measureForScrollbars(cm) { var d = cm.display, gutterW = d.gutters.offsetWidth; var docH = Math.round(cm.doc.height + paddingVert(cm.display)); return { clientHeight: d.scroller.clientHeight, viewHeight: d.wrapper.clientHeight, scrollWidth: d.scroller.scrollWidth, clientWidth: d.scroller.clientWidth, viewWidth: d.wrapper.clientWidth, barLeft: cm.options.fixedGutter ? gutterW : 0, docHeight: docH, scrollHeight: docH + scrollGap(cm) + d.barHeight, nativeBarWidth: d.nativeBarWidth, gutterWidth: gutterW } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function createScrollBarForAll(){\n if($('body').hasClass(RESPONSIVE)){\n removeResponsiveScrollOverflows();\n }\n else{\n forEachSectionAndSlide(createScrollBar);\n }\n }", "function createScrollBarForAl...
[ "0.69221926", "0.6867306", "0.68645257", "0.681939", "0.6619201", "0.6619201", "0.6619201", "0.66106427", "0.6462986", "0.6462986", "0.6462986", "0.6459632", "0.64464295", "0.639866", "0.6393667", "0.6378429", "0.6358009", "0.63557327", "0.63541985", "0.63348293", "0.63275594...
0.0
-1
Resynchronize the fake scrollbars with the actual size of the content.
function updateScrollbarsInner(cm, measure) { var d = cm.display; var sizes = d.scrollbars.update(measure); d.sizer.style.paddingRight = (d.barWidth = sizes.right) + "px"; d.sizer.style.paddingBottom = (d.barHeight = sizes.bottom) + "px"; d.heightForcer.style.borderBottom = sizes.bottom + "px solid transparent"; if (sizes.right && sizes.bottom) { d.scrollbarFiller.style.display = "block"; d.scrollbarFiller.style.height = sizes.bottom + "px"; d.scrollbarFiller.style.width = sizes.right + "px"; } else { d.scrollbarFiller.style.display = ""; } if (sizes.bottom && cm.options.coverGutterNextToScrollbar && cm.options.fixedGutter) { d.gutterFiller.style.display = "block"; d.gutterFiller.style.height = sizes.bottom + "px"; d.gutterFiller.style.width = measure.gutterWidth + "px"; } else { d.gutterFiller.style.display = ""; } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "updateScrollableContents() {\n if (this.intervalId_ !== null) {\n return;\n } // notifyResize is already in progress.\n\n this.requestUpdateScroll();\n\n const nodeList = this.shadowRoot.querySelectorAll('[scrollable] iron-list');\n if (!nodeList.length) {\n return;\n }\n\n let node...
[ "0.67457443", "0.6548727", "0.6544334", "0.6544334", "0.6544334", "0.6540867", "0.653737", "0.65143853", "0.6505358", "0.65028185", "0.6500194", "0.6498328", "0.64833677", "0.6422464", "0.6417735", "0.6417735", "0.6413763", "0.64106846", "0.64106846", "0.64106846", "0.6410684...
0.6532113
23
Start a new operation.
function startOperation(cm) { cm.curOp = { cm: cm, viewChanged: false, // Flag that indicates that lines might need to be redrawn startHeight: cm.doc.height, // Used to detect need to update scrollbar forceUpdate: false, // Used to force a redraw updateInput: 0, // Whether to reset the input textarea typing: false, // Whether this reset should be careful to leave existing text (for compositing) changeObjs: null, // Accumulated changes, for firing change events cursorActivityHandlers: null, // Set of handlers to fire cursorActivity on cursorActivityCalled: 0, // Tracks which cursorActivity handlers have been called already selectionChanged: false, // Whether the selection needs to be redrawn updateMaxLine: false, // Set when the widest line needs to be determined anew scrollLeft: null, scrollTop: null, // Intermediate scroll position, not pushed to DOM yet scrollToPos: null, // Used to scroll to a specific position focus: false, id: ++nextOpId // Unique ID }; pushOperation(cm.curOp); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function startNew(options) {\n if (options === void 0) { options = {}; }\n return default_1.DefaultKernel.startNew(options);\n }", "function startNew(options) {\n return Private.startNew(options);\n }", "function startNew(options) {\n return Private.startNew(options);\n }",...
[ "0.61408204", "0.61112124", "0.61112124", "0.5981286", "0.58847827", "0.5828475", "0.57273746", "0.57061714", "0.5692559", "0.5688068", "0.5688068", "0.5688068", "0.5681768", "0.5661453", "0.5646481", "0.5626896", "0.5626896", "0.5626896", "0.5626896", "0.5626896", "0.5621532...
0.5602222
32
Finish an operation, updating the display and signalling delayed events
function endOperation(cm) { var op = cm.curOp; if (op) { finishOperation(op, function (group) { for (var i = 0; i < group.ops.length; i++) { group.ops[i].cm.curOp = null; } endOperations(group); }); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "finishProcessing() {\n this.busy = false;\n this.successful = true;\n }", "function handleFinish(values) {\n job.current = getJob(values, job.current, writeMessage);\n setBusy(job.current.pendingTime);\n }", "finish() {\n window.setTimeout(\n this.displayAbsorptionTexts.bind(thi...
[ "0.629807", "0.61485785", "0.6140222", "0.612951", "0.6117914", "0.60944146", "0.6089772", "0.6063745", "0.60262775", "0.6023023", "0.6008797", "0.600425", "0.5962399", "0.5962399", "0.5962399", "0.5962399", "0.59612703", "0.5959648", "0.59489655", "0.59489655", "0.59301424",...
0.0
-1
The DOM updates done when an operation finishes are batched so that the minimum number of relayouts are required.
function endOperations(group) { var ops = group.ops; for (var i = 0; i < ops.length; i++) // Read DOM { endOperation_R1(ops[i]); } for (var i$1 = 0; i$1 < ops.length; i$1++) // Write DOM (maybe) { endOperation_W1(ops[i$1]); } for (var i$2 = 0; i$2 < ops.length; i$2++) // Read DOM { endOperation_R2(ops[i$2]); } for (var i$3 = 0; i$3 < ops.length; i$3++) // Write DOM (maybe) { endOperation_W2(ops[i$3]); } for (var i$4 = 0; i$4 < ops.length; i$4++) // Read DOM { endOperation_finish(ops[i$4]); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function processQueue() {\n\t\t if (updateQueue.length) {\n\t\t ReactComponentEnvironment.processChildrenUpdates(updateQueue, markupQueue);\n\t\t clearQueue();\n\t\t }\n\t\t}", "function processQueue() {\n\t if (updateQueue.length) {\n\t ReactComponentEnvironment.processChildrenUpdates(\n\t upda...
[ "0.65626323", "0.65111285", "0.65111285", "0.65111285", "0.65111285", "0.65111285", "0.6498817", "0.6498817", "0.6498817", "0.6498817", "0.6498817", "0.6498817", "0.6498817", "0.6498817", "0.6498817", "0.6498817", "0.6498817", "0.6498817", "0.6498817", "0.6498817", "0.6498817...
0.0
-1
Run the given function in an operation
function runInOp(cm, f) { if (cm.curOp) { return f() } startOperation(cm); try { return f() } finally { endOperation(cm); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function runInOp(cm, f) {\n\t\t if (cm.curOp) { return f() }\n\t\t startOperation(cm);\n\t\t try { return f() }\n\t\t finally { endOperation(cm); }\n\t\t }", "function runInOp(cm, f) {\n\t if (cm.curOp) return f();\n\t startOperation(cm);\n\t try { return f(); }\n\t finally { endOperatio...
[ "0.721918", "0.7210265", "0.7210265", "0.7210265", "0.719278", "0.71893203", "0.7070357", "0.706983", "0.706983", "0.706983", "0.70266515", "0.70266515", "0.70266515", "0.70266515", "0.70266515", "0.70266515", "0.70266515", "0.70266515", "0.7011207", "0.69852394", "0.69852394...
0.70376015
22
Wraps a function in an operation. Returns the wrapped function.
function operation(cm, f) { return function() { if (cm.curOp) { return f.apply(cm, arguments) } startOperation(cm); try { return f.apply(cm, arguments) } finally { endOperation(cm); } } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function wrap(func, wrapper) {\n return partial(wrapper, func);\n }", "function wrap(func, wrapper) {\n return partial(wrapper, func);\n }", "function wrap(func, wrapper) {\n return partial(wrapper, func);\n }", "function wrap(func, wrapper) {\n return partial(wrapper, func);\n }", "functio...
[ "0.6697798", "0.6697798", "0.6697798", "0.6697798", "0.6697798", "0.6697798", "0.6697798", "0.6697798", "0.6697798", "0.66419894", "0.6519431", "0.6468018", "0.6468018", "0.6468018", "0.6468018", "0.6468018", "0.6468018", "0.6468018", "0.6468018", "0.6468018", "0.6468018", ...
0.6096213
80
Used to add methods to editor and doc instances, wrapping them in operations.
function methodOp(f) { return function() { if (this.curOp) { return f.apply(this, arguments) } startOperation(this); try { return f.apply(this, arguments) } finally { endOperation(this); } } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function addEditorMethods(CodeMirror) {\n\t\t var optionHandlers = CodeMirror.optionHandlers;\n\n\t\t var helpers = CodeMirror.helpers = {};\n\n\t\t CodeMirror.prototype = {\n\t\t constructor: CodeMirror,\n\t\t focus: function(){win(this).focus(); this.display.input.focus();},\n\n\t\t setOp...
[ "0.6233383", "0.61421245", "0.61421245", "0.6118489", "0.6118489", "0.6118489", "0.6118489", "0.6118489", "0.6118489", "0.6118489", "0.6118489", "0.6118489", "0.61172724", "0.61172724", "0.61172724", "0.61172724", "0.61172724", "0.61172724", "0.60847", "0.60688365", "0.606883...
0.0
-1
Does the actual updating of the line display. Bails out (returning false) when there is nothing to be done and forced is false.
function updateDisplayIfNeeded(cm, update) { var display = cm.display, doc = cm.doc; if (update.editorIsHidden) { resetView(cm); return false } // Bail out if the visible area is already rendered and nothing changed. if (!update.force && update.visible.from >= display.viewFrom && update.visible.to <= display.viewTo && (display.updateLineNumbers == null || display.updateLineNumbers >= display.viewTo) && display.renderedView == display.view && countDirtyView(cm) == 0) { return false } if (maybeUpdateLineNumberWidth(cm)) { resetView(cm); update.dims = getDimensions(cm); } // Compute a suitable new viewport (from & to) var end = doc.first + doc.size; var from = Math.max(update.visible.from - cm.options.viewportMargin, doc.first); var to = Math.min(end, update.visible.to + cm.options.viewportMargin); if (display.viewFrom < from && from - display.viewFrom < 20) { from = Math.max(doc.first, display.viewFrom); } if (display.viewTo > to && display.viewTo - to < 20) { to = Math.min(end, display.viewTo); } if (sawCollapsedSpans) { from = visualLineNo(cm.doc, from); to = visualLineEndNo(cm.doc, to); } var different = from != display.viewFrom || to != display.viewTo || display.lastWrapHeight != update.wrapperHeight || display.lastWrapWidth != update.wrapperWidth; adjustView(cm, from, to); display.viewOffset = heightAtLine(getLine(cm.doc, display.viewFrom)); // Position the mover div to align with the current scroll position cm.display.mover.style.top = display.viewOffset + "px"; var toUpdate = countDirtyView(cm); if (!different && toUpdate == 0 && !update.force && display.renderedView == display.view && (display.updateLineNumbers == null || display.updateLineNumbers >= display.viewTo)) { return false } // For big changes, we hide the enclosing element during the // update, since that speeds up the operations on most browsers. var selSnapshot = selectionSnapshot(cm); if (toUpdate > 4) { display.lineDiv.style.display = "none"; } patchDisplay(cm, display.updateLineNumbers, update.dims); if (toUpdate > 4) { display.lineDiv.style.display = ""; } display.renderedView = display.view; // There might have been a widget with a focused element that got // hidden or updated, if so re-focus it. restoreSelection(selSnapshot); // Prevent selection and cursors from interfering with the scroll // width and height. removeChildren(display.cursorDiv); removeChildren(display.selectionDiv); display.gutters.style.height = display.sizer.style.minHeight = 0; if (different) { display.lastWrapHeight = update.wrapperHeight; display.lastWrapWidth = update.wrapperWidth; startWorker(cm, 400); } display.updateLineNumbers = null; return true }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function drawUpdate( current ) {\n\n\t\tif ( previous.x !== current.x || previous.y !== current.y ) {\n\t\t\tmultiline( previous.x, previous.y, current.x, current.y, splits, lineSymmetryCtrl.checked );\n\t\t}\n\t}", "function checkLineChanged(currLine){\n if (currLine != prevLine){\n return true;\n }\n ret...
[ "0.61671597", "0.60710144", "0.60607845", "0.60607845", "0.6054482", "0.60209095", "0.6020216", "0.5998901", "0.5991269", "0.5989356", "0.59745157", "0.59646004", "0.5963395", "0.59491736", "0.59491736", "0.59491736", "0.59491736", "0.592617", "0.5924417", "0.5922792", "0.592...
0.59182984
32
Sync the actual display DOM structure with display.view, removing nodes for lines that are no longer in view, and creating the ones that are not there yet, and updating the ones that are out of date.
function patchDisplay(cm, updateNumbersFrom, dims) { var display = cm.display, lineNumbers = cm.options.lineNumbers; var container = display.lineDiv, cur = container.firstChild; function rm(node) { var next = node.nextSibling; // Works around a throw-scroll bug in OS X Webkit if (webkit && mac && cm.display.currentWheelTarget == node) { node.style.display = "none"; } else { node.parentNode.removeChild(node); } return next } var view = display.view, lineN = display.viewFrom; // Loop over the elements in the view, syncing cur (the DOM nodes // in display.lineDiv) with the view as we go. for (var i = 0; i < view.length; i++) { var lineView = view[i]; if (lineView.hidden) ; else if (!lineView.node || lineView.node.parentNode != container) { // Not drawn yet var node = buildLineElement(cm, lineView, lineN, dims); container.insertBefore(node, cur); } else { // Already drawn while (cur != lineView.node) { cur = rm(cur); } var updateNumber = lineNumbers && updateNumbersFrom != null && updateNumbersFrom <= lineN && lineView.lineNumber; if (lineView.changes) { if (indexOf(lineView.changes, "gutter") > -1) { updateNumber = false; } updateLineForChanges(cm, lineView, lineN, dims); } if (updateNumber) { removeChildren(lineView.lineNumber); lineView.lineNumber.appendChild(document.createTextNode(lineNumberFor(cm.options, lineN))); } cur = lineView.node.nextSibling; } lineN += lineView.size; } while (cur) { cur = rm(cur); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function patchDisplay(cm, updateNumbersFrom, dims) {\n\t var display = cm.display, lineNumbers = cm.options.lineNumbers;\n\t var container = display.lineDiv, cur = container.firstChild;\n\t\n\t function rm(node) {\n\t var next = node.nextSibling;\n\t // Works around a throw-scroll bug in OS X We...
[ "0.6638065", "0.66379964", "0.66379964", "0.66375774", "0.66260344", "0.6615293", "0.65646994", "0.65646994", "0.65557706", "0.65557706", "0.65557706", "0.65557706", "0.65557706", "0.65557706", "0.6532206", "0.6509948", "0.65085167", "0.65085167", "0.646983", "0.646983", "0.6...
0.65705675
19
Realign line numbers and gutter marks to compensate for horizontal scrolling.
function alignHorizontally(cm) { var display = cm.display, view = display.view; if (!display.alignWidgets && (!display.gutters.firstChild || !cm.options.fixedGutter)) { return } var comp = compensateForHScroll(display) - display.scroller.scrollLeft + cm.doc.scrollLeft; var gutterW = display.gutters.offsetWidth, left = comp + "px"; for (var i = 0; i < view.length; i++) { if (!view[i].hidden) { if (cm.options.fixedGutter) { if (view[i].gutter) { view[i].gutter.style.left = left; } if (view[i].gutterBackground) { view[i].gutterBackground.style.left = left; } } var align = view[i].alignable; if (align) { for (var j = 0; j < align.length; j++) { align[j].style.left = left; } } } } if (cm.options.fixedGutter) { display.gutters.style.left = (comp + gutterW) + "px"; } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "ensureLineGaps(current, mayMeasure) {\n let wrapping = this.heightOracle.lineWrapping;\n let margin = wrapping ? 10000 /* MarginWrap */ : 2000 /* Margin */, halfMargin = margin >> 1, doubleMargin = margin << 1;\n // The non-wrapping logic won't work at all in predominantly right-to-left text.\...
[ "0.6321616", "0.6283151", "0.6254765", "0.6179584", "0.6179584", "0.6179584", "0.61641204", "0.6133896", "0.6133896", "0.6133896", "0.6133896", "0.6133247", "0.6133247", "0.6133247", "0.6133247", "0.6133247", "0.6133247", "0.6124336", "0.6124336", "0.6117045", "0.61085737", ...
0.613407
19
Used to ensure that the line number gutter is still the right size for the current document size. Returns true when an update is needed.
function maybeUpdateLineNumberWidth(cm) { if (!cm.options.lineNumbers) { return false } var doc = cm.doc, last = lineNumberFor(cm.options, doc.first + doc.size - 1), display = cm.display; if (last.length != display.lineNumChars) { var test = display.measure.appendChild(elt("div", [elt("div", last)], "CodeMirror-linenumber CodeMirror-gutter-elt")); var innerW = test.firstChild.offsetWidth, padding = test.offsetWidth - innerW; display.lineGutter.style.width = ""; display.lineNumInnerWidth = Math.max(innerW, display.lineGutter.offsetWidth - padding) + 1; display.lineNumWidth = display.lineNumInnerWidth + padding; display.lineNumChars = display.lineNumInnerWidth ? last.length : -1; display.lineGutter.style.width = display.lineNumWidth + "px"; updateGutterSpace(cm.display); return true } return false }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function maybeUpdateLineNumberWidth(cm) {\n if (!cm.options.lineNumbers) return false;\n var doc = cm.doc, last = lineNumberFor(cm.options, doc.first + doc.size - 1), display = cm.display;\n if (last.length != display.lineNumChars) {\n var test = display.measure.appendChild(elt(\"div\", [elt(\"div\",...
[ "0.6707741", "0.6707741", "0.6707741", "0.6707741", "0.6707741", "0.6707741", "0.6697914", "0.6697914", "0.66803974", "0.66803974", "0.66803974", "0.66803974", "0.66591954", "0.66591954", "0.6634631", "0.6634631", "0.6634631", "0.66250575", "0.66222084", "0.66222084", "0.6622...
0.6648584
26
Rebuild the gutter elements, ensure the margin to the left of the code matches their width.
function renderGutters(display) { var gutters = display.gutters, specs = display.gutterSpecs; removeChildren(gutters); display.lineGutter = null; for (var i = 0; i < specs.length; ++i) { var ref = specs[i]; var className = ref.className; var style = ref.style; var gElt = gutters.appendChild(elt("div", null, "CodeMirror-gutter " + className)); if (style) { gElt.style.cssText = style; } if (className == "CodeMirror-linenumbers") { display.lineGutter = gElt; gElt.style.width = (display.lineNumWidth || 1) + "px"; } } gutters.style.display = specs.length ? "" : "none"; updateGutterSpace(display); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function wa(e){for(var t=e.display,a={},n={},r=t.gutters.clientLeft,f=t.gutters.firstChild,o=0;f;f=f.nextSibling,++o)a[e.options.gutters[o]]=f.offsetLeft+f.clientLeft+r,n[e.options.gutters[o]]=f.clientWidth;return{fixedPos:xa(t),gutterTotalWidth:t.gutters.offsetWidth,gutterLeft:a,gutterWidth:n,wrapperWidth:t.wrapp...
[ "0.6624648", "0.6136517", "0.5908344", "0.5870894", "0.5870894", "0.5870894", "0.5870894", "0.5870894", "0.5870894", "0.5870894", "0.5870894", "0.5870894", "0.5870894", "0.5870894", "0.5870894", "0.5870894", "0.5870894", "0.5870894", "0.5870894", "0.5870894", "0.58042896", ...
0.0
-1
The display handles the DOM integration, both for input reading and content drawing. It holds references to DOM nodes and displayrelated state.
function Display(place, doc, input, options) { var d = this; this.input = input; // Covers bottom-right square when both scrollbars are present. d.scrollbarFiller = elt("div", null, "CodeMirror-scrollbar-filler"); d.scrollbarFiller.setAttribute("cm-not-content", "true"); // Covers bottom of gutter when coverGutterNextToScrollbar is on // and h scrollbar is present. d.gutterFiller = elt("div", null, "CodeMirror-gutter-filler"); d.gutterFiller.setAttribute("cm-not-content", "true"); // Will contain the actual code, positioned to cover the viewport. d.lineDiv = eltP("div", null, "CodeMirror-code"); // Elements are added to these to represent selection and cursors. d.selectionDiv = elt("div", null, null, "position: relative; z-index: 1"); d.cursorDiv = elt("div", null, "CodeMirror-cursors"); // A visibility: hidden element used to find the size of things. d.measure = elt("div", null, "CodeMirror-measure"); // When lines outside of the viewport are measured, they are drawn in this. d.lineMeasure = elt("div", null, "CodeMirror-measure"); // Wraps everything that needs to exist inside the vertically-padded coordinate system d.lineSpace = eltP("div", [d.measure, d.lineMeasure, d.selectionDiv, d.cursorDiv, d.lineDiv], null, "position: relative; outline: none"); var lines = eltP("div", [d.lineSpace], "CodeMirror-lines"); // Moved around its parent to cover visible view. d.mover = elt("div", [lines], null, "position: relative"); // Set to the height of the document, allowing scrolling. d.sizer = elt("div", [d.mover], "CodeMirror-sizer"); d.sizerWidth = null; // Behavior of elts with overflow: auto and padding is // inconsistent across browsers. This is used to ensure the // scrollable area is big enough. d.heightForcer = elt("div", null, null, "position: absolute; height: " + scrollerGap + "px; width: 1px;"); // Will contain the gutters, if any. d.gutters = elt("div", null, "CodeMirror-gutters"); d.lineGutter = null; // Actual scrollable element. d.scroller = elt("div", [d.sizer, d.heightForcer, d.gutters], "CodeMirror-scroll"); d.scroller.setAttribute("tabIndex", "-1"); // The element in which the editor lives. d.wrapper = elt("div", [d.scrollbarFiller, d.gutterFiller, d.scroller], "CodeMirror"); // Work around IE7 z-index bug (not perfect, hence IE7 not really being supported) if (ie && ie_version < 8) { d.gutters.style.zIndex = -1; d.scroller.style.paddingRight = 0; } if (!webkit && !(gecko && mobile)) { d.scroller.draggable = true; } if (place) { if (place.appendChild) { place.appendChild(d.wrapper); } else { place(d.wrapper); } } // Current rendered range (may be bigger than the view window). d.viewFrom = d.viewTo = doc.first; d.reportedViewFrom = d.reportedViewTo = doc.first; // Information about the rendered lines. d.view = []; d.renderedView = null; // Holds info about a single rendered line when it was rendered // for measurement, while not in view. d.externalMeasured = null; // Empty space (in pixels) above the view d.viewOffset = 0; d.lastWrapHeight = d.lastWrapWidth = 0; d.updateLineNumbers = null; d.nativeBarWidth = d.barHeight = d.barWidth = 0; d.scrollbarsClipped = false; // Used to only resize the line number gutter when necessary (when // the amount of lines crosses a boundary that makes its width change) d.lineNumWidth = d.lineNumInnerWidth = d.lineNumChars = null; // Set to true when a non-horizontal-scrolling line widget is // added. As an optimization, line widget aligning is skipped when // this is false. d.alignWidgets = false; d.cachedCharWidth = d.cachedTextHeight = d.cachedPaddingH = null; // Tracks the maximum line length so that the horizontal scrollbar // can be kept static when scrolling. d.maxLine = null; d.maxLineLength = 0; d.maxLineChanged = false; // Used for measuring wheel scrolling granularity d.wheelDX = d.wheelDY = d.wheelStartX = d.wheelStartY = null; // True when shift is held down. d.shift = false; // Used to track whether anything happened since the context menu // was opened. d.selForContextMenu = null; d.activeTouch = null; d.gutterSpecs = getGutters(options.gutters, options.lineNumbers); renderGutters(d); input.init(d); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function displayDOM(){\r\n\t\tvar str = '';\r\n\t\tcontainer.getChildren().each(function(item){\r\n\t\t\tstr += '<div style=\"' + item.style.cssText + '\">' + item.get('text') + '</div>\\n';\r\n\t\t});\r\n\t\tdocument.id('output').set('text', str);\r\n\t}", "displayScene() {\n\n //Process all component n...
[ "0.71113545", "0.66074544", "0.6554401", "0.62461466", "0.62349385", "0.62249076", "0.6143888", "0.6131278", "0.6119149", "0.6119149", "0.61026573", "0.6072142", "0.60649383", "0.6028712", "0.6020695", "0.6014327", "0.60055435", "0.5979706", "0.58654046", "0.58615804", "0.579...
0.0
-1
Take an unsorted, potentially overlapping set of ranges, and build a selection out of it. 'Consumes' ranges array (modifying it).
function normalizeSelection(cm, ranges, primIndex) { var mayTouch = cm && cm.options.selectionsMayTouch; var prim = ranges[primIndex]; ranges.sort(function (a, b) { return cmp(a.from(), b.from()); }); primIndex = indexOf(ranges, prim); for (var i = 1; i < ranges.length; i++) { var cur = ranges[i], prev = ranges[i - 1]; var diff = cmp(prev.to(), cur.from()); if (mayTouch && !cur.empty() ? diff > 0 : diff >= 0) { var from = minPos(prev.from(), cur.from()), to = maxPos(prev.to(), cur.to()); var inv = prev.empty() ? cur.from() == cur.head : prev.from() == prev.head; if (i <= primIndex) { --primIndex; } ranges.splice(--i, 2, new Range(inv ? to : from, inv ? from : to)); } } return new Selection(ranges, primIndex) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "static _mergeRanges(ranges, newRange) {\n let inRange = false;\n for (let i = 0; i < ranges.length; i++) {\n const range = ranges[i];\n if (!inRange) {\n if (newRange[1] <= range[0]) {\n // Case 1: New range is before the search range\n ...
[ "0.70186657", "0.6829976", "0.6789967", "0.6774615", "0.6716162", "0.66930807", "0.6687457", "0.6687457", "0.6687457", "0.6687457", "0.6687457", "0.6687457", "0.6687457", "0.6687457", "0.66794205", "0.66419154", "0.6637528", "0.6637528", "0.6637528", "0.6637528", "0.6637528",...
0.6089187
49
Compute the position of the end of a change (its 'to' property refers to the prechange end).
function changeEnd(change) { if (!change.text) { return change.to } return Pos(change.from.line + change.text.length - 1, lst(change.text).length + (change.text.length == 1 ? change.from.ch : 0)) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function changeEnd(change) {\n if (!change.text) {\n return change.to;\n }\n\n return Pos(change.from.line + change.text.length - 1, lst(change.text).length + (change.text.length == 1 ? change.from.ch : 0));\n } // Adjust a position to refer to the post-change position of the", "function changeEnd...
[ "0.81361943", "0.7953961", "0.78976995", "0.7896871", "0.7896871", "0.7896871", "0.7896871", "0.7896871", "0.7896871", "0.7896871", "0.7896871", "0.7896871", "0.7896871", "0.7896871", "0.7896871", "0.7896871", "0.6733018", "0.67322105", "0.6654323", "0.6598373", "0.6589914", ...
0.7954137
17
Adjust a position to refer to the postchange position of the same text, or the end of the change if the change covers it.
function adjustForChange(pos, change) { if (cmp(pos, change.from) < 0) { return pos } if (cmp(pos, change.to) <= 0) { return changeEnd(change) } var line = pos.line + change.text.length - (change.to.line - change.from.line) - 1, ch = pos.ch; if (pos.line == change.to.line) { ch += changeEnd(change).ch - change.to.ch; } return Pos(line, ch) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function adjustForChange(pos, change) {\n\t\t if (cmp(pos, change.from) < 0) return pos;\n\t\t if (cmp(pos, change.to) <= 0) return changeEnd(change);\n\t\t\n\t\t var line = pos.line + change.text.length - (change.to.line - change.from.line) - 1, ch = pos.ch;\n\t\t if (pos.line == change.to.line) ch +=...
[ "0.7517424", "0.75166106", "0.7476101", "0.7449859", "0.7449859", "0.7445846", "0.7444705", "0.7421281", "0.7421281", "0.7421281", "0.7421281", "0.7421281", "0.7421281", "0.7421281", "0.7408827", "0.7380149", "0.7380149", "0.7374359", "0.7374359", "0.7374359", "0.7374359", ...
0.741919
27
Used by replaceSelections to allow moving the selection to the start or around the replaced test. Hint may be "start" or "around".
function computeReplacedSel(doc, changes, hint) { var out = []; var oldPrev = Pos(doc.first, 0), newPrev = oldPrev; for (var i = 0; i < changes.length; i++) { var change = changes[i]; var from = offsetPos(change.from, oldPrev, newPrev); var to = offsetPos(changeEnd(change), oldPrev, newPrev); oldPrev = change.to; newPrev = to; if (hint == "around") { var range = doc.sel.ranges[i], inv = cmp(range.head, range.anchor) < 0; out[i] = new Range(inv ? to : from, inv ? from : to); } else { out[i] = new Range(from, from); } } return new Selection(out, doc.sel.primIndex) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "replaceBeforeCursor(start, text) {\n this.insertBetween(start, this.el.selectionStart, text);\n }", "function moveSelection(event) {\n event.preventDefault();\n event.stopPropagation();\n console.log('Calling moveSelection');\n \n optimalApp.selectionPosition[0] = event.pageX - optimalApp.selectionOffse...
[ "0.6645743", "0.6270994", "0.61845195", "0.6150499", "0.6104101", "0.60757375", "0.60718614", "0.60028625", "0.6002224", "0.5982876", "0.5982876", "0.5982876", "0.597064", "0.59512234", "0.59484506", "0.59484506", "0.59484506", "0.59349036", "0.58870625", "0.5841855", "0.5833...
0.5666932
66
Used to get the editor into a consistent state again when options change.
function loadMode(cm) { cm.doc.mode = getMode(cm.options, cm.doc.modeOption); resetModeState(cm); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function updateEditor() {\n\t\ttextToEditor();\n\t\tpositionEditorCaret();\n\t}", "optionsUpdateHook() { }", "function _onEditorChanged() {\n\t\t_close();\n\t\tcurrentEditor = EditorManager.getCurrentFullEditor();\n\n\t\tcurrentEditor.$textNode = $(currentEditor.getRootElement()).find(\".CodeMirror-lines\");\n...
[ "0.65174145", "0.6448267", "0.6407012", "0.6382705", "0.63655174", "0.63512903", "0.6341789", "0.6240036", "0.62384015", "0.62281793", "0.6186693", "0.61820716", "0.614012", "0.6127556", "0.61134076", "0.61133647", "0.6105441", "0.6083987", "0.6079587", "0.60270965", "0.60219...
0.0
-1
DOCUMENT DATA STRUCTURE By default, updates that start and end at the beginning of a line are treated specially, in order to make the association of line widgets and marker elements with the text behave more intuitive.
function isWholeLineUpdate(doc, change) { return change.from.ch == 0 && change.to.ch == 0 && lst(change.text) == "" && (!doc.cm || doc.cm.options.wholeLineUpdateBefore) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "update(text, start, end) {\n this.lineOffsets = undefined;\n const content = this.getText();\n this.setText(content.slice(0, start) + text + content.slice(end));\n }", "function updateDoc(doc, change, markedSpans, estimateHeight) {\n\t\t function spansFor(n) {return markedSpans ? marke...
[ "0.62110734", "0.57639134", "0.5717615", "0.5717556", "0.5717556", "0.5697219", "0.56847644", "0.56847644", "0.56847644", "0.56847644", "0.56847644", "0.56847644", "0.56847644", "0.56847644", "0.56847644", "0.56847644", "0.56847644", "0.56392586", "0.56392586", "0.56392586", ...
0.0
-1
Perform a change on the document data structure.
function updateDoc(doc, change, markedSpans, estimateHeight) { function spansFor(n) {return markedSpans ? markedSpans[n] : null} function update(line, text, spans) { updateLine(line, text, spans, estimateHeight); signalLater(line, "change", line, change); } function linesFor(start, end) { var result = []; for (var i = start; i < end; ++i) { result.push(new Line(text[i], spansFor(i), estimateHeight)); } return result } var from = change.from, to = change.to, text = change.text; var firstLine = getLine(doc, from.line), lastLine = getLine(doc, to.line); var lastText = lst(text), lastSpans = spansFor(text.length - 1), nlines = to.line - from.line; // Adjust the line structure if (change.full) { doc.insert(0, linesFor(0, text.length)); doc.remove(text.length, doc.size - text.length); } else if (isWholeLineUpdate(doc, change)) { // This is a whole-line replace. Treated specially to make // sure line objects move the way they are supposed to. var added = linesFor(0, text.length - 1); update(lastLine, lastLine.text, lastSpans); if (nlines) { doc.remove(from.line, nlines); } if (added.length) { doc.insert(from.line, added); } } else if (firstLine == lastLine) { if (text.length == 1) { update(firstLine, firstLine.text.slice(0, from.ch) + lastText + firstLine.text.slice(to.ch), lastSpans); } else { var added$1 = linesFor(1, text.length - 1); added$1.push(new Line(lastText + firstLine.text.slice(to.ch), lastSpans, estimateHeight)); update(firstLine, firstLine.text.slice(0, from.ch) + text[0], spansFor(0)); doc.insert(from.line + 1, added$1); } } else if (text.length == 1) { update(firstLine, firstLine.text.slice(0, from.ch) + text[0] + lastLine.text.slice(to.ch), spansFor(0)); doc.remove(from.line + 1, nlines); } else { update(firstLine, firstLine.text.slice(0, from.ch) + text[0], spansFor(0)); update(lastLine, lastText + lastLine.text.slice(to.ch), lastSpans); var added$2 = linesFor(1, text.length - 1); if (nlines > 1) { doc.remove(from.line + 1, nlines - 1); } doc.insert(from.line + 1, added$2); } signalLater(doc, "change", doc, change); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "change(docId, doc) {\n const cleanedDoc = this._getCleanedObject(doc);\n let storedDoc = this.store[docId];\n deepExtend(storedDoc, cleanedDoc);\n\n let changedData = {};\n _.each(cleanedDoc, (value, key) => {\n changedData[key] = storedDoc[key];\n });\n\n ...
[ "0.70639664", "0.65255326", "0.60612947", "0.5983165", "0.57900375", "0.5765763", "0.57389504", "0.5728134", "0.56999445", "0.5689289", "0.568801", "0.5685086", "0.5677597", "0.5652581", "0.5643472", "0.563531", "0.563531", "0.563531", "0.56288433", "0.55978465", "0.5595986",...
0.0
-1
Call f for all linked documents.
function linkedDocs(doc, f, sharedHistOnly) { function propagate(doc, skip, sharedHist) { if (doc.linked) { for (var i = 0; i < doc.linked.length; ++i) { var rel = doc.linked[i]; if (rel.doc == skip) { continue } var shared = sharedHist && rel.sharedHist; if (sharedHistOnly && !shared) { continue } f(rel.doc, shared); propagate(rel.doc, doc, shared); } } } propagate(doc, null, true); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function linkedDocs(doc, f, sharedHistOnly) {\r\n function propagate(doc, skip, sharedHist) {\r\n if (doc.linked) for (var i = 0; i < doc.linked.length; ++i) {\r\n var rel = doc.linked[i];\r\n if (rel.doc == skip) continue;\r\n var shared = sharedHist && rel.sharedHist;\r\n if (...
[ "0.72876906", "0.7267145", "0.7267145", "0.7267145", "0.7267145", "0.7267145", "0.7267145", "0.7267145", "0.72423947", "0.72423947", "0.72423947", "0.7223533", "0.72208107", "0.71978104", "0.716727", "0.716727", "0.716727", "0.716727", "0.716727", "0.716727", "0.716727", "0...
0.7237777
26
Attach a document to an editor.
function attachDoc(cm, doc) { if (doc.cm) { throw new Error("This document is already in use.") } cm.doc = doc; doc.cm = cm; estimateLineHeights(cm); loadMode(cm); setDirectionClass(cm); if (!cm.options.lineWrapping) { findMaxLine(cm); } cm.options.mode = doc.modeOption; regChange(cm); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function attachDoc(cm, doc) {\n\t\t if (doc.cm) throw new Error(\"This document is already in use.\");\n\t\t cm.doc = doc;\n\t\t doc.cm = cm;\n\t\t estimateLineHeights(cm);\n\t\t loadMode(cm);\n\t\t if (!cm.options.lineWrapping) findMaxLine(cm);\n\t\t cm.options.mode = doc.modeOption;\n\t\t ...
[ "0.6626215", "0.6624217", "0.6578821", "0.6578821", "0.6578821", "0.65262896", "0.6516365", "0.6516365", "0.6516365", "0.6516365", "0.6516365", "0.6516365", "0.6516365", "0.64938515", "0.64938515", "0.64938515", "0.6477321", "0.6477321", "0.6477321", "0.6477321", "0.6477321",...
0.64563096
37
Create a history change event from an updateDocstyle change object.
function historyChangeFromChange(doc, change) { var histChange = {from: copyPos(change.from), to: changeEnd(change), text: getBetween(doc, change.from, change.to)}; attachLocalSpans(doc, histChange, change.from.line, change.to.line + 1); linkedDocs(doc, function (doc) { return attachLocalSpans(doc, histChange, change.from.line, change.to.line + 1); }, true); return histChange }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function historyChangeFromChange(doc, change) {\n\t\t var histChange = {from: copyPos(change.from), to: changeEnd(change), text: getBetween(doc, change.from, change.to)};\n\t\t attachLocalSpans(doc, histChange, change.from.line, change.to.line + 1);\n\t\t linkedDocs(doc, function(doc) {attachLocalSpans(do...
[ "0.696248", "0.694849", "0.69350445", "0.69350445", "0.6926954", "0.6926954", "0.6926954", "0.6926954", "0.6926954", "0.6926954", "0.6926954", "0.6926954", "0.6926954", "0.6926954", "0.6926954", "0.69227433", "0.69227433", "0.69227433", "0.6911714", "0.6911714", "0.6911714", ...
0.68901587
38
Pop all selection events off the end of a history array. Stop at a change event.
function clearSelectionEvents(array) { while (array.length) { var last = lst(array); if (last.ranges) { array.pop(); } else { break } } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function clearSelectionEvents(array) {\n\t\t while (array.length) {\n\t\t var last = lst(array);\n\t\t if (last.ranges) array.pop();\n\t\t else break;\n\t\t }\n\t\t }", "function clearSelectionEvents(array) {\n while (array.length) {\n var last = lst(array);\n if (last.ranges) ...
[ "0.7114935", "0.7105218", "0.7105218", "0.7105218", "0.7105218", "0.7105218", "0.7105218", "0.7105218", "0.71047795", "0.71020734", "0.71020734", "0.71020734", "0.70783186", "0.69916886", "0.69916886", "0.69916886", "0.69916886", "0.69916886", "0.69916886", "0.69916886", "0.6...
0.7082853
24
Find the top change event in the history. Pop off selection events that are in the way.
function lastChangeEvent(hist, force) { if (force) { clearSelectionEvents(hist.done); return lst(hist.done) } else if (hist.done.length && !lst(hist.done).ranges) { return lst(hist.done) } else if (hist.done.length > 1 && !hist.done[hist.done.length - 2].ranges) { hist.done.pop(); return lst(hist.done) } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function lastChangeEvent(hist, force) {\n if (force) {\n clearSelectionEvents(hist.done);\n return lst(hist.done);\n } else if (hist.done.length && !lst(hist.done).ranges) {\n return lst(hist.done);\n } else if (hist.done.length > 1 && !hist.done[hist.done.length - 2].ranges) {\n hist....
[ "0.6685738", "0.63823617", "0.6360518", "0.6342472", "0.6342472", "0.6342472", "0.6278475", "0.6278475", "0.6278475", "0.6278475", "0.6278475", "0.6278475", "0.6278475", "0.62490594", "0.623188", "0.623188", "0.62148124", "0.62148124", "0.62148124", "0.62148124", "0.62148124"...
0.6287687
22
Register a change in the history. Merges changes that are within a single operation, or are close together with an origin that allows merging (starting with "+") into a single event.
function addChangeToHistory(doc, change, selAfter, opId) { var hist = doc.history; hist.undone.length = 0; var time = +new Date, cur; var last; if ((hist.lastOp == opId || hist.lastOrigin == change.origin && change.origin && ((change.origin.charAt(0) == "+" && hist.lastModTime > time - (doc.cm ? doc.cm.options.historyEventDelay : 500)) || change.origin.charAt(0) == "*")) && (cur = lastChangeEvent(hist, hist.lastOp == opId))) { // Merge this change into the last event last = lst(cur.changes); if (cmp(change.from, change.to) == 0 && cmp(change.from, last.to) == 0) { // Optimized case for simple insertion -- don't want to add // new changesets for every character typed last.to = changeEnd(change); } else { // Add new sub-event cur.changes.push(historyChangeFromChange(doc, change)); } } else { // Can not be merged, start a new event. var before = lst(hist.done); if (!before || !before.ranges) { pushSelectionToHistory(doc.sel, hist.done); } cur = {changes: [historyChangeFromChange(doc, change)], generation: hist.generation}; hist.done.push(cur); while (hist.done.length > hist.undoDepth) { hist.done.shift(); if (!hist.done[0].ranges) { hist.done.shift(); } } } hist.done.push(selAfter); hist.generation = ++hist.maxGeneration; hist.lastModTime = hist.lastSelTime = time; hist.lastOp = hist.lastSelOp = opId; hist.lastOrigin = hist.lastSelOrigin = change.origin; if (!last) { signal(doc, "historyAdded"); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function addChangeToHistory(doc, change, selAfter, opId) {\n var hist = doc.history;\n hist.undone.length = 0;\n var time = +new Date, cur;\n\n if ((hist.lastOp == opId ||\n hist.lastOrigin == change.origin && change.origin &&\n ((change.origin.charAt(0) == \"+\" && doc.cm && hist.lastM...
[ "0.6184258", "0.6176788", "0.6174049", "0.6174049", "0.6174049", "0.6174049", "0.6174049", "0.6174049", "0.6159121", "0.6155636", "0.6155636", "0.61505264", "0.6144719", "0.61193234", "0.611699", "0.611699", "0.6108021", "0.6108021", "0.6108021", "0.6108021", "0.6108021", "...
0.6182238
17
Called whenever the selection changes, sets the new selection as the pending selection in the history, and pushes the old pending selection into the 'done' array when it was significantly different (in number of selected ranges, emptiness, or time).
function addSelectionToHistory(doc, sel, opId, options) { var hist = doc.history, origin = options && options.origin; // A new event is started when the previous origin does not match // the current, or the origins don't allow matching. Origins // starting with * are always merged, those starting with + are // merged when similar and close together in time. if (opId == hist.lastSelOp || (origin && hist.lastSelOrigin == origin && (hist.lastModTime == hist.lastSelTime && hist.lastOrigin == origin || selectionEventCanBeMerged(doc, origin, lst(hist.done), sel)))) { hist.done[hist.done.length - 1] = sel; } else { pushSelectionToHistory(sel, hist.done); } hist.lastSelTime = +new Date; hist.lastSelOrigin = origin; hist.lastSelOp = opId; if (options && options.clearRedo !== false) { clearSelectionEvents(hist.undone); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "_gcSelections () {\n for (let i = 0; i < this._selections.length; ++i) {\n const s = this._selections[i]\n const oldOffset = s.offset\n\n // check for newly downloaded pieces in selection\n while (this.bitfield.get(s.from + s.offset) && s.from + s.offset < s.to) {\n s.offset += 1\n ...
[ "0.66112244", "0.66112244", "0.66112244", "0.6406183", "0.6334268", "0.62584734", "0.62584734", "0.62584734", "0.6165519", "0.6138466", "0.6100709", "0.6091438", "0.6091438", "0.60838115", "0.60519296", "0.60515946", "0.6047643", "0.6047643", "0.6046075", "0.60457534", "0.602...
0.6019837
38
Used to store marked span information in the history.
function attachLocalSpans(doc, change, from, to) { var existing = change["spans_" + doc.id], n = 0; doc.iter(Math.max(doc.first, from), Math.min(doc.first + doc.size, to), function (line) { if (line.markedSpans) { (existing || (existing = change["spans_" + doc.id] = {}))[n] = line.markedSpans; } ++n; }); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function addMarkedSpan(line, span) {\n\t\t line.markedSpans = line.markedSpans ? line.markedSpans.concat([span]) : [span];\n\t\t span.marker.attachLine(line);\n\t\t }", "function addMarkedSpan(line, span) {\n\t line.markedSpans = line.markedSpans ? line.markedSpans.concat([span]) : [span];\n\t span....
[ "0.6327484", "0.6285503", "0.6285503", "0.6285503", "0.62029684", "0.61554384", "0.6131782", "0.6125477", "0.6125477", "0.6085742", "0.60608774", "0.60608774", "0.60608774", "0.60608774", "0.60608774", "0.60608774", "0.60608774", "0.60608774", "0.60608774", "0.60608774", "0.6...
0.54982615
82
When un/redoing restores text containing marked spans, those that have been explicitly cleared should not be restored.
function removeClearedSpans(spans) { if (!spans) { return null } var out; for (var i = 0; i < spans.length; ++i) { if (spans[i].marker.explicitlyCleared) { if (!out) { out = spans.slice(0, i); } } else if (out) { out.push(spans[i]); } } return !out ? spans : out.length ? out : null }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function remark() {\n for (var i = 0; i < vm.game.marked.length; i++) {\n var element = angular.element(document.getElementById('text-' + i));\n var marked = vm.game.marked[i];\n element.removeClass('last');\n element.removeClass('first');\n ...
[ "0.6541307", "0.65243256", "0.64623547", "0.6354376", "0.63102525", "0.62996334", "0.6291705", "0.6282214", "0.62536573", "0.62536573", "0.62536573", "0.6238591", "0.62097794", "0.6202563", "0.62011385", "0.620092", "0.6195618", "0.6195618", "0.6195618", "0.6195618", "0.61956...
0.0
-1
Retrieve and filter the old marked spans stored in a change event.
function getOldSpans(doc, change) { var found = change["spans_" + doc.id]; if (!found) { return null } var nw = []; for (var i = 0; i < change.text.length; ++i) { nw.push(removeClearedSpans(found[i])); } return nw }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function getOldSpans(doc, change) {\n\t\t var found = change[\"spans_\" + doc.id];\n\t\t if (!found) { return null }\n\t\t var nw = [];\n\t\t for (var i = 0; i < change.text.length; ++i)\n\t\t { nw.push(removeClearedSpans(found[i])); }\n\t\t return nw\n\t\t }", "function getOldSpans(doc, cha...
[ "0.7795729", "0.7775589", "0.7745061", "0.7745061", "0.7745061", "0.76677495", "0.76677495", "0.76677495", "0.76677495", "0.76677495", "0.76677495", "0.76677495", "0.76551306", "0.7651843", "0.7651843", "0.7651643", "0.76475054", "0.76475054", "0.76475054", "0.76475054", "0.7...
0.77104664
21
Used for un/redoing changes from the history. Combines the result of computing the existing spans with the set of spans that existed in the history (so that deleting around a span and then undoing brings back the span).
function mergeOldSpans(doc, change) { var old = getOldSpans(doc, change); var stretched = stretchSpansOverChange(doc, change); if (!old) { return stretched } if (!stretched) { return old } for (var i = 0; i < old.length; ++i) { var oldCur = old[i], stretchCur = stretched[i]; if (oldCur && stretchCur) { spans: for (var j = 0; j < stretchCur.length; ++j) { var span = stretchCur[j]; for (var k = 0; k < oldCur.length; ++k) { if (oldCur[k].marker == span.marker) { continue spans } } oldCur.push(span); } } else if (stretchCur) { old[i] = stretchCur; } } return old }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function getOldSpans(doc, change) {\n\t\t var found = change[\"spans_\" + doc.id];\n\t\t if (!found) return null;\n\t\t for (var i = 0, nw = []; i < change.text.length; ++i)\n\t\t nw.push(removeClearedSpans(found[i]));\n\t\t return nw;\n\t\t }", "function getOldSpans(doc, change) {\n\t\t var...
[ "0.62034744", "0.6182492", "0.6147326", "0.6147326", "0.6147326", "0.60734504", "0.60734504", "0.60734504", "0.60734504", "0.60734504", "0.60734504", "0.60734504", "0.6068917", "0.6055901", "0.6031862", "0.6031862", "0.6031862", "0.6031862", "0.6031862", "0.6031862", "0.60318...
0.0
-1
Used both to provide a JSONsafe object in .getHistory, and, when detaching a document, to split the history in two
function copyHistoryArray(events, newGroup, instantiateSel) { var copy = []; for (var i = 0; i < events.length; ++i) { var event = events[i]; if (event.ranges) { copy.push(instantiateSel ? Selection.prototype.deepCopy.call(event) : event); continue } var changes = event.changes, newChanges = []; copy.push({changes: newChanges}); for (var j = 0; j < changes.length; ++j) { var change = changes[j], m = (void 0); newChanges.push({from: change.from, to: change.to, text: change.text}); if (newGroup) { for (var prop in change) { if (m = prop.match(/^spans_(\d+)$/)) { if (indexOf(newGroup, Number(m[1])) > -1) { lst(newChanges)[prop] = change[prop]; delete change[prop]; } } } } } } return copy }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "serializeHistory(state) {\r\n if (!state)\r\n return null;\r\n // Ensure sure that all entries have url\r\n var entries = state.entries.filter(e => e.url);\r\n if (!entries.length)\r\n return null;\r\n // Ensure the index is in bounds.\r\n var index = (state.index || entries.length) - 1...
[ "0.6128736", "0.597194", "0.5751274", "0.5658887", "0.5648688", "0.55759466", "0.55759466", "0.55759466", "0.5567405", "0.5567405", "0.5567405", "0.5567405", "0.5567405", "0.5567405", "0.5567405", "0.55629796", "0.555769", "0.555769", "0.555769", "0.555769", "0.555769", "0....
0.0
-1
The 'scroll' parameter given to many of these indicated whether the new cursor position should be scrolled into view after modifying the selection. If shift is held or the extend flag is set, extends a range to include a given position (and optionally a second position). Otherwise, simply returns the range between the given positions. Used for cursor motion and such.
function extendRange(range, head, other, extend) { if (extend) { var anchor = range.anchor; if (other) { var posBefore = cmp(head, anchor) < 0; if (posBefore != (cmp(other, anchor) < 0)) { anchor = head; head = other; } else if (posBefore != (cmp(head, other) < 0)) { head = other; } } return new Range(anchor, head) } else { return new Range(other || head, head) } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function extendRange(doc, range, head, other) {\n\t\t if (doc.cm && doc.cm.display.shift || doc.extend) {\n\t\t var anchor = range.anchor;\n\t\t if (other) {\n\t\t var posBefore = cmp(head, anchor) < 0;\n\t\t if (posBefore != (cmp(other, anchor) < 0)) {\n\t\t anchor = head;\n\t\...
[ "0.64107454", "0.6394376", "0.6394376", "0.6394376", "0.63048786", "0.626854", "0.626854", "0.626854", "0.626854", "0.626854", "0.626854", "0.626854", "0.626854", "0.6225508", "0.6225508", "0.6140053", "0.5967149", "0.5950152", "0.5857598", "0.58396757", "0.58396757", "0.58...
0.58298576
41
Extend the primary selection range, discard the rest.
function extendSelection(doc, head, other, options, extend) { if (extend == null) { extend = doc.cm && (doc.cm.display.shift || doc.extend); } setSelection(doc, new Selection([extendRange(doc.sel.primary(), head, other, extend)], 0), options); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function extendRange(range, head, other, extend) {\n if (extend) {\n var anchor = range.anchor;\n\n if (other) {\n var posBefore = cmp(head, anchor) < 0;\n\n if (posBefore != cmp(other, anchor) < 0) {\n anchor = head;\n head = other;\n } else if (posBefore != cmp...
[ "0.7361317", "0.72121984", "0.71236956", "0.71236956", "0.71236956", "0.7040623", "0.7038878", "0.7036874", "0.7036874", "0.7036874", "0.7036874", "0.7036874", "0.7036874", "0.7036874", "0.7036874", "0.70040554", "0.70040554", "0.67941666", "0.6732129", "0.6732129", "0.673212...
0.6841599
28
Extend all selections (pos is an array of selections with length equal the number of selections)
function extendSelections(doc, heads, options) { var out = []; var extend = doc.cm && (doc.cm.display.shift || doc.extend); for (var i = 0; i < doc.sel.ranges.length; i++) { out[i] = extendRange(doc.sel.ranges[i], heads[i], null, extend); } var newSel = normalizeSelection(doc.cm, out, doc.sel.primIndex); setSelection(doc, newSel, options); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function extendSelections(doc, heads, options) {\n\t\t for (var out = [], i = 0; i < doc.sel.ranges.length; i++)\n\t\t out[i] = extendRange(doc, doc.sel.ranges[i], heads[i], null);\n\t\t var newSel = normalizeSelection(out, doc.sel.primIndex);\n\t\t setSelection(doc, newSel, options);\n\t\t }", "f...
[ "0.67251664", "0.66988546", "0.66988546", "0.66988546", "0.66708016", "0.6634704", "0.663125", "0.663125", "0.663125", "0.663125", "0.663125", "0.663125", "0.663125", "0.663125", "0.6623119", "0.65670156", "0.65670156", "0.6553308", "0.6553308", "0.6553308", "0.65335655", "...
0.6371589
36
Updates a single range in the selection.
function replaceOneSelection(doc, i, range, options) { var ranges = doc.sel.ranges.slice(0); ranges[i] = range; setSelection(doc, normalizeSelection(doc.cm, ranges, doc.sel.primIndex), options); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "updateInRange(editor, range, offset = 0, updateFunc) {\n const baseRange = editor.getSelectedRange();\n editor.setSelectedRange(range);\n updateFunc();\n editor.setSelectedRange([baseRange[0] + offset, baseRange[1] + offset]);\n }", "updateRange(start, end) {\n this.range.start = start\n this....
[ "0.7218381", "0.69966", "0.6366824", "0.6361162", "0.6361162", "0.6361162", "0.63484067", "0.63484067", "0.63484067", "0.63484067", "0.63484067", "0.63484067", "0.63484067", "0.63484067", "0.63363445", "0.63199526", "0.63136816", "0.63136816", "0.6311347", "0.6283103", "0.626...
0.62980735
30
Reset the selection to a single range.
function setSimpleSelection(doc, anchor, head, options) { setSelection(doc, simpleSelection(anchor, head), options); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "_resetSelection() {\n this.__selectedRangeArr = [];\n this.__anchorSelectionIndex = -1;\n this.__leadSelectionIndex = -1;\n }", "restoreRange() {\n if (this.lastRange) {\n this.lastRange.select();\n this.focus();\n }\n }", "reset() {\n this._selection = -1;\n }", "funct...
[ "0.79783505", "0.76575625", "0.7616093", "0.74678564", "0.7437772", "0.72755456", "0.72359824", "0.71725357", "0.69074774", "0.69074774", "0.69074774", "0.68833935", "0.68802726", "0.68802726", "0.68802726", "0.68802726", "0.68802726", "0.68802726", "0.68802726", "0.68802726", ...
0.0
-1
Give beforeSelectionChange handlers a change to influence a selection update.
function filterSelectionChange(doc, sel, options) { var obj = { ranges: sel.ranges, update: function(ranges) { this.ranges = []; for (var i = 0; i < ranges.length; i++) { this.ranges[i] = new Range(clipPos(doc, ranges[i].anchor), clipPos(doc, ranges[i].head)); } }, origin: options && options.origin }; signal(doc, "beforeSelectionChange", doc, obj); if (doc.cm) { signal(doc.cm, "beforeSelectionChange", doc.cm, obj); } if (obj.ranges != sel.ranges) { return normalizeSelection(doc.cm, obj.ranges, obj.ranges.length - 1) } else { return sel } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function SelectionChange() {}", "function SelectionChange() {}", "function SelectionChange() {}", "function SelectionChange() {}", "function SelectionChange() { }", "function SelectionChange() { }", "beforeSelectRow(rowid, e){\n }", "selectionChanged(context, onContextChanged) {\n retur...
[ "0.7436134", "0.7436134", "0.7436134", "0.7436134", "0.7315609", "0.7315609", "0.64987767", "0.6486742", "0.64495426", "0.64479816", "0.6396452", "0.6395277", "0.6395277", "0.6395277", "0.6390618", "0.6350694", "0.63113916", "0.6283778", "0.6238949", "0.6238949", "0.61821294"...
0.5942009
49
Set a new selection.
function setSelection(doc, sel, options) { setSelectionNoUndo(doc, sel, options); addSelectionToHistory(doc, doc.sel, doc.cm ? doc.cm.curOp.id : NaN, options); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function setSelection(doc, sel, options) {\n\t\t setSelectionNoUndo(doc, sel, options);\n\t\t addSelectionToHistory(doc, doc.sel, doc.cm ? doc.cm.curOp.id : NaN, options);\n\t\t }", "function setSelection(doc, sel, options) {\n\t\t setSelectionNoUndo(doc, sel, options);\n\t\t addSelectionToHistory(d...
[ "0.7453179", "0.7453179", "0.7395772", "0.7395772", "0.7395772", "0.7356902", "0.72738075", "0.72738075", "0.7272042", "0.724487", "0.724487", "0.724487", "0.724487", "0.724487", "0.724487", "0.724487", "0.724487", "0.724487", "0.724487", "0.724487", "0.7192502", "0.6912936...
0.7300484
24
Verify that the selection does not partially select any atomic marked ranges.
function reCheckSelection(doc) { setSelectionInner(doc, skipAtomicInSelection(doc, doc.sel, null, false)); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "get hasSelection() {\n const start = this._model.finalSelectionStart;\n const end = this._model.finalSelectionEnd;\n if (!start || !end) {\n return false;\n }\n return start[0] !== end[0] || start[1] !== end[1];\n }", "function selectionIsSane() {\n\t\t\tvar minSi...
[ "0.6870172", "0.60677147", "0.6066715", "0.6055218", "0.60424894", "0.5962891", "0.5962891", "0.5962891", "0.5962891", "0.5962891", "0.5962891", "0.5962891", "0.596198", "0.5916995", "0.5891306", "0.5881634", "0.5881634", "0.5879924", "0.5879924", "0.5879924", "0.5879924", ...
0.57861257
69
Return a selection that does not partially select any atomic ranges.
function skipAtomicInSelection(doc, sel, bias, mayClear) { var out; for (var i = 0; i < sel.ranges.length; i++) { var range = sel.ranges[i]; var old = sel.ranges.length == doc.sel.ranges.length && doc.sel.ranges[i]; var newAnchor = skipAtomic(doc, range.anchor, old && old.anchor, bias, mayClear); var newHead = skipAtomic(doc, range.head, old && old.head, bias, mayClear); if (out || newAnchor != range.anchor || newHead != range.head) { if (!out) { out = sel.ranges.slice(0, i); } out[i] = new Range(newAnchor, newHead); } } return out ? normalizeSelection(doc.cm, out, sel.primIndex) : sel }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "selection_excluding(cells) {\n const selection = new Set(this.selection);\n for (const cell of cells) {\n selection.delete(cell);\n }\n return selection;\n }", "function skipAtomicInSelection(doc, sel, bias, mayClear) {\n var out;\n for (var i = 0; i < sel.ranges.l...
[ "0.68471473", "0.6635531", "0.6635531", "0.6635531", "0.6635531", "0.6635531", "0.6635531", "0.6635531", "0.6594504", "0.6475148", "0.6474048", "0.6474048", "0.6436025", "0.6436025", "0.6436025", "0.6436025", "0.6436025", "0.6436025", "0.6436025", "0.6436025", "0.6436025", ...
0.64379954
22
Ensure a given position is not inside an atomic range.
function skipAtomic(doc, pos, oldPos, bias, mayClear) { var dir = bias || 1; var found = skipAtomicInner(doc, pos, oldPos, dir, mayClear) || (!mayClear && skipAtomicInner(doc, pos, oldPos, dir, true)) || skipAtomicInner(doc, pos, oldPos, -dir, mayClear) || (!mayClear && skipAtomicInner(doc, pos, oldPos, -dir, true)); if (!found) { doc.cantEdit = true; return Pos(doc.first, 0) } return found }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "static isInsideRange(position, range) {\n if (range.start.line === range.end.line) {\n return range.start.line === position.line\n && range.start.character <= position.character\n && position.character <= range.end.character;\n }\n else if (range.start....
[ "0.59879375", "0.5966708", "0.59146243", "0.562402", "0.56166", "0.5598513", "0.5584527", "0.5547357", "0.5532226", "0.5531274", "0.5508034", "0.54775023", "0.547714", "0.5409574", "0.54091066", "0.5399065", "0.5388472", "0.5386206", "0.53633547", "0.5344547", "0.5343511", ...
0.0
-1