mirror of
				https://github.com/MaskRay/ccls.git
				synced 2025-11-04 06:15:20 +00:00 
			
		
		
		
	working_files: normalize \r\n and \n to \n
Clients may normalize end-of-line sequences, thus cause a mismatch between index_lines and buffer_lines. Thanks to CXuesong for reporting this issue!
This commit is contained in:
		
							parent
							
								
									dcaa5a07af
								
							
						
					
					
						commit
						74432a641d
					
				@ -12,7 +12,6 @@
 | 
				
			|||||||
#include <chrono>
 | 
					#include <chrono>
 | 
				
			||||||
#include <climits>
 | 
					#include <climits>
 | 
				
			||||||
#include <numeric>
 | 
					#include <numeric>
 | 
				
			||||||
#include <sstream>
 | 
					 | 
				
			||||||
namespace chrono = std::chrono;
 | 
					namespace chrono = std::chrono;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
using namespace clang;
 | 
					using namespace clang;
 | 
				
			||||||
@ -43,13 +42,17 @@ Position GetPositionForOffset(const std::string &content, int offset) {
 | 
				
			|||||||
  return {line, col};
 | 
					  return {line, col};
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
std::vector<std::string> ToLines(const std::string &content) {
 | 
					std::vector<std::string> ToLines(const std::string &c) {
 | 
				
			||||||
  std::vector<std::string> result;
 | 
					  std::vector<std::string> ret;
 | 
				
			||||||
  std::istringstream lines(content);
 | 
					  int last = 0, e = c.size();
 | 
				
			||||||
  std::string line;
 | 
					  for (int i = 0; i < e; i++)
 | 
				
			||||||
  while (getline(lines, line))
 | 
					    if (c[i] == '\n') {
 | 
				
			||||||
    result.push_back(line);
 | 
					      ret.emplace_back(&c[last], i - last - (i && c[i - 1] == '\r'));
 | 
				
			||||||
  return result;
 | 
					      last = i + 1;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  if (last < e)
 | 
				
			||||||
 | 
					    ret.emplace_back(&c[last], e - last);
 | 
				
			||||||
 | 
					  return ret;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Computes the edit distance of strings [a,a+la) and [b,b+lb) with Eugene W.
 | 
					// Computes the edit distance of strings [a,a+la) and [b,b+lb) with Eugene W.
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user