summary refs log tree commit diff stats
path: root/compiler/nimsuggest/nimsuggest.nim
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2015-01-29 03:08:41 +0100
committerAraq <rumpf_a@web.de>2015-01-29 03:08:41 +0100
commit8710a3738470e19e0d05c8e68db0803100caf3d8 (patch)
tree2169fe70ef9b4acf33379d5d6e33ffbd0c9d06ec /compiler/nimsuggest/nimsuggest.nim
parentebda8e89e15e3af88822fb2dd57c108830609ec6 (diff)
downloadNim-8710a3738470e19e0d05c8e68db0803100caf3d8.tar.gz
nimsuggest: sane dirty buffer handling
Diffstat (limited to 'compiler/nimsuggest/nimsuggest.nim')
-rw-r--r--compiler/nimsuggest/nimsuggest.nim34
1 files changed, 18 insertions, 16 deletions
diff --git a/compiler/nimsuggest/nimsuggest.nim b/compiler/nimsuggest/nimsuggest.nim
index 3a447effb..6edea06e5 100644
--- a/compiler/nimsuggest/nimsuggest.nim
+++ b/compiler/nimsuggest/nimsuggest.nim
@@ -37,7 +37,7 @@ var
 
 const
   seps = {':', ';', ' ', '\t'}
-  Help = "usage: sug|con|def|use dirtybuffer.nim[;originalfile.nim]:line:col\n"&
+  Help = "usage: sug|con|def|use file.nim[;dirtyfile.nim]:line:col\n"&
          "type 'quit' to quit\n" &
          "type 'debug' to toggle debug mode on/off\n" &
          "type 'terse' to toggle terse mode on/off"
@@ -59,6 +59,10 @@ proc action(cmd: string) =
       incl(gGlobalOptions, sw)
     return
 
+  template err() =
+    echo Help
+    return
+
   var opc = ""
   var i = parseIdent(cmd, opc, 0)
   case opc.normalize
@@ -71,35 +75,33 @@ proc action(cmd: string) =
   of "quit": quit()
   of "debug": toggle optIdeDebug
   of "terse": toggle optIdeTerse
-  else:
-    echo Help
-    return
+  else: err()
   var dirtyfile = ""
   var orig = ""
-  i = parseQuoted(cmd, dirtyfile, i)
+  i = parseQuoted(cmd, orig, i)
   if cmd[i] == ';':
-    i = parseQuoted(cmd, orig, i+1)
+    i = parseQuoted(cmd, dirtyfile, i+1)
   i += skipWhile(cmd, seps, i)
   var line, col = -1
   i += parseInt(cmd, line, i)
   i += skipWhile(cmd, seps, i)
   i += parseInt(cmd, col, i)
-  if dirtyfile.len != 0:
-    gDirtyBufferIdx = dirtyfile.fileInfoIdx
-    gDirtyOriginalIdx = if orig.len != 0: orig.fileInfoIdx else: gDirtyBufferIdx
-  else:
-    discard "use the same filename as in the last command"
-  resetModule gDirtyBufferIdx
-  if gDirtyBufferIdx != gProjectMainIdx:
+
+  if orig.len == 0: err()
+  let dirtyIdx = orig.fileInfoIdx
+
+  if dirtyfile.len != 0: msgs.setDirtyFile(dirtyIdx, dirtyfile)
+  else: msgs.setDirtyFile(dirtyIdx, nil)
+
+  resetModule dirtyIdx
+  if dirtyIdx != gProjectMainIdx:
     resetModule gProjectMainIdx
-  gTrackPos = newLineInfo(gDirtyBufferIdx, line, col)
+  gTrackPos = newLineInfo(dirtyIdx, line, col)
   #echo dirtyfile, gDirtyBufferIdx, " project ", gProjectMainIdx
   gErrorCounter = 0
   compileProject()
 
 proc serve() =
-  gDirtyBufferIdx = gProjectMainIdx
-  gDirtyOriginalIdx = gProjectMainIdx
   # do not stop after the first error:
   msgs.gErrorMax = high(int)
   if gUseStdin:
44cb820d186c7dac96c753ce25253ad628'>^
45a5c64c9 ^




ab525cc48 ^

45a5c64c9 ^
730ce53b7 ^





1e89e5bf9 ^
506418ef5 ^
0bb76dde5 ^
e0afacb9f ^
0bb76dde5 ^
3d7d06571 ^


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