How to use the monaco-editor.Range 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 onflow / cadence / tools / astexplorer / src / index.tsx View on Github external
onOver={node => {
          if (!isNode(node)) {
            return false
          }
          current = node
          decorations = model.deltaDecorations(decorations, [
            {
              range: new monaco.Range(
                node.StartPos.Line,
                node.StartPos.Column + 1,
                node.EndPos.Line,
                node.EndPos.Column + 2
              ),
              options: {
                inlineClassName: 'highlighted'
              }
            },
          ]);
          return true
        }}
        onLeave={node => {
github mattgodbolt / compiler-explorer / static / panes / editor.js View on Github external
Editor.prototype.onEditorLinkLine = function (editorId, lineNum, columnNum, reveal) {
    if (Number(editorId) === this.id) {
        if (reveal && lineNum) this.editor.revealLineInCenter(lineNum);
        this.decorations.linkedCode = lineNum === -1 || !lineNum ? [] : [{
            range: new monaco.Range(lineNum, 1, lineNum, 1),
            options: {
                isWholeLine: true,
                linesDecorationsClassName: 'linked-code-decoration-margin',
                className: 'linked-code-decoration-line'
            }
        }];

        if (lineNum > 0 && columnNum !== -1) {
            this.decorations.linkedCode.push({
                range: new monaco.Range(lineNum, columnNum, lineNum, columnNum + 1),
                options: {
                    isWholeLine: false,
                    inlineClassName: 'linked-code-decoration-column'
                }
            });
        }

        if (this.fadeTimeoutId !== -1) {
            clearTimeout(this.fadeTimeoutId);
        }
        this.fadeTimeoutId = setTimeout(_.bind(function () {
            this.clearLinkedLine();
            this.fadeTimeoutId = -1;
        }, this), 5000);

        this.updateDecorations();
github mattgodbolt / compiler-explorer / static / panes / editor.js View on Github external
this.decorations.tags = _.map(widgets, function (tag) {
        return {
            range: new monaco.Range(tag.startLineNumber, tag.startColumn, tag.startLineNumber + 1, 1),
            options: {
                isWholeLine: false,
                inlineClassName: "error-code"
            }
        };
    }, this);
    this.updateDecorations();
github Coding / WebIDE-Frontend / app / components / MonacoEditor / mergeConflictMinxin / mergeConflictParser.js View on Github external
function lineAt (model, lineNumber) {
  const lineContent = model.getLineContent(lineNumber)
  const lineCount = model.getLineCount()
  const range = new monaco.Range(lineNumber, 0, lineNumber, lineContent.length)
  const firstNonWhitespaceCharacterIndex = /^(\s*)/.exec(lineContent)[1].length
  const line = {
    lineNumber,
    text: lineContent,
    range,
    rangeIncludingLineBreak: lineNumber < lineCount - 1
      ? new monaco.Range(lineNumber, 0, lineNumber + 1, 0)
      : range,
    firstNonWhitespaceCharacterIndex,
    isEmptyOrWhitespace: firstNonWhitespaceCharacterIndex === lineContent.length
  }
  return line
}
github apache / zeppelin / zeppelin-web-angular / src / app / share / ng1-migration / ng1-migration.component.ts View on Github external
messages.map(failure => {
        const line = failure.pos.line + 1;
        const character = failure.pos.character + 1;
        return {
          range: new Range(line, character, line, character + failure.length),
          options: {
            className: failure.level === LogLevel.Error ? '' : 'warn-content',
            inlineClassName: failure.level === LogLevel.Error ? 'decoration-link' : '',
            stickiness: 1,
            hoverMessage: {
              value: failure.message + (failure.url ? ` [more](${failure.url})` : '')
            }
          }
        };
      })
    );
github Coding / WebIDE-Frontend / app / components / MonacoEditor / mergeConflictMinxin / mergeConflictParser.js View on Github external
function lineAt (model, lineNumber) {
  const lineContent = model.getLineContent(lineNumber)
  const lineCount = model.getLineCount()
  const range = new monaco.Range(lineNumber, 0, lineNumber, lineContent.length)
  const firstNonWhitespaceCharacterIndex = /^(\s*)/.exec(lineContent)[1].length
  const line = {
    lineNumber,
    text: lineContent,
    range,
    rangeIncludingLineBreak: lineNumber < lineCount - 1
      ? new monaco.Range(lineNumber, 0, lineNumber + 1, 0)
      : range,
    firstNonWhitespaceCharacterIndex,
    isEmptyOrWhitespace: firstNonWhitespaceCharacterIndex === lineContent.length
  }
  return line
}
github Coding / WebIDE-Frontend / app / components / MonacoEditor / mergeConflictMinxin / mergeConflictParser.js View on Github external
commonAncestors: match.commonAncestors.map((currentTokenLine, index, commonAncestors) => {
      const nextTokenLine = commonAncestors[index + 1] || match.splitter
      return {
        header: currentTokenLine.range,
        decoratorContent: new monaco.Range(
          currentTokenLine.rangeIncludingLineBreak.endLineNumber,
          currentTokenLine.rangeIncludingLineBreak.endColumn,
          ...shiftBackOneCharacter(
            model,
            {
              lineNumber: nextTokenLine.range.startLineNumber,
              column: nextTokenLine.range.startColumn,
            },
            {
              lineNumber: currentTokenLine.rangeIncludingLineBreak.endLineNumber,
              column: currentTokenLine.rangeIncludingLineBreak.endColumn,
            }
          )
        ),
        content: new monaco.Range(
          currentTokenLine.rangeIncludingLineBreak.endLineNumber,
github graphql-editor / graphql-editor / src / editor / code / monaco / errors.ts View on Github external
export const mapEditorErrorToMonacoDecoration = (e: EditorError) =>
  ({
    range: new monaco.Range(e.row + 1, 1, e.row + 1, 1000),
    options: {
      className: 'monacoError',
      isWholeLine: true,
      minimap: {
        color: Colors.red[0],
        position: 1,
      },
      hoverMessage: [
        {
          value: e.text,
        },
      ],
      glyphMarginHoverMessage: {
        value: e.text,
      },
      glyphMarginClassName: 'monacoMarginError',
github mattgodbolt / compiler-explorer / static / panes / opt-view.js View on Github external
_.mapObject(results, function (value, key) {
        var linenumber = Number(key);
        var className = value.reduce(function (acc, x) {
            if (x.optType === "Missed" || acc === "Missed") {
                return "Missed";
            } else if (x.optType === "Passed" || acc === "Passed") {
                return "Passed";
            }
            return x.optType;
        }, "");
        var contents = _.map(value, this.getDisplayableOpt, this);
        opt.push({
            range: new monaco.Range(linenumber, 1, linenumber, Infinity),
            options: {
                isWholeLine: true,
                glyphMarginClassName: "opt-decoration." + className.toLowerCase(),
                hoverMessage: contents,
                glyphMarginHoverMessage: contents
            }
        });
    }, this);