diff --git a/ui/src/components/codemirror-editor/index.vue b/ui/src/components/codemirror-editor/index.vue index 5e63c7cad55..c4086b872e6 100644 --- a/ui/src/components/codemirror-editor/index.vue +++ b/ui/src/components/codemirror-editor/index.vue @@ -22,7 +22,11 @@ defineOptions({ name: 'CodemirrorEditor' }) function getRangeFromLineAndColumn(state: any, line: number, column: number, end_column?: number) { const l = state.doc.line(line) const form = l.from + column - return { form: form > l.to ? l.to : form, to: end_column ? l.from + end_column : l.to } + const to_end_column = l.from + end_column + return { + form: form > l.to ? l.to : form, + to: end_column && to_end_column < l.to ? to_end_column : l.to + } } const regexpLinter = linter(async (view) => {