MCPcopy Index your code
hub / github.com/codeaashu/claude-code / _getWordAt

Method _getWordAt

src/server/web/public/terminal.js:2195–2243  ·  view source on GitHub ↗
(e3, t3, i3 = true, s3 = true)

Source from the content-addressed store, hash-verified

2193 this._isClickInSelection(e3) || (this._selectWordAtCursor(e3, false) && this.refresh(true), this._fireEventIfSelectionChanged());
2194 }
2195 _getWordAt(e3, t3, i3 = true, s3 = true) {
2196 if (e3[0] >= this._bufferService.cols) return;
2197 const r2 = this._bufferService.buffer, n2 = r2.lines.get(e3[1]);
2198 if (!n2) return;
2199 const o2 = r2.translateBufferLineToString(e3[1], false);
2200 let a2 = this._convertViewportColToCharacterIndex(n2, e3[0]), h2 = a2;
2201 const c2 = e3[0] - a2;
2202 let l2 = 0, d2 = 0, _2 = 0, u2 = 0;
2203 if (" " === o2.charAt(a2)) {
2204 for (; a2 > 0 && " " === o2.charAt(a2 - 1); ) a2--;
2205 for (; h2 < o2.length && " " === o2.charAt(h2 + 1); ) h2++;
2206 } else {
2207 let t4 = e3[0], i4 = e3[0];
2208 0 === n2.getWidth(t4) && (l2++, t4--), 2 === n2.getWidth(i4) && (d2++, i4++);
2209 const s4 = n2.getString(i4).length;
2210 for (s4 > 1 && (u2 += s4 - 1, h2 += s4 - 1); t4 > 0 && a2 > 0 && !this._isCharWordSeparator(n2.loadCell(t4 - 1, this._workCell)); ) {
2211 n2.loadCell(t4 - 1, this._workCell);
2212 const e4 = this._workCell.getChars().length;
2213 0 === this._workCell.getWidth() ? (l2++, t4--) : e4 > 1 && (_2 += e4 - 1, a2 -= e4 - 1), a2--, t4--;
2214 }
2215 for (; i4 < n2.length && h2 + 1 < o2.length && !this._isCharWordSeparator(n2.loadCell(i4 + 1, this._workCell)); ) {
2216 n2.loadCell(i4 + 1, this._workCell);
2217 const e4 = this._workCell.getChars().length;
2218 2 === this._workCell.getWidth() ? (d2++, i4++) : e4 > 1 && (u2 += e4 - 1, h2 += e4 - 1), h2++, i4++;
2219 }
2220 }
2221 h2++;
2222 let f2 = a2 + c2 - l2 + _2, v2 = Math.min(this._bufferService.cols, h2 - a2 + l2 + d2 - _2 - u2);
2223 if (t3 || "" !== o2.slice(a2, h2).trim()) {
2224 if (i3 && 0 === f2 && 32 !== n2.getCodePoint(0)) {
2225 const t4 = r2.lines.get(e3[1] - 1);
2226 if (t4 && n2.isWrapped && 32 !== t4.getCodePoint(this._bufferService.cols - 1)) {
2227 const t5 = this._getWordAt([this._bufferService.cols - 1, e3[1] - 1], false, true, false);
2228 if (t5) {
2229 const e4 = this._bufferService.cols - t5.start;
2230 f2 -= e4, v2 += e4;
2231 }
2232 }
2233 }
2234 if (s3 && f2 + v2 === this._bufferService.cols && 32 !== n2.getCodePoint(this._bufferService.cols - 1)) {
2235 const t4 = r2.lines.get(e3[1] + 1);
2236 if ((t4 == null ? void 0 : t4.isWrapped) && 32 !== t4.getCodePoint(0)) {
2237 const t5 = this._getWordAt([0, e3[1] + 1], false, false, true);
2238 t5 && (v2 += t5.length);
2239 }
2240 }
2241 return { start: f2, length: v2 };
2242 }
2243 }
2244 _selectWordAt(e3, t3) {
2245 const i3 = this._getWordAt(e3, t3);
2246 if (i3) {

Callers 2

_selectWordAtMethod · 0.80
_selectToWordAtMethod · 0.80

Calls 9

getStringMethod · 0.80
_isCharWordSeparatorMethod · 0.80
loadCellMethod · 0.80
getCodePointMethod · 0.80
getMethod · 0.65
getWidthMethod · 0.45
getCharsMethod · 0.45

Tested by

no test coverage detected