Sublime Forum

ST4 auto-complete behavior

#1

Hi there - love the new version, but I’m struggling with the way the auto-complete is matching vs ST3 and I feel like I’m fighting with it more often than not. I took some time today to note the specific behaviors that are feeling off. All of these are from while banging out a little 50 line self contained python script that only imports os. Any suggestions on how to tweak things so it behaves more like ST3?

“dirns” is matching a way longer string here - this used to match with the one below

I’ve typed out the variable name explicitly here, and auto-complete is still about to force insert a longer thing

Here I’ve typed out “dirpath” all lower-case, but instead of matching the “dirPath” directly above, it’s matching the way longer name again (that still upper-cased)

2 Likes

ST4: Regression -- autocomplete is now more limited
#2

Can you share this python script?

0 Likes

#3

I intended to, but text files can’t get uploaded here. I’ll just paste the current contents, but it’s not in the exact state at which the screenshots were taken:

from __future__ import print_function

import os


def quotePath(path):
    return "'" + path.replace("'", "\\'") + "'"


def shouldIgnoreItem(itemName):
    return itemName.startswith('.') or \
            itemName.endswith('~') or \
            itemName == 'cvs'

def shouldIgnoreFile(fileName):
    return fileName.endswith == '.tmp' or shouldIgnoreItem(fileName)

def addPaths(resultSet, rootPath, itemNames):
    resultSet.update([os.path.join(rootPath, itemName) for itemName in itemNames])

def report(header, filePaths):
    if not filePaths:
        return
    print(header)
    for filePath in filePaths:
        print('  ', filePath)

emptyDirPaths = []
dirPathsWithMissingMetas = set()
filePathsWithMissingMetas = set()
orphanedMetaFilePaths = set()

rootPath = r'D:\some\path'
for dirPath, dirNamesList, fileNamesList in os.walk(rootPath):
    if not fileNamesList and not dirNamesList:
        emptyDirPaths.append(dirPath)
        # proactively flag this, since it will be orphaned
        orphanedMetaFilePaths.add(dirPath + '.meta')
        continue

    for dirName in dirNamesList:
        if shouldIgnoreItem(dirName):
            dirNamesList.remove(dirName)

    dirNames = set(dirNamesList)
    metaNamesWithoutExt = set()
    fileNames = set()
    for fileName in fileNamesList:
        if shouldIgnoreFile(fileName):
            continue
        name, ext = os.path.splitext(fileName)
        if ext.lower() == '.meta':
            metaNamesWithoutExt.add(name)
        else:
            fileNames.add(fileName)

    orphanedMetaNamesWithoutExt = metaNamesWithoutExt - (dirNames.union(fileNames))
    orphanedMetaNames = set([mn + '.meta' for mn in orphanedMetaNamesWithoutExt])

    addPaths(dirPathsWithMissingMetas, dirPath, dirNames - metaNamesWithoutExt)
    addPaths(filePathsWithMissingMetas, dirPath, fileNames - metaNamesWithoutExt)
    addPaths(orphanedMetaFilePaths, dirPath, orphanedMetaNames)

report('emptyDirPaths', emptyDirPaths)
report('orphanedMetaFilePaths', orphanedMetaFilePaths)
report('dirPathsWithMissingMetas', dirPathsWithMissingMetas)
report('filePathsWithMissingMetas', filePathsWithMissingMetas)

for dirPath in emptyDirPaths:
    print("Removing dir %s" % quotePath(dirPath))
    os.rmdir(dirPath)

for filePath in orphanedMetaFilePaths:
    print("Removing file %s" % quotePath(filePath))
    os.unlink(filePath)
0 Likes

#4

For future reference of others: setting “auto_complete_use_history” to false in preferences seems to have fixed the issue, and results in much better matches again.

2 Likes

#5

Related issue

  • the solution in this thread does not seem to resolve the issue with completions being dependent on the currently-enabled syntax mode

See also

0 Likes