MCPcopy Create free account
hub / github.com/TheRedDeveloper/ply-engine / cursor_to_raw_for_insertion

Function cursor_to_raw_for_insertion

src/text_input.rs:2069–2074  ·  view source on GitHub ↗

Like `cursor_to_raw`, but also enters empty style tags at the boundary when the basic position lands right before one. Use this for cursor positioning and single-point insertion.

(raw: &str, visual_pos: usize)

Source from the content-addressed store, hash-verified

2067 /// when the basic position lands right before one.
2068 /// Use this for cursor positioning and single-point insertion.
2069 pub fn cursor_to_raw_for_insertion(raw: &str, visual_pos: usize) -> usize {
2070 let pos = cursor_to_raw(raw, visual_pos);
2071 let chars: Vec<char> = raw.chars().collect();
2072 // If pos lands right at the start of an empty {name|} tag, enter it
2073 enter_empty_tags_at(&chars, pos)
2074 }
2075
2076 /// Insert a (pre-escaped) string at the given visual position in the raw text.
2077 /// Returns the new raw string and the new visual cursor position after insertion.

Callers 4

move_up_styledMethod · 0.85
move_down_styledMethod · 0.85
cursor_pos_rawMethod · 0.85
insert_at_visualFunction · 0.85

Calls 2

cursor_to_rawFunction · 0.85
enter_empty_tags_atFunction · 0.85

Tested by

no test coverage detected