Activity

  Dennis Hackethal revised criticism #3271.

Escape special characters


I’ve asked Gemini to explain it:

1. Auto-Closure (Insertion State)

When the user inputs an opening delimiter, the system immediately injects the corresponding closing delimiter and places the caret (cursor) between them.

Input: (

Buffer State: (|)

Logic: insert(openingchar) + insert(closingchar) + move_caret(-1)

2. Type-Through (Escape State)

If the caret is positioned immediately before a closing delimiter that was autopaired, and the user types that specific closing delimiter, the system suppresses the character insertion and instead advances the caret.

Context: [text|]

Input: ]

Buffer State: [text]| (Not [text]])

Logic: if (nextchar == inputchar) { movecaret(+1); preventdefault(); }

3. Atomic Deletion (Regression State)

If the caret is between an empty pair of delimiters, a backspace event deletes both the opening and closing characters simultaneously, returning the buffer to the pre-insertion state.

Context: (|)

Input: Backspace

Buffer State: |

Logic: if (prevchar == open && nextchar == close) { delete_range(caret-1, caret+1); }

4. Selection Wrapping (Transformation State)

If a text range is selected (highlighted) and an opening delimiter is typed, the system wraps the selection rather than replacing it.

Context: |selected_text|

Input: [[

Buffer State: [[selected_text]]

Logic: surroundselection(inputpair)

5. Markdown-Specific Heuristics

Obsidian applies context-aware logic for Markdown syntax (e.g., * or _). It often checks word boundaries to determine if the user intends to bold/italicize or use a bullet point.

Context (Start of line): | + * + Space -> Bullet list (autopair disabled/consumed by formatting).

Context (Middle of line): word | + * -> word | (autopair enabled for italics).

I’ve asked Gemini to explain it:

1. Auto-Closure (Insertion State)

When the user inputs an opening delimiter, the system immediately injects the corresponding closing delimiter and places the caret (cursor) between them.

Input: (

Buffer State: (|)

Logic: insert(opening_char) + insert(closing_char) + move_caret(-1)

2. Type-Through (Escape State)

If the caret is positioned immediately before a closing delimiter that was autopaired, and the user types that specific closing delimiter, the system suppresses the character insertion and instead advances the caret.

Context: [text|]

Input: ]

Buffer State: [text]| (Not [text]])

Logic: if (next_char == input_char) { move_caret(+1); prevent_default(); }

3. Atomic Deletion (Regression State)

If the caret is between an empty pair of delimiters, a backspace event deletes both the opening and closing characters simultaneously, returning the buffer to the pre-insertion state.

Context: (|)

Input: Backspace

Buffer State: |

Logic: if (prev_char == open && next_char == close) { delete_range(caret-1, caret+1); }

4. Selection Wrapping (Transformation State)

If a text range is selected (highlighted) and an opening delimiter is typed, the system wraps the selection rather than replacing it.

Context: |selected_text|

Input: [[

Buffer State: [[selected_text]]

Logic: surround_selection(input_pair)

5. Markdown-Specific Heuristics

Obsidian applies context-aware logic for Markdown syntax (e.g., * or _). It often checks word boundaries to determine if the user intends to bold/italicize or use a bullet point.

Context (Start of line): | + * + Space -> Bullet list (autopair disabled/consumed by formatting).

Context (Middle of line): word | + * -> word *|* (autopair enabled for italics).