mirror of
https://github.com/dbeaver/cloudbeaver.git
synced 2026-09-24 16:04:36 +08:00
reverts insert property logic
This commit is contained in:
@@ -19,6 +19,7 @@ import { type IReactCodemirrorContext, ReactCodemirrorContext } from './ReactCod
|
||||
import { useCodemirrorExtensions } from './useCodemirrorExtensions.js';
|
||||
import { validateCursorBoundaries } from './validateCursorBoundaries.js';
|
||||
import { ReactCodemirrorSearchPanel } from './ReactCodemirrorSearchPanel.js';
|
||||
import { hasInsertProperty } from './hasInsertProperty.js';
|
||||
|
||||
const External = Annotation.define<boolean>();
|
||||
|
||||
@@ -213,6 +214,13 @@ export const ReactCodemirror = observer<IReactCodeMirrorProps, IEditorRef>(
|
||||
}
|
||||
}
|
||||
|
||||
if (hasInsertProperty(transaction.changes) && !transaction.selection) {
|
||||
transaction.selection = {
|
||||
anchor: transaction.changes.insert?.length ?? 0,
|
||||
head: transaction.changes.insert?.length ?? 0,
|
||||
};
|
||||
}
|
||||
|
||||
if (transaction.changes) {
|
||||
view.dispatch({ changes: transaction.changes });
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
/*
|
||||
* CloudBeaver - Cloud Database Manager
|
||||
* Copyright (C) 2020-2025 DBeaver Corp and others
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0.
|
||||
* you may not use this file except in compliance with the License.
|
||||
*/
|
||||
import type { ChangeSpec, Text } from '@codemirror/state';
|
||||
|
||||
export function hasInsertProperty(spec: ChangeSpec | undefined): spec is { from: number; to?: number; insert?: string | Text } {
|
||||
return typeof spec === 'object' && spec !== null && 'insert' in spec;
|
||||
}
|
||||
Reference in New Issue
Block a user