@@ -128,11 +128,38 @@ local function showDoc()
128
128
end
129
129
end
130
130
131
- local function gotoDeclaration ()
131
+
132
+ M .gotoStack = {}
133
+
134
+ function M .goBack ()
135
+ if # M .gotoStack == 0 then return end
136
+ local top = M .gotoStack [# M .gotoStack ]
137
+ ui .goto_view (top .view )
138
+ if top .file ~= nil then
139
+ ui .goto_file (top .file )
140
+ else
141
+ if top .buffer > _BUFFERS then
142
+ table.remove (M .gotoStack )
143
+ return
144
+ end
145
+ view :goto_buffer (top .buffer )
146
+ end
147
+ buffer :goto_line (top .line )
148
+ buffer :vertical_centre_caret ()
149
+ table.remove (M .gotoStack ) -- pop last item
150
+ end
151
+
152
+ function M .gotoDeclaration ()
132
153
local r = runDCDClient (" -l" )
133
154
if r ~= " Not found\n " then
134
155
path , position = r :match (" ^(.-)\t (%d+)" )
135
156
if (path ~= nil and position ~= nil ) then
157
+ table.insert (M .gotoStack , {
158
+ line = buffer :line_from_position (buffer .current_pos ),
159
+ view = _VIEWS [_G .view ],
160
+ file = buffer .filename ,
161
+ buffer = _BUFFERS [_G .buffer ]
162
+ })
136
163
if (path ~= " stdin" ) then
137
164
io .open_file (path )
138
165
end
@@ -253,12 +280,11 @@ end
253
280
events .connect (events .CHAR_ADDED , function (ch )
254
281
if buffer :get_lexer () ~= " dmd" or ch > 255 then return end
255
282
if string.char (ch ) == ' (' or string.char (ch ) == ' .' or string.char (ch ) == ' :' then
256
- -- local setting = buffer.auto_c_choose_single
257
- -- buffer.auto_c_choose_single = false
283
+ local setting = buffer .auto_c_choose_single
284
+ buffer .auto_c_choose_single = false
258
285
autocomplete (ch )
259
- -- buffer.auto_c_choose_single = setting
286
+ buffer .auto_c_choose_single = setting
260
287
end
261
-
262
288
end )
263
289
264
290
-- Run dscanner's static analysis after saves and print the warnings and errors
@@ -337,7 +363,8 @@ keys.dmd = {
337
363
[' cH' ] = {showDoc },
338
364
[' down' ] = {cycleCalltips , 1 },
339
365
[' up' ] = {cycleCalltips , - 1 },
340
- [' cG' ] = {gotoDeclaration },
366
+ [' cG' ] = {M .gotoDeclaration },
367
+ [' caG' ] = {M .goBack },
341
368
[' cM' ] = {symbolIndex },
342
369
}
343
370
0 commit comments