Skip to content

Commit

Permalink
Fix shortcuts in code completion
Browse files Browse the repository at this point in the history
  • Loading branch information
guillep committed Dec 18, 2020
1 parent 0107bb1 commit 1cad22b
Showing 1 changed file with 38 additions and 15 deletions.
53 changes: 38 additions & 15 deletions src/NECompletion-Morphic/CompletionEngine.class.st
Expand Up @@ -100,19 +100,7 @@ CompletionEngine >> editor [
]

{ #category : #keyboard }
CompletionEngine >> handleKeystrokeAfter: aKeyboardEvent editor: aParagraphEditor [
(aParagraphEditor isNil or: [ self isMenuOpen not ])
ifTrue: [ ^ self ].

aParagraphEditor atCompletionPosition
ifFalse: [ ^ self closeMenu ].

context narrowWith: aParagraphEditor wordAtCaret.
menuMorph refreshSelection.
]

{ #category : #keyboard }
CompletionEngine >> handleKeystrokeBefore: aKeyboardEvent editor: anEditor [
CompletionEngine >> handleKeyDownBefore: aKeyboardEvent editor: anEditor [
"I return a boolean.
true when I have handled the event and no futher processing is needed by the caller.
Expand All @@ -124,8 +112,7 @@ CompletionEngine >> handleKeystrokeBefore: aKeyboardEvent editor: anEditor [
controlKeyPressed := aKeyboardEvent controlKeyPressed.
commandKeyPressed := aKeyboardEvent commandKeyPressed.

self isMenuOpen
ifFalse: [ ^ self handleKeystrokeWithoutMenu: aKeyboardEvent ].
self isMenuOpen ifFalse: [ ^ false ].

(keyCharacter = Character arrowLeft or: [ keyCharacter = Character arrowRight ])
ifTrue: [ "just move the caret" ^ false ].
Expand Down Expand Up @@ -159,6 +146,42 @@ CompletionEngine >> handleKeystrokeBefore: aKeyboardEvent editor: anEditor [
editor isCaretBehindChar
ifFalse: [ self closeMenu ].
^ false ].
(controlKeyPressed not & aKeyboardEvent commandKeyPressed not
and: [ aKeyboardEvent keyCharacter isCompletionCharacter ])
ifFalse: [
self closeMenu.
^ keyCharacter isCompletionCharacter not ].
^ false
]

{ #category : #keyboard }
CompletionEngine >> handleKeystrokeAfter: aKeyboardEvent editor: aParagraphEditor [
(aParagraphEditor isNil or: [ self isMenuOpen not ])
ifTrue: [ ^ self ].

aParagraphEditor atCompletionPosition
ifFalse: [ ^ self closeMenu ].

context narrowWith: aParagraphEditor wordAtCaret.
menuMorph refreshSelection.
]

{ #category : #keyboard }
CompletionEngine >> handleKeystrokeBefore: aKeyboardEvent editor: anEditor [
"I return a boolean.
true when I have handled the event and no futher processing is needed by the caller.
This method would be cleaner if splitted."

| keyCharacter controlKeyPressed commandKeyPressed |
self setEditor: anEditor.
keyCharacter := aKeyboardEvent keyCharacter.
controlKeyPressed := aKeyboardEvent controlKeyPressed.
commandKeyPressed := aKeyboardEvent commandKeyPressed.

self isMenuOpen
ifFalse: [ ^ self handleKeystrokeWithoutMenu: aKeyboardEvent ].

(controlKeyPressed not & aKeyboardEvent commandKeyPressed not
and: [ aKeyboardEvent keyCharacter isCompletionCharacter ])
ifFalse: [
Expand Down

0 comments on commit 1cad22b

Please sign in to comment.