Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb16f6c2

Browse files
committed
[Fix]:#2022 Tab spacing issue in code editor
1 parentae2422c commitb16f6c2

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

‎client/packages/lowcoder/src/base/codeEditor/extensions.tsx‎

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import {
2727
foldKeymap,
2828
indentOnInput,
2929
}from"@codemirror/language";
30-
import{defaultKeymap,history,historyKeymap,indentWithTab}from"@codemirror/commands";
30+
import{defaultKeymap,history,historyKeymap,insertTab,indentLess,indentMore}from"@codemirror/commands";
3131
import{highlightSelectionMatches,searchKeymap}from"@codemirror/search";
3232
import{Diagnostic,linter,lintKeymap}from"@codemirror/lint";
3333
import{typeEditorState,Prec}from"@codemirror/state";
@@ -282,7 +282,20 @@ export function useFocusExtension(onFocus?: (focused: boolean) => void): [Extens
282282
}
283283

284284
functionindentWithTabExtension(open?:boolean){
285-
returnopen??true ?keymap.of([indentWithTab]) :[];
285+
if(!(open??true))return[];
286+
returnkeymap.of([
287+
{
288+
key:"Tab",
289+
run:(view:EditorView)=>{
290+
const{ main}=view.state.selection;
291+
if(!main.empty&&main.from!==main.to){
292+
returnindentMore(view);
293+
}
294+
returninsertTab(view);
295+
},
296+
},
297+
{key:"Shift-Tab",run:indentLess},
298+
]);
286299
}
287300

288301
exportfunctionlineNoExtension(showLineNumber?:boolean){
@@ -493,26 +506,26 @@ export function useExtensions(props: CodeEditorProps) {
493506
basicSetup,
494507
defaultTheme,
495508
highlightJsExt,
496-
autocompletionExtension,
497509
focusExtension,
498510
lineNoExt,
499511
languageExt,
500512
onChangeExt,
501513
placeholderExt,
502514
indentWithTabExt,
515+
autocompletionExtension,
503516
tooltipExt,
504517
lintExt,
505518
iconExt,
506519
],
507520
[
508521
highlightJsExt,
509-
autocompletionExtension,
510522
focusExtension,
511523
lineNoExt,
512524
languageExt,
513525
onChangeExt,
514526
placeholderExt,
515527
indentWithTabExt,
528+
autocompletionExtension,
516529
tooltipExt,
517530
lintExt,
518531
iconExt,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp