MCPcopy Create free account
hub / github.com/Exafunction/codeium-chrome / getValueAndStartOffset

Function getValueAndStartOffset

src/monacoCompletionProvider.ts:98–111  ·  view source on GitHub ↗
(
  monacoSite: MonacoSite,
  model: monaco.editor.ITextModel | string
)

Source from the content-addressed store, hash-verified

96// Some environments like Databricks will include extraneous text, such as %sql
97// as the first line. We need to trim this out.
98function getValueAndStartOffset(
99 monacoSite: MonacoSite,
100 model: monaco.editor.ITextModel | string
101): { value: string; utf16Offset: number } {
102 const originalValue = typeof model === 'string' ? model : model.getValue();
103 if (monacoSite !== OMonacoSite.DATABRICKS || !originalValue.startsWith('%')) {
104 return { value: originalValue, utf16Offset: 0 };
105 }
106 const indexofNewline = originalValue.indexOf('\n');
107 const indexOfSecondLine = indexofNewline === -1 ? originalValue.length : indexofNewline + 1;
108 // TODO(prem): This is going to let completions start at the end of %python lines, etc.
109 // https://github.com/Exafunction/Exafunction/pull/3652#discussion_r1102165558
110 return { value: originalValue.substring(indexOfSecondLine), utf16Offset: indexOfSecondLine };
111}
112
113function createInlineCompletionItem(
114 monacoSite: MonacoSite,

Callers 2

computeTextAndOffsetsMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected