Comments (3)
it should probably just reject these files -- similar to what it does for non-UTF-8 files
from babi.
it only comes up when trying to render the char, so opening the file with \x00
in it works (second case passes, since the display height is 80 lines) fine, as long as it is not rendered (first case).
@pytest.mark.parametrize('s', (b'\x00', b'\n' * 81 + b'\x00'))
def test_file_contains_zero_bytes(s, run, tmpdir):
f = tmpdir.join('f')
f.write_binary(s)
with run(str(f)) as h, and_exit(h):
h.press('a')
h.await_text('*')
h.press('^S')
h.await_text('saved!')
# h.await_text('error! zero byte found:')
It should probably display an error message like for non utf-8 files. So how can we catch this earlier, like when opening instead of when it's rendered? somewhere in babi.file.get_lines
, but sio
is IO[str]
so we can't check b'\x00' in ...
and a non byte string of '\x00'
should still be allowed...
from babi.
here's where the other errors are checked:
Lines 67 to 75 in 511de75
from babi.
Related Issues (20)
- jump-by-word (^+right) goes too far when tabs are involved HOT 13
- Display Line Numbers HOT 2
- Syntax highlighting is not working HOT 10
- ^\ during linting causes SIGQUIT to exit the editor
- Paste operation for emojis doesn't work in Windows HOT 1
- Word Wrapping HOT 1
- pre-commit runs with the wrong configuration when accessing a file in a different repository
- opening linting panel can cause cursor to be out-of-bounds
- Recursive argument on opening files HOT 1
- saving over a non-utf-8 file causes a crash
- LSP support HOT 2
- babi not using babi_grammars when installed in a venv HOT 3
- babi won't install in ARM64 Debian 11 system HOT 2
- unknown key Error HOT 2
- Add support for delete whole word
- give up on highlighting if lines are too long
- Usage with pipx HOT 1
- lint panel should close when switching files
- replace all does not account for line change HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from babi.