Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var label = this.getLabelAtPosition(position);
if (!label) {
return;
}
var labelDefLineNum = this.labelDefinitions[label.name];
if (!labelDefLineNum) {
return;
}
// Highlight the new range.
var endLineContent =
this.outputEditor.getModel().getLineContent(labelDefLineNum);
this.outputEditor.setSelection(new monaco.Selection(
labelDefLineNum, 0,
labelDefLineNum, endLineContent.length + 1));
// Jump to the given line.
this.outputEditor.revealLineInCenter(labelDefLineNum);
};
it('sets cursor to end of the replaced string', () => {
const selection = editor.getSelection();
expect(selection).toEqual(new Selection(1, 10, 1, 10));
});
});
const options = {
language: 'json',
theme: 'vs-dark',
options: {
formatOnType: true,
formatOnPaste: true,
autoIndent: true
}
}
this.editorInstance = monaco.editor.create(this.monaco.current, {
...options
});
this.editorInstance.setModel(model);
this.editorInstance.setSelection(new monaco.Selection(3,13,3,13));
this.editorInstance.focus();
window.onresize = () => this.editorInstance.layout();
setTimeout(() => this.editorInstance.layout(), 1000);
this.editorInstance.onDidChangeModelContent(() => {
const changedSchema = this.editorInstance.getValue();
window.localStorage.setItem('schema', changedSchema);
this.props.onChange(changedSchema);
});
this.addCommands(this.editorInstance);
}
addCommands(editor) {
range: content,
text: '',
forceMoveMarkers: false,
}])
break
}
case 'accept-both':
default:
break
}
}
})
if (props.selection) {
const { startLineNumber, startColumn } = props.selection
const selection = new monaco.Selection(startLineNumber, startColumn, startLineNumber, startColumn)
this.selection = selection
monacoEditor.setSelection(selection)
monacoEditor.revealLineInCenter(startLineNumber, 1)
}
monacoEditor._editorInfo = this
this.monacoEditor = monacoEditor
if (props.debug) {
this.setDebugDeltaDecorations()
}
if (containsConflict(this.content)) {
this.containsConflict = true
if (hasCache(this.filePath)) {
this.conflicts = cacheConflicts.get(this.filePath)
const options = {
language: "json",
options: {
autoIndent: true,
formatOnPaste: true,
formatOnType: true,
},
theme: this.props.uiSchema.appBar["ui:darkMode"] ? "vs-dark" : "vs",
};
if (this.monaco && this.monaco.current) {
this.editorInstance = monaco.editor.create(this.monaco.current, {
...options,
});
this.editorInstance.setModel(model);
this.editorInstance.setSelection(new monaco.Selection(4, 13, 4, 13));
this.editorInstance.focus();
window.onresize = () => this.editorInstance && this.editorInstance.layout();
setTimeout(() => this.editorInstance && this.editorInstance.layout(), 1000);
this.editorInstance.onDidChangeModelContent(() => {
const changedSchema = this.editorInstance && this.editorInstance.getValue();
if (changedSchema) {
window.localStorage.setItem("schema", changedSchema);
this.props.onChange(changedSchema);
}
});
this.props.onCreate(this.editorInstance);
}
this.addCommands(this.editorInstance);
setTimeout(_.bind(function () {
this.editor.setSelection(new monaco.Selection(1, 1, 1, 1));
this.editor.focus();
this.editor.getAction("editor.fold").run();
this.editor.clearSelection();
}, this), 500);
}
enableSchemaRequest: true,
schemas: [
{
fileMatch: ["*"],
schema,
uri: modelUri.toString(),
},
],
validate: true,
});
m.updateOptions({ tabSize: 2 });
setModel(m);
editor.setModel(m);
const [selectionStartLineNumber, selectionStartColumn, positionLineNumber, positionColumn] = position;
editor.setSelection(
new monaco.Selection(selectionStartLineNumber, selectionStartColumn, positionLineNumber, positionColumn),
);
editor.focus();
}
return () => {
if (model) {
model.dispose();
}
};
}, [editor, schema]);
return [model, setPosition];