CB-3975 fix: selection out of boundaries (#2173)

Co-authored-by: Daria Marutkina <125263541+dariamarutkina@users.noreply.github.com>
This commit is contained in:
Alexey
2023-11-28 15:58:05 +03:00
committed by GitHub
co-authored by Daria Marutkina
parent 76a440c482
commit c3d6490efb
2 changed files with 2 additions and 4 deletions
@@ -43,10 +43,10 @@ export const SQLCodeEditorPanel: TabContainerPanelComponent<ISqlEditorModeProps>
useEffect(() => {
editorRef?.view?.dispatch({
selection: { anchor: localState.selection.from, head: localState.selection.to },
selection: { anchor: Math.min(localState.selection.to, data.value.length), head: Math.min(localState.selection.to, data.value.length) },
scrollIntoView: true,
});
}, [editorRef?.view, localState]);
}, [editorRef?.view, localState, data]);
useEffect(() => {
if (!editorRef?.selection) {
@@ -26,7 +26,6 @@ import { SqlEditorService } from '../SqlEditorService';
import { ISQLScriptSegment, SQLParser } from '../SQLParser';
import { SqlExecutionPlanService } from '../SqlResultTabs/ExecutionPlan/SqlExecutionPlanService';
import { OUTPUT_LOGS_TAB_ID } from '../SqlResultTabs/OutputLogs/OUTPUT_LOGS_TAB_ID';
import { OutputLogsService } from '../SqlResultTabs/OutputLogs/OutputLogsService';
import { SqlQueryService } from '../SqlResultTabs/SqlQueryService';
import { SqlResultTabsService } from '../SqlResultTabs/SqlResultTabsService';
import type { ICursor, ISQLEditorData } from './ISQLEditorData';
@@ -69,7 +68,6 @@ export function useSqlEditor(state: ISqlEditorTabState): ISQLEditorData {
const sqlResultTabsService = useService(SqlResultTabsService);
const commonDialogService = useService(CommonDialogService);
const sqlDataSourceService = useService(SqlDataSourceService);
const sqlOutputLogsService = useService(OutputLogsService);
const data = useObservableRef<ISQLEditorDataPrivate>(
() => ({