UI: Word Boundary Seeking #107762
No reviewers
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#107762
Loading…
Reference in New Issue
No description provided.
Delete Branch "Harley:WordBoundaries"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Changes to how we detect boundaries between words when selecting,
moving the cursor, deleting, etc.
When moving any text cursor position to a word boundary we always first move in the intended direction by one character without any further testing. This results in unintended bad behavior. The following shows where your cursor is moved when you use ctrl-arrow keys to move to the next word boundary. You will see that the movements shown in red are inconsistent with all other movement:
This incorrect boundary movement causes errors when selecting words near the ends of word positions and if the word is only a single letter long. Following shows three types of word selections that accidentally include whitespace:
This happens because our "Cursor Step" functions take a
use_init_step
argument that forces this initial one-character movement. This argument was added so that movement between words would occur a word at a time. For example ctrl-left arrow will move from word start to previous word start, rather than word start, then word end, then word start.However this movement should only happen when at whitespace. And we always call the "Cursor Step" functions with this set to true. So this PR just removes this argument entirely and does the initial movement only when appropriate.
@ -145,3 +144,3 @@
if (direction == STRCUR_DIR_NEXT) {
if (use_init_step) {
if (jump == STRCUR_JUMP_DELIM && ELEM(str[*pos], ' ', '\n', '\t')) {
Use
cursor_delim_type_unicode(..)
instead & check forSTRCUR_DELIM_WHITESPACE
.This breaks selecting white-space for the text-editor, text-fields and 3d-text (not the Python console) try add multiple spaces then double-click to select the space between words. From what I cn see the white-space check should check adjacent character is not white-space.
Also, please leave changes to double-click word selection out of this patch, the checks for
ELEM(..,' ', '\n', '\t')
aren't great it's probably better to have a function as part of theBLI_str_cursor_*
API, then there is no need to do character level checks & forwards/backwards motion. There is also less likelihood of behavior being inconsistent for text editing fields (currently the case with this patch, maybe a simple mistake/change).@ideasman42 -... selecting white-space for the text-editor, text-fields and 3d-text (not the Python console)...
Yikes, it takes quite a bit more to get consistent behavior everywhere and deal with groups of multiple whitespaces correctly. Mostly that
BLI_str_cursor_step_utf8
has to seek over multiple whitespace characters rather than that single character move.Lots of current code, including the double-click for word selection rely on current behavior that needs to change. This does get rid of all those whitespace checks by instead using
cursor_delim_type_unicode
that I make public here as BLI_str_cursor_delim_type_utf8/32.But yeah, lots of change here to fix something that is only slightly wonky now.
@ -11,6 +11,17 @@
extern "C" {
#endif
typedef enum eStrCursorDelimType {
I'd rather avoid exposing internal implementation details and instead have a
BLI_str_cursor_step_range(..)
or similar.Having to duplicate this logic about seems unnecessarily involved when it can be handled by a reusable utility function.
In fact, a
BLI_str_cursor_step_range(..)
utility function could be added as a separate refactor (it can use the current logic, which then simplifies this patch).@ideasman42 - I'd rather avoid exposing internal implementation details and instead have...
Yes, it is much nicer like that. Added BLI_str_cursor_at_word_boundary_utfx() to clean that up and it gets rid of a lot of mess there.
After some discussion this patch makes functional changes to cursor stepping (stepping over spaces works differently for e.g.) that should be made carefully and aren't directly related to resolving the issue selecting words.
Proposed solution is to add
BLI_str_cursor_step_bounds_utf*
which takes a point and returns a bounding range. This can be done without any changes to existing cursor stepping functions.Internally it can step over matching character categories,
pos
&&pos-1
categories match, seek in both directions, delimit by character category.[alpha-numeric, brackets, punctuation, space]
.This way double clicking at a word boundary always prioritizes the words not the spaces.
Closing this PR as the proposed changes is quite a different direction from this one.
Pull request closed