diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2021-11-14 00:02:04 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2021-11-14 00:02:04 -0800 |
commit | c5261224dfa8cdfd6f501f341affbc047465740e (patch) | |
tree | eff31a00b044f905ddfa8020c444cf7ca41ee5af /src/kilo.c | |
parent | 8e9534ed4f186771d00e0955afaf93d3de057652 (diff) | |
download | teliva-c5261224dfa8cdfd6f501f341affbc047465740e.tar.gz |
use word at cursor when it's not at start of line
Diffstat (limited to 'src/kilo.c')
-rw-r--r-- | src/kilo.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/kilo.c b/src/kilo.c index e78e543..25660d2 100644 --- a/src/kilo.c +++ b/src/kilo.c @@ -939,11 +939,13 @@ void word_at_cursor(char* out, int capacity) { int cidx = E.coloff + E.cx; int len = 0; memset(out, 0, capacity); - /* scan back */ + /* scan back to first identifier char */ while (cidx > 0) { --cidx; - if (!identifier_char(row->chars[cidx])) + if (!identifier_char(row->chars[cidx])) { + ++cidx; break; + } } /* now scan forward */ for (len = 0; cidx+len < row->size; ++len) { |