Merge pull request #3146 from atom/ns-latency

Improve cursor movement and typing latency a bit
This commit is contained in:
Nathan Sobo 2014-08-02 09:21:51 -07:00
commit de6ccd8c08
3 changed files with 14 additions and 8 deletions

View File

@ -20,13 +20,13 @@
"atomShellVersion": "0.15.1", "atomShellVersion": "0.15.1",
"dependencies": { "dependencies": {
"async": "0.2.6", "async": "0.2.6",
"atom-keymap": "^1.0.0", "atom-keymap": "^1.0.2",
"bootstrap": "git+https://github.com/atom/bootstrap.git#6af81906189f1747fd6c93479e3d998ebe041372", "bootstrap": "git+https://github.com/atom/bootstrap.git#6af81906189f1747fd6c93479e3d998ebe041372",
"clear-cut": "0.4.0", "clear-cut": "0.4.0",
"coffee-script": "1.7.0", "coffee-script": "1.7.0",
"coffeestack": "0.7.0", "coffeestack": "0.7.0",
"delegato": "^1", "delegato": "^1",
"emissary": "^1.2.1", "emissary": "^1.2.2",
"first-mate": "^2.0.1", "first-mate": "^2.0.1",
"fs-plus": "^2.2.6", "fs-plus": "^2.2.6",
"fstream": "0.1.24", "fstream": "0.1.24",
@ -89,7 +89,7 @@
"grammar-selector": "0.27.0", "grammar-selector": "0.27.0",
"image-view": "0.36.0", "image-view": "0.36.0",
"incompatible-packages": "0.5.0", "incompatible-packages": "0.5.0",
"keybinding-resolver": "0.18.0", "keybinding-resolver": "0.19.0",
"link": "0.25.0", "link": "0.25.0",
"markdown-preview": "0.95.0", "markdown-preview": "0.95.0",
"metrics": "0.33.0", "metrics": "0.33.0",

View File

@ -524,6 +524,12 @@ EditorComponent = React.createClass
@refs.input.focus() @refs.input.focus()
onTextInput: (event) -> onTextInput: (event) ->
event.stopPropagation()
# If we prevent the insertion of a space character, then the browser
# interprets the spacebar keypress as a page-down command.
event.preventDefault() unless event.data is ' '
return unless @isInputEnabled() return unless @isInputEnabled()
{editor} = @props {editor} = @props
@ -539,9 +545,6 @@ EditorComponent = React.createClass
editor.insertText(event.data) editor.insertText(event.data)
inputNode.value = event.data inputNode.value = event.data
# If we prevent the insertion of a space character, then the browser
# interprets the spacebar keypress as a page-down command.
event.preventDefault() unless event.data is ' '
onInputFocused: -> onInputFocused: ->
@setState(focused: true) @setState(focused: true)

View File

@ -57,8 +57,7 @@ class WindowEventHandler
@subscribeToCommand $(document), 'core:focus-previous', @focusPrevious @subscribeToCommand $(document), 'core:focus-previous', @focusPrevious
@subscribe $(document), 'keydown', (event) -> document.addEventListener 'keydown', @onKeydown
atom.keymaps.handleKeyboardEvent(event.originalEvent)
@subscribe $(document), 'drop', (e) -> @subscribe $(document), 'drop', (e) ->
e.preventDefault() e.preventDefault()
@ -95,6 +94,10 @@ class WindowEventHandler
bindCommandToAction('core:redo', 'redo:') bindCommandToAction('core:redo', 'redo:')
bindCommandToAction('core:select-all', 'selectAll:') bindCommandToAction('core:select-all', 'selectAll:')
onKeydown: (event) ->
atom.keymaps.handleKeyboardEvent(event)
event.stopImmediatePropagation()
openLink: ({target, currentTarget}) -> openLink: ({target, currentTarget}) ->
location = target?.getAttribute('href') or currentTarget?.getAttribute('href') location = target?.getAttribute('href') or currentTarget?.getAttribute('href')
if location and location[0] isnt '#' and /^https?:\/\//.test(location) if location and location[0] isnt '#' and /^https?:\/\//.test(location)