about summary refs log tree commit diff stats
path: root/src/local
diff options
context:
space:
mode:
Diffstat (limited to 'src/local')
-rw-r--r--src/local/pager.nim35
1 files changed, 8 insertions, 27 deletions
diff --git a/src/local/pager.nim b/src/local/pager.nim
index 5c639a20..25042f5f 100644
--- a/src/local/pager.nim
+++ b/src/local/pager.nim
@@ -801,39 +801,20 @@ proc toggleSource(pager: Pager) {.jsfunc.} =
       pager.container.sourcepair = container
       pager.addContainer(container)
 
-func formatEditorName(editor, file: string; line: int): string =
-  result = newStringOfCap(editor.len + file.len)
-  var i = 0
-  var filefound = false
-  while i < editor.len:
-    if editor[i] == '%' and i < editor.high:
-      if editor[i + 1] == 's':
-        result &= file
-        filefound = true
-        i += 2
-        continue
-      elif editor[i + 1] == 'd':
-        result &= $line
-        i += 2
-        continue
-      elif editor[i + 1] == '%':
-        result &= '%'
-        i += 2
-        continue
-    result &= editor[i]
-    inc i
-  if not filefound:
-    if result[^1] != ' ':
-      result &= ' '
-    result &= file
-
 func getEditorCommand(pager: Pager; file: string; line = 1): string {.jsfunc.} =
   var editor = pager.config.external.editor
   if editor == "":
     editor = getEnv("EDITOR")
     if editor == "":
       editor = "vi %s +%d"
-  return formatEditorName(editor, file, line)
+  var canpipe = false
+  var s = unquoteCommand(editor, "", file, nil, canpipe, line)
+  if canpipe:
+    # %s not in command; add file name ourselves
+    if s[^1] != ' ':
+      s &= ' '
+    s &= quoteFile(file, qsNormal)
+  return s
 
 proc openInEditor(pager: Pager; input: var string): bool =
   try:
='oid'>401835f3 ^
21ab1821 ^












95ff1313 ^
9dda7036 ^


475dfebd ^
904a5a81 ^
53fc89f7 ^
6640a089 ^
21ab1821 ^

19e71f05 ^



21ab1821 ^
19e71f05 ^


53fc89f7 ^
e043029a ^
bc9e6b79 ^
21ab1821 ^


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81