Skip to content

Commit

Permalink
Fixed bug in completion and added short names
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-p committed Dec 24, 2017
1 parent 3b1ff2f commit ad1f103
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
5 changes: 4 additions & 1 deletion basis/code/code.factor
Original file line number Diff line number Diff line change
Expand Up @@ -275,13 +275,16 @@ CONSTANT: special-variadic-words { "call" }
[ elt (in-out) ]
} cond ;

: short-name ( str -- str )
" (constructor)" " (accessor)" " (mutator)" [ "" replace ] tri@ ;

:: matching-words ( str -- seq )
! returns all Factor words whose name begins with a certain string
interactive-vocabs get [ vocabs:vocab-words ] map concat [ name>> str head? ] filter ;

:: matching-words-exact ( str -- seq )
! returns all Factor words that have a certain name
interactive-vocabs get [ vocabs:vocab-words ] map concat [ name>> str = ] filter ;
interactive-vocabs get [ vocabs:vocab-words ] map concat [ name>> short-name str = ] filter ;

:: find-target ( call -- seq )
! returns the Factor word that has the same name as the call
Expand Down
2 changes: 1 addition & 1 deletion basis/ui/tools/environment/cell/cell.factor
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ M: cell graft*

:: ask-for-completion ( cell -- )
cell children>> [ editor? ] filter first editor-string
[ cell model>> [ swap >>name t >>completion ] with change-model
[ cell model>> [ swap [ >>name ] [ matching-words >>completion ] bi ] with change-model
cell selection>> notify-connections ] unless-empty ;

cell H{
Expand Down
4 changes: 2 additions & 2 deletions basis/ui/tools/environment/tree/tree.factor
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ M:: path-display model-changed ( model path-display -- )
model value>> call? [
model value>> target>> number? [
model value>> completion>>
[ model value>> name>> matching-words [ <path-item> ] map add-gadgets ]
[ model value>> completion>> [ <path-item> ] map add-gadgets ]
[ model value>> target>> [ <path-item> add-gadget ] when* ] if
] unless
] when drop ;
Expand All @@ -149,7 +149,7 @@ M:: path-display model-changed ( model path-display -- )

: choose-word ( path-item -- )
[ word>> ] [ parent>> model>> ] bi
[ swap >>target dup target>> name>> >>name f >>completion ] with change-model ;
[ swap >>target dup target>> name>> short-name >>name f >>completion ] with change-model ;

: select-word ( path-item -- )
dark-background second <solid> >>interior relayout-1 ;
Expand Down

0 comments on commit ad1f103

Please sign in to comment.