Bug 256829 - <TAB> auto-completes a nick even if the person has left the channel if you don't specify the beginning of the nick
Summary: <TAB> auto-completes a nick even if the person has left the channel if you do...
Status: RESOLVED FIXED
Alias: None
Product: konversation
Classification: Applications
Component: tabcompletion (show other bugs)
Version: 1.3.1
Platform: Arch Linux Linux
: NOR minor
Target Milestone: ---
Assignee: Konversation Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-11-13 18:55 UTC by Victor Gavrish
Modified: 2010-11-13 19:28 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Victor Gavrish 2010-11-13 18:55:30 UTC
Version:           1.3.1 (using KDE 4.5.3) 
OS:                Linux

Just now I spent five minutes talking to an absent person on IRC who wasn't even there and felt stupid afterwards. It's Konversation's fault :P

Reproducible: Always

Steps to Reproduce:
1. Wait for a person to leave a channel you're watching.
2. If he was the last poster, press <TAB>

Actual Results:  
Konversation auto-completes his nickname even though he's absent from the channel.

Expected Results:  
Either auto-complete the next-to-last message's author or (preferably) refuse to auto-complete at all.

OS: Linux (i686) release 2.6.36-zen1-20101109-stable-00321-g32771c4
Compiler: gcc
Comment 1 Peter Simonsson 2010-11-13 19:26:34 UTC
commit 0078505c526d2d04a07b3f666a61d0a2a53656e5
branch master
Author: Peter Simonsson <peter.simonsson@gmail.com>
Date:   Sat Nov 13 19:22:37 2010 +0100

    Check if the nick is still around before inserting last completion
    
    BUG:256829

diff --git a/src/irc/channel.cpp b/src/irc/channel.cpp
index 3d1f6ab..0c63e19 100644
--- a/src/irc/channel.cpp
+++ b/src/irc/channel.cpp
@@ -502,8 +502,8 @@ void Channel::completeNick()
         pos = oldPos;
     }
 
-    // If the cursor is at beginning of line, insert last completion
-    if(pos == 0 && !channelInput->lastCompletion().isEmpty())
+    // If the cursor is at beginning of line, insert last completion if the nick is still around
+    if(pos == 0 && !channelInput->lastCompletion().isEmpty() && nicknameList.containsNick(channelInput->lastCompletion()))
     {
         QString addStart(Preferences::self()->nickCompleteSuffixStart());
         newLine = channelInput->lastCompletion() + addStart;
Comment 2 Eike Hein 2010-11-13 19:28:35 UTC
Your steps to reproduce are slightly wrong; what's going on is slightly different from what you think is going on.

What happens is that <TAB> at the beginning of the line when no prefix has been typed repeats the last successful completion. So there has to have been a successful completion based on a prefix first; whether the person was the last poster or not isn't relevant.

Now it's true that while a prefix-based completion obviously operates on the list of nicknames attending a channel at the time, merely repeating the last successful completion by pressing <TAB> without typing a prefix first does not - because in that case, that data isn't actually needed. Repeating the last completion doesn't require a lookup in the nickname list.

Whether it *should* check for whether the nickname is still in attendance and do nothing if it isn't is debatable. On the one hand I see your conundrum. On the other hand, the nickname leaving isn't strictly speaking cause to throw away data about the last successful completion. Someone who is familiar with the mechanic might expect it to work regardless of whether the nickname just left or not.

Another way to look at it though is that the mechanic is obviously designed with the objective of addressing someone in mind (as evidenced by the fact that it only works on the line start and not mid-line, limiting the sort of sentence structures in which you can tap into it) and once the addressee leaves addressing him or her becomes pointless.

So I'd lean toward your "side", but I'm still somewhat unsure. Does anyone else have an opinion?
Comment 3 Eike Hein 2010-11-13 19:28:55 UTC
Well, I guess Peter made up his mind faster ...