Refined-github: Remove newlines around TODO checkboxes in the editor

Created on 4 Dec 2020  路  5Comments  路  Source: sindresorhus/refined-github


On https://github.com/sindresorhus/refined-github/issues/new, there is an "Add a task list" button. There is no autocomplete on Enter and I often use a button again to add a new item but Github adds 2 newlines around the TODO item with checkbox and in 90% of cases, that's not what I want (I tend to have headers for each task list, so I need to add newlines anyway). I would like to have a feature that can be toggled in the settings of the extension, e.g. disable-task-list-newlines that would make the "Add a task list button" simply add a new checkbox item on the next line (1 newline that is). This is the default behaviour of Gitlab if I recall correctly.

I am almost embarrased to ask for this as I cannot imagine I am the only one stuggling with constant loop of pressing the "Add a task list" and removing two extra lines (unless I get tired and copy an empty task list item with a following newline and paste a dozen). I did thoroughly check https://github.com/Mottie/GitHub-userscripts and the issue tracker.

enhancement under discussion

Most helpful comment

I鈥檓 super glad we don鈥檛 have to deal with this 馃槍

All 5 comments

Heh, that's kind of a ridiculous behavior, but reimplementing it is a little tough.

Look at this file: https://github.com/sindresorhus/refined-github/blob/master/source/helpers/smart-block-wrap.ts

That code replicates the current "block" injection that GitHub uses. Implementing this feature would mean copying that so it works when starting a new list but adjusting it so that checkboxes are injected together.

I can think of 2 alternative solutions:

  • detect the injection of a checkbox and subsequently just drop the extra newline via textFieldEdit.replace (this creates a new undo entry)
  • reuse smartBlockWrap but drop the extra line _before_ injecting the text via textFieldEdit.insert

Thank you, I will see if I can prototype a possible solution. Does Refined GH use text-field-edit already?

Yes, it鈥檚 probably used in tandem with smartBlockWrap so you can refer to that code

I鈥檓 super glad we don鈥檛 have to deal with this 馃槍

Was this page helpful?
0 / 5 - 0 ratings

Related issues

alexanderadam picture alexanderadam  路  3Comments

mareksuscak picture mareksuscak  路  3Comments

shivapoudel picture shivapoudel  路  3Comments

olso picture olso  路  3Comments

hkdobrev picture hkdobrev  路  3Comments