From 0cdf4a8770bf090d9797031ba72726c7b1bbac2d Mon Sep 17 00:00:00 2001 From: Aleksei Potsetsuev Date: Mon, 26 Feb 2024 23:10:20 +0800 Subject: [PATCH] CB-4740 fix: sql editor mode detection --- .../plugin-sql-editor/src/SqlDataSource/BaseSqlDataSource.ts | 4 ++-- .../packages/plugin-sql-editor/src/SqlEditor/useSqlEditor.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/webapp/packages/plugin-sql-editor/src/SqlDataSource/BaseSqlDataSource.ts b/webapp/packages/plugin-sql-editor/src/SqlDataSource/BaseSqlDataSource.ts index e9dd014a93..bcf54266d4 100644 --- a/webapp/packages/plugin-sql-editor/src/SqlDataSource/BaseSqlDataSource.ts +++ b/webapp/packages/plugin-sql-editor/src/SqlDataSource/BaseSqlDataSource.ts @@ -239,10 +239,10 @@ export abstract class BaseSqlDataSource implements ISqlDataSource { const scriptLength = this.script.length; - this.innerCursorState = { + this.innerCursorState = Object.freeze({ begin: Math.min(begin, scriptLength), end: Math.min(end, scriptLength), - }; + }); this.onUpdate.execute(); } diff --git a/webapp/packages/plugin-sql-editor/src/SqlEditor/useSqlEditor.ts b/webapp/packages/plugin-sql-editor/src/SqlEditor/useSqlEditor.ts index 5b8b6fd043..23361e73ff 100644 --- a/webapp/packages/plugin-sql-editor/src/SqlEditor/useSqlEditor.ts +++ b/webapp/packages/plugin-sql-editor/src/SqlEditor/useSqlEditor.ts @@ -5,7 +5,7 @@ * Licensed under the Apache License, Version 2.0. * you may not use this file except in compliance with the License. */ -import { action, autorun, computed, IReactionDisposer, observable, untracked } from 'mobx'; +import { action, autorun, computed, IReactionDisposer, observable, runInAction, untracked } from 'mobx'; import { useEffect } from 'react'; import { ConfirmationDialog, useExecutor, useObservableRef } from '@cloudbeaver/core-blocks'; @@ -538,7 +538,7 @@ export function useSqlEditor(state: ISqlEditorTabState): ISQLEditorData { const contexts = data.onMode.execute(data); const activeSegmentMode = contexts.getContext(SQLEditorModeContext); - action(() => { + runInAction(() => { data.activeSegmentMode = activeSegmentMode; }); });