remove use of substr, cleanup hungry backspace

This commit is contained in:
Felix Angell 2018-05-16 21:12:13 +01:00
parent 58e8ba1ad6
commit 8067084340
2 changed files with 7 additions and 2 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
tests/
phi-editor
phi

View File

@ -541,8 +541,12 @@ func (b *Buffer) deletePrev() {
// cut out the last {TAB_SIZE} amount of characters
// and check em
tabSize := int(b.cfg.Editor.Tab_Size)
lastTabSizeChars := b.table.Lines[b.curs.y].Substr(b.curs.x+1-tabSize, tabSize)
if strings.Compare(lastTabSizeChars, b.makeTab()) == 0 {
// render the line...
currLine := b.table.Lines[b.curs.y].String()
before := currLine[b.curs.x-tabSize:]
if strings.HasPrefix(before, b.makeTab()) {
// delete {TAB_SIZE} amount of characters
// from the cursors x pos
for i := 0; i < int(b.cfg.Editor.Tab_Size); i++ {