QuickFix sorts for 'vimgrep', 'grep', 'cs' commands.
dblume

dblume commited on 2022-03-11 20:04:23
Showing 1 changed files, with 2 additions and 24 deletions.

... ...
@@ -156,28 +155,6 @@ vnoremap <leader>s :sort<cr>
156 155
 vnoremap < <gv
157 156
 vnoremap > >gv
158 157
 
159
-" TODO: Delete this MaximizeToggle(), use OpenCurrentAsNewTab() instead.
160
-" Make <C-W>o toggle maximizing a window.
161
-" https://vim.fandom.com/wiki/Maximize_window_and_return_to_previous_split_structure
162
-"nnoremap <C-W>o :call MaximizeToggle()<CR>
163
-function! MaximizeToggle()
164
-  if exists("s:maximize_session")
165
-    exec "source " . s:maximize_session
166
-    call delete(s:maximize_session)
167
-    unlet s:maximize_session
168
-    let &hidden=s:maximize_hidden_save
169
-    unlet s:maximize_hidden_save
170
-    " ColorColumn highlight gets changed. Workaround: unset it.
171
-    highlight clear ColorColumn
172
-  else
173
-    let s:maximize_hidden_save = &hidden
174
-    let s:maximize_session = tempname()
175
-    set hidden
176
-    exec "mksession! " . s:maximize_session
177
-    only
178
-  endif
179
-endfunction
180
-
181 158
 " If too many file system events are getting triggered.
182 159
 set nobackup       " ~ files
183 160
 set nowritebackup  " Don't write buff to temp, delete orig, rename temp to orig
... ...
@@ -326,8 +303,8 @@ autocmd! QuickfixCmdPost * call MaybeSortQuickfix('QfStrCmp')
326 303
 function! MaybeSortQuickfix(fn)
327 304
 "    exe 'normal! '  " Doesn't work. Wanted to jump back to where we were.
328 305
     let t = getqflist({'title': 1}).title
329
-    " Only sort the files if cscope generated the list, not for "make" commands.
330
-    if stridx(t, "cs ") == 0
306
+    " Only sort the files if for search-style commands, not "make".
307
+    if stridx(t, "cs ") == 0 || stridx(t, ":gr") == 0 || stridx(t, ":vim") == 0
331 308
         call setqflist(sort(getqflist(), a:fn), 'r')
332 309
         call setqflist([], 'r', {'title': t})
333 310
     endif
334 311