mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
feat(loki-monaco-editor): fix deprecations and errors in situation
This commit is contained in:
parent
458bda6eb1
commit
491c934538
@ -27,9 +27,9 @@ function assertSituation(situation: string, expectedSituation: Situation | null)
|
||||
|
||||
describe('situation', () => {
|
||||
it('handles things', () => {
|
||||
// assertSituation('^', {
|
||||
// type: 'EMPTY',
|
||||
// });
|
||||
assertSituation('^', {
|
||||
type: 'EMPTY',
|
||||
});
|
||||
|
||||
assertSituation('s^', {
|
||||
type: 'AT_ROOT',
|
||||
|
@ -474,9 +474,9 @@ function getErrorNode(tree: Tree, text: string, cursorPos: number): SyntaxNode |
|
||||
// sometimes the cursor is a couple spaces after the end of the expression.
|
||||
// to account for this situation, we "move" the cursor position back,
|
||||
// so that there are no spaces between the end-of-expression and the cursor
|
||||
const trimRightTextLen = text.trimRight().length;
|
||||
const trimRightTextLen = text.trimEnd().length;
|
||||
const pos = trimRightTextLen < cursorPos ? trimRightTextLen : cursorPos;
|
||||
const cur = tree.cursor(pos);
|
||||
const cur = tree.cursorAt(pos);
|
||||
do {
|
||||
if (cur.from === pos && cur.to === pos) {
|
||||
const { node } = cur;
|
||||
@ -507,7 +507,7 @@ export function getSituation(text: string, pos: number): Situation | null {
|
||||
// so first we check if there is an error node at the cursor position
|
||||
const maybeErrorNode = getErrorNode(tree, text, pos);
|
||||
|
||||
const cur = maybeErrorNode != null ? maybeErrorNode.cursor() : tree.cursor(pos);
|
||||
const cur = maybeErrorNode != null ? maybeErrorNode.cursor() : tree.cursorAt(pos);
|
||||
|
||||
const currentNode = cur.node;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user