( textMarker: TextMarker, ch: string, cursor: CodeMirror.Position, characterBeforeCursor: string )
| 33 | |
| 34 | // Helps simulate a typing as completed effect. Will only work on the same line. |
| 35 | function maybeUpdateTextMarker( |
| 36 | textMarker: TextMarker, |
| 37 | ch: string, |
| 38 | cursor: CodeMirror.Position, |
| 39 | characterBeforeCursor: string |
| 40 | ): boolean { |
| 41 | if (cursor.line != textMarker.pos.line || cursor.ch != textMarker.pos.ch) { |
| 42 | return false; |
| 43 | } |
| 44 | if (ch === 'Backspace') { |
| 45 | if (characterBeforeCursor === '') { |
| 46 | return false; |
| 47 | } |
| 48 | textMarker.spanElement.innerText = characterBeforeCursor + textMarker.spanElement.innerText; |
| 49 | return true; |
| 50 | } |
| 51 | if (ch.length > 1 || ch === '\n') { |
| 52 | return false; |
| 53 | } |
| 54 | const innerText = textMarker.spanElement.innerText; |
| 55 | if (innerText.length === 1) { |
| 56 | // TODO(prem): Why is this necessary? |
| 57 | // This was necessary for the following case: |
| 58 | // In GitHub, type "def fib(n)" and accept the completion. |
| 59 | // Then go to a new line in the function and type "fib(5)". |
| 60 | // On the ")", it should freeze. |
| 61 | return false; |
| 62 | } |
| 63 | if (!innerText.startsWith(ch)) { |
| 64 | return false; |
| 65 | } |
| 66 | textMarker.spanElement.innerText = textMarker.spanElement.innerText.substring(1); |
| 67 | return true; |
| 68 | } |
| 69 | |
| 70 | export class CodeMirrorManager { |
| 71 | private client: LanguageServerClient; |
no outgoing calls
no test coverage detected