Closed refi64 closed 8 years ago
I cannot reproduce this in master. Here are my screenshots - works as expected. Anything special with your config or file?
Well, this is weird.
If I try it on the file anywhere else, it works correctly.
BUT...
If I save the file as ~/rejit2/tst.c
, then the bug appears!
EDIT: Or it has to do with the files in the directory. If I rename it, then it still doesn't work.
Here's how to reproduce it:
tst.c
in that directory.Any other way will cause the bug not to appear. This is easily the weirdest bug I've ever come across...
OK, I can reproduce this now by the instructions above. I haven't found the root issue but I suspect it is either in aullar/buffer.moon or in replacement.moon.
The following patch fixes it for me, @kirbyfan64 can you verify it fixes it for you too?:
--- a/lib/howl/interactions/replacement.moon
+++ b/lib/howl/interactions/replacement.moon
@@ -285,6 +285,7 @@ class Replacement
highlight.remove_all 'replace_strikeout', @preview_buffer
_highlight_match: (name, pos, len) =>
+ @preview_buffer.text
highlight.apply name, @preview_buffer, pos, len
_toggle_current: =>
I discovered this because I wasn't able to reproduce the issue once I added the log that accessed preview_buffer.text
.
I'm also having trouble reducing the test case itself. It seems some combination of the below is needed:
I suspect calling preview_buffer\chunk(...) = ...
to replace some chunk (line 241 in replacement.py) has something to do with it.
Still looking, ideas welcome...
I can reproduce the problem by using the buffer API directly, so I think the bug is in aullar.buffer
.
wget https://github.com/kirbyfan64/rejit/raw/master/tst.c
Run howl, open a new buffer, paste below code. Select all and howl-moon-eval
:
howl.bindings.push
f2: ->
buffer = howl.app.editor.buffer
first = 26985
last = 27376
text = buffer\chunk(first, last).text
buffer\chunk(first, last).text = text
tst.c
, go to line 759f2
to run the test code above.The buffer text changes, even though the text should not because the replacement is identical.
@nilnor - sorry, couldn't reduce the test case to something simpler.
@kirbyfan64 Thanks for the report, and thanks @shalabhc for drilling down and making it easy to reproduce! Should be fixed now, but please verify if you have a moment.
@nilnor Yup, that fixed the issue!
Well, this is...interesting...
Download this huge, 700-line file C source file. Now, open the file in Howl, hit Ctrl-H to replace text, and enter
m->groups
, then enter a slash to move on to the replacement text. Notice that Howl selects the wrong region of text to replace:Now, anything you type will proceed to completely wreck the remainder of the file: