Skip to content

Commit 3a91dcd

Browse files
committed
workaround for the problem with file/dir completion
1 parent e6d3c08 commit 3a91dcd

2 files changed

Lines changed: 14 additions & 4 deletions

File tree

TODO.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
- Completion on file names and directories should work better
1+
- Alert if notebook was changed and offer to save before closing tab
22
- Better control for scrolling: if I have large ouput in the last cell that suddenly gets replaced, then my scroll position is screwed up
33
- Maybe shuold keep scroll position fixed while changing output!
44
- Unclosed parenthesis still break highlighting (""" for python, and ' + " for R cells)

ipy_view.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -490,9 +490,19 @@ def handle_completions(self, view, prefix, locations):
490490
sel = sel[0]
491491
line = view.substr(view.line(sel))
492492
row, col = view.rowcol(sel.begin())
493-
compl = self.kernel.get_completitions(line, col, timeout=0.5)
494-
#compl = [s[col:] for s in compl]
495-
return ([(s + "\t (IPython)", s) for s in compl], sublime.INHIBIT_EXPLICIT_COMPLETIONS | sublime.INHIBIT_WORD_COMPLETIONS)
493+
compl = self.kernel.get_completitions(line, col, timeout=0.7)
494+
495+
496+
if len(compl) > 0:
497+
def get_last_word(s): # needed for file/directory completion
498+
if s.endswith("/"):
499+
s = s[:-1]
500+
res = s.split("/")[-1]
501+
return res
502+
503+
return ([(s + "\t (IPython)", get_last_word(s)) for s in compl], sublime.INHIBIT_EXPLICIT_COMPLETIONS | sublime.INHIBIT_WORD_COMPLETIONS)
504+
else:
505+
return None
496506

497507
def delete_current_cell(self, edit):
498508
cell_index = self.get_current_cell_index()

0 commit comments

Comments
 (0)