Close `(` with `)` as it is typed

Closed
#56 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
Half a day
Newbie friendliness
45/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
typescript
Domain
frontend

Research direction

Start in the onKeyDown handler in app/src/renderer/project/Block/Block.tsx. The issue wants ( and ) added as one more entry in the pair table that #55 introduces there, so check whether #55 has landed before starting. Done means typing ( gives () with the caret between, typing ) steps over an existing ), Backspace removes an empty (|) pair, a selection gets wrapped, and undo reverts the pair in one step.

Written by the indexing model from the issue text.

Description

enhancement

Same as #55, for parentheses. Typing ( while editing a block should insert () and leave the caret between them.

Behaviour

The rules from #55, with ( and ) in place of [ and ]:

  • Typing ( inserts () with the caret between them.
  • Typing ) when the next character is already ) moves the caret past it instead of inserting a second one.
  • Backspace with the caret inside an empty pair, (|), deletes both.
  • With text selected, typing ( wraps the selection, (selection), instead of replacing it.
  • Undo (Cmd/Ctrl+Z) takes back the pair in one step.

Together with #55 this makes the aliased link from #7 easy to type: [foo]( gives [foo](|), and [[ then gives [foo]([[|]]), where the autocomplete in #29 opens for the aliased form.

What already exists

  • Whatever #55 adds to the onKeyDown handler in app/src/renderer/project/Block/Block.tsx should take a table of pairs, so this issue is one more entry in it, not a second copy of the logic.

Out of scope

  • Pairing * or quotes. ` is #57.
Dominant language
TypeScript
Stars
0
Forks
1
Avg merge
10m
Merged PRs (30d)
57

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from shovon/pbnotes

All issues in shovon/pbnotes

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.