| 677 | } |
| 678 | |
| 679 | void ZepEditor::SetBufferMode(ZepBuffer& buffer) const { |
| 680 | // Reset it in case we are changing the text in a buffer |
| 681 | buffer.SetMode(nullptr); |
| 682 | |
| 683 | std::string ext; |
| 684 | std::string fileName; |
| 685 | if (buffer.GetFilePath().has_filename() && buffer.GetFilePath().filename().has_extension()) { |
| 686 | ext = string_tolower(buffer.GetFilePath().filename().extension().string()); |
| 687 | fileName = string_tolower(buffer.GetFilePath().filename().string()); |
| 688 | } else { |
| 689 | auto str = buffer.GetName(); |
| 690 | size_t dot_pos = str.find_last_of("."); |
| 691 | if (dot_pos != std::string::npos) { |
| 692 | ext = string_tolower(str.substr(dot_pos, str.length() - dot_pos)); |
| 693 | } |
| 694 | } |
| 695 | |
| 696 | auto itr = m_mapBufferModes.find(ext); |
| 697 | if (itr != m_mapBufferModes.end()) { |
| 698 | buffer.SetMode(itr->second); |
| 699 | } |
| 700 | } |
| 701 | |
| 702 | void ZepEditor::SetBufferSyntax(ZepBuffer& buffer) const { |
| 703 | std::string ext; |
nothing calls this directly
no test coverage detected