aboutsummaryrefslogtreecommitdiff
path: root/vis.c
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2014-12-23 17:35:22 +0100
committerMarc André Tanner <mat@brain-dump.org>2014-12-23 17:36:05 +0100
commit25a7a0e334ccb7df3cfda334c9427d1a7e688eae (patch)
tree7b364afc43f665706f5c6f0e387016e015b1dec6 /vis.c
parent985a828346a5d3185f6ee1e00d2ab4154024a9c8 (diff)
downloadvis-25a7a0e334ccb7df3cfda334c9427d1a7e688eae.tar.gz
vis-25a7a0e334ccb7df3cfda334c9427d1a7e688eae.tar.xz
Simplify # and * commands by using inner text objects
Diffstat (limited to 'vis.c')
-rw-r--r--vis.c16
1 files changed, 3 insertions, 13 deletions
diff --git a/vis.c b/vis.c
index 7f3b9ca..135d112 100644
--- a/vis.c
+++ b/vis.c
@@ -676,26 +676,16 @@ static void op_join(OperatorContext *c) {
/** movement implementations of type: size_t (*move)(const Arg*) */
static char *get_word_under_cursor() {
- size_t pos = window_cursor_get(vis->win->win);
- Filerange word = text_object_word(vis->win->text, pos);
+ Filerange word = text_object_word(vis->win->text, window_cursor_get(vis->win->win));
if (!text_range_valid(&word))
return NULL;
size_t len = word.end - word.start;
- char *buf = malloc(len+1), *start = buf, *end;
+ char *buf = malloc(len+1);
if (!buf)
return NULL;
len = text_bytes_get(vis->win->text, word.start, len, buf);
buf[len] = '\0';
- /* remove leading / trailing white spaces */
- while (*start && isspace(*start))
- start++;
- end = start;
- for (char *cur = start; *cur; cur++) {
- if (!isspace(*cur))
- end = cur;
- }
- end[1] = '\0';
- return start;
+ return buf;
}
static size_t search_word_forward(const Arg *arg) {