コード例 #1
0
        private static async Task <string> GetChangedFileTextAsync(VsrModule module, GitItemStatus file)
        {
            var changes = await module.GetCurrentChangesAsync(file.Name, file.OldName, file.Staged == StagedStatus.Index, "-U1000000")
                          .ConfigureAwait(false);

            if (changes != null)
            {
                return(changes.Text);
            }

            var content = await module.GetFileContentsAsync(file).ConfigureAwaitRunInline();

            if (content != null)
            {
                return(content);
            }

            // Try to read the contents of the file: if it cannot be read, skip the operation silently.
            try
            {
                using (var reader = File.OpenText(Path.Combine(module.WorkingDir, file.Name)))
                {
                    return(await reader.ReadToEndAsync());
                }
            }
            catch
            {
                return("");
            }
        }