Modify ↓
#12925 closed defect (fixed)
linkresolvers should be sorted by name
Reported by: | Jun Omae | Owned by: | Peter Suter |
---|---|---|---|
Priority: | normal | Component: | WikiAutoCompletePlugin |
Severity: | normal | Keywords: | |
Cc: | Trac Release: | 1.0 |
Description (last modified by )
Currently, linkresolvers suggests unsorted link names. I think the suggestion should be sorted by name.
The 20 link resolvers are defined by Trac core.
>>> from trac.test import EnvironmentStub >>> from trac.loader import load_components >>> from trac.wiki.api import WikiSystem >>> env = EnvironmentStub() >>> load_components(env) >>> wikisys = WikiSystem(env) >>> names = set() >>> for provider in wikisys.syntax_providers: ... for name, resolver in provider.get_link_resolvers(): ... names.add(name) ... >>> names = sorted(names) >>> len(names) 20 >>> names ['attachment', 'browser', 'bug', 'changeset', 'comment', 'diff', 'export', 'htdocs', 'log', 'milestone', 'query', 'raw-attachment', 'report', 'repos', 'search', 'sha', 'source', 'ticket', 'timeline', 'wiki']
-
wikiautocomplete/htdocs/js/wikiautocomplete.js
diff --git a/wikiautocomplete/htdocs/js/wikiautocomplete.js b/wikiautocomplete/htdocs/js/wikiautocomplete.js index 22e1899..34da355 100644
a b jQuery(document).ready(function($) { 78 78 79 79 ], { 80 80 appendTo: $('body'), 81 maxCount: 20 81 82 }); 82 83 }); -
wikiautocomplete/web_ui.py
diff --git a/wikiautocomplete/web_ui.py b/wikiautocomplete/web_ui.py index 4afa1f4..ea81c25 100644
a b class WikiAutoCompleteModule(Component): 74 74 75 75 if strategy == 'linkresolvers': 76 76 wiki = WikiSystem(self.env) 77 completions = [] 78 for provider in wiki.syntax_providers: 79 for name, resolver in provider.get_link_resolvers(): 80 if name.startswith(term): 81 completions.append(name) 82 self._send_json(req, completions) 77 completions = set(name for provider in wiki.syntax_providers 78 for name, resolver 79 in provider.get_link_resolvers() 80 if name.startswith(term)) 81 self._send_json(req, sorted(completions)) 83 82 84 83 elif strategy == 'ticket': 85 84 try:
Attachments (0)
Change History (5)
comment:1 Changed 8 years ago by
Description: | modified (diff) |
---|
comment:2 Changed 8 years ago by
comment:3 Changed 8 years ago by
The owner of jquery-textcomplete suggests to use max-height
with large maxCount
in the issue comment.
What about modifying like this?
-
wikiautocomplete/htdocs/css/jquery.textcomplete.css
diff --git a/wikiautocomplete/htdocs/css/jquery.textcomplete.css b/wikiautocomplete/htdocs/css/jquery.textcomplete.css index 37a761b..ea83431 100644
a b 3 3 .dropdown-menu { 4 4 border: 1px solid #ddd; 5 5 background-color: white; 6 max-height: 20em; 7 overflow-x: hidden; 8 overflow-y: auto; 6 9 } 7 10 8 11 .dropdown-menu li { -
wikiautocomplete/htdocs/js/wikiautocomplete.js
diff --git a/wikiautocomplete/htdocs/js/wikiautocomplete.js b/wikiautocomplete/htdocs/js/wikiautocomplete.js index 2b14015..47579a1 100644
a b jQuery(document).ready(function($) { 78 78 79 79 ], { 80 80 appendTo: $('body'), 81 maxCount: 10000 81 82 }); 82 83 });
Note: See
TracTickets for help on using
tickets.
I agree it is unfortunate that not all available resolvers are shown. I also agree that 10 (the default) is maybe often too small. But increasing
maxCount
is not a perfect solution. It will still be too small when plugins add more resolvers. 20 seems maybe a bit too large to me on smaller screens, but maybe acceptable.I filed an issue upstream about scrolling through longer lists.
Sounds good. Please commit, thanks.