GTG

Tags added with Task.add_tag() don't show in the editor window if the task already has text

Bug #498572 reported by Kevin Mehall
This bug report is a duplicate of:  Bug #493835: task.add_tag behavior unclear. Edit Remove
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
GTG
New
Undecided
Unassigned

Bug Description

The editor window adds the tags to the text, but only if the text is empty (GTG/taskeditor/editor.py line 159).

Right now, the only way to add tags are with the quick add (before the task can have text, so it works correctly when the editor is opened for the first time), or by adding them in the editor (in which case, the @tag_name text is added by the user typing).

I'm trying to implement adding tags by drag and drop (bug #460763), which can add tags after text exists, triggering this bug. Having add_tag work correctly may also be useful for plugins.

I don't know if the fix is to have Task.add_tag() modify the text, or to have the editor window check to make sure the text contains all of the task's tags and add them if they aren't present. There's also the issue of finding the correct place in the text to insert the tag.

Related branches

Revision history for this message
Luca Invernizzi (invernizzi) wrote :

Hi kevin, the add_tag() seems to be an internal function used to manage the tags list. The correct way to add tag in a task is the plugin_api.insert_tag(), which is:

 def insert_tag(self, tag):
        """Inserts a tag into the current task (in the textview).

        Note: this method only works with the onTaskOpened method.

        @param tag: The tag's name (without the '@').
        """
        itera = self.textview.get_insert()
        if itera.starts_line() :
            self.textview.insert_text("@" + tag,itera)
        else :
            self.textview.insert_text(" @" + tag,itera)
        self.textview.grab_focus()

I noticed that the add_tag () method creates confusion, that is why I opened bug #493835

Revision history for this message
Kevin Mehall (kevin-mehall) wrote :

I think there should be a Task method that handles this correctly, though. The plugin API method is not sufficient for what I'm trying to do here.

To implement assigning tags by drag and drop, there needs to be a way to correctly add tags that works
  1. without the plugin API (this is in core, not a plugin, so it would be messy to call the plugin API, and copy/paste is bad too)
  2. without having the editor window open

Revision history for this message
Luca Invernizzi (invernizzi) wrote :

I agree. I'll add:
3- works whether the task editor windows is open or not.

Revision history for this message
Luca Invernizzi (invernizzi) wrote :

kevin has resolved this bug in his branch lp:~gtg/gtg/drag-and-drop .
I'm notifying this since ploum has started working on it.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.