MCPcopy Create free account
hub / github.com/breck7/scroll / codeMirrorAutocomplete

Method codeMirrorAutocomplete

external/.scrollLibs.js:21564–21578  ·  view source on GitHub ↗
(cmInstance, options)

Source from the content-addressed store, hash-verified

21562 return this._codeMirrorLib
21563 }
21564 async codeMirrorAutocomplete(cmInstance, options) {
21565 const cursor = cmInstance.getDoc().getCursor()
21566 const codeMirrorLib = this._getCodeMirrorLib()
21567 const program = this._getParsedProgram()
21568 const result = await program.getAutocompleteResultsAt(cursor.line, cursor.ch)
21569 // It seems to be better UX if there's only 1 result, and its the atom the user entered, to close autocomplete
21570 if (result.matches.length === 1 && result.matches[0].text === result.atom) return null
21571 return result.matches.length
21572 ? {
21573 list: result.matches,
21574 from: codeMirrorLib.Pos(cursor.line, result.startCharIndex),
21575 to: codeMirrorLib.Pos(cursor.line, result.endCharIndex)
21576 }
21577 : null
21578 }
21579 register() {
21580 const codeMirrorLib = this._getCodeMirrorLib()
21581 codeMirrorLib.defineMode(this._name, () => this)

Callers 1

Calls 2

_getCodeMirrorLibMethod · 0.95

Tested by

no test coverage detected