|
2 | 2 | require 'atom-message-panel' |
3 | 3 | InformationView = require './views/information-view' |
4 | 4 | HolesView = require './views/holes-view' |
5 | | -Logger = require './Logger' |
| 5 | +Logger = require './utils/Logger' |
6 | 6 | IdrisModel = require './idris-model' |
7 | 7 | Ipkg = require './utils/ipkg' |
8 | 8 | Symbol = require './utils/symbol' |
@@ -31,6 +31,7 @@ class IdrisController |
31 | 31 | 'language-idris:add-proof-clause': @runCommand @doAddProofClause |
32 | 32 | 'language-idris:browse-namespace': @runCommand @doBrowseNamespace |
33 | 33 | 'language-idris:legacy-keymap-notice': migrations.showKeymapDeprecationNotice |
| 34 | + 'language-idris:close-information-view': @hideAndClearMessagePanel |
34 | 35 |
|
35 | 36 | isIdrisFile: (uri) -> |
36 | 37 | uri?.match? /\.idr$/ |
@@ -72,14 +73,14 @@ class IdrisController |
72 | 73 | @statusbar.destroy() |
73 | 74 |
|
74 | 75 | # clear the message panel and optionally display a new title |
75 | | - clearMessagePanel: (title) -> |
| 76 | + clearMessagePanel: (title) => |
76 | 77 | @messages.attach() |
77 | 78 | @messages.show() |
78 | 79 | @messages.clear() |
79 | 80 | @messages.setTitle title, true if title? |
80 | 81 |
|
81 | 82 | # hide the message panel |
82 | | - hideAndClearMessagePanel: () -> |
| 83 | + hideAndClearMessagePanel: () => |
83 | 84 | @clearMessagePanel() |
84 | 85 | @messages.hide() |
85 | 86 |
|
@@ -191,6 +192,7 @@ class IdrisController |
191 | 192 | @saveFile editor |
192 | 193 | uri = editor.getURI() |
193 | 194 | word = Symbol.serializeWord editorHelper.getWordUnderCursor(editor) |
| 195 | + |
194 | 196 | @clearMessagePanel 'Idris: Searching type of <tt>' + word + '</tt> ...' |
195 | 197 |
|
196 | 198 | successHandler = ({ responseType, msg }) => |
@@ -239,11 +241,13 @@ class IdrisController |
239 | 241 | @saveFile editor |
240 | 242 | uri = editor.getURI() |
241 | 243 | line = editor.getLastCursor().getBufferRow() |
242 | | - word = editorHelper.getWordUnderCursor editor |
| 244 | + # by adding a clause we make sure that the word is |
| 245 | + # not treated as a symbol |
| 246 | + word = ' ' + editorHelper.getWordUnderCursor editor |
243 | 247 |
|
244 | 248 | @clearMessagePanel 'Idris: Add clause ...' |
245 | 249 |
|
246 | | - successHandler = ({ responseType, msg }) => |
| 250 | + successHandler = ({ responseType, msg }) => |
247 | 251 | [clause] = @prefixLiterateClause msg |
248 | 252 |
|
249 | 253 | @hideAndClearMessagePanel() |
@@ -322,12 +326,14 @@ class IdrisController |
322 | 326 | editor.moveToBeginningOfLine() |
323 | 327 | editor.moveUp() |
324 | 328 |
|
325 | | - |
326 | | - @model |
327 | | - .load uri |
328 | | - .filter ({ responseType }) -> responseType == 'return' |
329 | | - .flatMap => @model.makeWith line + 1, word |
330 | | - .subscribe successHandler, @displayErrors |
| 329 | + if (word?.length) |
| 330 | + @model |
| 331 | + .load uri |
| 332 | + .filter ({ responseType }) -> responseType == 'return' |
| 333 | + .flatMap => @model.makeWith line + 1, word |
| 334 | + .subscribe successHandler, @displayErrors |
| 335 | + else |
| 336 | + @clearMessagePanel "Idris: Illegal position to make a with view" |
331 | 337 |
|
332 | 338 | # construct a lemma from a hole |
333 | 339 | doMakeLemma: ({ target }) => |
@@ -401,6 +407,7 @@ class IdrisController |
401 | 407 |
|
402 | 408 | editor.transact -> |
403 | 409 | # Delete old line, insert the new case block |
| 410 | + editor.moveToBeginningOfLine() |
404 | 411 | editor.deleteLine() |
405 | 412 | editor.insertText clause |
406 | 413 | # And move the cursor to the beginning of |
@@ -447,18 +454,22 @@ class IdrisController |
447 | 454 | [res] = msg |
448 | 455 |
|
449 | 456 | @hideAndClearMessagePanel() |
450 | | - |
451 | | - editor.transact -> |
452 | | - # Move the cursor to the beginning of the word |
453 | | - editor.moveToBeginningOfWord() |
454 | | - # Because the ? in the Holes isn't part of |
455 | | - # the word, we move left once, and then select two |
456 | | - # words |
457 | | - editor.moveLeft() |
458 | | - editor.selectToEndOfWord() |
459 | | - editor.selectToEndOfWord() |
460 | | - # And then replace the replacement with the guess.. |
461 | | - editor.insertText res |
| 457 | + console.log res |
| 458 | + if (res.startsWith("?")) |
| 459 | + # proof search returned a new hole |
| 460 | + @clearMessagePanel 'Idris: Searching proof was not successful.' |
| 461 | + else |
| 462 | + editor.transact -> |
| 463 | + # Move the cursor to the beginning of the word |
| 464 | + editor.moveToBeginningOfWord() |
| 465 | + # Because the ? in the Holes isn't part of |
| 466 | + # the word, we move left once, and then select two |
| 467 | + # words |
| 468 | + editor.moveLeft() |
| 469 | + editor.selectToEndOfWord() |
| 470 | + editor.selectToEndOfWord() |
| 471 | + # And then replace the replacement with the guess.. |
| 472 | + editor.insertText res |
462 | 473 |
|
463 | 474 | @model |
464 | 475 | .load uri |
|
0 commit comments