mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Populate url list of file finder as user types.
This commit is contained in:
@@ -1,15 +1,24 @@
|
||||
$ = require 'jquery'
|
||||
Template = require 'template'
|
||||
stringScore = require 'stringscore'
|
||||
|
||||
module.exports =
|
||||
class FileFinder extends Template
|
||||
content: -> @div
|
||||
content: ->
|
||||
@div class: 'file-finder', =>
|
||||
@ol outlet: 'urlList'
|
||||
@input outlet: 'input', keypress: 'populateUrlList'
|
||||
|
||||
viewProperties:
|
||||
urls: null
|
||||
|
||||
initialize: ({@urls}) ->
|
||||
|
||||
populateUrlList: ->
|
||||
@urlList.empty()
|
||||
for url in @findMatches(@input.text())
|
||||
@urlList.append $("<li>#{url}</li>")
|
||||
|
||||
findMatches: (query) ->
|
||||
scoredUrls = ({url, score: stringScore(url, query)} for url in @urls)
|
||||
sortedUrls = scoredUrls.sort (a, b) -> a.score > b.score
|
||||
|
||||
Reference in New Issue
Block a user