How to use the monaco-editor.Position function in monaco-editor

To help you get started, we’ve selected a few monaco-editor examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tabixio / tabix / app / src / components / Dashboard / EditorTabPage / SqlEditor / SqlEditor.tsx View on Github external
public tokenizeModel = (
    model: monacoEditor.editor.ITextModel,
    cursorPos?: Position | undefined,
    selection?: Selection | undefined
  ): Array => {
    //

    /**
     *
     * Получаем ВЕСЬ текст (editor),
     * 1) Токинизируем, с разбивкой на ключевые составляющие которые нужны: KeyWords[SELECT,DELETE], TabixCommands
     * 2) Определяем выделенную область после токинизации
     * 3) Определяем какой текст выполнять
     */

    const cursorPosition = cursorPos || new Position(0, 0);

    const splitterQueryToken = 'warn-token.sql'; // Токен разбития на запросы
    const splitterTabixToken = 'tabix.sql'; // Токен разбития на запросы
    let countTabixCommandsInQuery: number = 0; // Кол-во tabix комманд запросе

    let tokensList: any[] = [];
    const tokens = globalMonaco.editor.tokenize(model.getValue(), 'clickhouse'); // ВЕСЬ текст редактора
    let countQuery: number = 0; // Кол-во запросов в тексте
    const splits: any[] = [];
    let splitToken = {
      line: 1,
      offset: 1,
      type: '',
      language: '',
    };
    let previousToken = {
github sourcegraph / sourcegraph / src / settings / MonacoSettingsEditor.tsx View on Github external
function getPositionAt(text: string, offset: number): monaco.IPosition {
    const lines = text.split('\n')
    let pos = 0
    for (const [i, line] of lines.entries()) {
        if (offset < pos + line.length + 1) {
            return new monaco.Position(i + 1, offset - pos + 1)
        }
        pos += line.length + 1
    }
    throw new Error(`offset ${offset} out of bounds in text of length ${text.length}`)
}
github sourcegraph / sourcegraph / packages / webapp / src / settings / MonacoSettingsEditor.tsx View on Github external
function getPositionAt(text: string, offset: number): monaco.IPosition {
    const lines = text.split('\n')
    let pos = 0
    for (const [i, line] of lines.entries()) {
        if (offset < pos + line.length + 1) {
            return new monaco.Position(i + 1, offset - pos + 1)
        }
        pos += line.length + 1
    }
    throw new Error(`offset ${offset} out of bounds in text of length ${text.length}`)
}
github sourcegraph / sourcegraph / cmd / management-console / web / src / CriticalConfigEditor.tsx View on Github external
function getPositionAt(text: string, offset: number): _monaco.IPosition {
    const lines = text.split('\n')
    let pos = 0
    let i = 0
    for (const line of lines) {
        if (offset < pos + line.length + 1) {
            return new _monaco.Position(i + 1, offset - pos + 1)
        }
        pos += line.length + 1
        i++
    }
    throw new Error(`offset ${offset} out of bounds in text of length ${text.length}`)
}
github gitlabhq / gitlabhq / spec / frontend / editor / editor_markdown_ext_spec.js View on Github external
const setPosition = endCol => {
      const currentPos = new Position(2, endCol);
      instance.setPosition(currentPos);
    };
github Coding / WebIDE-Frontend / app / components / MonacoEditor / mergeConflictMinxin / mergeConflictParser.js View on Github external
function shiftBackOneCharacter (model, start, end) {
  const range = new monaco.Range(start.lineNumber, start.column, start.lineNumber, start.column)
  const unlessEqual = new monaco.Range(end.lineNumber, end.column, end.lineNumber, end.column)
  if (range.equalsRange(unlessEqual)) {
    return range
  }

  let line = range.startLineNumber
  let character = range.startColumn - 1

  if (character < 0) {
    line -= 1
    character = lineAt(model, line).range.endColumn
  }

  const { lineNumber, column } = new monaco.Position(line, character)
  return [lineNumber, column]
}
github brijeshb42 / monaco-vim / src / cm_adapter.js View on Github external
function toMonacoPos(pos) {
  return new Position(pos.line + 1, pos.ch + 1);
}