avoid duplicate entries in prediction window
@@ -37,17 +37,24 @@ class PredictionListController(app.controller.Controller):
if app.config.strict_debug:
assert type(currentFile) is str
+ added = set()
items = self.items = []
+ if 1:
# Add open buffers.
for i in app.buffer_manager.buffers.buffers:
dirty = '*' if i.isDirty() else '.'
if i.fullPath:
items.append((i, i.fullPath, dirty, 'open'))
+ added.add(i.fullPath)
else:
items.append((i, '<new file> %s'%(i.lines[0][:20]), dirty, 'open'))
+ if 1:
# Add recent files.
for recentFile in app.history.getRecentFiles():
+ if recentFile not in added:
items.append((None, recentFile, '=', 'recent'))
+ added.add(recentFile)
+ if 1:
# Add alternate files.
dirPath, fileName = os.path.split(currentFile)
file, ext = os.path.splitext(fileName)
@@ -62,17 +69,22 @@ class PredictionListController(app.controller.Controller):
for i in contents:
f, e = os.path.splitext(i)
if file == f and ext != e and e not in ignoreExt:
- items.append((None, os.path.join(dirPath, i), '=', 'alt'))
+ fullPath = os.path.join(dirPath, i)
+ if fullPath not in added:
+ items.append((None, fullPath, '=', 'alt'))
+ added.add(fullPath)
if 1:
# Chromium specific hack.
if currentFile.endswith('-extracted.js'):
chromiumPath = currentFile[:-len('-extracted.js')] + '.html'
- if os.path.isfile(chromiumPath):
+ if os.path.isfile(chromiumPath) and chromiumPath not in added:
items.append((None, chromiumPath, '=', 'alt'))
+ added.add(chromiumPath)
elif currentFile.endswith('.html'):
chromiumPath = currentFile[:-len('.html')] + '-extracted.js'
- if os.path.isfile(chromiumPath):
+ if os.path.isfile(chromiumPath) and chromiumPath not in added:
items.append((None, chromiumPath, '=', 'alt'))
+ added.add(chromiumPath)
if self.filter is not None:
regex = re.compile(self.filter)
i = 0
