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

Method findCharacter

src/utils/Cursor.ts:1062–1105  ·  view source on GitHub ↗

* Find a character using vim f/F/t/T semantics. * * @param char - The character to find * @param type - 'f' (forward to), 'F' (backward to), 't' (forward till), 'T' (backward till) * @param count - Find the Nth occurrence * @returns The target offset, or null if not found

(
    char: string,
    type: 'f' | 'F' | 't' | 'T',
    count: number = 1,
  )

Source from the content-addressed store, hash-verified

1060 * @returns The target offset, or null if not found
1061 */
1062 findCharacter(
1063 char: string,
1064 type: 'f' | 'F' | 't' | 'T',
1065 count: number = 1,
1066 ): number | null {
1067 const text = this.text
1068 const forward = type === 'f' || type === 't'
1069 const till = type === 't' || type === 'T'
1070 let found = 0
1071
1072 if (forward) {
1073 let pos = this.measuredText.nextOffset(this.offset)
1074 while (pos < text.length) {
1075 const grapheme = this.graphemeAt(pos)
1076 if (grapheme === char) {
1077 found++
1078 if (found === count) {
1079 return till
1080 ? Math.max(this.offset, this.measuredText.prevOffset(pos))
1081 : pos
1082 }
1083 }
1084 pos = this.measuredText.nextOffset(pos)
1085 }
1086 } else {
1087 if (this.offset === 0) return null
1088 let pos = this.measuredText.prevOffset(this.offset)
1089 while (pos >= 0) {
1090 const grapheme = this.graphemeAt(pos)
1091 if (grapheme === char) {
1092 found++
1093 if (found === count) {
1094 return till
1095 ? Math.min(this.offset, this.measuredText.nextOffset(pos))
1096 : pos
1097 }
1098 }
1099 if (pos === 0) break
1100 pos = this.measuredText.prevOffset(pos)
1101 }
1102 }
1103
1104 return null
1105 }
1106}
1107
1108class WrappedLine {

Callers 3

executeOperatorFindFunction · 0.80
fromFindFunction · 0.80
executeRepeatFindFunction · 0.80

Calls 4

graphemeAtMethod · 0.95
nextOffsetMethod · 0.80
maxMethod · 0.80
prevOffsetMethod · 0.80

Tested by

no test coverage detected