Anonymous avatar Anonymous committed d0425ef

Tab inserts 4 spaces

Comments (0)

Files changed (5)

docs/workingon.txt

---- Separating indenting and correcting indentation @ 1 ---
+- Tab should insert 4 spaces
+
 
 ? SF repository; Subversion or CVS? Synchronizing local SVN with SF?
 ? Functional tests
             self.indenter.correct_indentation(self.get_insert())
             return 'break'
         def doInsertTab(event):
-            self.insertTab()
+            self.insert_tab()
             return 'break'
         self.text.bind('<Control-i>', indent_line)
         self.text.bind('<Tab>', doInsertTab)
     def prevPage(self):
         self.text.event_generate('<Prior>')
 
-    def insertTab(self, text_index = None):
+    def insert_tab(self, text_index = None):
         if text_index is None:
             text_index = self.get_insert()
-        self.indenter.indent(text_index)
+        self.indenter.insert_tab(text_index)
 
     def set_highlighting(self, highlighting):
         self.highlighting = highlighting
         new_indents = current_indents + 4
         self._set_line_indents(start, new_indents)
 
+    def insert_tab(self, index):
+        '''Inserts a tab in the given index'''
+        self.editor.insert(index, ' ' * 4)
+
     def _get_prev_line_start(self, line_start):
         return self._get_line_start(self.editor.get_relative(line_start, -1))
 

ropetest/editortest.py

 
     def test_insert_tab(self):
         self.editor.set_text('')
-        self.editor.insertTab()
+        self.editor.insert_tab()
         self.assertEquals((' ' * 4), self.editor.get_text())
-        self.editor.insertTab(self.editor.get_end())
+        self.editor.insert_tab(self.editor.get_end())
         self.assertEquals((' ' * 8), self.editor.get_text())
 
     def test_current_line_number(self):

ropetest/indentertest.py

         indenter.correct_indentation(self.editor.get_end())
         self.assertEquals('a sample \ntext', self.editor.get_text())
 
+    def test_inserting_tab(self):
+        self.editor.set_text('print "a"')
+        self.indenter.insert_tab(self.editor.get_end())
+        self.assertEquals('print "a"    ', self.editor.get_text())
+
 
 if __name__ == '__main__':
     unittest.main()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.