MCPcopy Create free account
hub / github.com/WinMerge/winmerge / ChangeFile

Method ChangeFile

Src/MergeDoc.cpp:2561–2595  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2559}
2560
2561void CMergeDoc::ChangeFile(int nBuffer, const String& path, int nLineIndex)
2562{
2563 if (!PromptAndSaveIfNeeded(true))
2564 return;
2565
2566 FileLocation fileloc[3];
2567 String strDesc[3];
2568 bool bRO[3]{};
2569 for (int pane = 0; pane < m_nBuffers; pane++)
2570 {
2571 bRO[pane] = m_ptBuf[pane]->GetReadOnly();
2572 fileloc[pane].encoding.m_unicoding = m_ptBuf[pane]->getUnicoding();
2573 fileloc[pane].encoding.m_codepage = m_ptBuf[pane]->getCodepage();
2574 fileloc[pane].setPath(m_filePaths[pane]);
2575 }
2576 std::copy_n(m_strDesc, m_nBuffers, strDesc);
2577
2578 strDesc[nBuffer].clear();
2579 fileloc[nBuffer].setPath(path);
2580 fileloc[nBuffer].encoding = codepage_detect::Guess(path, GetOptionsMgr()->GetInt(OPT_CP_DETECT));
2581
2582 bool filenameChanged = path != m_filePaths[nBuffer];
2583 auto columnWidths = m_ptBuf[nBuffer]->GetColumnWidths();
2584 int nActivePane = GetActiveMergeView()->m_nThisPane;
2585
2586 if (OpenDocs(m_nBuffers, fileloc, bRO, strDesc))
2587 {
2588 // Restore column widths and active pane changed by OpenDocs to their previous state
2589 if (!filenameChanged)
2590 {
2591 m_ptBuf[nBuffer]->SetColumnWidths(columnWidths);
2592 }
2593 MoveOnLoad(nActivePane, nLineIndex);
2594 }
2595}
2596
2597/**
2598 * @brief Re-load a document.

Callers 4

OnCreateClientMethod · 0.45
TESTFunction · 0.45
OnCreateClientMethod · 0.45
OnDropFilesMethod · 0.45

Calls 9

GuessFunction · 0.85
getUnicodingMethod · 0.80
getCodepageMethod · 0.80
SetColumnWidthsMethod · 0.80
GetOptionsMgrFunction · 0.70
GetReadOnlyMethod · 0.45
setPathMethod · 0.45
clearMethod · 0.45
GetIntMethod · 0.45

Tested by 1

TESTFunction · 0.36