@@ -295,7 +295,8 @@ void Workspace::stop_tracking_file(const LSPSpec::DocumentUri& file_uri) {
295295
296296WorkspaceOGFile::WorkspaceOGFile (const std::string& content, const GameVersion& game_version)
297297 : m_content(content), m_game_version(game_version) {
298- m_lines = str_util::split (content);
298+ const auto line_ending = file_util::get_majority_file_line_endings (content);
299+ m_lines = str_util::split_string (content, line_ending);
299300 lg::info (" Added new OG file. {} lines with {} symbols and {} diagnostics" , m_lines.size (),
300301 m_symbols.size (), m_diagnostics.size ());
301302}
@@ -322,24 +323,17 @@ std::optional<std::string> WorkspaceOGFile::get_symbol_at_position(
322323}
323324
324325WorkspaceIRFile::WorkspaceIRFile (const std::string& content) {
325- // Get all lines of file
326- std::string::size_type pos = 0 ;
327- std::string::size_type prev = 0 ;
328-
329- // TODO - i hate this assignment inside a conditional, get rid of it
330- while ((pos = content.find (" \r\n " , prev)) != std::string::npos) {
331- std::string line = content.substr (prev, pos - prev);
332- m_lines.push_back (line);
333- // Run any checks on that line
334- find_all_types_path (line);
335- find_function_symbol (m_lines.size () - 1 , line);
336- identify_diagnostics (m_lines.size () - 1 , line);
337- prev = pos + 1 ;
326+ const auto line_ending = file_util::get_majority_file_line_endings (content);
327+ m_lines = str_util::split_string (content, line_ending);
328+
329+ for (int i = 0 ; i < m_lines.size (); i++) {
330+ const auto & line = m_lines.at (i);
331+ if (m_all_types_uri == " " ) {
332+ find_all_types_path (line);
333+ }
334+ find_function_symbol (i, line);
335+ identify_diagnostics (i, line);
338336 }
339- std::string line = content.substr (prev);
340- m_lines.push_back (line);
341- find_function_symbol (m_lines.size () - 1 , line);
342- identify_diagnostics (m_lines.size () - 1 , line);
343337
344338 lg::info (" Added new IR file. {} lines with {} symbols and {} diagnostics" , m_lines.size (),
345339 m_symbols.size (), m_diagnostics.size ());
0 commit comments