Skip to content

Commit 4792f46

Browse files
committed
fix arabic and rtl support
1 parent bad3c52 commit 4792f46

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

lib/src/code/reg_exp.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
class RegExps {
2-
static final wordSplit = RegExp('[^_a-zA-Z0-9]+');
2+
static final wordSplit = RegExp(r'[^_a-zA-Z0-9\u0600-\u06FF]+');
33
}

lib/src/code_field/code_field.dart

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ class CodeField extends StatefulWidget {
173173
final Color? background;
174174
final EdgeInsets padding;
175175
final Decoration? decoration;
176+
final TextDirection textDirection;
176177
final TextSelectionThemeData? textSelectionTheme;
177178
final FocusNode? focusNode;
178179

@@ -196,6 +197,7 @@ class CodeField extends StatefulWidget {
196197
this.smartQuotesType = SmartQuotesType.disabled,
197198
this.padding = EdgeInsets.zero,
198199
GutterStyle? gutterStyle,
200+
this.textDirection = TextDirection.ltr,
199201
this.enabled,
200202
this.readOnly = false,
201203
this.cursorColor,
@@ -434,6 +436,7 @@ class _CodeFieldState extends State<CodeField> {
434436
maxLines: widget.maxLines,
435437
expands: widget.expands,
436438
scrollController: _codeScroll,
439+
textDirection: widget.textDirection,
437440
decoration: const InputDecoration(
438441
isCollapsed: true,
439442
contentPadding: EdgeInsets.symmetric(vertical: 16),
@@ -464,17 +467,19 @@ class _CodeFieldState extends State<CodeField> {
464467
return FocusableActionDetector(
465468
actions: widget.controller.actions,
466469
shortcuts: _shortcuts,
467-
child: Container(
468-
decoration: widget.decoration,
469-
color: _backgroundCol,
470-
key: _codeFieldKey,
471-
padding: const EdgeInsets.only(left: 8),
472-
child: Row(
473-
crossAxisAlignment: CrossAxisAlignment.start,
474-
children: [
475-
if (widget.gutterStyle.showGutter) _buildGutter(),
476-
Expanded(key: _editorKey, child: editingField),
477-
],
470+
child: Directionality(
471+
textDirection: widget.textDirection,
472+
child: Container(
473+
decoration: widget.decoration,
474+
color: _backgroundCol,
475+
key: _codeFieldKey,
476+
child: Row(
477+
crossAxisAlignment: CrossAxisAlignment.start,
478+
children: [
479+
if (widget.gutterStyle.showGutter) _buildGutter(),
480+
Expanded(key: _editorKey, child: editingField),
481+
],
482+
),
478483
),
479484
),
480485
);

0 commit comments

Comments
 (0)