<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -2,7 +2,7 @@ import unittest
 import os
 from textwrap import dedent
 
-from pysmell.idehelper import inferClass, detectCompletionType, CompletionOptions, findPYSMELLDICT, Types
+from pysmell.idehelper import inferClass, detectCompletionType, CompletionOptions, findPYSMELLDICT, Types, findBase
 NESTEDDICT = {
         'CONSTANTS' : [],
         'FUNCTIONS' : [],
@@ -409,8 +409,21 @@ class DetectOptionsTest(unittest.TestCase):
         self.assertEquals(options, expected)
         
 
-
-
+class FindBaseTest(unittest.TestCase):
+
+    def testThem(self):
+        index = findBase('bbbb', 2)
+        self.assertEquals(index, 0)
+        index = findBase('a.bbbb(', 7)
+        self.assertEquals(index, 2)
+        index = findBase('bbbb(', 5)
+        self.assertEquals(index, 0)
+        index = findBase('    bbbb', 6)
+        self.assertEquals(index, 4)
+        index = findBase('hehe.bbbb', 7)
+        self.assertEquals(index, 5)
+        index = findBase('    hehe.bbbb', 11)
+        self.assertEquals(index, 9)
 
 if __name__ == '__main__':
     unittest.main()</diff>
      <filename>Tests/test_idehelper.py</filename>
    </modified>
    <modified>
      <diff>@@ -4,10 +4,64 @@ import time
 from subprocess import Popen, PIPE, call
 import sys
 import unittest
+from pysmell.vimhelper import findWord
 
 vim_test = os.path.join(&quot;Tests&quot;, &quot;test_vim.vim&quot;)
 
 
+class MockVim(object):
+    class _current(object):
+        class _window(object):
+            cursor = (-1, -1)
+        buffer = []
+        window = _window()
+    current = _current()
+    command = lambda _, __:Non
+    def eval(*_):
+        pass
+
+class VimHelperTest(unittest.TestCase):
+
+    def setUp(self):
+        import pysmell.vimhelper
+        pysmell.vimhelper.vim = self.vim = MockVim()
+
+    def testFindBaseName(self):
+        self.vim.current.buffer = ['aaaa', 'bbbb', 'cccc']
+        self.vim.current.window.cursor =(2, 2)
+        word = findWord(self.vim, 2, 'bbbb')
+        self.assertEquals(word, 'bb')
+
+    def testFindBaseMethodCall(self):
+        self.vim.current.buffer = ['aaaa', 'a.bbbb(', 'cccc']
+        self.vim.current.window.cursor =(2, 7)
+        word = findWord(self.vim, 7, 'a.bbbb(')
+        self.assertEquals(word, 'a.bbbb(')
+
+    def testFindBaseFuncCall(self):
+        self.vim.current.buffer = ['aaaa', 'bbbb(', 'cccc']
+        self.vim.current.window.cursor =(2, 5)
+        word = findWord(self.vim, 5, 'bbbb(')
+        self.assertEquals(word, 'bbbb(')
+
+    def testFindBaseNameIndent(self):
+        self.vim.current.buffer = ['aaaa', '    bbbb', 'cccc']
+        self.vim.current.window.cursor =(2, 6)
+        word = findWord(self.vim, 6, '    bbbb')
+        self.assertEquals(word, 'bb')
+
+    def testFindBaseProp(self):
+        self.vim.current.buffer = ['aaaa', 'hehe.bbbb', 'cccc']
+        self.vim.current.window.cursor =(2, 7)
+        word = findWord(self.vim, 7, 'hehe.bbbb')
+        self.assertEquals(word, 'hehe.bb')
+
+    def testFindBasePropIndent(self):
+        self.vim.current.buffer = ['aaaa', '    hehe.bbbb', 'cccc']
+        self.vim.current.window.cursor =(2, 11)
+        word = findWord(self.vim, 11, '    hehe.bbbb')
+        self.assertEquals(word, 'hehe.bb')
+
 class VimTest(unittest.TestCase):
     def testVimFunctionally(self):
         try:</diff>
      <filename>Tests/test_vim.py</filename>
    </modified>
    <modified>
      <diff>@@ -42,7 +42,7 @@ function! pysmell#Complete(findstart, base)
 python &lt;&lt; eopython
 row, col = vim.current.window.cursor
 line = vim.current.buffer[row-1]
-index = vimhelper.findBase(line, col)
+index = idehelper.findBase(line, col)
 vim.command('let g:pysmell_origCol = %d' % col)
 vim.command('return %d' % index)
 eopython</diff>
      <filename>pysmell.vim</filename>
    </modified>
    <modified>
      <diff>@@ -14,6 +14,18 @@ from dircache import listdir
 from pysmell.codefinder import findRootPackageList, getImports, getNames, getClassAndParents
 from pysmell.matchers import MATCHERS
 
+def findBase(line, col):
+    index = col
+    # col points at the end of the completed string
+    # so col-1 is the last character of base
+    while index &gt; 0:
+        index -= 1
+        if line[index] in '. ':
+            index += 1
+            break
+    return index #this is zero based :S
+    
+
 def updatePySmellDict(master, partial):
     for key, value in partial.items():
         if isinstance(value, dict):</diff>
      <filename>pysmell/idehelper.py</filename>
    </modified>
    <modified>
      <diff>@@ -1,12 +1,13 @@
 import os
 import sys
-from pysmell import idehelper, vimhelper
+from pysmell import idehelper
 from pysmell import tags as tags_module
 from pysmell import tm_dialog
 
-tm_support_path = os.environ['TM_SUPPORT_PATH'] + '/lib'
-if tm_support_path not in sys.path:
-    sys.path.insert(0, tm_support_path)
+
+#tm_support_path = os.environ['TM_SUPPORT_PATH'] + '/lib'
+#if tm_support_path not in sys.path:
+    #sys.path.insert(0, tm_support_path)
 
 
 def write(word):
@@ -19,22 +20,28 @@ def tags(projectDir):
     tags_module.main()
     write('PYSMELLTAGS created in %s' % projectDir)
 
+TOOLTIP = 206
 
 def main():
     cur_file = os.environ.get(&quot;TM_FILEPATH&quot;)
+    line_no = int(os.environ.get(&quot;TM_LINE_NUMBER&quot;))
+    cur_col = int(os.environ.get(&quot;TM_LINE_INDEX&quot;))
+    result = _main(cur_file, line_no, cur_col)
+    if result is not None:
+        sys.exit(result)
+
+def _main(cur_file, line_no, cur_col):
     if not cur_file:
         write('No filename - is the file saved?')
-        sys.exit(206) #magic code for tooltip
+        return TOOLTIP
     source = sys.stdin.read()
-    line_no = int(os.environ.get(&quot;TM_LINE_NUMBER&quot;))
-    cur_col = int(os.environ.get(&quot;TM_LINE_INDEX&quot;))
 
     PYSMELLDICT = idehelper.findPYSMELLDICT(cur_file)
     if PYSMELLDICT is None:
         write('No PYSMELLTAGS found - you have to generate one.')
-        sys.exit(206) #magic code for tooltip
+        return TOOLTIP
     line = source.splitlines()[line_no - 1]
-    index = vimhelper.findBase(line, cur_col)
+    index = idehelper.findBase(line, cur_col)
     base = line[index:cur_col]
 
     options = idehelper.detectCompletionType(cur_file, source, line_no, cur_col, base, PYSMELLDICT)
@@ -42,7 +49,7 @@ def main():
 
     if not completions:
         write('No completions found')
-        sys.exit(206) #magic code for tooltip
+        return TOOLTIP
     if len(completions) == 1:
         new_word = completions[0]['word']
         write(new_word)
@@ -58,7 +65,7 @@ def main():
         except Exception, e:
             import traceback
             write(traceback.format_exc(e))
-            sys.exit(206)
+            return TOOLTIP
         if compIndex is not None:
             write(completions[compIndex]['word'])
 </diff>
      <filename>pysmell/textmate.py</filename>
    </modified>
    <modified>
      <diff>@@ -6,18 +6,6 @@
 # http://orestis.gr
 
 # Released subject to the BSD License 
-
-def findBase(line, col):
-    index = col
-    # col points at the end of the completed string
-    # so col-1 is the last character of base
-    while index &gt; 0:
-        index -= 1
-        if line[index] in '. ':
-            index += 1
-            break
-    return index #this is zero based :S
-    
 def findWord(vim, origCol, origLine):
     # vim moves the cursor and deletes the text by the time we are called
     # so we need the original position and the original line...</diff>
      <filename>pysmell/vimhelper.py</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>Tests/test_vimhelper.py</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>d29d2cab219aa20d026b7038dccc4bc384199e57</id>
    </parent>
  </parents>
  <author>
    <name>Orestis Markou</name>
    <email>orestis@orestis.gr</email>
  </author>
  <url>http://github.com/orestis/pysmell/commit/ea6fe92f5cca07cd660204e373b0ae51efb3192c</url>
  <id>ea6fe92f5cca07cd660204e373b0ae51efb3192c</id>
  <committed-date>2008-11-04T15:29:53-08:00</committed-date>
  <authored-date>2008-11-04T15:29:53-08:00</authored-date>
  <message>Moved findBase from vimhelper to idehelper
Refactored textmate.py in vain attempt to write a test for it; failed miserably...</message>
  <tree>225e351240da00ccd70cd895956e04d0f794154b</tree>
  <committer>
    <name>Orestis Markou</name>
    <email>orestis@orestis.gr</email>
  </committer>
</commit>
