14 Commits
Author SHA1 Message Date
Seongjae Lee b5f7ba7b75 Prepare 0.6.0 release 2015-09-12 01:36:40 -07:00
Seongjae Lee da888fa461 Prepare to move git repository from notational-velocity to nvatom 2015-09-12 01:36:12 -07:00
Seongjae Lee 97830b31db Prepare to move git repository from notational-velocity to nvatom 2015-09-12 01:33:38 -07:00
Seongjae Lee a06e0127c2 Prepare 0.5.1 release 2015-09-12 01:15:24 -07:00
Seongjae Lee cfd9dcef85 Fix typo on readme 2015-09-12 01:15:09 -07:00
Seongjae Lee ca6f9e76a3 Prepare 0.5.0 release 2015-09-12 01:08:24 -07:00
Seongjae Lee 5e44098ae3 Update changelog 2015-09-12 01:08:19 -07:00
Seongjae Lee a3f5d445c0 Make lunr pipeline feature optionable
If we have a note "Atom", and if the user types "a" or "at", then lunr pipeline ignores searching them because they are stop words. However, turning off this feature might not be a good idea when we have tons of body texts. So we turn it on as a default, but provide a way to turn it off as an option.
2015-09-12 01:04:11 -07:00
Seongjae Lee abb7339a6e Improve autoselect/autocomplete logic
Say we have two notes "Mark" and "Markdown". When the user type "Markd", then it will autocomplete to "Markd[own]". Say the user presses backspace key twice to make it to "Mark". In this case, we want to autoselect "Mark".
2015-09-12 00:54:56 -07:00
Seongjae Lee 4ddc133920 Refactor schedulePopulateList 2015-09-12 00:42:11 -07:00
Seongjae Lee bca1646f8f Refactor filter 2015-09-12 00:40:21 -07:00
Seongjae Lee 40e785ef57 Remove unnessary whitespaces
Refer https://github.com/polarmobile/coffeescript-style-guide#whitespace-in-expressions-and-statements.
2015-09-11 22:51:03 -07:00
Seongjae Lee 273d506f38 Make the searching query to be the non-selected text, not the full text
For example, if we have two notes "Car" and "Care", when we type "Ca", then it automatically fills "Care" and drops "Car". (Assume "Care" comes ahead of "Car"). However, we still want to search with "Ca".
2015-09-11 22:46:06 -07:00
Seongjae Lee 09d0efc06f Make the first found item to be automatically selected
This is a regression caused by docquery integration (56821bccbc). indexof always returns -1. Since the selected item is always the first filtered item, we can safely set it to 1.
2015-09-11 22:43:09 -07:00
5 changed files with 59 additions and 39 deletions
+5
View File
@@ -1,3 +1,8 @@
## 0.5.0
- Add `useLunrPipeline` feature
- Improve autoselect/autocomplete logic
- Fix a bug that autocomplete feature does not work
## 0.4.0 ## 0.4.0
- Rename `notational-velocity` to `nvatom` - Rename `notational-velocity` to `nvatom`
- Copy `notational-velocity` settings/notes on initialization - Copy `notational-velocity` settings/notes on initialization
+4 -4
View File
@@ -59,7 +59,7 @@ You can also override `cmd-l` if you want to keep your muscle memory from Notati
## Migration ## Migration
v0.1.0 under published package name `notational-velocity` had a fatal bug that sets the default value of its note directory under package directory. Since package directory is overwritten when the user updates `notational-velocity` package. For more information, refer [#25][6]. v0.1.0 under published package name `notational-velocity` had a fatal bug that sets the default value of its note directory under package directory. In that case, all notes are deleted once the user updates the package, since package directory is overwritten when the user. For more information, refer [#25][6].
To resolve this problem, we renamed our package name to `nvatom`. Users who have the old `notational-velocity` need to **install `nvatom` package first**, activate the package to automatically migrate the existing notes, and then delete `notational-velocity` package. To resolve this problem, we renamed our package name to `nvatom`. Users who have the old `notational-velocity` need to **install `nvatom` package first**, activate the package to automatically migrate the existing notes, and then delete `notational-velocity` package.
@@ -76,7 +76,7 @@ Since keymaps overlap with `notational-velocity`, follow the menu *Packages > nv
[1]: http://notational.net/ [1]: http://notational.net/
[2]: http://daringfireball.net/projects/markdown/syntax [2]: http://daringfireball.net/projects/markdown/syntax
[3]: https://travis-ci.org/seongjaelee/notational-velocity.svg?branch=master [3]: https://travis-ci.org/seongjaelee/nvatom.svg?branch=master
[4]: https://travis-ci.org/seongjaelee/notational-velocity [4]: https://travis-ci.org/seongjaelee/nvatom
[5]: https://cloud.githubusercontent.com/assets/948301/7246990/2e2b4c6e-e7b9-11e4-93b0-57954e011e81.gif [5]: https://cloud.githubusercontent.com/assets/948301/7246990/2e2b4c6e-e7b9-11e4-93b0-57954e011e81.gif
[6]: https://github.com/seongjaelee/notational-velocity/issues/25 [6]: https://github.com/seongjaelee/nvatom/issues/25
+41 -31
View File
@@ -14,7 +14,7 @@ class NotationalVelocityView extends SelectListView
if !fs.existsSync(@rootDirectory) if !fs.existsSync(@rootDirectory)
throw new Error("The given directory #{@rootDirectory} does not exist. " throw new Error("The given directory #{@rootDirectory} does not exist. "
+ "Set the note directory to the existing one from Settings.") + "Set the note directory to the existing one from Settings.")
@prevFilterQuery = '' @skipPopulateList = false
@prevCursorPosition = 0 @prevCursorPosition = 0
@documentsLoaded = false @documentsLoaded = false
@docQuery = new DocQuery(@rootDirectory, {recursive: true}) @docQuery = new DocQuery(@rootDirectory, {recursive: true})
@@ -28,27 +28,41 @@ class NotationalVelocityView extends SelectListView
@populateList() if @documentsLoaded @populateList() if @documentsLoaded
@docQuery.on "removed", (fileDetails) => @docQuery.on "removed", (fileDetails) =>
@populateList() if @documentsLoaded @populateList() if @documentsLoaded
if !atom.config.get('nvatom.enableLunrPipeline')
@docQuery.searchIndex.pipeline.reset()
selectItem: (filterQuery) -> isCursorProceeded: ->
if filterQuery.length == 0
@prevCursorPosition = 0
return null
titleItem = @docQuery.search(filterQuery)[0]
# If title item is not null, auto-fill the search panel.
# But we don't want to fill it when deleting.
editor = @filterEditorView.model editor = @filterEditorView.model
currCursorPosition = editor.getCursorBufferPosition().column currCursorPosition = editor.getCursorBufferPosition().column
if titleItem != undefined && @prevCursorPosition < currCursorPosition isCursorProceeded = @prevCursorPosition < currCursorPosition
@prevFilterQuery = titleItem.title
editor.setText(filterQuery + titleItem.title.slice(filterQuery.length))
editor.selectLeft(titleItem.title.length - filterQuery.length)
@prevCursorPosition = currCursorPosition @prevCursorPosition = currCursorPosition
return isCursorProceeded
return titleItem selectItem: (filteredItems, filterQuery) ->
isCursorProceeded = @isCursorProceeded()
for item in filteredItems
if item.title.match(///^#{filterQuery}$///i) != null
# autoselect
n = filteredItems.indexOf(item) + 1
@selectItemView(@list.find("li:nth-child(#{n})"))
return
for item in filteredItems
if item.title.match(///^#{filterQuery}///i) != null && isCursorProceeded
# autocomplete
@skipPopulateList = true
editor = @filterEditorView.model
editor.setText(filterQuery + item.title.slice(filterQuery.length))
editor.selectLeft(item.title.length - filterQuery.length)
# autoselect
n = filteredItems.indexOf(item) + 1
@selectItemView(@list.find("li:nth-child(#{n})"))
filter: (filterQuery) -> filter: (filterQuery) ->
if filterQuery == "" || filterQuery == undefined
return @docQuery.documents
return @docQuery.search(filterQuery) return @docQuery.search(filterQuery)
getFilterKey: -> getFilterKey: ->
@@ -75,8 +89,8 @@ class NotationalVelocityView extends SelectListView
@div class: 'secondary-line', "#{content}" @div class: 'secondary-line', "#{content}"
confirmSelection: -> confirmSelection: ->
item = @getSelectedItem() item = @getSelectedItem()
filePath = null filePath = null
sanitizedQuery = @getFilterQuery().replace(/\s+$/, '') sanitizedQuery = @getFilterQuery().replace(/\s+$/, '')
calculatedPath = path.join(@rootDirectory, sanitizedQuery + '.md') calculatedPath = path.join(@rootDirectory, sanitizedQuery + '.md')
if item? if item?
@@ -115,15 +129,15 @@ class NotationalVelocityView extends SelectListView
hide: -> hide: ->
@panel?.hide() @panel?.hide()
getFilterQuery: ->
editor = @filterEditorView.model
fullText = editor.getText()
selectedText = editor.getSelectedText()
return fullText.substring(0, fullText.length - selectedText.length)
populateList: -> populateList: ->
filterQuery = @getFilterQuery() filterQuery = @getFilterQuery()
filteredItems = null filteredItems = @filter(filterQuery)
if filterQuery == "" || filterQuery == undefined
filteredItems = @docQuery.documents
else
filteredItems = @filter(filterQuery)
selectedItem = @selectItem(filterQuery)
@list.empty() @list.empty()
if filteredItems.length if filteredItems.length
@@ -135,16 +149,12 @@ class NotationalVelocityView extends SelectListView
itemView.data('select-list-item', item) itemView.data('select-list-item', item)
@list.append(itemView) @list.append(itemView)
if selectedItem @selectItem(filteredItems, filterQuery)
n = filteredItems.indexOf(selectedItem) + 1
@selectItemView(@list.find("li:nth-child(#{n})"))
else else
@setError(@getEmptyMessage(@docQuery.documents.length, filteredItems.length)) @setError(@getEmptyMessage(@docQuery.documents.length, filteredItems.length))
schedulePopulateList: -> schedulePopulateList: ->
# We can skip it when we are just moving the position of the cursor. if !@skipPopulateList
currFilterQuery = @getFilterQuery()
if @prevFilterQuery != currFilterQuery
super super
@prevFilterQuery = currFilterQuery @skipPopulateList = false
+5
View File
@@ -9,6 +9,11 @@ module.exports =
description: 'The directory to archive notes' description: 'The directory to archive notes'
type: 'string' type: 'string'
default: path.join(process.env.ATOM_HOME, 'nvatom-notes') default: path.join(process.env.ATOM_HOME, 'nvatom-notes')
enableLunrPipeline:
title: 'Enable Lunr Pipeline'
description: 'Lunr pipeline preprocesses query to make search faster. However, it will skip searching some of stop words such as "an" or "be".'
type: 'boolean'
default: true
notationalVelocityView: null notationalVelocityView: null
+4 -4
View File
@@ -1,7 +1,7 @@
{ {
"name": "nvatom", "name": "nvatom",
"main": "./lib/notational-velocity", "main": "./lib/notational-velocity",
"version": "0.4.2", "version": "0.6.0",
"private": true, "private": true,
"contributors": [ "contributors": [
"Seongjae Lee <seongjae@gmail.com>", "Seongjae Lee <seongjae@gmail.com>",
@@ -12,15 +12,15 @@
"activationCommands": { "activationCommands": {
"atom-workspace": "nvatom:toggle" "atom-workspace": "nvatom:toggle"
}, },
"repository": "https://github.com/seongjaelee/notational-velocity", "repository": "https://github.com/seongjaelee/nvatom",
"license": "MIT", "license": "MIT",
"engines": { "engines": {
"atom": ">0.50.0" "atom": ">0.50.0"
}, },
"bugs": { "bugs": {
"url": "https://github.com/seongjaelee/notational-velocity/issues" "url": "https://github.com/seongjaelee/nvatom/issues"
}, },
"homepage": "https://github.com/seongjaelee/notational-velocity", "homepage": "https://github.com/seongjaelee/nvatom",
"dependencies": { "dependencies": {
"atom-space-pen-views": "^2.0.3", "atom-space-pen-views": "^2.0.3",
"chokidar": "^1.0.5", "chokidar": "^1.0.5",