Every line of 'jupyterlab autocomplete' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.
202 def autocomplete(self): 203 # TODO: Add recursive dir() attribute suggestions 204 205 last_line = self.get_last_line() 206 cursor_line_index = self.tbox.CaretIndex - self.tbox.Text.rfind(Console.CARET) - len(Console.CARET) 207 text = last_line[0:cursor_line_index] 208 possibilities = set(self.stack_locals.keys() + self.stack_globals.keys()) # + self.get_all_history() 209 suggestions = [p for p in possibilities if p.lower().startswith(text.lower())] 210 211 logger.debug('Text: {}'.format(text)) 212 logger.debug('Sug: {}'.format(suggestions)) 213 214 if not suggestions: 215 return None 216 # Create Dictionary to Track iteration over suggestion 217 index = self.ac_options[text] 218 try: 219 suggestion = suggestions[index] 220 except IndexError: 221 self.ac_options[text] = 0 222 suggestion = suggestions[0] 223 self.ac_options[text] += 1 224 225 if suggestion is not None: 226 caret_index = self.tbox.CaretIndex 227 self.write_text(suggestion) 228 self.tbox.CaretIndex = caret_index
Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code
4 def autocomplete(shell, line, text, state): 5 6 # should never go this big... 7 if len(line.split()) > 2: 8 return None 9 10 options = [x + " " for x in shell.actions if x.startswith(text)] 11 12 try: 13 return options[state] 14 except: 15 return None