Text Editor: Auto Close Pairs on Selected Text #111900
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
4 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#111900
Loading…
Reference in New Issue
No description provided.
Delete Branch "Matheus-Santos/blender:text_wrap_selection"
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?
When the auto-close preference is enabled & brackets or quotes are entered with a selection,
the selection is surrounded by those characters - instead of replacing the selection.
Match functionality from visual-studio code.
Hi, thanks for the PR. Looks correct so far.
Patch fails when selected string contains only empty spaces.
@ -3560,0 +3583,4 @@
txt_move_to(st->text, BLI_findindex(&st->text->lines, curl), curc, false);
}
else if (curl == sell) {
int ch = curc > selc ? curc : selc;
can be
const
?Yes, it can. Should I update it?
yes, that'd be good :)
Also consider this case. I expect it not surround spaces with auto close character
I've made the requested changes. Now when there are only white spaces it will replace the selection
cc @pablovazquez
Haven't tested it yet but I love this feature, absolute +1
Thanks!
There is a bug when this option is enabled. Selecting a word and pressing a key no longer removes the selected text first.
@ -98,0 +103,4 @@
* \param line2_char: The character number of line2.
* \return True if there is at least one non whitespace character.
*/
static bool text_test_has_non_whitespace(TextLine *line1,
text_test_has_non_whitespace
could be negated and renamed totext_span_is_blank(...)
I think it's a bit easier to follow.@ -3529,6 +3575,10 @@ static int text_insert_invoke(bContext *C, wmOperator *op, const wmEvent *event)
SpaceText *st = CTX_wm_space_text(C);
uint auto_close_char = 0;
int ret;
TextLine *sell = nullptr;
These are generically named variables for something fairly spesific.
I'd prefer these use a local struct.
e.g.
@ideasman42 I forgot to separate it in a different commit, but the bug is also solved now.
@ -96,2 +96,4 @@
}
/**
* This function receives a range and returns true if there is at least one non whitespace
Doc string needs updating, by convention each
\param
starts on a newline.@ -3551,0 +3602,4 @@
if (txt_has_sel(st->text) &&
!text_span_is_blank(st->text->sell, st->text->selc, st->text->curl, st->text->curc) &&
text_closing_character_pair_get(auto_close_char) != 0)
text_closing_character_pair_get
is likely to be a cheaper check thantext_span_is_blank
, better check that first.@ -3551,0 +3610,4 @@
auto_close_select.curc = st->text->curc;
/* Move the cursor to the start of the selection. */
if (txt_get_span(auto_close_select.curl, auto_close_select.sell) > 0 ||
txt_get_span(auto_close_select.curl, auto_close_select.sell)
is called multiple times, should the result be stored inauto_close_select
?Added that, it looks a lot cleaner.