simpletask-android icon indicating copy to clipboard operation
simpletask-android copied to clipboard

[AddTask] Don't create double spaces when adding lists/tags

Open smichel17 opened this issue 5 years ago • 8 comments

Right now if the task ends in a space, adding a list or tag will still prepend a space, resulting in a double space.

Low priority; just clearing this out of my personal task list.

smichel17 avatar Nov 10 '20 05:11 smichel17

This bothers me as well in this great app. I looked through the code how to implement this. What is the purpose of the WhitespaceToken in the first place?

jdckr avatar Sep 15 '21 19:09 jdckr

Whitespace token is needed to reconstruct the task and all the whitespace after it has been tokenized

mpcjanssen avatar Sep 17 '21 18:09 mpcjanssen

Also needs to be done when adding due or threshold dates.

mpcjanssen avatar Sep 20 '21 18:09 mpcjanssen

Being a newbie on the Android/NextCloud version (on Sailfish OS), I like the someday/maybe label of this issue. However, I like the idea of clean lines. There was a discussion back in the day on #51 https://github.com/mpcjanssen/simpletask-android/issues/51#issue-28240753 Is there a way to run a text = text.replace(/\s{2,}/g, ' ') // cleanup multiple whitespaces (via Zutun.txt, a native todo.txt for Sailfish OS: https://github.com/fuchsmich/zutun.txt/pull/35/commits/ccdf64dd851a3b0a7235085088f485edcb360f1c# )

  • still a minor issue, but nice to have.

sphenotux avatar Dec 15 '21 19:12 sphenotux

Terrible workaround:

Add the following to your main lua config (NOT in the script section of the filter):

function onAdd(t)
  return string.gsub(t, "%s+", " ")
end

What it does: Whenever you add a task, any amount of whitespace (spaces & tabs) will be replaced by a single space. So any double spaces will be replaced with a single one.

Limitations: Doesn't work for editing a task, only adding a new task.

smichel17 avatar Dec 15 '21 20:12 smichel17

Is there a function onChange or onEdit this could be applied to additonally?

Workaround, yes - anyhow, I appreciate the idea.

sphenotux avatar Dec 15 '21 21:12 sphenotux

I don't think so. They could be added, but of course also this bug could be fixed :P

smichel17 avatar Dec 15 '21 21:12 smichel17

Hmja, I agree - partly ;-). Of course adding and then removing in the next step takes efforts a) for adding and b) for removing something. Whitespaces, in this case.

However, I guess (yes, guess) it is hard to add @context and +project tags without "sourrounding" whitespaces, as those tags may appear anywhere in the string of a task. When adding @a_context, the @a_context does not - and IMHO cannot - "know" where it is placed, and what kind of string lies behind or ahead of it. The "final" string=task can.

My suggestion is: leave the "add project/context" functions unchanged. Let them create double (or even triple, ...) whitespaces. Clean up when finally saving the string - no matter if first time saved (created) or afterwards (edited).

What do you think?

(Lot of comment for a minor priority issue, I know ;-).)

sphenotux avatar Dec 16 '21 06:12 sphenotux