GothenburgBitFactory / timewarrior

Timewarrior - Commandline Time Tracking and Reporting
https://timewarrior.net
MIT License
1.2k stars 91 forks source link

Bash completion of tags broken since 1.7.0 #581

Closed sanjayankur31 closed 2 weeks ago

sanjayankur31 commented 6 months ago

We've just updated timew to 1.7.0 in Fedora. Now, my bash completion seems to be broken. For example, if I go:

timew track <TAB>

I just get all my tags:

timew track DEI\ abstract\ admin\ agenda\ ...

This isn't useful, and did not happen previously. Completion of individual tags does not work either:

timew track j<tab>

does nothing, previously, it would have completed to job and so on.

sanjayankur31 commented 6 months ago

Downgrading to 1.6.0 gets things working again.

sanjayankur31 commented 6 months ago

The diff b/w the two bash completions is quite straightforward for this bit:

@@ -42,7 +42,7 @@

 function __get_tags()
 {
-  timew tags | tail -n +4 -- | sed -e "s|[[:space:]]*-$||"
+  timew get dom.tracked.tags "${TIMEW_COMPLETION_TAGS_RANGE:-":all"}"
 }

 function __get_extensions()

The two commands don't return the same information though. The previous timew tags .. returned tags on individual lines, but the new dom system does not:

$ timew tags | tail -n +4 -- | sed -e "s|[[:space:]]*-$||"
DEI
abstract
admin
agenda
...

vs

$ timew get dom.tracked.tags "${TIMEW_COMPLETION_TAGS_RANGE:-":all"}"
DEI abstract admin ...

So the wordlist variable later where __get_tags is used is different now:

#! /bin/bash
# test.sh
function __get_tags()
{
  timew tags | tail -n +4 -- | sed -e "s|[[:space:]]*-$||"
}
declare -a wordlist
while IFS=$'\n' read -r line ; do
    wordlist+=( "${line}" )
done <<< "$( __get_tags )"

echo "** Before, wordlist was:
echo $wordlist

function __get_tags_new()
{
  timew get dom.tracked.tags "${TIMEW_COMPLETION_TAGS_RANGE:-":all"}"
}

declare -a wordlist1
while IFS=$'\n' read -r line ; do
    wordlist1+=( "${line}" )
done <<< "$( __get_tags_new )"

echo "** Now, wordlist is:
echo $wordlist1

gives:

$ ./test.sh 
** Before, wordlist was:
DEI
** Now, wordlist is:
DEI abstract admin agenda ...
lauft commented 5 months ago

@sanjayankur31 What do your tags look like? Do you have (a lot of) tags containing spaces?

sanjayankur31 commented 5 months ago

@sanjayankur31 What do your tags look like? Do you have (a lot of) tags containing spaces?

No, I only have a few tags that have spaces in them. All the rest are single words (often hyphenated). Here's the output of timew get dom.tracked.tags with a few personal ones removed:

DEI abstract admin agenda appstream arbor arc atas awayday back-end bank bash bbsrc biosciences bookings bucket budget call calliope car career career-development cbt cerebellum citizenship claims clarity cloud-harness cns2022 cns2023 code coffee-break collaboration combine community commute conference conferences cortexclub coursework covid cybsafe czi dandi dataclub datalad debugging dendrify departmental deploy dinner dissemination diversity docs documentation e-i-balance eden editing editors eduroam elephant elife elifepaper email emails errand errands estates expense-claim expenses fedora feedback "festival of post docs" forum forums foss foss.fedora foss.fedora.neuro frontiers git github google-deepmind grant gsoc gym haircut harmony health hed-tools hh highfive hl23 housekeeping human "ih_project" incf issues jlems job job.ucl.cortexclub job.ucl.dataclub job.ucl.neuroml job.ucl.neuroml.agenda job.ucl.neuroml.elifepaper job.ucl.neuroml.hl23 job.ucl.neuroml.l23model join join-sig journal jupyter kavli kitchen l23 l23-hay l23model l5pc lab-tour lems lessons libneuroml libsonata lit literature lunch matlab matrix matrix-nio matteo mdf meditation meeting meetings mentoring metacell migration misc modeci modelling modelspec nest netpyne netpyne-ui neuro neurodatashare neurofedora neuroinformatics neuroml neuroml2 neuromllite news newsboat next npp nsg nwb nwb-explorer nwbexplorer ocns octave omv osb osb-status osbv1 osbv2 outreachy package packages packaging pagure paper personal phone pint-of-science planning poster presentation professional-development programming project public-engagement publication publishing pyelectro pyneuroml python react reading recycling redux research research.conferences.cns2023 research.lit.bucket research.lit.next research.reviews.dinkelbach2022 research.volunteering.softwarewg rest review reviews rpmfusion rpmlint rsS rss safety-induction sbml scripting seminar seminars service sick-leave simselect single-neuron skinnerlab slack softwarewg sprint strp structural-plasticity student students supervision survey swc talk taskforce taskreview teaching "teaching for postdocs" tech-fix timew to-skim training tutorial tvb uc ucl ucu updates upgrade upgrades vim vispy volunteering website welcome-to-fedora wellcome willow workout writing 
sanjayankur31 commented 3 months ago

Hi @lauft : please do let me know if there's anything else I can do to help debug this one. Cheers.

lauft commented 1 month ago

@sanjayankur31 You may give this another try with the version currently in the repository

sanjayankur31 commented 1 month ago

Thanks, will do and report back.

sanjayankur31 commented 2 weeks ago

Sorry for the delay, that does look like it fixes it here. Thanks very much :+1:

lauft commented 2 weeks ago

Thanks for the feedback.