diff --git a/lib/src/code/reg_exp.dart b/lib/src/code/reg_exp.dart index 698ed128..e99fbd71 100644 --- a/lib/src/code/reg_exp.dart +++ b/lib/src/code/reg_exp.dart @@ -1,3 +1,3 @@ class RegExps { - static final wordSplit = RegExp('[^_a-zA-Z0-9]+'); + static final wordSplit = RegExp(r'[^_a-zA-Z0-9\u0600-\u06FF]+'); } diff --git a/lib/src/code_field/code_field.dart b/lib/src/code_field/code_field.dart index 8e40fd85..0ec855f7 100644 --- a/lib/src/code_field/code_field.dart +++ b/lib/src/code_field/code_field.dart @@ -173,6 +173,7 @@ class CodeField extends StatefulWidget { final Color? background; final EdgeInsets padding; final Decoration? decoration; + final TextDirection textDirection; final TextSelectionThemeData? textSelectionTheme; final FocusNode? focusNode; @@ -196,6 +197,7 @@ class CodeField extends StatefulWidget { this.smartQuotesType = SmartQuotesType.disabled, this.padding = EdgeInsets.zero, GutterStyle? gutterStyle, + this.textDirection = TextDirection.ltr, this.enabled, this.readOnly = false, this.cursorColor, @@ -434,6 +436,7 @@ class _CodeFieldState extends State { maxLines: widget.maxLines, expands: widget.expands, scrollController: _codeScroll, + textDirection: widget.textDirection, decoration: const InputDecoration( isCollapsed: true, contentPadding: EdgeInsets.symmetric(vertical: 16), @@ -464,17 +467,19 @@ class _CodeFieldState extends State { return FocusableActionDetector( actions: widget.controller.actions, shortcuts: _shortcuts, - child: Container( - decoration: widget.decoration, - color: _backgroundCol, - key: _codeFieldKey, - padding: const EdgeInsets.only(left: 8), - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - if (widget.gutterStyle.showGutter) _buildGutter(), - Expanded(key: _editorKey, child: editingField), - ], + child: Directionality( + textDirection: widget.textDirection, + child: Container( + decoration: widget.decoration, + color: _backgroundCol, + key: _codeFieldKey, + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + if (widget.gutterStyle.showGutter) _buildGutter(), + Expanded(key: _editorKey, child: editingField), + ], + ), ), ), );